guix.texi 1.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guix.info
  5. @documentencoding UTF-8
  6. @settitle GNU Guix Reference Manual
  7. @c %**end of header
  8. @include version.texi
  9. @c Identifier of the OpenPGP key used to sign tarballs and such.
  10. @set OPENPGP-SIGNING-KEY-ID 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
  11. @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=15145
  12. @c Base URL for downloads.
  13. @set BASE-URL https://ftp.gnu.org/gnu/guix
  14. @c The official substitute server used by default.
  15. @set SUBSTITUTE-SERVER-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-2023 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, 2023 Leo Famulari@*
  27. Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 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, 2022, 2023 Efraim Flashner@*
  31. Copyright @copyright{} 2016 John Darrington@*
  32. Copyright @copyright{} 2016, 2017 Nikita Gillmann@*
  33. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 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, 2022 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, 2022 Marius Bakke@*
  45. Copyright @copyright{} 2017, 2019, 2020, 2022 Hartmut Goebel@*
  46. Copyright @copyright{} 2017, 2019, 2020, 2021, 2022, 2023 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, 2023 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, 2022, 2023 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, 2022 Guillaume Le Vaillant@*
  67. Copyright @copyright{} 2020 Liliana Marie Prikler@*
  68. Copyright @copyright{} 2019, 2020, 2021, 2022, 2023 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, 2022 Pierre Langlois@*
  77. Copyright @copyright{} 2020 pinoaffe@*
  78. Copyright @copyright{} 2020, 2023 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-2023 Josselin Poiret@*
  94. Copyright @copyright{} 2021, 2023 muradm@*
  95. Copyright @copyright{} 2021, 2022 Andrew Tropin@*
  96. Copyright @copyright{} 2021 Sarah Morgensen@*
  97. Copyright @copyright{} 2022 Remco van 't Veer@*
  98. Copyright @copyright{} 2022 Aleksandr Vityazev@*
  99. Copyright @copyright{} 2022 Philip M@sup{c}Grath@*
  100. Copyright @copyright{} 2022 Karl Hallsby@*
  101. Copyright @copyright{} 2022 Justin Veilleux@*
  102. Copyright @copyright{} 2022 Reily Siegel@*
  103. Copyright @copyright{} 2022 Simon Streit@*
  104. Copyright @copyright{} 2022 (@*
  105. Copyright @copyright{} 2022 John Kehayias@*
  106. Copyright @copyright{} 2022⁠–⁠2023 Bruno Victal@*
  107. Copyright @copyright{} 2022 Ivan Vilata-i-Balaguer@*
  108. Copyright @copyright{} 2023 Giacomo Leidi@*
  109. Copyright @copyright{} 2022 Antero Mejr@*
  110. Copyright @copyright{} 2023 Karl Hallsby@*
  111. Copyright @copyright{} 2023 Nathaniel Nicandro@*
  112. Copyright @copyright{} 2023 Tanguy Le Carrour@*
  113. Copyright @copyright{} 2023 Zheng Junjie@*
  114. Copyright @copyright{} 2023 Brian Cully@*
  115. Copyright @copyright{} 2023 Felix Lechner@*
  116. Permission is granted to copy, distribute and/or modify this document
  117. under the terms of the GNU Free Documentation License, Version 1.3 or
  118. any later version published by the Free Software Foundation; with no
  119. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  120. copy of the license is included in the section entitled ``GNU Free
  121. Documentation License''.
  122. @end copying
  123. @dircategory System administration
  124. @direntry
  125. * Guix: (guix). Manage installed software and system configuration.
  126. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  127. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  128. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  129. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  130. * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
  131. @end direntry
  132. @dircategory Software development
  133. @direntry
  134. * guix shell: (guix)Invoking guix shell. Creating software environments.
  135. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  136. * guix build: (guix)Invoking guix build. Building packages.
  137. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  138. @end direntry
  139. @titlepage
  140. @title GNU Guix Reference Manual
  141. @subtitle Using the GNU Guix Functional Package Manager
  142. @author The GNU Guix Developers
  143. @page
  144. @vskip 0pt plus 1filll
  145. Edition @value{EDITION} @*
  146. @value{UPDATED} @*
  147. @insertcopying
  148. @end titlepage
  149. @contents
  150. @c *********************************************************************
  151. @node Top
  152. @top GNU Guix
  153. This document describes GNU Guix version @value{VERSION}, a functional
  154. package management tool written for the GNU system.
  155. @c TRANSLATORS: You can replace the following paragraph with information on
  156. @c how to join your own translation team and how to report issues with the
  157. @c translation.
  158. This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
  159. GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
  160. Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
  161. Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}),
  162. Brazilian Portuguese (@pxref{Top,,, guix.pt_BR, Manual de referência do
  163. GNU Guix}), and Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
  164. would like to translate it in your native language, consider joining
  165. @uref{https://translate.fedoraproject.org/projects/guix/documentation-manual,
  166. Weblate} (@pxref{Translating Guix}).
  167. @menu
  168. * Introduction:: What is Guix about?
  169. * Installation:: Installing Guix.
  170. * System Installation:: Installing the whole operating system.
  171. * System Troubleshooting Tips:: When things don't go as planned.
  172. * Getting Started:: Your first steps.
  173. * Package Management:: Package installation, upgrade, etc.
  174. * Channels:: Customizing the package collection.
  175. * Development:: Guix-aided software development.
  176. * Programming Interface:: Using Guix in Scheme.
  177. * Utilities:: Package management commands.
  178. * Foreign Architectures:: Build for foreign architectures.
  179. * System Configuration:: Configuring the operating system.
  180. * Home Configuration:: Configuring the home environment.
  181. * Documentation:: Browsing software user manuals.
  182. * Platforms:: Defining platforms.
  183. * System Images:: Creating system images.
  184. * Installing Debugging Files:: Feeding the debugger.
  185. * Using TeX and LaTeX:: Typesetting.
  186. * Security Updates:: Deploying security fixes quickly.
  187. * Bootstrapping:: GNU/Linux built from scratch.
  188. * Porting:: Targeting another platform or kernel.
  189. * Contributing:: Your help needed!
  190. * Acknowledgments:: Thanks!
  191. * GNU Free Documentation License:: The license of this manual.
  192. * Concept Index:: Concepts.
  193. * Programming Index:: Data types, functions, and variables.
  194. @detailmenu
  195. --- The Detailed Node Listing ---
  196. Introduction
  197. * Managing Software the Guix Way:: What's special.
  198. * GNU Distribution:: The packages and tools.
  199. Installation
  200. * Binary Installation:: Getting Guix running in no time!
  201. * Requirements:: Software needed to build and run Guix.
  202. * Running the Test Suite:: Testing Guix.
  203. * Setting Up the Daemon:: Preparing the build daemon's environment.
  204. * Invoking guix-daemon:: Running the build daemon.
  205. * Application Setup:: Application-specific setup.
  206. * Upgrading Guix:: Upgrading Guix and its build daemon.
  207. Setting Up the Daemon
  208. * Build Environment Setup:: Preparing the isolated build environment.
  209. * Daemon Offload Setup:: Offloading builds to remote machines.
  210. * SELinux Support:: Using an SELinux policy for the daemon.
  211. System Installation
  212. * Limitations:: What you can expect.
  213. * Hardware Considerations:: Supported hardware.
  214. * USB Stick and DVD Installation:: Preparing the installation medium.
  215. * Preparing for Installation:: Networking, partitioning, etc.
  216. * Guided Graphical Installation:: Easy graphical installation.
  217. * Manual Installation:: Manual installation for wizards.
  218. * After System Installation:: When installation succeeded.
  219. * Installing Guix in a VM:: Guix System playground.
  220. * Building the Installation Image:: How this comes to be.
  221. Manual Installation
  222. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  223. * Proceeding with the Installation:: Installing.
  224. System Troubleshooting Tips
  225. * Chrooting into an existing system::
  226. Package Management
  227. * Features:: How Guix will make your life brighter.
  228. * Invoking guix package:: Package installation, removal, etc.
  229. * Substitutes:: Downloading pre-built binaries.
  230. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  231. * Invoking guix locate:: Locating packages that provide a file.
  232. * Invoking guix gc:: Running the garbage collector.
  233. * Invoking guix pull:: Fetching the latest Guix and distribution.
  234. * Invoking guix time-machine:: Running an older revision of Guix.
  235. * Inferiors:: Interacting with another revision of Guix.
  236. * Invoking guix describe:: Display information about your Guix revision.
  237. * Invoking guix archive:: Exporting and importing store files.
  238. Substitutes
  239. * Official Substitute Servers:: One particular source of substitutes.
  240. * Substitute Server Authorization:: How to enable or disable substitutes.
  241. * Getting Substitutes from Other Servers:: Substitute diversity.
  242. * Substitute Authentication:: How Guix verifies substitutes.
  243. * Proxy Settings:: How to get substitutes via proxy.
  244. * Substitution Failure:: What happens when substitution fails.
  245. * On Trusting Binaries:: How can you trust that binary blob?
  246. Channels
  247. * Specifying Additional Channels:: Extending the package collection.
  248. * Using a Custom Guix Channel:: Using a customized Guix.
  249. * Replicating Guix:: Running the @emph{exact same} Guix.
  250. * Channel Authentication:: How Guix verifies what it fetches.
  251. * Channels with Substitutes:: Using channels with available substitutes.
  252. * Creating a Channel:: How to write your custom channel.
  253. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  254. * Declaring Channel Dependencies:: How to depend on other channels.
  255. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  256. * Primary URL:: Distinguishing mirror to original.
  257. * Writing Channel News:: Communicating information to channel's users.
  258. Development
  259. * Invoking guix shell:: Spawning one-off software environments.
  260. * Invoking guix environment:: Setting up development environments.
  261. * Invoking guix pack:: Creating software bundles.
  262. * The GCC toolchain:: Working with languages supported by GCC.
  263. * Invoking guix git authenticate:: Authenticating Git repositories.
  264. Programming Interface
  265. * Package Modules:: Packages from the programmer's viewpoint.
  266. * Defining Packages:: Defining new packages.
  267. * Defining Package Variants:: Customizing packages.
  268. * Writing Manifests:: The bill of materials of your environment.
  269. * Build Systems:: Specifying how packages are built.
  270. * Build Phases:: Phases of the build process of a package.
  271. * Build Utilities:: Helpers for your package definitions and more.
  272. * Search Paths:: Declaring search path environment variables.
  273. * The Store:: Manipulating the package store.
  274. * Derivations:: Low-level interface to package derivations.
  275. * The Store Monad:: Purely functional interface to the store.
  276. * G-Expressions:: Manipulating build expressions.
  277. * Invoking guix repl:: Programming Guix in Guile
  278. * Using Guix Interactively:: Fine-grain interaction at the REPL.
  279. Defining Packages
  280. * package Reference:: The package data type.
  281. * origin Reference:: The origin data type.
  282. Utilities
  283. * Invoking guix build:: Building packages from the command line.
  284. * Invoking guix edit:: Editing package definitions.
  285. * Invoking guix download:: Downloading a file and printing its hash.
  286. * Invoking guix hash:: Computing the cryptographic hash of a file.
  287. * Invoking guix import:: Importing package definitions.
  288. * Invoking guix refresh:: Updating package definitions.
  289. * Invoking guix style:: Styling package definitions.
  290. * Invoking guix lint:: Finding errors in package definitions.
  291. * Invoking guix size:: Profiling disk usage.
  292. * Invoking guix graph:: Visualizing the graph of packages.
  293. * Invoking guix publish:: Sharing substitutes.
  294. * Invoking guix challenge:: Challenging substitute servers.
  295. * Invoking guix copy:: Copying to and from a remote store.
  296. * Invoking guix container:: Process isolation.
  297. * Invoking guix weather:: Assessing substitute availability.
  298. * Invoking guix processes:: Listing client processes.
  299. Invoking @command{guix build}
  300. * Common Build Options:: Build options for most commands.
  301. * Package Transformation Options:: Creating variants of packages.
  302. * Additional Build Options:: Options specific to 'guix build'.
  303. * Debugging Build Failures:: Real life packaging experience.
  304. Foreign Architectures
  305. * Cross-Compilation:: Cross-compiling for another architecture.
  306. * Native Builds:: Targeting another architecture through native builds.
  307. System Configuration
  308. * Using the Configuration System:: Customizing your GNU system.
  309. * operating-system Reference:: Detail of operating-system declarations.
  310. * File Systems:: Configuring file system mounts.
  311. * Mapped Devices:: Block device extra processing.
  312. * Swap Space:: Backing RAM with disk space.
  313. * User Accounts:: Specifying user accounts.
  314. * Keyboard Layout:: How the system interprets key strokes.
  315. * Locales:: Language and cultural convention settings.
  316. * Services:: Specifying system services.
  317. * Setuid Programs:: Programs running with elevated privileges.
  318. * X.509 Certificates:: Authenticating HTTPS servers.
  319. * Name Service Switch:: Configuring libc's name service switch.
  320. * Initial RAM Disk:: Linux-Libre bootstrapping.
  321. * Bootloader Configuration:: Configuring the boot loader.
  322. * Invoking guix system:: Instantiating a system configuration.
  323. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  324. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  325. * Defining Services:: Adding new service definitions.
  326. File Systems
  327. * Btrfs file system::
  328. Services
  329. * Base Services:: Essential system services.
  330. * Scheduled Job Execution:: The mcron service.
  331. * Log Rotation:: The rottlog service.
  332. * Networking Setup:: Setting up network interfaces.
  333. * Networking Services:: Firewall, SSH daemon, etc.
  334. * Unattended Upgrades:: Automated system upgrades.
  335. * X Window:: Graphical display.
  336. * Printing Services:: Local and remote printer support.
  337. * Desktop Services:: D-Bus and desktop services.
  338. * Sound Services:: ALSA and Pulseaudio services.
  339. * File Search Services:: Tools to search for files.
  340. * Database Services:: SQL databases, key-value stores, etc.
  341. * Mail Services:: IMAP, POP3, SMTP, and all that.
  342. * Messaging Services:: Messaging services.
  343. * Telephony Services:: Telephony services.
  344. * File-Sharing Services:: File-sharing services.
  345. * Monitoring Services:: Monitoring services.
  346. * Kerberos Services:: Kerberos services.
  347. * LDAP Services:: LDAP services.
  348. * Web Services:: Web servers.
  349. * Certificate Services:: TLS certificates via Let's Encrypt.
  350. * DNS Services:: DNS daemons.
  351. * VNC Services:: VNC daemons.
  352. * VPN Services:: VPN daemons.
  353. * Network File System:: NFS related services.
  354. * Samba Services:: Samba services.
  355. * Continuous Integration:: Cuirass and Laminar services.
  356. * Power Management Services:: Extending battery life.
  357. * Audio Services:: The MPD.
  358. * Virtualization Services:: Virtualization services.
  359. * Version Control Services:: Providing remote access to Git repositories.
  360. * Game Services:: Game servers.
  361. * PAM Mount Service:: Service to mount volumes when logging in.
  362. * Guix Services:: Services relating specifically to Guix.
  363. * Linux Services:: Services tied to the Linux kernel.
  364. * Hurd Services:: Services specific for a Hurd System.
  365. * Miscellaneous Services:: Other services.
  366. Defining Services
  367. * Service Composition:: The model for composing services.
  368. * Service Types and Services:: Types and services.
  369. * Service Reference:: API reference.
  370. * Shepherd Services:: A particular type of service.
  371. * Complex Configurations:: Defining bindings for complex configurations.
  372. Home Configuration
  373. * Declaring the Home Environment:: Customizing your Home.
  374. * Configuring the Shell:: Enabling home environment.
  375. * Home Services:: Specifying home services.
  376. * Invoking guix home:: Instantiating a home configuration.
  377. Home Services
  378. * Essential Home Services:: Environment variables, packages, on-* scripts.
  379. * Shells: Shells Home Services. POSIX shells, Bash, Zsh.
  380. * Mcron: Mcron Home Service. Scheduled User's Job Execution.
  381. * Power Management: Power Management Home Services. Services for battery power.
  382. * Shepherd: Shepherd Home Service. Managing User's Daemons.
  383. * SSH: Secure Shell. Setting up the secure shell client.
  384. * GPG: GNU Privacy Guard. Setting up GPG and related tools.
  385. * Desktop: Desktop Home Services. Services for graphical environments.
  386. * Guix: Guix Home Services. Services for Guix.
  387. * Fonts: Fonts Home Services. Services for managing User's fonts.
  388. * Sound: Sound Home Services. Dealing with audio.
  389. * Mail: Mail Home Services. Services for managing mail.
  390. * Messaging: Messaging Home Services. Services for managing messaging.
  391. * Media: Media Home Services. Services for managing media.
  392. * Networking: Networking Home Services. Networking services.
  393. * Miscellaneous: Miscellaneous Home Services. More services.
  394. Platforms
  395. * platform Reference:: Detail of platform declarations.
  396. * Supported Platforms:: Description of the supported platforms.
  397. Creating System Images
  398. * image Reference:: Detail of image declarations.
  399. * Instantiate an Image:: How to instantiate an image record.
  400. * image-type Reference:: Detail of image types declaration.
  401. * Image Modules:: Definition of image modules.
  402. @code{image} Reference
  403. * partition Reference::
  404. Installing Debugging Files
  405. * Separate Debug Info:: Installing 'debug' outputs.
  406. * Rebuilding Debug Info:: Building missing debug info.
  407. Bootstrapping
  408. * Full-Source Bootstrap:: A Bootstrap worthy of GNU.
  409. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  410. @end detailmenu
  411. @end menu
  412. @c *********************************************************************
  413. @node Introduction
  414. @chapter Introduction
  415. @cindex purpose
  416. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  417. using the international phonetic alphabet (IPA).} is a package
  418. management tool for and distribution of the GNU system.
  419. Guix makes it easy for unprivileged
  420. users to install, upgrade, or remove software packages, to roll back to a
  421. previous package set, to build packages from source, and generally
  422. assists with the creation and maintenance of software environments.
  423. @cindex Guix System
  424. @cindex GuixSD, now Guix System
  425. @cindex Guix System Distribution, now Guix System
  426. You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
  427. complements the available tools without interference (@pxref{Installation}),
  428. or you can use it as a standalone operating system distribution,
  429. @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
  430. System Distribution'' or ``GuixSD''. We now consider it makes more sense to
  431. group everything under the ``Guix'' banner since, after all, Guix System is
  432. readily available through the @command{guix system} command, even if you're
  433. using a different distro underneath!}. @xref{GNU Distribution}.
  434. @menu
  435. * Managing Software the Guix Way:: What's special.
  436. * GNU Distribution:: The packages and tools.
  437. @end menu
  438. @node Managing Software the Guix Way
  439. @section Managing Software the Guix Way
  440. @cindex user interfaces
  441. Guix provides a command-line package management interface
  442. (@pxref{Package Management}), tools to help with software development
  443. (@pxref{Development}), command-line utilities for more advanced usage
  444. (@pxref{Utilities}), as well as Scheme programming interfaces
  445. (@pxref{Programming Interface}).
  446. @cindex build daemon
  447. Its @dfn{build daemon} is responsible for building packages on behalf of
  448. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  449. binaries from authorized sources (@pxref{Substitutes}).
  450. @cindex extensibility of the distribution
  451. @cindex customization, of packages
  452. Guix includes package definitions for many GNU and non-GNU packages, all
  453. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  454. user's computing freedom}. It is @emph{extensible}: users can write
  455. their own package definitions (@pxref{Defining Packages}) and make them
  456. available as independent package modules (@pxref{Package Modules}). It
  457. is also @emph{customizable}: users can @emph{derive} specialized package
  458. definitions from existing ones, including from the command line
  459. (@pxref{Package Transformation Options}).
  460. @cindex functional package management
  461. @cindex isolation
  462. Under the hood, Guix implements the @dfn{functional package management}
  463. discipline pioneered by Nix (@pxref{Acknowledgments}).
  464. In Guix, the package build and installation process is seen
  465. as a @emph{function}, in the mathematical sense. That function takes inputs,
  466. such as build scripts, a compiler, and libraries, and
  467. returns an installed package. As a pure function, its result depends
  468. solely on its inputs---for instance, it cannot refer to software or
  469. scripts that were not explicitly passed as inputs. A build function
  470. always produces the same result when passed a given set of inputs. It
  471. cannot alter the environment of the running system in
  472. any way; for instance, it cannot create, modify, or delete files outside
  473. of its build and installation directories. This is achieved by running
  474. build processes in isolated environments (or @dfn{containers}), where only their
  475. explicit inputs are visible.
  476. @cindex store
  477. The result of package build functions is @dfn{cached} in the file
  478. system, in a special directory called @dfn{the store} (@pxref{The
  479. Store}). Each package is installed in a directory of its own in the
  480. store---by default under @file{/gnu/store}. The directory name contains
  481. a hash of all the inputs used to build that package; thus, changing an
  482. input yields a different directory name.
  483. This approach is the foundation for the salient features of Guix: support
  484. for transactional package upgrade and rollback, per-user installation, and
  485. garbage collection of packages (@pxref{Features}).
  486. @node GNU Distribution
  487. @section GNU Distribution
  488. @cindex Guix System
  489. Guix comes with a distribution of the GNU system consisting entirely of
  490. free software@footnote{The term ``free'' here refers to the
  491. @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
  492. users of that software}.}. The
  493. distribution can be installed on its own (@pxref{System Installation}),
  494. but it is also possible to install Guix as a package manager on top of
  495. an installed GNU/Linux system (@pxref{Installation}). When we need to
  496. distinguish between the two, we refer to the standalone distribution as
  497. Guix@tie{}System.
  498. The distribution provides core GNU packages such as GNU libc, GCC, and
  499. Binutils, as well as many GNU and non-GNU applications. The complete
  500. list of available packages can be browsed
  501. @url{https://www.gnu.org/software/guix/packages,on-line} or by
  502. running @command{guix package} (@pxref{Invoking guix package}):
  503. @example
  504. guix package --list-available
  505. @end example
  506. Our goal is to provide a practical 100% free software distribution of
  507. Linux-based and other variants of GNU, with a focus on the promotion and
  508. tight integration of GNU components, and an emphasis on programs and
  509. tools that help users exert that freedom.
  510. Packages are currently available on the following platforms:
  511. @table @code
  512. @item x86_64-linux
  513. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel.
  514. @item i686-linux
  515. Intel 32-bit architecture (IA32), Linux-Libre kernel.
  516. @item armhf-linux
  517. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  518. using the EABI hard-float application binary interface (ABI),
  519. and Linux-Libre kernel.
  520. @item aarch64-linux
  521. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
  522. @item i586-gnu
  523. @uref{https://hurd.gnu.org, GNU/Hurd} on the Intel 32-bit architecture
  524. (IA32).
  525. This configuration is experimental and under development. The easiest
  526. way for you to give it a try is by setting up an instance of
  527. @code{hurd-vm-service-type} on your GNU/Linux machine
  528. (@pxref{transparent-emulation-qemu, @code{hurd-vm-service-type}}).
  529. @xref{Contributing}, on how to help!
  530. @item mips64el-linux (unsupported)
  531. little-endian 64-bit MIPS processors, specifically the Loongson series,
  532. n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
  533. supported; in particular, there is no ongoing work to ensure that this
  534. architecture still works. Should someone decide they wish to revive this
  535. architecture then the code is still available.
  536. @item powerpc-linux (unsupported)
  537. big-endian 32-bit PowerPC processors, specifically the PowerPC G4 with
  538. AltiVec support, and Linux-Libre kernel. This configuration is not
  539. fully supported and there is no ongoing work to ensure this architecture
  540. works.
  541. @item powerpc64le-linux
  542. little-endian 64-bit Power ISA processors, Linux-Libre kernel. This
  543. includes POWER9 systems such as the
  544. @uref{https://www.fsf.org/news/talos-ii-mainboard-and-talos-ii-lite-mainboard-now-fsf-certified-to-respect-your-freedom,
  545. RYF Talos II mainboard}. This platform is available as a "technology
  546. preview": although it is supported, substitutes are not yet available
  547. from the build farm (@pxref{Substitutes}), and some packages may fail to
  548. build (@pxref{Tracking Bugs and Changes}). That said, the Guix
  549. community is actively working on improving this support, and now is a
  550. great time to try it and get involved!
  551. @item riscv64-linux
  552. little-endian 64-bit RISC-V processors, specifically RV64GC, and
  553. Linux-Libre kernel. This platform is available as a "technology
  554. preview": although it is supported, substitutes are not yet available
  555. from the build farm (@pxref{Substitutes}), and some packages may fail to
  556. build (@pxref{Tracking Bugs and Changes}). That said, the Guix
  557. community is actively working on improving this support, and now is a
  558. great time to try it and get involved!
  559. @end table
  560. With Guix@tie{}System, you @emph{declare} all aspects of the operating system
  561. configuration and Guix takes care of instantiating the configuration in a
  562. transactional, reproducible, and stateless fashion (@pxref{System
  563. Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
  564. initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
  565. Manual}), the well-known GNU utilities and tool chain, as well as the
  566. graphical environment or system services of your choice.
  567. Guix System is available on all the above platforms except
  568. @code{mips64el-linux}, @code{powerpc-linux}, @code{powerpc64le-linux} and
  569. @code{riscv64-linux}.
  570. @noindent
  571. For information on porting to other architectures or kernels,
  572. @pxref{Porting}.
  573. Building this distribution is a cooperative effort, and you are invited
  574. to join! @xref{Contributing}, for information about how you can help.
  575. @c *********************************************************************
  576. @node Installation
  577. @chapter Installation
  578. @cindex installing Guix
  579. @quotation Note
  580. We recommend the use of this
  581. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  582. shell installer script} to install Guix on top of a running GNU/Linux system,
  583. thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
  584. with the installation of the package manager, which can be done on top of a
  585. running GNU/Linux system. If, instead, you want to install the complete GNU
  586. operating system, @pxref{System Installation}.} The script automates the
  587. download, installation, and initial configuration of Guix. It should be run
  588. as the root user.
  589. @end quotation
  590. @cindex foreign distro
  591. @cindex directories related to foreign distro
  592. When installed on a foreign distro, GNU@tie{}Guix complements the available
  593. tools without interference. Its data lives exclusively in two directories,
  594. usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
  595. such as @file{/etc}, are left untouched.
  596. Once installed, Guix can be updated by running @command{guix pull}
  597. (@pxref{Invoking guix pull}).
  598. If you prefer to perform the installation steps manually or want to tweak
  599. them, you may find the following subsections useful. They describe the
  600. software requirements of Guix, as well as how to install it manually and get
  601. ready to use it.
  602. @menu
  603. * Binary Installation:: Getting Guix running in no time!
  604. * Requirements:: Software needed to build and run Guix.
  605. * Running the Test Suite:: Testing Guix.
  606. * Setting Up the Daemon:: Preparing the build daemon's environment.
  607. * Invoking guix-daemon:: Running the build daemon.
  608. * Application Setup:: Application-specific setup.
  609. * Upgrading Guix:: Upgrading Guix and its build daemon.
  610. @end menu
  611. @node Binary Installation
  612. @section Binary Installation
  613. @cindex installing Guix from binaries
  614. @cindex installer script
  615. This section describes how to install Guix on an arbitrary system from a
  616. self-contained tarball providing binaries for Guix and for all its
  617. dependencies. This is often quicker than installing from source, which
  618. is described in the next sections. The only requirement is to have
  619. GNU@tie{}tar and Xz.
  620. @c Note duplicated from the ``Installation'' node.
  621. @quotation Note
  622. We recommend the use of this
  623. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  624. shell installer script}. The script automates the download, installation, and
  625. initial configuration steps described below. It should be run as the root
  626. user. As root, you can thus run this:
  627. @example
  628. cd /tmp
  629. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  630. chmod +x guix-install.sh
  631. ./guix-install.sh
  632. @end example
  633. If you're running Debian or a derivative such as Ubuntu, you can instead
  634. install the package (it might be a version older than @value{VERSION}
  635. but you can update it afterwards by running @samp{guix pull}):
  636. @example
  637. sudo apt install guix
  638. @end example
  639. Likewise on openSUSE:
  640. @example
  641. sudo zypper install guix
  642. @end example
  643. When you're done, @pxref{Application Setup} for extra configuration you
  644. might need, and @ref{Getting Started} for your first steps!
  645. @end quotation
  646. Installing goes along these lines:
  647. @enumerate
  648. @item
  649. @cindex downloading Guix binary
  650. Download the binary tarball from
  651. @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
  652. where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
  653. @code{i686} (32-bits) machine already running the kernel Linux, and so on
  654. (@pxref{GNU Distribution}).
  655. @c The following is somewhat duplicated in ``System Installation''.
  656. Make sure to download the associated @file{.sig} file and to verify the
  657. authenticity of the tarball against it, along these lines:
  658. @example
  659. $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  660. $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  661. @end example
  662. If that command fails because you do not have the required public key,
  663. then run this command to import it:
  664. @example
  665. $ wget '@value{OPENPGP-SIGNING-KEY-URL}' \
  666. -qO - | gpg --import -
  667. @end example
  668. @noindent
  669. and rerun the @code{gpg --verify} command.
  670. Take note that a warning like ``This key is not certified with a trusted
  671. signature!'' is normal.
  672. @c end authentication part
  673. @item
  674. Now, you need to become the @code{root} user. Depending on your distribution,
  675. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  676. @example
  677. # cd /tmp
  678. # tar --warning=no-timestamp -xf \
  679. /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
  680. # mv var/guix /var/ && mv gnu /
  681. @end example
  682. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  683. The latter contains a ready-to-use profile for @code{root} (see next
  684. step).
  685. Do @emph{not} unpack the tarball on a working Guix system since that
  686. would overwrite its own essential files.
  687. The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  688. not emit warnings about ``implausibly old time stamps'' (such
  689. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  690. versions are fine).
  691. They stem from the fact that all the
  692. files in the archive have their modification time set to 1 (which
  693. means January 1st, 1970). This is done on purpose to make sure the
  694. archive content is independent of its creation time, thus making it
  695. reproducible.
  696. @item
  697. Make the profile available under @file{~root/.config/guix/current}, which is
  698. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  699. @example
  700. # mkdir -p ~root/.config/guix
  701. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  702. ~root/.config/guix/current
  703. @end example
  704. Source @file{etc/profile} to augment @env{PATH} and other relevant
  705. environment variables:
  706. @example
  707. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  708. source $GUIX_PROFILE/etc/profile
  709. @end example
  710. @item
  711. Create the group and user accounts for build users as explained below
  712. (@pxref{Build Environment Setup}).
  713. @item
  714. Run the daemon, and set it to automatically start on boot.
  715. If your host distro uses the systemd init system, this can be achieved
  716. with these commands:
  717. @c Versions of systemd that supported symlinked service files are not
  718. @c yet widely deployed, so we should suggest that users copy the service
  719. @c files into place.
  720. @c
  721. @c See this thread for more information:
  722. @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  723. @example
  724. # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  725. ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  726. /etc/systemd/system/
  727. # systemctl enable --now gnu-store.mount guix-daemon
  728. @end example
  729. You may also want to arrange for @command{guix gc} to run periodically:
  730. @example
  731. # cp ~root/.config/guix/current/lib/systemd/system/guix-gc.service \
  732. ~root/.config/guix/current/lib/systemd/system/guix-gc.timer \
  733. /etc/systemd/system/
  734. # systemctl enable --now guix-gc.timer
  735. @end example
  736. You may want to edit @file{guix-gc.service} to adjust the command line
  737. options to fit your needs (@pxref{Invoking guix gc}).
  738. If your host distro uses the Upstart init system:
  739. @example
  740. # initctl reload-configuration
  741. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  742. /etc/init/
  743. # start guix-daemon
  744. @end example
  745. Otherwise, you can still start the daemon manually with:
  746. @example
  747. # ~root/.config/guix/current/bin/guix-daemon \
  748. --build-users-group=guixbuild
  749. @end example
  750. @item
  751. Make the @command{guix} command available to other users on the machine,
  752. for instance with:
  753. @example
  754. # mkdir -p /usr/local/bin
  755. # cd /usr/local/bin
  756. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  757. @end example
  758. It is also a good idea to make the Info version of this manual available
  759. there:
  760. @example
  761. # mkdir -p /usr/local/share/info
  762. # cd /usr/local/share/info
  763. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  764. do ln -s $i ; done
  765. @end example
  766. That way, assuming @file{/usr/local/share/info} is in the search path,
  767. running @command{info guix} will open this manual (@pxref{Other Info
  768. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  769. Info search path).
  770. @item
  771. @cindex substitutes, authorization thereof
  772. To use substitutes from @code{@value{SUBSTITUTE-SERVER-1}},
  773. @code{@value{SUBSTITUTE-SERVER-2}} or a mirror (@pxref{Substitutes}),
  774. authorize them:
  775. @example
  776. # guix archive --authorize < \
  777. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
  778. # guix archive --authorize < \
  779. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
  780. @end example
  781. @quotation Note
  782. If you do not enable substitutes, Guix will end up building
  783. @emph{everything} from source on your machine, making each installation
  784. and upgrade very expensive. @xref{On Trusting Binaries}, for a
  785. discussion of reasons why one might want do disable substitutes.
  786. @end quotation
  787. @item
  788. Each user may need to perform a few additional steps to make their Guix
  789. environment ready for use, @pxref{Application Setup}.
  790. @end enumerate
  791. Voilà, the installation is complete!
  792. You can confirm that Guix is working by installing a sample package into
  793. the root profile:
  794. @example
  795. # guix install hello
  796. @end example
  797. The binary installation tarball can be (re)produced and verified simply
  798. by running the following command in the Guix source tree:
  799. @example
  800. make guix-binary.@var{system}.tar.xz
  801. @end example
  802. @noindent
  803. ...@: which, in turn, runs:
  804. @example
  805. guix pack -s @var{system} --localstatedir \
  806. --profile-name=current-guix guix
  807. @end example
  808. @xref{Invoking guix pack}, for more info on this handy tool.
  809. @node Requirements
  810. @section Requirements
  811. This section lists requirements when building Guix from source. The
  812. build procedure for Guix is the same as for other GNU software, and is
  813. not covered here. Please see the files @file{README} and @file{INSTALL}
  814. in the Guix source tree for additional details.
  815. @cindex official website
  816. GNU Guix is available for download from its website at
  817. @url{https://www.gnu.org/software/guix/}.
  818. GNU Guix depends on the following packages:
  819. @itemize
  820. @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x,
  821. version 3.0.3 or later;
  822. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  823. 0.1.0 or later;
  824. @item
  825. @uref{https://gitlab.com/gnutls/guile/, Guile-GnuTLS} (@pxref{Guile
  826. Preparations, how to install the GnuTLS bindings for Guile,,
  827. gnutls-guile, GnuTLS-Guile})@footnote{The Guile bindings to
  828. @uref{https://gnutls.org/, GnuTLS} were distributed as part of GnuTLS
  829. until version 3.7.8 included.};
  830. @item
  831. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  832. or later;
  833. @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib},
  834. version 0.1.0 or later;
  835. @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
  836. @item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi};
  837. @item
  838. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.5.0
  839. or later;
  840. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
  841. 4.3.0 or later;
  842. @item @url{https://www.gnu.org/software/make/, GNU Make}.
  843. @end itemize
  844. The following dependencies are optional:
  845. @itemize
  846. @item
  847. @c Note: We need at least 0.13.0 for #:nodelay.
  848. Support for build offloading (@pxref{Daemon Offload Setup}) and
  849. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  850. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  851. version 0.13.0 or later.
  852. @item
  853. @uref{https://notabug.org/guile-zstd/guile-zstd, Guile-zstd}, for zstd
  854. compression and decompression in @command{guix publish} and for
  855. substitutes (@pxref{Invoking guix publish}).
  856. @item
  857. @uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for
  858. the @code{crate} importer (@pxref{Invoking guix import}).
  859. @item
  860. @uref{https://www.nongnu.org/guile-lib/doc/ref/htmlprag/, Guile-Lib} for
  861. the @code{go} importer (@pxref{Invoking guix import}) and for some of
  862. the ``updaters'' (@pxref{Invoking guix refresh}).
  863. @item
  864. When @url{http://www.bzip.org, libbz2} is available,
  865. @command{guix-daemon} can use it to compress build logs.
  866. @end itemize
  867. Unless @option{--disable-daemon} was passed to @command{configure}, the
  868. following packages are also needed:
  869. @itemize
  870. @item @url{https://gnupg.org/, GNU libgcrypt};
  871. @item @url{https://sqlite.org, SQLite 3};
  872. @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
  873. C++11 standard.
  874. @end itemize
  875. @cindex state directory
  876. @cindex localstatedir
  877. @cindex system configuration directory
  878. @cindex sysconfdir
  879. When configuring Guix on a system that already has a Guix installation,
  880. be sure to specify the same state directory as the existing installation
  881. using the @option{--localstatedir} option of the @command{configure}
  882. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  883. GNU Coding Standards}). Usually, this @var{localstatedir} option is set
  884. to the value @file{/var}. The @command{configure} script protects
  885. against unintended misconfiguration of @var{localstatedir} so you do not
  886. inadvertently corrupt your store (@pxref{The Store}). The configuration
  887. directory should also be configured by setting the @option{--sysconfdir}
  888. option to the @file{/etc} value, which is the location used by Guix to
  889. store for example the access control list of authorized machines and the
  890. definition of offload machines.
  891. @node Running the Test Suite
  892. @section Running the Test Suite
  893. @cindex test suite
  894. After a successful @command{configure} and @code{make} run, it is a good
  895. idea to run the test suite. It can help catch issues with the setup or
  896. environment, or bugs in Guix itself---and really, reporting test
  897. failures is a good way to help improve the software. To run the test
  898. suite, type:
  899. @example
  900. make check
  901. @end example
  902. Test cases can run in parallel: you can use the @code{-j} option of
  903. GNU@tie{}make to speed things up. The first run may take a few minutes
  904. on a recent machine; subsequent runs will be faster because the store
  905. that is created for test purposes will already have various things in
  906. cache.
  907. It is also possible to run a subset of the tests by defining the
  908. @code{TESTS} makefile variable as in this example:
  909. @example
  910. make check TESTS="tests/store.scm tests/cpio.scm"
  911. @end example
  912. By default, tests results are displayed at a file level. In order to
  913. see the details of every individual test cases, it is possible to define
  914. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  915. @example
  916. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  917. @end example
  918. The underlying SRFI 64 custom Automake test driver used for the 'check'
  919. test suite (located at @file{build-aux/test-driver.scm}) also allows
  920. selecting which test cases to run at a finer level, via its
  921. @option{--select} and @option{--exclude} options. Here's an example, to
  922. run all the test cases from the @file{tests/packages.scm} test file
  923. whose names start with ``transaction-upgrade-entry'':
  924. @example
  925. export SCM_LOG_DRIVER_FLAGS="--select=^transaction-upgrade-entry"
  926. make check TESTS="tests/packages.scm"
  927. @end example
  928. Those wishing to inspect the results of failed tests directly from the
  929. command line can add the @option{--errors-only=yes} option to the
  930. @code{SCM_LOG_DRIVER_FLAGS} makefile variable and set the @code{VERBOSE}
  931. Automake makefile variable, as in:
  932. @example
  933. make check SCM_LOG_DRIVER_FLAGS="--brief=no --errors-only=yes" VERBOSE=1
  934. @end example
  935. The @option{--show-duration=yes} option can be used to print the
  936. duration of the individual test cases, when used in combination with
  937. @option{--brief=no}:
  938. @example
  939. make check SCM_LOG_DRIVER_FLAGS="--brief=no --show-duration=yes"
  940. @end example
  941. @xref{Parallel Test Harness,,,automake,GNU Automake} for more
  942. information about the Automake Parallel Test Harness.
  943. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  944. @file{test-suite.log} file. Please specify the Guix version being used
  945. as well as version numbers of the dependencies (@pxref{Requirements}) in
  946. your message.
  947. Guix also comes with a whole-system test suite that tests complete
  948. Guix System instances. It can only run on systems where
  949. Guix is already installed, using:
  950. @example
  951. make check-system
  952. @end example
  953. @noindent
  954. or, again, by defining @code{TESTS} to select a subset of tests to run:
  955. @example
  956. make check-system TESTS="basic mcron"
  957. @end example
  958. These system tests are defined in the @code{(gnu tests @dots{})}
  959. modules. They work by running the operating systems under test with
  960. lightweight instrumentation in a virtual machine (VM). They can be
  961. computationally intensive or rather cheap, depending on whether
  962. substitutes are available for their dependencies (@pxref{Substitutes}).
  963. Some of them require a lot of storage space to hold VM images.
  964. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  965. all the details.
  966. @node Setting Up the Daemon
  967. @section Setting Up the Daemon
  968. @cindex daemon
  969. Operations such as building a package or running the garbage collector
  970. are all performed by a specialized process, the @dfn{build daemon}, on
  971. behalf of clients. Only the daemon may access the store and its
  972. associated database. Thus, any operation that manipulates the store
  973. goes through the daemon. For instance, command-line tools such as
  974. @command{guix package} and @command{guix build} communicate with the
  975. daemon (@i{via} remote procedure calls) to instruct it what to do.
  976. The following sections explain how to prepare the build daemon's
  977. environment. See also @ref{Substitutes}, for information on how to allow
  978. the daemon to download pre-built binaries.
  979. @menu
  980. * Build Environment Setup:: Preparing the isolated build environment.
  981. * Daemon Offload Setup:: Offloading builds to remote machines.
  982. * SELinux Support:: Using an SELinux policy for the daemon.
  983. @end menu
  984. @node Build Environment Setup
  985. @subsection Build Environment Setup
  986. @cindex build environment
  987. In a standard multi-user setup, Guix and its daemon---the
  988. @command{guix-daemon} program---are installed by the system
  989. administrator; @file{/gnu/store} is owned by @code{root} and
  990. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  991. Guix tools to build packages or otherwise access the store, and the
  992. daemon will do it on their behalf, ensuring that the store is kept in a
  993. consistent state, and allowing built packages to be shared among users.
  994. @cindex build users
  995. When @command{guix-daemon} runs as @code{root}, you may not want package
  996. build processes themselves to run as @code{root} too, for obvious
  997. security reasons. To avoid that, a special pool of @dfn{build users}
  998. should be created for use by build processes started by the daemon.
  999. These build users need not have a shell and a home directory: they will
  1000. just be used when the daemon drops @code{root} privileges in build
  1001. processes. Having several such users allows the daemon to launch
  1002. distinct build processes under separate UIDs, which guarantees that they
  1003. do not interfere with each other---an essential feature since builds are
  1004. regarded as pure functions (@pxref{Introduction}).
  1005. On a GNU/Linux system, a build user pool may be created like this (using
  1006. Bash syntax and the @code{shadow} commands):
  1007. @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  1008. @c for why `-G' is needed.
  1009. @example
  1010. # groupadd --system guixbuild
  1011. # for i in $(seq -w 1 10);
  1012. do
  1013. useradd -g guixbuild -G guixbuild \
  1014. -d /var/empty -s $(which nologin) \
  1015. -c "Guix build user $i" --system \
  1016. guixbuilder$i;
  1017. done
  1018. @end example
  1019. @noindent
  1020. The number of build users determines how many build jobs may run in
  1021. parallel, as specified by the @option{--max-jobs} option
  1022. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  1023. @command{guix system vm} and related commands, you may need to add the
  1024. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  1025. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  1026. (@pxref{Invoking guix system}).
  1027. The @code{guix-daemon} program may then be run as @code{root} with the
  1028. following command@footnote{If your machine uses the systemd init system,
  1029. copying the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  1030. file to @file{/etc/systemd/system} will ensure that
  1031. @command{guix-daemon} is automatically started. Similarly, if your
  1032. machine uses the Upstart init system, copy the
  1033. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  1034. file to @file{/etc/init}.}:
  1035. @example
  1036. # guix-daemon --build-users-group=guixbuild
  1037. @end example
  1038. @cindex chroot
  1039. @noindent
  1040. This way, the daemon starts build processes in a chroot, under one of
  1041. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  1042. environment contains nothing but:
  1043. @c Keep this list in sync with libstore/build.cc! -----------------------
  1044. @itemize
  1045. @item
  1046. a minimal @code{/dev} directory, created mostly independently from the
  1047. host @code{/dev}@footnote{``Mostly'', because while the set of files
  1048. that appear in the chroot's @code{/dev} is fixed, most of these files
  1049. can only be created if the host has them.};
  1050. @item
  1051. the @code{/proc} directory; it only shows the processes of the container
  1052. since a separate PID name space is used;
  1053. @item
  1054. @file{/etc/passwd} with an entry for the current user and an entry for
  1055. user @file{nobody};
  1056. @item
  1057. @file{/etc/group} with an entry for the user's group;
  1058. @item
  1059. @file{/etc/hosts} with an entry that maps @code{localhost} to
  1060. @code{127.0.0.1};
  1061. @item
  1062. a writable @file{/tmp} directory.
  1063. @end itemize
  1064. The chroot does not contain a @file{/home} directory, and the @env{HOME}
  1065. environment variable is set to the non-existent
  1066. @file{/homeless-shelter}. This helps to highlight inappropriate uses of
  1067. @env{HOME} in the build scripts of packages.
  1068. You can influence the directory where the daemon stores build trees
  1069. @i{via} the @env{TMPDIR} environment variable. However, the build tree
  1070. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  1071. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  1072. This way, the value of @env{TMPDIR} does not leak inside build
  1073. environments, which avoids discrepancies in cases where build processes
  1074. capture the name of their build tree.
  1075. @vindex http_proxy
  1076. @vindex https_proxy
  1077. The daemon also honors the @env{http_proxy} and @env{https_proxy}
  1078. environment variables for HTTP and HTTPS downloads it performs, be it
  1079. for fixed-output derivations (@pxref{Derivations}) or for substitutes
  1080. (@pxref{Substitutes}).
  1081. If you are installing Guix as an unprivileged user, it is still possible
  1082. to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
  1083. However, build processes will not be isolated from one another, and not
  1084. from the rest of the system. Thus, build processes may interfere with
  1085. each other, and may access programs, libraries, and other files
  1086. available on the system---making it much harder to view them as
  1087. @emph{pure} functions.
  1088. @node Daemon Offload Setup
  1089. @subsection Using the Offload Facility
  1090. @cindex offloading
  1091. @cindex build hook
  1092. When desired, the build daemon can @dfn{offload} derivation builds to
  1093. other machines running Guix, using the @code{offload} @dfn{build
  1094. hook}@footnote{This feature is available only when
  1095. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  1096. present.}. When that feature is enabled, a list of user-specified build
  1097. machines is read from @file{/etc/guix/machines.scm}; every time a build
  1098. is requested, for instance via @code{guix build}, the daemon attempts to
  1099. offload it to one of the machines that satisfy the constraints of the
  1100. derivation, in particular its system types---e.g., @code{x86_64-linux}.
  1101. A single machine can have multiple system types, either because its
  1102. architecture natively supports it, via emulation
  1103. (@pxref{transparent-emulation-qemu, Transparent Emulation with QEMU}),
  1104. or both. Missing prerequisites for the build are
  1105. copied over SSH to the target machine, which then proceeds with the
  1106. build; upon success the output(s) of the build are copied back to the
  1107. initial machine. The offload facility comes with a basic scheduler that
  1108. attempts to select the best machine. The best machine is chosen among
  1109. the available machines based on criteria such as:
  1110. @enumerate
  1111. @item
  1112. The availability of a build slot. A build machine can have as many
  1113. build slots (connections) as the value of the @code{parallel-builds}
  1114. field of its @code{build-machine} object.
  1115. @item
  1116. Its relative speed, as defined via the @code{speed} field of its
  1117. @code{build-machine} object.
  1118. @item
  1119. Its load. The normalized machine load must be lower than a threshold
  1120. value, configurable via the @code{overload-threshold} field of its
  1121. @code{build-machine} object.
  1122. @item
  1123. Disk space availability. More than a 100 MiB must be available.
  1124. @end enumerate
  1125. The @file{/etc/guix/machines.scm} file typically looks like this:
  1126. @lisp
  1127. (list (build-machine
  1128. (name "eightysix.example.org")
  1129. (systems (list "x86_64-linux" "i686-linux"))
  1130. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  1131. (user "bob")
  1132. (speed 2.)) ;incredibly fast!
  1133. (build-machine
  1134. (name "armeight.example.org")
  1135. (systems (list "aarch64-linux"))
  1136. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  1137. (user "alice")
  1138. ;; Remember 'guix offload' is spawned by
  1139. ;; 'guix-daemon' as root.
  1140. (private-key "/root/.ssh/identity-for-guix")))
  1141. @end lisp
  1142. @noindent
  1143. In the example above we specify a list of two build machines, one for
  1144. the @code{x86_64} and @code{i686} architectures and one for the
  1145. @code{aarch64} architecture.
  1146. In fact, this file is---not surprisingly!---a Scheme file that is
  1147. evaluated when the @code{offload} hook is started. Its return value
  1148. must be a list of @code{build-machine} objects. While this example
  1149. shows a fixed list of build machines, one could imagine, say, using
  1150. DNS-SD to return a list of potential build machines discovered in the
  1151. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  1152. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  1153. detailed below.
  1154. @deftp {Data Type} build-machine
  1155. This data type represents build machines to which the daemon may offload
  1156. builds. The important fields are:
  1157. @table @code
  1158. @item name
  1159. The host name of the remote machine.
  1160. @item systems
  1161. The system types the remote machine supports---e.g., @code{(list
  1162. "x86_64-linux" "i686-linux")}.
  1163. @item user
  1164. The user account on the remote machine to use when connecting over SSH.
  1165. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  1166. allow non-interactive logins.
  1167. @item host-key
  1168. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  1169. This is used to authenticate the machine when we connect to it. It is a
  1170. long string that looks like this:
  1171. @example
  1172. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  1173. @end example
  1174. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  1175. key can be found in a file such as
  1176. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  1177. If the machine is running the SSH daemon of GNU@tie{}lsh,
  1178. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  1179. similar file. It can be converted to the OpenSSH format using
  1180. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  1181. @example
  1182. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  1183. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  1184. @end example
  1185. @end table
  1186. A number of optional fields may be specified:
  1187. @table @asis
  1188. @item @code{port} (default: @code{22})
  1189. Port number of SSH server on the machine.
  1190. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  1191. The SSH private key file to use when connecting to the machine, in
  1192. OpenSSH format. This key must not be protected with a passphrase.
  1193. Note that the default value is the private key @emph{of the root
  1194. account}. Make sure it exists if you use the default.
  1195. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  1196. @itemx @code{compression-level} (default: @code{3})
  1197. The SSH-level compression methods and compression level requested.
  1198. Note that offloading relies on SSH compression to reduce bandwidth usage
  1199. when transferring files to and from build machines.
  1200. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  1201. File name of the Unix-domain socket @command{guix-daemon} is listening
  1202. to on that machine.
  1203. @item @code{overload-threshold} (default: @code{0.8})
  1204. The load threshold above which a potential offload machine is
  1205. disregarded by the offload scheduler. The value roughly translates to
  1206. the total processor usage of the build machine, ranging from 0.0 (0%) to
  1207. 1.0 (100%). It can also be disabled by setting
  1208. @code{overload-threshold} to @code{#f}.
  1209. @item @code{parallel-builds} (default: @code{1})
  1210. The number of builds that may run in parallel on the machine.
  1211. @item @code{speed} (default: @code{1.0})
  1212. A ``relative speed factor''. The offload scheduler will tend to prefer
  1213. machines with a higher speed factor.
  1214. @item @code{features} (default: @code{'()})
  1215. A list of strings denoting specific features supported by the machine.
  1216. An example is @code{"kvm"} for machines that have the KVM Linux modules
  1217. and corresponding hardware support. Derivations can request features by
  1218. name, and they will be scheduled on matching build machines.
  1219. @end table
  1220. @end deftp
  1221. The @command{guix} command must be in the search path on the build
  1222. machines. You can check whether this is the case by running:
  1223. @example
  1224. ssh build-machine guix repl --version
  1225. @end example
  1226. There is one last thing to do once @file{machines.scm} is in place. As
  1227. explained above, when offloading, files are transferred back and forth
  1228. between the machine stores. For this to work, you first need to
  1229. generate a key pair on each machine to allow the daemon to export signed
  1230. archives of files from the store (@pxref{Invoking guix archive}):
  1231. @example
  1232. # guix archive --generate-key
  1233. @end example
  1234. @quotation Note
  1235. This key pair is not related to the SSH key pair that was previously
  1236. mentioned in the description of the @code{build-machine} data type.
  1237. @end quotation
  1238. @noindent
  1239. Each build machine must authorize the key of the master machine so that
  1240. it accepts store items it receives from the master:
  1241. @example
  1242. # guix archive --authorize < master-public-key.txt
  1243. @end example
  1244. @noindent
  1245. Likewise, the master machine must authorize the key of each build machine.
  1246. All the fuss with keys is here to express pairwise mutual trust
  1247. relations between the master and the build machines. Concretely, when
  1248. the master receives files from a build machine (and @i{vice versa}), its
  1249. build daemon can make sure they are genuine, have not been tampered
  1250. with, and that they are signed by an authorized key.
  1251. @cindex offload test
  1252. To test whether your setup is operational, run this command on the
  1253. master node:
  1254. @example
  1255. # guix offload test
  1256. @end example
  1257. This will attempt to connect to each of the build machines specified in
  1258. @file{/etc/guix/machines.scm}, make sure Guix is
  1259. available on each machine, attempt to export to the machine and import
  1260. from it, and report any error in the process.
  1261. If you want to test a different machine file, just specify it on the
  1262. command line:
  1263. @example
  1264. # guix offload test machines-qualif.scm
  1265. @end example
  1266. Last, you can test the subset of the machines whose name matches a
  1267. regular expression like this:
  1268. @example
  1269. # guix offload test machines.scm '\.gnu\.org$'
  1270. @end example
  1271. @cindex offload status
  1272. To display the current load of all build hosts, run this command on the
  1273. main node:
  1274. @example
  1275. # guix offload status
  1276. @end example
  1277. @node SELinux Support
  1278. @subsection SELinux Support
  1279. @cindex SELinux, daemon policy
  1280. @cindex mandatory access control, SELinux
  1281. @cindex security, guix-daemon
  1282. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  1283. can be installed on a system where SELinux is enabled, in order to label
  1284. Guix files and to specify the expected behavior of the daemon. Since
  1285. Guix System does not provide an SELinux base policy, the daemon policy cannot
  1286. be used on Guix System.
  1287. @subsubsection Installing the SELinux policy
  1288. @cindex SELinux, policy installation
  1289. @quotation Note
  1290. The @code{guix-install.sh} binary installation script offers to perform
  1291. the steps below for you (@pxref{Binary Installation}).
  1292. @end quotation
  1293. To install the policy run this command as root:
  1294. @example
  1295. semodule -i /var/guix/profiles/per-user/root/current-guix/share/selinux/guix-daemon.cil
  1296. @end example
  1297. Then, as root, relabel the file system, possibly after making it
  1298. writable:
  1299. @example
  1300. mount -o remount,rw /gnu/store
  1301. restorecon -R /gnu /var/guix
  1302. @end example
  1303. At this point you can start or restart @command{guix-daemon}; on a
  1304. distribution that uses systemd as its service manager, you can do that
  1305. with:
  1306. @example
  1307. systemctl restart guix-daemon
  1308. @end example
  1309. Once the policy is installed, the file system has been relabeled, and
  1310. the daemon has been restarted, it should be running in the
  1311. @code{guix_daemon_t} context. You can confirm this with the following
  1312. command:
  1313. @example
  1314. ps -Zax | grep guix-daemon
  1315. @end example
  1316. Monitor the SELinux log files as you run a command like @code{guix build
  1317. hello} to convince yourself that SELinux permits all necessary
  1318. operations.
  1319. @subsubsection Limitations
  1320. @cindex SELinux, limitations
  1321. This policy is not perfect. Here is a list of limitations or quirks
  1322. that should be considered when deploying the provided SELinux policy for
  1323. the Guix daemon.
  1324. @enumerate
  1325. @item
  1326. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  1327. operations involve contexts that have anything to do with
  1328. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  1329. but it would be preferable to define socket rules for only this label.
  1330. @item
  1331. @code{guix gc} cannot access arbitrary links to profiles. By design,
  1332. the file label of the destination of a symlink is independent of the
  1333. file label of the link itself. Although all profiles under
  1334. @file{$localstatedir} are labelled, the links to these profiles inherit the
  1335. label of the directory they are in. For links in the user’s home
  1336. directory this will be @code{user_home_t}. But for links from the root
  1337. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  1338. directory, etc, this won’t work. @code{guix gc} would be prevented from
  1339. reading and following these links.
  1340. @item
  1341. The daemon’s feature to listen for TCP connections might no longer work.
  1342. This might require extra rules, because SELinux treats network sockets
  1343. differently from files.
  1344. @item
  1345. Currently all files with a name matching the regular expression
  1346. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  1347. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  1348. that name in any profile would be permitted to run in the
  1349. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  1350. build a package that provides this executable and convince a user to
  1351. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  1352. At that point SELinux could not prevent it from accessing files that are
  1353. allowed for processes in that domain.
  1354. You will need to relabel the store directory after all upgrades to
  1355. @file{guix-daemon}, such as after running @code{guix pull}. Assuming the
  1356. store is in @file{/gnu}, you can do this with @code{restorecon -vR /gnu},
  1357. or by other means provided by your operating system.
  1358. We could generate a much more restrictive policy at installation time,
  1359. so that only the @emph{exact} file name of the currently installed
  1360. @code{guix-daemon} executable would be labelled with
  1361. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  1362. The downside is that root would have to install or upgrade the policy at
  1363. installation time whenever the Guix package that provides the
  1364. effectively running @code{guix-daemon} executable is upgraded.
  1365. @end enumerate
  1366. @node Invoking guix-daemon
  1367. @section Invoking @command{guix-daemon}
  1368. @cindex @command{guix-daemon}
  1369. The @command{guix-daemon} program implements all the functionality to
  1370. access the store. This includes launching build processes, running the
  1371. garbage collector, querying the availability of a build result, etc. It
  1372. is normally run as @code{root} like this:
  1373. @example
  1374. # guix-daemon --build-users-group=guixbuild
  1375. @end example
  1376. @cindex socket activation, for @command{guix-daemon}
  1377. This daemon can also be started following the systemd ``socket
  1378. activation'' protocol (@pxref{Service De- and Constructors,
  1379. @code{make-systemd-constructor},, shepherd, The GNU Shepherd Manual}).
  1380. For details on how to set it up, @pxref{Setting Up the Daemon}.
  1381. @cindex chroot
  1382. @cindex container, build environment
  1383. @cindex build environment
  1384. @cindex reproducible builds
  1385. By default, @command{guix-daemon} launches build processes under
  1386. different UIDs, taken from the build group specified with
  1387. @option{--build-users-group}. In addition, each build process is run in a
  1388. chroot environment that only contains the subset of the store that the
  1389. build process depends on, as specified by its derivation
  1390. (@pxref{Programming Interface, derivation}), plus a set of specific
  1391. system directories. By default, the latter contains @file{/dev} and
  1392. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1393. @dfn{container}: in addition to having its own file system tree, it has
  1394. a separate mount name space, its own PID name space, network name space,
  1395. etc. This helps achieve reproducible builds (@pxref{Features}).
  1396. When the daemon performs a build on behalf of the user, it creates a
  1397. build directory under @file{/tmp} or under the directory specified by
  1398. its @env{TMPDIR} environment variable. This directory is shared with
  1399. the container for the duration of the build, though within the container,
  1400. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1401. The build directory is automatically deleted upon completion, unless the
  1402. build failed and the client specified @option{--keep-failed}
  1403. (@pxref{Common Build Options, @option{--keep-failed}}).
  1404. The daemon listens for connections and spawns one sub-process for each session
  1405. started by a client (one of the @command{guix} sub-commands). The
  1406. @command{guix processes} command allows you to get an overview of the activity
  1407. on your system by viewing each of the active sessions and clients.
  1408. @xref{Invoking guix processes}, for more information.
  1409. The following command-line options are supported:
  1410. @table @code
  1411. @item --build-users-group=@var{group}
  1412. Take users from @var{group} to run build processes (@pxref{Setting Up
  1413. the Daemon, build users}).
  1414. @item --no-substitutes
  1415. @cindex substitutes
  1416. Do not use substitutes for build products. That is, always build things
  1417. locally instead of allowing downloads of pre-built binaries
  1418. (@pxref{Substitutes}).
  1419. When the daemon runs with @option{--no-substitutes}, clients can still
  1420. explicitly enable substitution @i{via} the @code{set-build-options}
  1421. remote procedure call (@pxref{The Store}).
  1422. @anchor{daemon-substitute-urls}
  1423. @item --substitute-urls=@var{urls}
  1424. Consider @var{urls} the default whitespace-separated list of substitute
  1425. source URLs. When this option is omitted,
  1426. @indicateurl{@value{SUBSTITUTE-URLS}} is used.
  1427. This means that substitutes may be downloaded from @var{urls}, as long
  1428. as they are signed by a trusted signature (@pxref{Substitutes}).
  1429. @xref{Getting Substitutes from Other Servers}, for more information on
  1430. how to configure the daemon to get substitutes from other servers.
  1431. @cindex offloading
  1432. @item --no-offload
  1433. Do not use offload builds to other machines (@pxref{Daemon Offload
  1434. Setup}). That is, always build things locally instead of offloading
  1435. builds to remote machines.
  1436. @item --cache-failures
  1437. Cache build failures. By default, only successful builds are cached.
  1438. When this option is used, @command{guix gc --list-failures} can be used
  1439. to query the set of store items marked as failed; @command{guix gc
  1440. --clear-failures} removes store items from the set of cached failures.
  1441. @xref{Invoking guix gc}.
  1442. @item --cores=@var{n}
  1443. @itemx -c @var{n}
  1444. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1445. as available.
  1446. The default value is @code{0}, but it may be overridden by clients, such
  1447. as the @option{--cores} option of @command{guix build} (@pxref{Invoking
  1448. guix build}).
  1449. The effect is to define the @env{NIX_BUILD_CORES} environment variable
  1450. in the build process, which can then use it to exploit internal
  1451. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1452. @item --max-jobs=@var{n}
  1453. @itemx -M @var{n}
  1454. Allow at most @var{n} build jobs in parallel. The default value is
  1455. @code{1}. Setting it to @code{0} means that no builds will be performed
  1456. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1457. Setup}), or simply fail.
  1458. @item --max-silent-time=@var{seconds}
  1459. When the build or substitution process remains silent for more than
  1460. @var{seconds}, terminate it and report a build failure.
  1461. The default value is @code{0}, which disables the timeout.
  1462. The value specified here can be overridden by clients (@pxref{Common
  1463. Build Options, @option{--max-silent-time}}).
  1464. @item --timeout=@var{seconds}
  1465. Likewise, when the build or substitution process lasts for more than
  1466. @var{seconds}, terminate it and report a build failure.
  1467. The default value is @code{0}, which disables the timeout.
  1468. The value specified here can be overridden by clients (@pxref{Common
  1469. Build Options, @option{--timeout}}).
  1470. @item --rounds=@var{N}
  1471. Build each derivation @var{n} times in a row, and raise an error if
  1472. consecutive build results are not bit-for-bit identical. Note that this
  1473. setting can be overridden by clients such as @command{guix build}
  1474. (@pxref{Invoking guix build}).
  1475. When used in conjunction with @option{--keep-failed}, the differing
  1476. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1477. This makes it easy to look for differences between the two results.
  1478. @item --debug
  1479. Produce debugging output.
  1480. This is useful to debug daemon start-up issues, but then it may be
  1481. overridden by clients, for example the @option{--verbosity} option of
  1482. @command{guix build} (@pxref{Invoking guix build}).
  1483. @item --chroot-directory=@var{dir}
  1484. Add @var{dir} to the build chroot.
  1485. Doing this may change the result of build processes---for instance if
  1486. they use optional dependencies found in @var{dir} when it is available,
  1487. and not otherwise. For that reason, it is not recommended to do so.
  1488. Instead, make sure that each derivation declares all the inputs that it
  1489. needs.
  1490. @item --disable-chroot
  1491. Disable chroot builds.
  1492. Using this option is not recommended since, again, it would allow build
  1493. processes to gain access to undeclared dependencies. It is necessary,
  1494. though, when @command{guix-daemon} is running under an unprivileged user
  1495. account.
  1496. @item --log-compression=@var{type}
  1497. Compress build logs according to @var{type}, one of @code{gzip},
  1498. @code{bzip2}, or @code{none}.
  1499. Unless @option{--lose-logs} is used, all the build logs are kept in the
  1500. @var{localstatedir}. To save space, the daemon automatically compresses
  1501. them with gzip by default.
  1502. @item --discover[=yes|no]
  1503. Whether to discover substitute servers on the local network using mDNS
  1504. and DNS-SD.
  1505. This feature is still experimental. However, here are a few
  1506. considerations.
  1507. @enumerate
  1508. @item
  1509. It might be faster/less expensive than fetching from remote servers;
  1510. @item
  1511. There are no security risks, only genuine substitutes will be used
  1512. (@pxref{Substitute Authentication});
  1513. @item
  1514. An attacker advertising @command{guix publish} on your LAN cannot serve
  1515. you malicious binaries, but they can learn what software you’re
  1516. installing;
  1517. @item
  1518. Servers may serve substitute over HTTP, unencrypted, so anyone on the
  1519. LAN can see what software you’re installing.
  1520. @end enumerate
  1521. It is also possible to enable or disable substitute server discovery at
  1522. run-time by running:
  1523. @example
  1524. herd discover guix-daemon on
  1525. herd discover guix-daemon off
  1526. @end example
  1527. @item --disable-deduplication
  1528. @cindex deduplication
  1529. Disable automatic file ``deduplication'' in the store.
  1530. By default, files added to the store are automatically ``deduplicated'':
  1531. if a newly added file is identical to another one found in the store,
  1532. the daemon makes the new file a hard link to the other file. This can
  1533. noticeably reduce disk usage, at the expense of slightly increased
  1534. input/output load at the end of a build process. This option disables
  1535. this optimization.
  1536. @item --gc-keep-outputs[=yes|no]
  1537. Tell whether the garbage collector (GC) must keep outputs of live
  1538. derivations.
  1539. @cindex GC roots
  1540. @cindex garbage collector roots
  1541. When set to @code{yes}, the GC will keep the outputs of any live
  1542. derivation available in the store---the @file{.drv} files. The default
  1543. is @code{no}, meaning that derivation outputs are kept only if they are
  1544. reachable from a GC root. @xref{Invoking guix gc}, for more on GC
  1545. roots.
  1546. @item --gc-keep-derivations[=yes|no]
  1547. Tell whether the garbage collector (GC) must keep derivations
  1548. corresponding to live outputs.
  1549. When set to @code{yes}, as is the case by default, the GC keeps
  1550. derivations---i.e., @file{.drv} files---as long as at least one of their
  1551. outputs is live. This allows users to keep track of the origins of
  1552. items in their store. Setting it to @code{no} saves a bit of disk
  1553. space.
  1554. In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
  1555. liveness to flow from outputs to derivations, and setting
  1556. @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
  1557. derivations to outputs. When both are set to @code{yes}, the effect is
  1558. to keep all the build prerequisites (the sources, compiler, libraries,
  1559. and other build-time tools) of live objects in the store, regardless of
  1560. whether these prerequisites are reachable from a GC root. This is
  1561. convenient for developers since it saves rebuilds or downloads.
  1562. @item --impersonate-linux-2.6
  1563. On Linux-based systems, impersonate Linux 2.6. This means that the
  1564. kernel's @command{uname} system call will report 2.6 as the release number.
  1565. This might be helpful to build programs that (usually wrongfully) depend
  1566. on the kernel version number.
  1567. @item --lose-logs
  1568. Do not keep build logs. By default they are kept under
  1569. @file{@var{localstatedir}/guix/log}.
  1570. @item --system=@var{system}
  1571. Assume @var{system} as the current system type. By default it is the
  1572. architecture/kernel pair found at configure time, such as
  1573. @code{x86_64-linux}.
  1574. @item --listen=@var{endpoint}
  1575. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1576. as the file name of a Unix-domain socket if it starts with
  1577. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1578. host name or host name and port to listen to. Here are a few examples:
  1579. @table @code
  1580. @item --listen=/gnu/var/daemon
  1581. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1582. creating it if needed.
  1583. @item --listen=localhost
  1584. @cindex daemon, remote access
  1585. @cindex remote access to the daemon
  1586. @cindex daemon, cluster setup
  1587. @cindex clusters, daemon setup
  1588. Listen for TCP connections on the network interface corresponding to
  1589. @code{localhost}, on port 44146.
  1590. @item --listen=128.0.0.42:1234
  1591. Listen for TCP connections on the network interface corresponding to
  1592. @code{128.0.0.42}, on port 1234.
  1593. @end table
  1594. This option can be repeated multiple times, in which case
  1595. @command{guix-daemon} accepts connections on all the specified
  1596. endpoints. Users can tell client commands what endpoint to connect to
  1597. by setting the @env{GUIX_DAEMON_SOCKET} environment variable
  1598. (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
  1599. @quotation Note
  1600. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1601. @option{--listen=@var{host}} is suitable on local networks, such as
  1602. clusters, where only trusted nodes may connect to the build daemon. In
  1603. other cases where remote access to the daemon is needed, we recommend
  1604. using Unix-domain sockets along with SSH.
  1605. @end quotation
  1606. When @option{--listen} is omitted, @command{guix-daemon} listens for
  1607. connections on the Unix-domain socket located at
  1608. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1609. @end table
  1610. @node Application Setup
  1611. @section Application Setup
  1612. @cindex foreign distro
  1613. When using Guix on top of GNU/Linux distribution other than Guix System---a
  1614. so-called @dfn{foreign distro}---a few additional steps are needed to
  1615. get everything in place. Here are some of them.
  1616. @subsection Locales
  1617. @anchor{locales-and-locpath}
  1618. @cindex locales, when not on Guix System
  1619. @vindex LOCPATH
  1620. @vindex GUIX_LOCPATH
  1621. Packages installed @i{via} Guix will not use the locale data of the
  1622. host system. Instead, you must first install one of the locale packages
  1623. available with Guix and then define the @env{GUIX_LOCPATH} environment
  1624. variable:
  1625. @example
  1626. $ guix install glibc-locales
  1627. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1628. @end example
  1629. Note that the @code{glibc-locales} package contains data for all the
  1630. locales supported by the GNU@tie{}libc and weighs in at around
  1631. 930@tie{}MiB@footnote{The size of the @code{glibc-locales} package is
  1632. reduced down to about 213@tie{}MiB with store deduplication and further
  1633. down to about 67@tie{}MiB when using a zstd-compressed Btrfs file
  1634. system.}. If you only need a few locales, you can define your custom
  1635. locales package via the @code{make-glibc-utf8-locales} procedure from
  1636. the @code{(gnu packages base)} module. The following example defines a
  1637. package containing the various Canadian UTF-8 locales known to the
  1638. GNU@tie{}libc, that weighs around 14@tie{}MiB:
  1639. @lisp
  1640. (use-modules (gnu packages base))
  1641. (define my-glibc-locales
  1642. (make-glibc-utf8-locales
  1643. glibc
  1644. #:locales (list "en_CA" "fr_CA" "ik_CA" "iu_CA" "shs_CA")
  1645. #:name "glibc-canadian-utf8-locales"))
  1646. @end lisp
  1647. The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
  1648. (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
  1649. Manual}). There are two important differences though:
  1650. @enumerate
  1651. @item
  1652. @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1653. provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
  1654. to make sure the programs of the foreign distro will not end up loading
  1655. incompatible locale data.
  1656. @item
  1657. libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
  1658. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1659. should your Guix profile contain a mixture of programs linked against
  1660. different libc version, each libc version will only try to load locale
  1661. data in the right format.
  1662. @end enumerate
  1663. This is important because the locale data format used by different libc
  1664. versions may be incompatible.
  1665. @subsection Name Service Switch
  1666. @cindex name service switch, glibc
  1667. @cindex NSS (name service switch), glibc
  1668. @cindex @abbr{nscd, name service cache daemon}
  1669. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1670. the system run the GNU C library's @dfn{name service cache daemon},
  1671. @command{nscd}, which should be listening on the
  1672. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1673. installed with Guix may fail to look up host names or user accounts, or
  1674. may even crash. The next paragraphs explain why.
  1675. @cindex @file{nsswitch.conf}
  1676. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1677. an extensible mechanism for ``name lookups'' in general: host name
  1678. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1679. The GNU C Library Reference Manual}).
  1680. @cindex Network information service (NIS)
  1681. @cindex NIS (Network information service)
  1682. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1683. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1684. resolution of @code{.local} host names, the @code{nis} plugin allows
  1685. user account lookup using the Network information service (NIS), and so
  1686. on. These extra ``lookup services'' are configured system-wide in
  1687. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1688. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1689. Reference Manual}).
  1690. When they perform a name lookup---for instance by calling the
  1691. @code{getaddrinfo} function in C---applications first try to connect to
  1692. the nscd; on success, nscd performs name lookups on their behalf. If
  1693. the nscd is not running, then they perform the name lookup by
  1694. themselves, by loading the name lookup services into their own address
  1695. space and running it. These name lookup services---the
  1696. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1697. the host system's C library, rather than from the C library the
  1698. application is linked against (the C library coming from Guix).
  1699. And this is where the problem is: if your application is linked against
  1700. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1701. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1702. likely crash or have its name lookups fail unexpectedly.
  1703. Running @command{nscd} on the system, among other advantages, eliminates
  1704. this binary incompatibility problem because those @code{libnss_*.so}
  1705. files are loaded in the @command{nscd} process, not in applications
  1706. themselves.
  1707. @subsection X11 Fonts
  1708. @cindex fonts
  1709. The majority of graphical applications use Fontconfig to locate and load
  1710. fonts and perform X11-client-side rendering. The @code{fontconfig}
  1711. package in Guix looks for fonts in @file{$HOME/.guix-profile} by
  1712. default. Thus, to allow graphical applications installed with Guix to
  1713. display fonts, you have to install fonts with Guix as well. Essential
  1714. font packages include @code{font-ghostscript}, @code{font-dejavu}, and
  1715. @code{font-gnu-freefont}.
  1716. @cindex @code{fc-cache}
  1717. @cindex font cache
  1718. Once you have installed or removed fonts, or when you notice an
  1719. application that does not find fonts, you may need to install Fontconfig
  1720. and to force an update of its font cache by running:
  1721. @example
  1722. guix install fontconfig
  1723. fc-cache -rv
  1724. @end example
  1725. To display text written in Chinese languages, Japanese, or Korean in
  1726. graphical applications, consider installing
  1727. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1728. has multiple outputs, one per language family (@pxref{Packages with
  1729. Multiple Outputs}). For instance, the following command installs fonts
  1730. for Chinese languages:
  1731. @example
  1732. guix install font-adobe-source-han-sans:cn
  1733. @end example
  1734. @cindex @code{xterm}
  1735. Older programs such as @command{xterm} do not use Fontconfig and instead
  1736. rely on server-side font rendering. Such programs require to specify a
  1737. full name of a font using XLFD (X Logical Font Description), like this:
  1738. @example
  1739. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1740. @end example
  1741. To be able to use such full names for the TrueType fonts installed in
  1742. your Guix profile, you need to extend the font path of the X server:
  1743. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1744. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1745. @example
  1746. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1747. @end example
  1748. @cindex @code{xlsfonts}
  1749. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1750. to make sure your TrueType fonts are listed there.
  1751. @subsection X.509 Certificates
  1752. @cindex @code{nss-certs}
  1753. The @code{nss-certs} package provides X.509 certificates, which allow
  1754. programs to authenticate Web servers accessed over HTTPS.
  1755. When using Guix on a foreign distro, you can install this package and
  1756. define the relevant environment variables so that packages know where to
  1757. look for certificates. @xref{X.509 Certificates}, for detailed
  1758. information.
  1759. @subsection Emacs Packages
  1760. @cindex @code{emacs}
  1761. When you install Emacs packages with Guix, the Elisp files are placed
  1762. under the @file{share/emacs/site-lisp/} directory of the profile in
  1763. which they are installed. The Elisp libraries are made available to
  1764. Emacs through the @env{EMACSLOADPATH} environment variable, which is
  1765. set when installing Emacs itself.
  1766. Additionally, autoload definitions are automatically evaluated at the
  1767. initialization of Emacs, by the Guix-specific
  1768. @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
  1769. want to avoid auto-loading the Emacs packages installed with Guix, you
  1770. can do so by running Emacs with the @option{--no-site-file} option
  1771. (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1772. @quotation Note
  1773. Emacs can now compile packages natively. Under the default
  1774. configuration, this means that Emacs packages will now be
  1775. just-in-time (JIT) compiled as you use them, and the results
  1776. stored in a subdirectory of your @code{user-emacs-directory}.
  1777. Furthermore, the build system for Emacs packages transparently
  1778. supports native compilation, but note, that
  1779. @code{emacs-minimal}---the default Emacs for building
  1780. packages---has been configured without native compilation.
  1781. To natively compile your emacs packages ahead of time, use a
  1782. transformation like @option{--with-input=emacs-minimal=emacs}.
  1783. @end quotation
  1784. @node Upgrading Guix
  1785. @section Upgrading Guix
  1786. @cindex Upgrading Guix, on a foreign distro
  1787. To upgrade Guix, run:
  1788. @example
  1789. guix pull
  1790. @end example
  1791. @xref{Invoking guix pull}, for more information.
  1792. @cindex upgrading Guix for the root user, on a foreign distro
  1793. @cindex upgrading the Guix daemon, on a foreign distro
  1794. @cindex @command{guix pull} for the root user, on a foreign distro
  1795. On a foreign distro, you can upgrade the build daemon by running:
  1796. @example
  1797. sudo -i guix pull
  1798. @end example
  1799. @noindent
  1800. followed by (assuming your distro uses the systemd service management
  1801. tool):
  1802. @example
  1803. systemctl restart guix-daemon.service
  1804. @end example
  1805. On Guix System, upgrading the daemon is achieved by reconfiguring the
  1806. system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
  1807. @c TODO What else?
  1808. @c *********************************************************************
  1809. @node System Installation
  1810. @chapter System Installation
  1811. @cindex installing Guix System
  1812. @cindex Guix System, installation
  1813. This section explains how to install Guix System
  1814. on a machine. Guix, as a package manager, can
  1815. also be installed on top of a running GNU/Linux system,
  1816. @pxref{Installation}.
  1817. @ifinfo
  1818. @quotation Note
  1819. @c This paragraph is for people reading this from tty2 of the
  1820. @c installation image.
  1821. You are reading this documentation with an Info reader. For details on
  1822. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  1823. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  1824. Info}. Hit @kbd{l} afterwards to come back here.
  1825. Alternatively, run @command{info info} in another tty to keep the manual
  1826. available.
  1827. @end quotation
  1828. @end ifinfo
  1829. @menu
  1830. * Limitations:: What you can expect.
  1831. * Hardware Considerations:: Supported hardware.
  1832. * USB Stick and DVD Installation:: Preparing the installation medium.
  1833. * Preparing for Installation:: Networking, partitioning, etc.
  1834. * Guided Graphical Installation:: Easy graphical installation.
  1835. * Manual Installation:: Manual installation for wizards.
  1836. * After System Installation:: When installation succeeded.
  1837. * Installing Guix in a VM:: Guix System playground.
  1838. * Building the Installation Image:: How this comes to be.
  1839. @end menu
  1840. @node Limitations
  1841. @section Limitations
  1842. We consider Guix System to be ready for a wide range of ``desktop'' and server
  1843. use cases. The reliability guarantees it provides---transactional upgrades
  1844. and rollbacks, reproducibility---make it a solid foundation.
  1845. Nevertheless, before you proceed with the installation, be aware of the
  1846. following noteworthy limitations applicable to version @value{VERSION}:
  1847. @itemize
  1848. @item
  1849. More and more system services are provided (@pxref{Services}), but some
  1850. may be missing.
  1851. @item
  1852. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  1853. as well as a number of X11 window managers. However, KDE is currently
  1854. missing.
  1855. @end itemize
  1856. More than a disclaimer, this is an invitation to report issues (and success
  1857. stories!), and to join us in improving it. @xref{Contributing}, for more
  1858. info.
  1859. @node Hardware Considerations
  1860. @section Hardware Considerations
  1861. @cindex hardware support on Guix System
  1862. GNU@tie{}Guix focuses on respecting the user's computing freedom. It
  1863. builds around the kernel Linux-libre, which means that only hardware for
  1864. which free software drivers and firmware exist is supported. Nowadays,
  1865. a wide range of off-the-shelf hardware is supported on
  1866. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  1867. Ethernet controllers. Unfortunately, there are still areas where
  1868. hardware vendors deny users control over their own computing, and such
  1869. hardware is not supported on Guix System.
  1870. @cindex WiFi, hardware support
  1871. One of the main areas where free drivers or firmware are lacking is WiFi
  1872. devices. WiFi devices known to work include those using Atheros chips
  1873. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  1874. driver, and those using Broadcom/AirForce chips (BCM43xx with
  1875. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  1876. Linux-libre driver. Free firmware exists for both and is available
  1877. out-of-the-box on Guix System, as part of @code{%base-firmware}
  1878. (@pxref{operating-system Reference, @code{firmware}}).
  1879. The installer warns you early on if it detects devices that are known
  1880. @emph{not} to work due to the lack of free firmware or free drivers.
  1881. @cindex RYF, Respects Your Freedom
  1882. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  1883. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  1884. certification program for hardware products that respect your freedom
  1885. and your privacy and ensure that you have control over your device. We
  1886. encourage you to check the list of RYF-certified devices.
  1887. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  1888. web site. It contains a catalog of hardware devices with information
  1889. about their support in GNU/Linux.
  1890. @node USB Stick and DVD Installation
  1891. @section USB Stick and DVD Installation
  1892. An ISO-9660 installation image that can be written to a USB stick or
  1893. burnt to a DVD can be downloaded from
  1894. @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso},
  1895. where you can replace @code{x86_64-linux} with one of:
  1896. @table @code
  1897. @item x86_64-linux
  1898. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  1899. @item i686-linux
  1900. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  1901. @end table
  1902. @c start duplication of authentication part from ``Binary Installation''
  1903. Make sure to download the associated @file{.sig} file and to verify the
  1904. authenticity of the image against it, along these lines:
  1905. @example
  1906. $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
  1907. $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
  1908. @end example
  1909. If that command fails because you do not have the required public key,
  1910. then run this command to import it:
  1911. @example
  1912. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  1913. -qO - | gpg --import -
  1914. @end example
  1915. @noindent
  1916. and rerun the @code{gpg --verify} command.
  1917. Take note that a warning like ``This key is not certified with a trusted
  1918. signature!'' is normal.
  1919. @c end duplication
  1920. This image contains the tools necessary for an installation.
  1921. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  1922. @unnumberedsubsec Copying to a USB Stick
  1923. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  1924. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  1925. copy the image with:
  1926. @example
  1927. dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
  1928. sync
  1929. @end example
  1930. Access to @file{/dev/sdX} usually requires root privileges.
  1931. @unnumberedsubsec Burning on a DVD
  1932. Insert a blank DVD into your machine, and determine
  1933. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  1934. copy the image with:
  1935. @example
  1936. growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
  1937. @end example
  1938. Access to @file{/dev/srX} usually requires root privileges.
  1939. @unnumberedsubsec Booting
  1940. Once this is done, you should be able to reboot the system and boot from
  1941. the USB stick or DVD@. The latter usually requires you to get in the
  1942. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  1943. In order to boot from Libreboot, switch to the command mode by pressing
  1944. the @kbd{c} key and type @command{search_grub usb}.
  1945. Sadly, on some machines, the installation medium cannot be properly
  1946. booted and you only see a black screen after booting even after you
  1947. waited for ten minutes. This may indicate that your machine cannot run
  1948. Guix System; perhaps you instead want to install Guix on a foreign
  1949. distro (@pxref{Binary Installation}). But don't give up just yet; a
  1950. possible workaround is pressing the @kbd{e} key in the GRUB boot menu
  1951. and appending @option{nomodeset} to the Linux bootline.
  1952. Sometimes the black screen issue can also be resolved by connecting a
  1953. different display.
  1954. @xref{Installing Guix in a VM}, if, instead, you would like to install
  1955. Guix System in a virtual machine (VM).
  1956. @node Preparing for Installation
  1957. @section Preparing for Installation
  1958. Once you have booted, you can use the guided graphical installer, which makes
  1959. it easy to get started (@pxref{Guided Graphical Installation}). Alternatively,
  1960. if you are already familiar with GNU/Linux and if you want more control than
  1961. what the graphical installer provides, you can choose the ``manual''
  1962. installation process (@pxref{Manual Installation}).
  1963. The graphical installer is available on TTY1. You can obtain root shells on
  1964. TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
  1965. this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
  1966. is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  1967. Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
  1968. which allows you to select text with the left mouse button and to paste it
  1969. with the middle button.
  1970. @quotation Note
  1971. Installation requires access to the Internet so that any missing
  1972. dependencies of your system configuration can be downloaded. See the
  1973. ``Networking'' section below.
  1974. @end quotation
  1975. @node Guided Graphical Installation
  1976. @section Guided Graphical Installation
  1977. The graphical installer is a text-based user interface. It will guide you,
  1978. with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
  1979. The first dialog boxes allow you to set up the system as you use it during the
  1980. installation: you can choose the language, keyboard layout, and set up
  1981. networking, which will be used during the installation. The image below shows
  1982. the networking dialog.
  1983. @image{images/installer-network,5in,, networking setup with the graphical installer}
  1984. Later steps allow you to partition your hard disk, as shown in the image
  1985. below, to choose whether or not to use encrypted file systems, to enter the
  1986. host name and root password, and to create an additional account, among other
  1987. things.
  1988. @image{images/installer-partitions,5in,, partitioning with the graphical installer}
  1989. Note that, at any time, the installer allows you to exit the current
  1990. installation step and resume at a previous step, as show in the image below.
  1991. @image{images/installer-resume,5in,, resuming the installation process}
  1992. Once you're done, the installer produces an operating system configuration and
  1993. displays it (@pxref{Using the Configuration System}). At that point you can
  1994. hit ``OK'' and installation will proceed. On success, you can reboot into the
  1995. new system and enjoy. @xref{After System Installation}, for what's next!
  1996. @node Manual Installation
  1997. @section Manual Installation
  1998. This section describes how you would ``manually'' install GNU@tie{}Guix System
  1999. on your machine. This option requires familiarity with GNU/Linux, with the
  2000. shell, and with common administration tools. If you think this is not for
  2001. you, consider using the guided graphical installer (@pxref{Guided Graphical
  2002. Installation}).
  2003. The installation system provides root shells on TTYs 3 to 6; press
  2004. @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
  2005. many common tools needed to install the system, but is also a full-blown
  2006. Guix System. This means that you can install additional packages, should you
  2007. need it, using @command{guix package} (@pxref{Invoking guix package}).
  2008. @menu
  2009. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  2010. * Proceeding with the Installation:: Installing.
  2011. @end menu
  2012. @node Keyboard Layout and Networking and Partitioning
  2013. @subsection Keyboard Layout, Networking, and Partitioning
  2014. Before you can install the system, you may want to adjust the keyboard layout,
  2015. set up networking, and partition your target hard disk. This section will
  2016. guide you through this.
  2017. @subsubsection Keyboard Layout
  2018. @cindex keyboard layout
  2019. The installation image uses the US qwerty keyboard layout. If you want
  2020. to change it, you can use the @command{loadkeys} command. For example,
  2021. the following command selects the Dvorak keyboard layout:
  2022. @example
  2023. loadkeys dvorak
  2024. @end example
  2025. See the files under @file{/run/current-system/profile/share/keymaps} for
  2026. a list of available keyboard layouts. Run @command{man loadkeys} for
  2027. more information.
  2028. @anchor{manual-installation-networking}
  2029. @subsubsection Networking
  2030. Run the following command to see what your network interfaces are called:
  2031. @example
  2032. ifconfig -a
  2033. @end example
  2034. @noindent
  2035. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  2036. @example
  2037. ip address
  2038. @end example
  2039. @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  2040. Wired interfaces have a name starting with @samp{e}; for example, the
  2041. interface corresponding to the first on-board Ethernet controller is
  2042. called @samp{eno1}. Wireless interfaces have a name starting with
  2043. @samp{w}, like @samp{w1p2s0}.
  2044. @table @asis
  2045. @item Wired connection
  2046. To configure a wired network run the following command, substituting
  2047. @var{interface} with the name of the wired interface you want to use.
  2048. @example
  2049. ifconfig @var{interface} up
  2050. @end example
  2051. @noindent
  2052. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  2053. @example
  2054. ip link set @var{interface} up
  2055. @end example
  2056. @item Wireless connection
  2057. @cindex wireless
  2058. @cindex WiFi
  2059. To configure wireless networking, you can create a configuration file
  2060. for the @command{wpa_supplicant} configuration tool (its location is not
  2061. important) using one of the available text editors such as
  2062. @command{nano}:
  2063. @example
  2064. nano wpa_supplicant.conf
  2065. @end example
  2066. As an example, the following stanza can go to this file and will work
  2067. for many wireless networks, provided you give the actual SSID and
  2068. passphrase for the network you are connecting to:
  2069. @example
  2070. network=@{
  2071. ssid="@var{my-ssid}"
  2072. key_mgmt=WPA-PSK
  2073. psk="the network's secret passphrase"
  2074. @}
  2075. @end example
  2076. Start the wireless service and run it in the background with the
  2077. following command (substitute @var{interface} with the name of the
  2078. network interface you want to use):
  2079. @example
  2080. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  2081. @end example
  2082. Run @command{man wpa_supplicant} for more information.
  2083. @end table
  2084. @cindex DHCP
  2085. At this point, you need to acquire an IP address. On a network where IP
  2086. addresses are automatically assigned @i{via} DHCP, you can run:
  2087. @example
  2088. dhclient -v @var{interface}
  2089. @end example
  2090. Try to ping a server to see if networking is up and running:
  2091. @example
  2092. ping -c 3 gnu.org
  2093. @end example
  2094. Setting up network access is almost always a requirement because the
  2095. image does not contain all the software and tools that may be needed.
  2096. @cindex proxy, during system installation
  2097. If you need HTTP and HTTPS access to go through a proxy, run the
  2098. following command:
  2099. @example
  2100. herd set-http-proxy guix-daemon @var{URL}
  2101. @end example
  2102. @noindent
  2103. where @var{URL} is the proxy URL, for example
  2104. @code{http://example.org:8118}.
  2105. @cindex installing over SSH
  2106. If you want to, you can continue the installation remotely by starting
  2107. an SSH server:
  2108. @example
  2109. herd start ssh-daemon
  2110. @end example
  2111. Make sure to either set a password with @command{passwd}, or configure
  2112. OpenSSH public key authentication before logging in.
  2113. @subsubsection Disk Partitioning
  2114. Unless this has already been done, the next step is to partition, and
  2115. then format the target partition(s).
  2116. The installation image includes several partitioning tools, including
  2117. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  2118. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  2119. the partition layout you want:
  2120. @example
  2121. cfdisk
  2122. @end example
  2123. If your disk uses the GUID Partition Table (GPT) format and you plan to
  2124. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  2125. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  2126. manual}).
  2127. @cindex EFI, installation
  2128. @cindex UEFI, installation
  2129. @cindex ESP, EFI system partition
  2130. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  2131. (ESP) is required. This partition can be mounted at @file{/boot/efi} for
  2132. instance and must have the @code{esp} flag set. E.g., for @command{parted}:
  2133. @example
  2134. parted /dev/sda set 1 esp on
  2135. @end example
  2136. @quotation Note
  2137. @vindex grub-bootloader
  2138. @vindex grub-efi-bootloader
  2139. Unsure whether to use EFI- or BIOS-based GRUB? If the directory
  2140. @file{/sys/firmware/efi} exists in the installation image, then you should
  2141. probably perform an EFI installation, using @code{grub-efi-bootloader}.
  2142. Otherwise you should use the BIOS-based GRUB, known as
  2143. @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
  2144. bootloaders.
  2145. @end quotation
  2146. Once you are done partitioning the target hard disk drive, you have to
  2147. create a file system on the relevant partition(s)@footnote{Currently
  2148. Guix System only supports ext4, btrfs, JFS, F2FS, and XFS file systems. In
  2149. particular, code that reads file system UUIDs and labels only works for these
  2150. file system types.}. For the ESP, if you have one and assuming it is
  2151. @file{/dev/sda1}, run:
  2152. @example
  2153. mkfs.fat -F32 /dev/sda1
  2154. @end example
  2155. For the root file system, ext4 is the most widely used format. Other
  2156. file systems, such as Btrfs, support compression, which is reported to
  2157. nicely complement file deduplication that the daemon performs
  2158. independently of the file system (@pxref{Invoking guix-daemon,
  2159. deduplication}).
  2160. Preferably, assign file systems a label so that you can easily and
  2161. reliably refer to them in @code{file-system} declarations (@pxref{File
  2162. Systems}). This is typically done using the @code{-L} option of
  2163. @command{mkfs.ext4} and related commands. So, assuming the target root
  2164. partition lives at @file{/dev/sda2}, a file system with the label
  2165. @code{my-root} can be created with:
  2166. @example
  2167. mkfs.ext4 -L my-root /dev/sda2
  2168. @end example
  2169. @cindex encrypted disk
  2170. If you are instead planning to encrypt the root partition, you can use
  2171. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  2172. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  2173. @code{man cryptsetup}} for more information).
  2174. @quotation Warning
  2175. Note that GRUB can unlock LUKS2 devices since version 2.06, but only
  2176. supports the PBKDF2 key derivation function, which is not the default
  2177. for @command{cryptsetup luksFormat}. You can check which key derivation
  2178. function is being used by a device by running @command{cryptsetup
  2179. luksDump @var{device}}, and looking for the PBKDF field of your
  2180. keyslots.
  2181. @end quotation
  2182. Assuming you want to store the root partition on @file{/dev/sda2}, the
  2183. command sequence to format it as a LUKS2 partition would be along these
  2184. lines:
  2185. @example
  2186. cryptsetup luksFormat --type luks2 --pbkdf pbkdf2 /dev/sda2
  2187. cryptsetup open /dev/sda2 my-partition
  2188. mkfs.ext4 -L my-root /dev/mapper/my-partition
  2189. @end example
  2190. Once that is done, mount the target file system under @file{/mnt}
  2191. with a command like (again, assuming @code{my-root} is the label of the
  2192. root file system):
  2193. @example
  2194. mount LABEL=my-root /mnt
  2195. @end example
  2196. Also mount any other file systems you would like to use on the target
  2197. system relative to this path. If you have opted for @file{/boot/efi} as an
  2198. EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
  2199. found by @code{guix system init} afterwards.
  2200. Finally, if you plan to use one or more swap partitions (@pxref{Swap
  2201. Space}), make sure to initialize them with @command{mkswap}. Assuming
  2202. you have one swap partition on @file{/dev/sda3}, you would run:
  2203. @example
  2204. mkswap /dev/sda3
  2205. swapon /dev/sda3
  2206. @end example
  2207. Alternatively, you may use a swap file. For example, assuming that in
  2208. the new system you want to use the file @file{/swapfile} as a swap file,
  2209. you would run@footnote{This example will work for many types of file
  2210. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  2211. btrfs), the required steps may be different. For details, see the
  2212. manual pages for @command{mkswap} and @command{swapon}.}:
  2213. @example
  2214. # This is 10 GiB of swap space. Adjust "count" to change the size.
  2215. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  2216. # For security, make the file readable and writable only by root.
  2217. chmod 600 /mnt/swapfile
  2218. mkswap /mnt/swapfile
  2219. swapon /mnt/swapfile
  2220. @end example
  2221. Note that if you have encrypted the root partition and created a swap
  2222. file in its file system as described above, then the encryption also
  2223. protects the swap file, just like any other file in that file system.
  2224. @node Proceeding with the Installation
  2225. @subsection Proceeding with the Installation
  2226. With the target partitions ready and the target root mounted on
  2227. @file{/mnt}, we're ready to go. First, run:
  2228. @example
  2229. herd start cow-store /mnt
  2230. @end example
  2231. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  2232. during the installation phase are written to the target disk on @file{/mnt}
  2233. rather than kept in memory. This is necessary because the first phase of
  2234. the @command{guix system init} command (see below) entails downloads or
  2235. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  2236. Next, you have to edit a file and
  2237. provide the declaration of the operating system to be installed. To
  2238. that end, the installation system comes with three text editors. We
  2239. recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
  2240. supports syntax highlighting and parentheses matching; other editors
  2241. include mg (an Emacs clone), and
  2242. nvi (a clone of the original BSD @command{vi} editor).
  2243. We strongly recommend storing that file on the target root file system, say,
  2244. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  2245. configuration file once you have rebooted into the newly-installed system.
  2246. @xref{Using the Configuration System}, for an overview of the
  2247. configuration file. The example configurations discussed in that
  2248. section are available under @file{/etc/configuration} in the
  2249. installation image. Thus, to get started with a system configuration
  2250. providing a graphical display server (a ``desktop'' system), you can run
  2251. something along these lines:
  2252. @example
  2253. # mkdir /mnt/etc
  2254. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  2255. # nano /mnt/etc/config.scm
  2256. @end example
  2257. You should pay attention to what your configuration file contains, and
  2258. in particular:
  2259. @itemize
  2260. @item
  2261. Make sure the @code{bootloader-configuration} form refers to the targets
  2262. you want to install GRUB on. It should mention @code{grub-bootloader}
  2263. if you are installing GRUB in the legacy way, or
  2264. @code{grub-efi-bootloader} for newer UEFI systems. For legacy systems,
  2265. the @code{targets} field contain the names of the devices, like
  2266. @code{(list "/dev/sda")}; for UEFI systems it names the paths to mounted
  2267. EFI partitions, like @code{(list "/boot/efi")}; do make sure the paths
  2268. are currently mounted and a @code{file-system} entry is specified in
  2269. your configuration.
  2270. @item
  2271. Be sure that your file system labels match the value of their respective
  2272. @code{device} fields in your @code{file-system} configuration, assuming
  2273. your @code{file-system} configuration uses the @code{file-system-label}
  2274. procedure in its @code{device} field.
  2275. @item
  2276. If there are encrypted or RAID partitions, make sure to add a
  2277. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  2278. @end itemize
  2279. Once you are done preparing the configuration file, the new system must
  2280. be initialized (remember that the target root file system is mounted
  2281. under @file{/mnt}):
  2282. @example
  2283. guix system init /mnt/etc/config.scm /mnt
  2284. @end example
  2285. @noindent
  2286. This copies all the necessary files and installs GRUB on
  2287. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  2288. more information, @pxref{Invoking guix system}. This command may trigger
  2289. downloads or builds of missing packages, which can take some time.
  2290. Once that command has completed---and hopefully succeeded!---you can run
  2291. @command{reboot} and boot into the new system. The @code{root} password
  2292. in the new system is initially empty; other users' passwords need to be
  2293. initialized by running the @command{passwd} command as @code{root},
  2294. unless your configuration specifies otherwise
  2295. (@pxref{user-account-password, user account passwords}).
  2296. @xref{After System Installation}, for what's next!
  2297. @node After System Installation
  2298. @section After System Installation
  2299. Success, you've now booted into Guix System! From then on, you can update the
  2300. system whenever you want by running, say:
  2301. @example
  2302. guix pull
  2303. sudo guix system reconfigure /etc/config.scm
  2304. @end example
  2305. @noindent
  2306. This builds a new system generation with the latest packages and services
  2307. (@pxref{Invoking guix system}). We recommend doing that regularly so that
  2308. your system includes the latest security updates (@pxref{Security Updates}).
  2309. @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
  2310. @quotation Note
  2311. @cindex sudo vs. @command{guix pull}
  2312. Note that @command{sudo guix} runs your user's @command{guix} command and
  2313. @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
  2314. explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
  2315. The difference matters here, because @command{guix pull} updates
  2316. the @command{guix} command and package definitions only for the user it is run
  2317. as. This means that if you choose to use @command{guix system reconfigure} in
  2318. root's login shell, you'll need to @command{guix pull} separately.
  2319. @end quotation
  2320. Now, @pxref{Getting Started}, and
  2321. join us on @code{#guix} on the Libera Chat IRC network or on
  2322. @email{guix-devel@@gnu.org} to share your experience!
  2323. @node Installing Guix in a VM
  2324. @section Installing Guix in a Virtual Machine
  2325. @cindex virtual machine, Guix System installation
  2326. @cindex virtual private server (VPS)
  2327. @cindex VPS (virtual private server)
  2328. If you'd like to install Guix System in a virtual machine (VM) or on a
  2329. virtual private server (VPS) rather than on your beloved machine, this
  2330. section is for you.
  2331. To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
  2332. disk image, follow these steps:
  2333. @enumerate
  2334. @item
  2335. First, retrieve and decompress the Guix system installation image as
  2336. described previously (@pxref{USB Stick and DVD Installation}).
  2337. @item
  2338. Create a disk image that will hold the installed system. To make a
  2339. qcow2-formatted disk image, use the @command{qemu-img} command:
  2340. @example
  2341. qemu-img create -f qcow2 guix-system.img 50G
  2342. @end example
  2343. The resulting file will be much smaller than 50 GB (typically less than
  2344. 1 MB), but it will grow as the virtualized storage device is filled up.
  2345. @item
  2346. Boot the USB installation image in an VM:
  2347. @example
  2348. qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
  2349. -nic user,model=virtio-net-pci -boot menu=on,order=d \
  2350. -drive file=guix-system.img \
  2351. -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
  2352. @end example
  2353. @code{-enable-kvm} is optional, but significantly improves performance,
  2354. @pxref{Running Guix in a VM}.
  2355. @item
  2356. You're now root in the VM, proceed with the installation process.
  2357. @xref{Preparing for Installation}, and follow the instructions.
  2358. @end enumerate
  2359. Once installation is complete, you can boot the system that's on your
  2360. @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
  2361. that.
  2362. @node Building the Installation Image
  2363. @section Building the Installation Image
  2364. @cindex installation image
  2365. The installation image described above was built using the @command{guix
  2366. system} command, specifically:
  2367. @example
  2368. guix system image -t iso9660 gnu/system/install.scm
  2369. @end example
  2370. Have a look at @file{gnu/system/install.scm} in the source tree,
  2371. and see also @ref{Invoking guix system} for more information
  2372. about the installation image.
  2373. @section Building the Installation Image for ARM Boards
  2374. Many ARM boards require a specific variant of the
  2375. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  2376. If you build a disk image and the bootloader is not available otherwise
  2377. (on another boot drive etc), it's advisable to build an image that
  2378. includes the bootloader, specifically:
  2379. @example
  2380. guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  2381. @end example
  2382. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  2383. board, a list of possible boards will be printed.
  2384. @c *********************************************************************
  2385. @cindex troubleshooting, guix system
  2386. @cindex guix system troubleshooting
  2387. @node System Troubleshooting Tips
  2388. @chapter System Troubleshooting Tips
  2389. Guix System allows rebooting into a previous generation should the last
  2390. one be malfunctioning, which makes it quite robust against being broken
  2391. irreversibly. This feature depends on GRUB being correctly functioning
  2392. though, which means that if for whatever reasons your GRUB installation
  2393. becomes corrupted during a system reconfiguration, you may not be able
  2394. to easily boot into a previous generation. A technique that can be used
  2395. in this case is to @i{chroot} into your broken system and reconfigure it
  2396. from there. Such technique is explained below.
  2397. @cindex chroot, guix system
  2398. @cindex chrooting, guix system
  2399. @cindex repairing GRUB, via chroot
  2400. @menu
  2401. * Chrooting into an existing system::
  2402. @end menu
  2403. @node Chrooting into an existing system
  2404. @section Chrooting into an existing system
  2405. This section details how to @i{chroot} to an already installed Guix
  2406. System with the aim of reconfiguring it, for example to fix a broken
  2407. GRUB installation. The process is similar to how it would be done on
  2408. other GNU/Linux systems, but there are some Guix System particularities
  2409. such as the daemon and profiles that make it worthy of explaining here.
  2410. @enumerate
  2411. @item
  2412. Obtain a bootable image of Guix System. It is recommended the latest
  2413. development snapshot so the kernel and the tools used are at least as as
  2414. new as those of your installed system; it can be retrieved from the
  2415. @url{https://ci.guix.gnu.org/search/latest/ISO-9660?query=spec:images+status:success+system:x86_64-linux+image.iso,
  2416. https://ci.guix.gnu.org} URL. Follow the @pxref{USB Stick and DVD
  2417. Installation} section for copying it to a bootable media.
  2418. @item
  2419. Boot the image, and proceed with the graphical text-based installer
  2420. until your network is configured. Alternatively, you could configure
  2421. the network manually by following the
  2422. @ref{manual-installation-networking} section. If you get the error
  2423. @samp{RTNETLINK answers: Operation not possible due to RF-kill}, try
  2424. @samp{rfkill list} followed by @samp{rfkill unblock 0}, where @samp{0}
  2425. is your device identifier (ID).
  2426. @item
  2427. Switch to a virtual console (tty) if you haven't already by pressing
  2428. simultaneously the @kbd{Control + Alt + F4} keys. Mount your file
  2429. system at @file{/mnt}. Assuming your root partition is
  2430. @file{/dev/sda2}, you would do:
  2431. @example sh
  2432. mount /dev/sda2 /mnt
  2433. @end example
  2434. @item
  2435. Mount special block devices and Linux-specific directories:
  2436. @example sh
  2437. mount --rbind /proc /mnt/proc
  2438. mount --rbind /sys /mnt/sys
  2439. mount --rbind /dev /mnt/dev
  2440. @end example
  2441. If your system is EFI-based, you must also mount the ESP partition.
  2442. Assuming it is @file{/dev/sda1}, you can do so with:
  2443. @example sh
  2444. mount /dev/sda1 /mnt/boot/efi
  2445. @end example
  2446. @item
  2447. Enter your system via chroot:
  2448. @example sh
  2449. chroot /mnt /bin/sh
  2450. @end example
  2451. @item
  2452. Source the system profile as well as your @var{user} profile to setup
  2453. the environment, where @var{user} is the user name used for the Guix
  2454. System you are attempting to repair:
  2455. @example sh
  2456. source /var/guix/profiles/system/profile/etc/profile
  2457. source /home/@var{user}/.guix-profile/etc/profile
  2458. @end example
  2459. To ensure you are working with the Guix revision you normally would as
  2460. your normal user, also source your current Guix profile:
  2461. @example sh
  2462. source /home/@var{user}/.config/guix/current/etc/profile
  2463. @end example
  2464. @item
  2465. Start a minimal @command{guix-daemon} in the background:
  2466. @example sh
  2467. guix-daemon --build-users-group=guixbuild --disable-chroot &
  2468. @end example
  2469. @item
  2470. Edit your Guix System configuration if needed, then reconfigure with:
  2471. @example sh
  2472. guix system reconfigure your-config.scm
  2473. @end example
  2474. @item
  2475. Finally, you should be good to reboot the system to test your fix.
  2476. @end enumerate
  2477. @c *********************************************************************
  2478. @node Getting Started
  2479. @chapter Getting Started
  2480. Presumably, you've reached this section because either you have
  2481. installed Guix on top of another distribution (@pxref{Installation}), or
  2482. you've installed the standalone Guix System (@pxref{System
  2483. Installation}). It's time for you to get started using Guix and this
  2484. section aims to help you do that and give you a feel of what it's like.
  2485. Guix is about installing software, so probably the first thing you'll
  2486. want to do is to actually look for software. Let's say you're looking
  2487. for a text editor, you can run:
  2488. @example
  2489. guix search text editor
  2490. @end example
  2491. This command shows you a number of matching @dfn{packages}, each time
  2492. showing the package's name, version, a description, and additional info.
  2493. Once you've found out the one you want to use, let's say Emacs (ah ha!),
  2494. you can go ahead and install it (run this command as a regular user,
  2495. @emph{no need for root privileges}!):
  2496. @example
  2497. guix install emacs
  2498. @end example
  2499. @cindex profile
  2500. You've installed your first package, congrats! The package is now
  2501. visible in your default @dfn{profile}, @file{$HOME/.guix-profile}---a
  2502. profile is a directory containing installed packages.
  2503. In the process, you've
  2504. probably noticed that Guix downloaded pre-built binaries; or, if you
  2505. explicitly chose to @emph{not} use pre-built binaries, then probably
  2506. Guix is still building software (@pxref{Substitutes}, for more info).
  2507. Unless you're using Guix System, the @command{guix install} command must
  2508. have printed this hint:
  2509. @example
  2510. hint: Consider setting the necessary environment variables by running:
  2511. GUIX_PROFILE="$HOME/.guix-profile"
  2512. . "$GUIX_PROFILE/etc/profile"
  2513. Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
  2514. @end example
  2515. Indeed, you must now tell your shell where @command{emacs} and other
  2516. programs installed with Guix are to be found. Pasting the two lines
  2517. above will do just that: it will add
  2518. @code{$HOME/.guix-profile/bin}---which is where the installed package
  2519. is---to the @code{PATH} environment variable. You can paste these two
  2520. lines in your shell so they take effect right away, but more importantly
  2521. you should add them to @file{~/.bash_profile} (or equivalent file if you
  2522. do not use Bash) so that environment variables are set next time you
  2523. spawn a shell. You only need to do this once and other search paths
  2524. environment variables will be taken care of similarly---e.g., if you
  2525. eventually install @code{python} and Python libraries,
  2526. @env{GUIX_PYTHONPATH} will be defined.
  2527. You can go on installing packages at your will. To list installed
  2528. packages, run:
  2529. @example
  2530. guix package --list-installed
  2531. @end example
  2532. To remove a package, you would unsurprisingly run @command{guix remove}.
  2533. A distinguishing feature is the ability to @dfn{roll back} any operation
  2534. you made---installation, removal, upgrade---by simply typing:
  2535. @example
  2536. guix package --roll-back
  2537. @end example
  2538. This is because each operation is in fact a @dfn{transaction} that
  2539. creates a new @dfn{generation}. These generations and the difference
  2540. between them can be displayed by running:
  2541. @example
  2542. guix package --list-generations
  2543. @end example
  2544. Now you know the basics of package management!
  2545. @quotation Going further
  2546. @xref{Package Management}, for more about package management. You may
  2547. like @dfn{declarative} package management with @command{guix package
  2548. --manifest}, managing separate @dfn{profiles} with @option{--profile},
  2549. deleting old generations, collecting garbage, and other nifty features
  2550. that will come in handy as you become more familiar with Guix. If you
  2551. are a developer, @pxref{Development} for additional tools. And if
  2552. you're curious, @pxref{Features}, to peek under the hood.
  2553. @end quotation
  2554. Once you've installed a set of packages, you will want to periodically
  2555. @emph{upgrade} them to the latest and greatest version. To do that, you
  2556. will first pull the latest revision of Guix and its package collection:
  2557. @example
  2558. guix pull
  2559. @end example
  2560. The end result is a new @command{guix} command, under
  2561. @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
  2562. first time you run @command{guix pull}, be sure to follow the hint that
  2563. the command prints and, similar to what we saw above, paste these two
  2564. lines in your terminal and @file{.bash_profile}:
  2565. @example
  2566. GUIX_PROFILE="$HOME/.config/guix/current"
  2567. . "$GUIX_PROFILE/etc/profile"
  2568. @end example
  2569. @noindent
  2570. You must also instruct your shell to point to this new @command{guix}:
  2571. @example
  2572. hash guix
  2573. @end example
  2574. At this point, you're running a brand new Guix. You can thus go ahead
  2575. and actually upgrade all the packages you previously installed:
  2576. @example
  2577. guix upgrade
  2578. @end example
  2579. As you run this command, you will see that binaries are downloaded (or
  2580. perhaps some packages are built), and eventually you end up with the
  2581. upgraded packages. Should one of these upgraded packages not be to your
  2582. liking, remember you can always roll back!
  2583. You can display the exact revision of Guix you're currently using by
  2584. running:
  2585. @example
  2586. guix describe
  2587. @end example
  2588. The information it displays is @emph{all it takes to reproduce the exact
  2589. same Guix}, be it at a different point in time or on a different
  2590. machine.
  2591. @quotation Going further
  2592. @xref{Invoking guix pull}, for more information. @xref{Channels}, on
  2593. how to specify additional @dfn{channels} to pull packages from, how to
  2594. replicate Guix, and more. You may also find @command{time-machine}
  2595. handy (@pxref{Invoking guix time-machine}).
  2596. @end quotation
  2597. If you installed Guix System, one of the first things you'll want to do
  2598. is to upgrade your system. Once you've run @command{guix pull} to get
  2599. the latest Guix, you can upgrade the system like this:
  2600. @example
  2601. sudo guix system reconfigure /etc/config.scm
  2602. @end example
  2603. Upon completion, the system runs the latest versions of its software
  2604. packages. When you eventually reboot, you'll notice a sub-menu in the
  2605. bootloader that reads ``Old system generations'': it's what allows you
  2606. to boot @emph{an older generation of your system}, should the latest
  2607. generation be ``broken'' or otherwise unsatisfying. Just like for
  2608. packages, you can always @emph{roll back} to a previous generation
  2609. @emph{of the whole system}:
  2610. @example
  2611. sudo guix system roll-back
  2612. @end example
  2613. There are many things you'll probably want to tweak on your system:
  2614. adding new user accounts, adding new system services, fiddling with the
  2615. configuration of those services, etc. The system configuration is
  2616. @emph{entirely} described in the @file{/etc/config.scm} file.
  2617. @xref{Using the Configuration System}, to learn how to change it.
  2618. Now you know enough to get started!
  2619. @quotation Resources
  2620. The rest of this manual provides a reference for all things Guix. Here
  2621. are some additional resources you may find useful:
  2622. @itemize
  2623. @item
  2624. @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
  2625. ``how-to'' style of recipes for a variety of applications.
  2626. @item
  2627. The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
  2628. Card} lists in two pages most of the commands and options you'll ever
  2629. need.
  2630. @item
  2631. The web site contains @uref{https://guix.gnu.org/en/videos/,
  2632. instructional videos} covering topics such as everyday use of Guix, how
  2633. to get help, and how to become a contributor.
  2634. @item
  2635. @xref{Documentation}, to learn how to access documentation on your
  2636. computer.
  2637. @end itemize
  2638. We hope you will enjoy Guix as much as the community enjoys building it!
  2639. @end quotation
  2640. @c *********************************************************************
  2641. @node Package Management
  2642. @chapter Package Management
  2643. @cindex packages
  2644. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  2645. remove software packages, without having to know about their build
  2646. procedures or dependencies. Guix also goes beyond this obvious set of
  2647. features.
  2648. This chapter describes the main features of Guix, as well as the
  2649. package management tools it provides. Along with the command-line
  2650. interface described below (@pxref{Invoking guix package, @code{guix
  2651. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  2652. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  2653. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  2654. with it):
  2655. @example
  2656. guix install emacs-guix
  2657. @end example
  2658. @menu
  2659. * Features:: How Guix will make your life brighter.
  2660. * Invoking guix package:: Package installation, removal, etc.
  2661. * Substitutes:: Downloading pre-built binaries.
  2662. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  2663. * Invoking guix locate:: Locating packages that provide a file.
  2664. * Invoking guix gc:: Running the garbage collector.
  2665. * Invoking guix pull:: Fetching the latest Guix and distribution.
  2666. * Invoking guix time-machine:: Running an older revision of Guix.
  2667. * Inferiors:: Interacting with another revision of Guix.
  2668. * Invoking guix describe:: Display information about your Guix revision.
  2669. * Invoking guix archive:: Exporting and importing store files.
  2670. @end menu
  2671. @node Features
  2672. @section Features
  2673. Here we assume you've already made your first steps with Guix
  2674. (@pxref{Getting Started}) and would like to get an overview about what's
  2675. going on under the hood.
  2676. When using Guix, each package ends up in the @dfn{package store}, in its
  2677. own directory---something that resembles
  2678. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  2679. Instead of referring to these directories, users have their own
  2680. @dfn{profile}, which points to the packages that they actually want to
  2681. use. These profiles are stored within each user's home directory, at
  2682. @code{$HOME/.guix-profile}.
  2683. For example, @code{alice} installs GCC 4.7.2. As a result,
  2684. @file{/home/alice/.guix-profile/bin/gcc} points to
  2685. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  2686. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  2687. simply continues to point to
  2688. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  2689. coexist on the same system without any interference.
  2690. The @command{guix package} command is the central tool to manage
  2691. packages (@pxref{Invoking guix package}). It operates on the per-user
  2692. profiles, and can be used @emph{with normal user privileges}.
  2693. @cindex transactions
  2694. The command provides the obvious install, remove, and upgrade
  2695. operations. Each invocation is actually a @emph{transaction}: either
  2696. the specified operation succeeds, or nothing happens. Thus, if the
  2697. @command{guix package} process is terminated during the transaction,
  2698. or if a power outage occurs during the transaction, then the user's
  2699. profile remains in its previous state, and remains usable.
  2700. In addition, any package transaction may be @emph{rolled back}. So, if,
  2701. for example, an upgrade installs a new version of a package that turns
  2702. out to have a serious bug, users may roll back to the previous instance
  2703. of their profile, which was known to work well. Similarly, the global
  2704. system configuration on Guix is subject to
  2705. transactional upgrades and roll-back
  2706. (@pxref{Using the Configuration System}).
  2707. All packages in the package store may be @emph{garbage-collected}.
  2708. Guix can determine which packages are still referenced by user
  2709. profiles, and remove those that are provably no longer referenced
  2710. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  2711. generations of their profile so that the packages they refer to can be
  2712. collected.
  2713. @cindex reproducibility
  2714. @cindex reproducible builds
  2715. Guix takes a @dfn{purely functional} approach to package
  2716. management, as described in the introduction (@pxref{Introduction}).
  2717. Each @file{/gnu/store} package directory name contains a hash of all the
  2718. inputs that were used to build that package---compiler, libraries, build
  2719. scripts, etc. This direct correspondence allows users to make sure a
  2720. given package installation matches the current state of their
  2721. distribution. It also helps maximize @dfn{build reproducibility}:
  2722. thanks to the isolated build environments that are used, a given build
  2723. is likely to yield bit-identical files when performed on different
  2724. machines (@pxref{Invoking guix-daemon, container}).
  2725. @cindex substitutes
  2726. This foundation allows Guix to support @dfn{transparent binary/source
  2727. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  2728. available from an external source---a @dfn{substitute}, Guix just
  2729. downloads it and unpacks it;
  2730. otherwise, it builds the package from source, locally
  2731. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  2732. reproducible, users do not have to trust servers that provide
  2733. substitutes: they can force a local build and @emph{challenge} providers
  2734. (@pxref{Invoking guix challenge}).
  2735. Control over the build environment is a feature that is also useful for
  2736. developers. The @command{guix shell} command allows developers of
  2737. a package to quickly set up the right development environment for their
  2738. package, without having to manually install the dependencies of the
  2739. package into their profile (@pxref{Invoking guix shell}).
  2740. @cindex replication, of software environments
  2741. @cindex provenance tracking, of software artifacts
  2742. All of Guix and its package definitions is version-controlled, and
  2743. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  2744. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  2745. Guix instance on a different machine or at a later point in time, which in
  2746. turn allows you to @emph{replicate complete software environments}, while
  2747. retaining precise @dfn{provenance tracking} of the software.
  2748. @node Invoking guix package
  2749. @section Invoking @command{guix package}
  2750. @cindex installing packages
  2751. @cindex removing packages
  2752. @cindex package installation
  2753. @cindex package removal
  2754. @cindex profile
  2755. @cindex @command{guix package}
  2756. The @command{guix package} command is the tool that allows users to
  2757. install, upgrade, and remove packages, as well as rolling back to
  2758. previous configurations. These operations work on a user
  2759. @dfn{profile}---a directory of installed packages. Each user has a
  2760. default profile in @file{$HOME/.guix-profile}.
  2761. The command operates only on the user's own profile,
  2762. and works with normal user privileges (@pxref{Features}). Its syntax
  2763. is:
  2764. @example
  2765. guix package @var{options}
  2766. @end example
  2767. @cindex transactions
  2768. Primarily, @var{options} specifies the operations to be performed during
  2769. the transaction. Upon completion, a new profile is created, but
  2770. previous @dfn{generations} of the profile remain available, should the user
  2771. want to roll back.
  2772. For example, to remove @code{lua} and install @code{guile} and
  2773. @code{guile-cairo} in a single transaction:
  2774. @example
  2775. guix package -r lua -i guile guile-cairo
  2776. @end example
  2777. @cindex aliases, for @command{guix package}
  2778. For your convenience, we also provide the following aliases:
  2779. @itemize
  2780. @item
  2781. @command{guix search} is an alias for @command{guix package -s},
  2782. @item
  2783. @command{guix install} is an alias for @command{guix package -i},
  2784. @item
  2785. @command{guix remove} is an alias for @command{guix package -r},
  2786. @item
  2787. @command{guix upgrade} is an alias for @command{guix package -u},
  2788. @item
  2789. and @command{guix show} is an alias for @command{guix package --show=}.
  2790. @end itemize
  2791. These aliases are less expressive than @command{guix package} and provide
  2792. fewer options, so in some cases you'll probably want to use @command{guix
  2793. package} directly.
  2794. @command{guix package} also supports a @dfn{declarative approach}
  2795. whereby the user specifies the exact set of packages to be available and
  2796. passes it @i{via} the @option{--manifest} option
  2797. (@pxref{profile-manifest, @option{--manifest}}).
  2798. @cindex profile
  2799. For each user, a symlink to the user's default profile is automatically
  2800. created in @file{$HOME/.guix-profile}. This symlink always points to the
  2801. current generation of the user's default profile. Thus, users can add
  2802. @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
  2803. variable, and so on.
  2804. @cindex search paths
  2805. If you are not using Guix System, consider adding the
  2806. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  2807. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  2808. shells get all the right environment variable definitions:
  2809. @example
  2810. GUIX_PROFILE="$HOME/.guix-profile" ; \
  2811. source "$GUIX_PROFILE/etc/profile"
  2812. @end example
  2813. In a multi-user setup, user profiles are stored in a place registered as
  2814. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  2815. to (@pxref{Invoking guix gc}). That directory is normally
  2816. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  2817. @var{localstatedir} is the value passed to @code{configure} as
  2818. @option{--localstatedir}, and @var{user} is the user name. The
  2819. @file{per-user} directory is created when @command{guix-daemon} is
  2820. started, and the @var{user} sub-directory is created by @command{guix
  2821. package}.
  2822. The @var{options} can be among the following:
  2823. @table @code
  2824. @item --install=@var{package} @dots{}
  2825. @itemx -i @var{package} @dots{}
  2826. Install the specified @var{package}s.
  2827. Each @var{package} may specify a simple package name, such as
  2828. @code{guile}, optionally followed by an at-sign and version number,
  2829. such as @code{guile@@3.0.7} or simply @code{guile@@3.0}. In the latter
  2830. case, the newest version prefixed by @code{3.0} is selected.
  2831. If no version number is specified, the newest available version will be
  2832. selected. In addition, such a @var{package} specification
  2833. may contain a colon, followed by the name of one of the outputs of the
  2834. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  2835. (@pxref{Packages with Multiple Outputs}).
  2836. Packages with a corresponding
  2837. name (and optionally version) are searched for among the GNU
  2838. distribution modules (@pxref{Package Modules}).
  2839. Alternatively, a @var{package} can directly specify a store file name
  2840. such as @file{/gnu/store/...-guile-3.0.7}, as produced by, e.g.,
  2841. @code{guix build}.
  2842. @cindex propagated inputs
  2843. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  2844. that automatically get installed along with the required package
  2845. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  2846. @code{package} objects}, for information about propagated inputs in
  2847. package definitions).
  2848. @anchor{package-cmd-propagated-inputs}
  2849. An example is the GNU MPC library: its C header files refer to those of
  2850. the GNU MPFR library, which in turn refer to those of the GMP library.
  2851. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  2852. in the profile; removing MPC also removes MPFR and GMP---unless they had
  2853. also been explicitly installed by the user.
  2854. Besides, packages sometimes rely on the definition of environment
  2855. variables for their search paths (see explanation of
  2856. @option{--search-paths} below). Any missing or possibly incorrect
  2857. environment variable definitions are reported here.
  2858. @item --install-from-expression=@var{exp}
  2859. @itemx -e @var{exp}
  2860. Install the package @var{exp} evaluates to.
  2861. @var{exp} must be a Scheme expression that evaluates to a
  2862. @code{<package>} object. This option is notably useful to disambiguate
  2863. between same-named variants of a package, with expressions such as
  2864. @code{(@@ (gnu packages base) guile-final)}.
  2865. Note that this option installs the first output of the specified
  2866. package, which may be insufficient when needing a specific output of a
  2867. multiple-output package.
  2868. @item --install-from-file=@var{file}
  2869. @itemx -f @var{file}
  2870. Install the package that the code within @var{file} evaluates to.
  2871. As an example, @var{file} might contain a definition like this
  2872. (@pxref{Defining Packages}):
  2873. @lisp
  2874. @include package-hello.scm
  2875. @end lisp
  2876. Developers may find it useful to include such a @file{guix.scm} file
  2877. in the root of their project source tree that can be used to test
  2878. development snapshots and create reproducible development environments
  2879. (@pxref{Invoking guix shell}).
  2880. The @var{file} may also contain a JSON representation of one or more
  2881. package definitions. Running @code{guix package -f} on
  2882. @file{hello.json} with the following contents would result in installing
  2883. the package @code{greeter} after building @code{myhello}:
  2884. @example
  2885. @verbatiminclude package-hello.json
  2886. @end example
  2887. @item --remove=@var{package} @dots{}
  2888. @itemx -r @var{package} @dots{}
  2889. Remove the specified @var{package}s.
  2890. As for @option{--install}, each @var{package} may specify a version number
  2891. and/or output name in addition to the package name. For instance,
  2892. @samp{-r glibc:debug} would remove the @code{debug} output of
  2893. @code{glibc}.
  2894. @item --upgrade[=@var{regexp} @dots{}]
  2895. @itemx -u [@var{regexp} @dots{}]
  2896. @cindex upgrading packages
  2897. Upgrade all the installed packages. If one or more @var{regexp}s are
  2898. specified, upgrade only installed packages whose name matches a
  2899. @var{regexp}. Also see the @option{--do-not-upgrade} option below.
  2900. Note that this upgrades package to the latest version of packages found
  2901. in the distribution currently installed. To update your distribution,
  2902. you should regularly run @command{guix pull} (@pxref{Invoking guix
  2903. pull}).
  2904. @cindex package transformations, upgrades
  2905. When upgrading, package transformations that were originally applied
  2906. when creating the profile are automatically re-applied (@pxref{Package
  2907. Transformation Options}). For example, assume you first installed Emacs
  2908. from the tip of its development branch with:
  2909. @example
  2910. guix install emacs-next --with-branch=emacs-next=master
  2911. @end example
  2912. Next time you run @command{guix upgrade}, Guix will again pull the tip
  2913. of the Emacs development branch and build @code{emacs-next} from that
  2914. checkout.
  2915. Note that transformation options such as @option{--with-branch} and
  2916. @option{--with-source} depend on external state; it is up to you to
  2917. ensure that they work as expected. You can also discard a
  2918. transformations that apply to a package by running:
  2919. @example
  2920. guix install @var{package}
  2921. @end example
  2922. @item --do-not-upgrade[=@var{regexp} @dots{}]
  2923. When used together with the @option{--upgrade} option, do @emph{not}
  2924. upgrade any packages whose name matches a @var{regexp}. For example, to
  2925. upgrade all packages in the current profile except those containing the
  2926. substring ``emacs'':
  2927. @example
  2928. $ guix package --upgrade . --do-not-upgrade emacs
  2929. @end example
  2930. @item @anchor{profile-manifest}--manifest=@var{file}
  2931. @itemx -m @var{file}
  2932. @cindex profile declaration
  2933. @cindex profile manifest
  2934. Create a new generation of the profile from the manifest object
  2935. returned by the Scheme code in @var{file}. This option can be repeated
  2936. several times, in which case the manifests are concatenated.
  2937. This allows you to @emph{declare} the profile's contents rather than
  2938. constructing it through a sequence of @option{--install} and similar
  2939. commands. The advantage is that @var{file} can be put under version
  2940. control, copied to different machines to reproduce the same profile, and
  2941. so on.
  2942. @var{file} must return a @dfn{manifest} object, which is roughly a list
  2943. of packages:
  2944. @findex packages->manifest
  2945. @lisp
  2946. (use-package-modules guile emacs)
  2947. (packages->manifest
  2948. (list emacs
  2949. guile-2.0
  2950. ;; Use a specific package output.
  2951. (list guile-2.0 "debug")))
  2952. @end lisp
  2953. @xref{Writing Manifests}, for information on how to write a manifest.
  2954. @xref{export-manifest, @option{--export-manifest}}, to learn how to
  2955. obtain a manifest file from an existing profile.
  2956. @item --roll-back
  2957. @cindex rolling back
  2958. @cindex undoing transactions
  2959. @cindex transactions, undoing
  2960. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  2961. the last transaction.
  2962. When combined with options such as @option{--install}, roll back occurs
  2963. before any other actions.
  2964. When rolling back from the first generation that actually contains
  2965. installed packages, the profile is made to point to the @dfn{zeroth
  2966. generation}, which contains no files apart from its own metadata.
  2967. After having rolled back, installing, removing, or upgrading packages
  2968. overwrites previous future generations. Thus, the history of the
  2969. generations in a profile is always linear.
  2970. @item --switch-generation=@var{pattern}
  2971. @itemx -S @var{pattern}
  2972. @cindex generations
  2973. Switch to a particular generation defined by @var{pattern}.
  2974. @var{pattern} may be either a generation number or a number prefixed
  2975. with ``+'' or ``-''. The latter means: move forward/backward by a
  2976. specified number of generations. For example, if you want to return to
  2977. the latest generation after @option{--roll-back}, use
  2978. @option{--switch-generation=+1}.
  2979. The difference between @option{--roll-back} and
  2980. @option{--switch-generation=-1} is that @option{--switch-generation} will
  2981. not make a zeroth generation, so if a specified generation does not
  2982. exist, the current generation will not be changed.
  2983. @item --search-paths[=@var{kind}]
  2984. @cindex search paths
  2985. Report environment variable definitions, in Bash syntax, that may be
  2986. needed in order to use the set of installed packages. These environment
  2987. variables are used to specify @dfn{search paths} for files used by some
  2988. of the installed packages.
  2989. For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
  2990. environment variables to be defined so it can look for headers and
  2991. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  2992. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  2993. library are installed in the profile, then @option{--search-paths} will
  2994. suggest setting these variables to @file{@var{profile}/include} and
  2995. @file{@var{profile}/lib}, respectively (@pxref{Search Paths}, for info
  2996. on search path specifications associated with packages.)
  2997. The typical use case is to define these environment variables in the
  2998. shell:
  2999. @example
  3000. $ eval $(guix package --search-paths)
  3001. @end example
  3002. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  3003. meaning that the returned environment variable definitions will either
  3004. be exact settings, or prefixes or suffixes of the current value of these
  3005. variables. When omitted, @var{kind} defaults to @code{exact}.
  3006. This option can also be used to compute the @emph{combined} search paths
  3007. of several profiles. Consider this example:
  3008. @example
  3009. $ guix package -p foo -i guile
  3010. $ guix package -p bar -i guile-json
  3011. $ guix package -p foo -p bar --search-paths
  3012. @end example
  3013. The last command above reports about the @env{GUILE_LOAD_PATH}
  3014. variable, even though, taken individually, neither @file{foo} nor
  3015. @file{bar} would lead to that recommendation.
  3016. @cindex profile, choosing
  3017. @item --profile=@var{profile}
  3018. @itemx -p @var{profile}
  3019. Use @var{profile} instead of the user's default profile.
  3020. @var{profile} must be the name of a file that will be created upon
  3021. completion. Concretely, @var{profile} will be a mere symbolic link
  3022. (``symlink'') pointing to the actual profile where packages are
  3023. installed:
  3024. @example
  3025. $ guix install hello -p ~/code/my-profile
  3026. @dots{}
  3027. $ ~/code/my-profile/bin/hello
  3028. Hello, world!
  3029. @end example
  3030. All it takes to get rid of the profile is to remove this symlink and its
  3031. siblings that point to specific generations:
  3032. @example
  3033. $ rm ~/code/my-profile ~/code/my-profile-*-link
  3034. @end example
  3035. @item --list-profiles
  3036. List all the user's profiles:
  3037. @example
  3038. $ guix package --list-profiles
  3039. /home/charlie/.guix-profile
  3040. /home/charlie/code/my-profile
  3041. /home/charlie/code/devel-profile
  3042. /home/charlie/tmp/test
  3043. @end example
  3044. When running as root, list all the profiles of all the users.
  3045. @cindex collisions, in a profile
  3046. @cindex colliding packages in profiles
  3047. @cindex profile collisions
  3048. @item --allow-collisions
  3049. Allow colliding packages in the new profile. Use at your own risk!
  3050. By default, @command{guix package} reports as an error @dfn{collisions}
  3051. in the profile. Collisions happen when two or more different versions
  3052. or variants of a given package end up in the profile.
  3053. @item --bootstrap
  3054. Use the bootstrap Guile to build the profile. This option is only
  3055. useful to distribution developers.
  3056. @end table
  3057. In addition to these actions, @command{guix package} supports the
  3058. following options to query the current state of a profile, or the
  3059. availability of packages:
  3060. @table @option
  3061. @item --search=@var{regexp}
  3062. @itemx -s @var{regexp}
  3063. @anchor{guix-search}
  3064. @cindex searching for packages
  3065. List the available packages whose name, synopsis, or description matches
  3066. @var{regexp} (in a case-insensitive fashion), sorted by relevance.
  3067. Print all the metadata of matching packages in
  3068. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  3069. GNU recutils manual}).
  3070. This allows specific fields to be extracted using the @command{recsel}
  3071. command, for instance:
  3072. @example
  3073. $ guix package -s malloc | recsel -p name,version,relevance
  3074. name: jemalloc
  3075. version: 4.5.0
  3076. relevance: 6
  3077. name: glibc
  3078. version: 2.25
  3079. relevance: 1
  3080. name: libgc
  3081. version: 7.6.0
  3082. relevance: 1
  3083. @end example
  3084. Similarly, to show the name of all the packages available under the
  3085. terms of the GNU@tie{}LGPL version 3:
  3086. @example
  3087. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  3088. name: elfutils
  3089. name: gmp
  3090. @dots{}
  3091. @end example
  3092. It is also possible to refine search results using several @code{-s} flags to
  3093. @command{guix package}, or several arguments to @command{guix search}. For
  3094. example, the following command returns a list of board games (this time using
  3095. the @command{guix search} alias):
  3096. @example
  3097. $ guix search '\<board\>' game | recsel -p name
  3098. name: gnubg
  3099. @dots{}
  3100. @end example
  3101. If we were to omit @code{-s game}, we would also get software packages
  3102. that deal with printed circuit boards; removing the angle brackets
  3103. around @code{board} would further add packages that have to do with
  3104. keyboards.
  3105. And now for a more elaborate example. The following command searches
  3106. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  3107. libraries, and prints the name and synopsis of the matching packages:
  3108. @example
  3109. $ guix search crypto library | \
  3110. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  3111. @end example
  3112. @noindent
  3113. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  3114. information on @dfn{selection expressions} for @code{recsel -e}.
  3115. @item --show=@var{package}
  3116. Show details about @var{package}, taken from the list of available packages, in
  3117. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  3118. recutils manual}).
  3119. @example
  3120. $ guix package --show=guile | recsel -p name,version
  3121. name: guile
  3122. version: 3.0.5
  3123. name: guile
  3124. version: 3.0.2
  3125. name: guile
  3126. version: 2.2.7
  3127. @dots{}
  3128. @end example
  3129. You may also specify the full name of a package to only get details about a
  3130. specific version of it (this time using the @command{guix show} alias):
  3131. @example
  3132. $ guix show guile@@3.0.5 | recsel -p name,version
  3133. name: guile
  3134. version: 3.0.5
  3135. @end example
  3136. @item --list-installed[=@var{regexp}]
  3137. @itemx -I [@var{regexp}]
  3138. List the currently installed packages in the specified profile, with the
  3139. most recently installed packages shown last. When @var{regexp} is
  3140. specified, list only installed packages whose name matches @var{regexp}.
  3141. For each installed package, print the following items, separated by
  3142. tabs: the package name, its version string, the part of the package that
  3143. is installed (for instance, @code{out} for the default output,
  3144. @code{include} for its headers, etc.), and the path of this package in
  3145. the store.
  3146. @item --list-available[=@var{regexp}]
  3147. @itemx -A [@var{regexp}]
  3148. List packages currently available in the distribution for this system
  3149. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  3150. available packages whose name matches @var{regexp}.
  3151. For each package, print the following items separated by tabs: its name,
  3152. its version string, the parts of the package (@pxref{Packages with
  3153. Multiple Outputs}), and the source location of its definition.
  3154. @item --list-generations[=@var{pattern}]
  3155. @itemx -l [@var{pattern}]
  3156. @cindex generations
  3157. Return a list of generations along with their creation dates; for each
  3158. generation, show the installed packages, with the most recently
  3159. installed packages shown last. Note that the zeroth generation is never
  3160. shown.
  3161. For each installed package, print the following items, separated by
  3162. tabs: the name of a package, its version string, the part of the package
  3163. that is installed (@pxref{Packages with Multiple Outputs}), and the
  3164. location of this package in the store.
  3165. When @var{pattern} is used, the command returns only matching
  3166. generations. Valid patterns include:
  3167. @itemize
  3168. @item @emph{Integers and comma-separated integers}. Both patterns denote
  3169. generation numbers. For instance, @option{--list-generations=1} returns
  3170. the first one.
  3171. And @option{--list-generations=1,8,2} outputs three generations in the
  3172. specified order. Neither spaces nor trailing commas are allowed.
  3173. @item @emph{Ranges}. @option{--list-generations=2..9} prints the
  3174. specified generations and everything in between. Note that the start of
  3175. a range must be smaller than its end.
  3176. It is also possible to omit the endpoint. For example,
  3177. @option{--list-generations=2..}, returns all generations starting from the
  3178. second one.
  3179. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  3180. or months by passing an integer along with the first letter of the
  3181. duration. For example, @option{--list-generations=20d} lists generations
  3182. that are up to 20 days old.
  3183. @end itemize
  3184. @item --delete-generations[=@var{pattern}]
  3185. @itemx -d [@var{pattern}]
  3186. When @var{pattern} is omitted, delete all generations except the current
  3187. one.
  3188. This command accepts the same patterns as @option{--list-generations}.
  3189. When @var{pattern} is specified, delete the matching generations. When
  3190. @var{pattern} specifies a duration, generations @emph{older} than the
  3191. specified duration match. For instance, @option{--delete-generations=1m}
  3192. deletes generations that are more than one month old.
  3193. If the current generation matches, it is @emph{not} deleted. Also, the
  3194. zeroth generation is never deleted.
  3195. Note that deleting generations prevents rolling back to them.
  3196. Consequently, this command must be used with care.
  3197. @cindex manifest, exporting
  3198. @anchor{export-manifest}
  3199. @item --export-manifest
  3200. Write to standard output a manifest suitable for @option{--manifest}
  3201. corresponding to the chosen profile(s).
  3202. This option is meant to help you migrate from the ``imperative''
  3203. operating mode---running @command{guix install}, @command{guix upgrade},
  3204. etc.---to the declarative mode that @option{--manifest} offers.
  3205. Be aware that the resulting manifest @emph{approximates} what your
  3206. profile actually contains; for instance, depending on how your profile
  3207. was created, it can refer to packages or package versions that are not
  3208. exactly what you specified.
  3209. Keep in mind that a manifest is purely symbolic: it only contains
  3210. package names and possibly versions, and their meaning varies over time.
  3211. If you wish to ``pin'' channels to the revisions that were used to build
  3212. the profile(s), see @option{--export-channels} below.
  3213. @cindex pinning, channel revisions of a profile
  3214. @item --export-channels
  3215. Write to standard output the list of channels used by the chosen
  3216. profile(s), in a format suitable for @command{guix pull --channels} or
  3217. @command{guix time-machine --channels} (@pxref{Channels}).
  3218. Together with @option{--export-manifest}, this option provides
  3219. information allowing you to replicate the current profile
  3220. (@pxref{Replicating Guix}).
  3221. However, note that the output of this command @emph{approximates} what
  3222. was actually used to build this profile. In particular, a single
  3223. profile might have been built from several different revisions of the
  3224. same channel. In that case, @option{--export-manifest} chooses the last
  3225. one and writes the list of other revisions in a comment. If you really
  3226. need to pick packages from different channel revisions, you can use
  3227. inferiors in your manifest to do so (@pxref{Inferiors}).
  3228. Together with @option{--export-manifest}, this is a good starting point
  3229. if you are willing to migrate from the ``imperative'' model to the fully
  3230. declarative model consisting of a manifest file along with a channels
  3231. file pinning the exact channel revision(s) you want.
  3232. @end table
  3233. Finally, since @command{guix package} may actually start build
  3234. processes, it supports all the common build options (@pxref{Common Build
  3235. Options}). It also supports package transformation options, such as
  3236. @option{--with-source}, and preserves them across upgrades
  3237. (@pxref{Package Transformation Options}).
  3238. @node Substitutes
  3239. @section Substitutes
  3240. @cindex substitutes
  3241. @cindex pre-built binaries
  3242. Guix supports transparent source/binary deployment, which means that it
  3243. can either build things locally, or download pre-built items from a
  3244. server, or both. We call these pre-built items @dfn{substitutes}---they
  3245. are substitutes for local build results. In many cases, downloading a
  3246. substitute is much faster than building things locally.
  3247. Substitutes can be anything resulting from a derivation build
  3248. (@pxref{Derivations}). Of course, in the common case, they are
  3249. pre-built package binaries, but source tarballs, for instance, which
  3250. also result from derivation builds, can be available as substitutes.
  3251. @menu
  3252. * Official Substitute Servers:: One particular source of substitutes.
  3253. * Substitute Server Authorization:: How to enable or disable substitutes.
  3254. * Getting Substitutes from Other Servers:: Substitute diversity.
  3255. * Substitute Authentication:: How Guix verifies substitutes.
  3256. * Proxy Settings:: How to get substitutes via proxy.
  3257. * Substitution Failure:: What happens when substitution fails.
  3258. * On Trusting Binaries:: How can you trust that binary blob?
  3259. @end menu
  3260. @node Official Substitute Servers
  3261. @subsection Official Substitute Servers
  3262. @cindex build farm
  3263. @code{@value{SUBSTITUTE-SERVER-1}} and
  3264. @code{@value{SUBSTITUTE-SERVER-2}} are both front-ends to official build
  3265. farms that build packages from Guix continuously for some architectures,
  3266. and make them available as substitutes. These are the default source of
  3267. substitutes; which can be overridden by passing the
  3268. @option{--substitute-urls} option either to @command{guix-daemon}
  3269. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  3270. or to client tools such as @command{guix package}
  3271. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  3272. option}).
  3273. Substitute URLs can be either HTTP or HTTPS.
  3274. HTTPS is recommended because communications are encrypted; conversely,
  3275. using HTTP makes all communications visible to an eavesdropper, who
  3276. could use the information gathered to determine, for instance, whether
  3277. your system has unpatched security vulnerabilities.
  3278. Substitutes from the official build farms are enabled by default when
  3279. using Guix System (@pxref{GNU Distribution}). However,
  3280. they are disabled by default when using Guix on a foreign distribution,
  3281. unless you have explicitly enabled them via one of the recommended
  3282. installation steps (@pxref{Installation}). The following paragraphs
  3283. describe how to enable or disable substitutes for the official build
  3284. farm; the same procedure can also be used to enable substitutes for any
  3285. other substitute server.
  3286. @node Substitute Server Authorization
  3287. @subsection Substitute Server Authorization
  3288. @cindex security
  3289. @cindex substitutes, authorization thereof
  3290. @cindex access control list (ACL), for substitutes
  3291. @cindex ACL (access control list), for substitutes
  3292. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER-1}}, @code{@value{SUBSTITUTE-SERVER-2}} or a mirror, you
  3293. must add the relevant public key to the access control list (ACL) of archive
  3294. imports, using the @command{guix archive} command (@pxref{Invoking guix
  3295. archive}). Doing so implies that you trust the substitute server to not
  3296. be compromised and to serve genuine substitutes.
  3297. @quotation Note
  3298. If you are using Guix System, you can skip this section: Guix System
  3299. authorizes substitutes from @code{@value{SUBSTITUTE-SERVER-1}} and
  3300. @code{@value{SUBSTITUTE-SERVER-2}} by default.
  3301. @end quotation
  3302. The public keys for each of the project maintained substitute servers
  3303. are installed along with Guix, in @code{@var{prefix}/share/guix/}, where
  3304. @var{prefix} is the installation prefix of Guix. If you installed Guix
  3305. from source, make sure you checked the GPG signature of
  3306. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  3307. Then, you can run something like this:
  3308. @example
  3309. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
  3310. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
  3311. @end example
  3312. Once this is in place, the output of a command like @code{guix build}
  3313. should change from something like:
  3314. @example
  3315. $ guix build emacs --dry-run
  3316. The following derivations would be built:
  3317. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  3318. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  3319. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  3320. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  3321. @dots{}
  3322. @end example
  3323. @noindent
  3324. to something like:
  3325. @example
  3326. $ guix build emacs --dry-run
  3327. 112.3 MB would be downloaded:
  3328. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  3329. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  3330. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  3331. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  3332. @dots{}
  3333. @end example
  3334. @noindent
  3335. The text changed from ``The following derivations would be built'' to
  3336. ``112.3 MB would be downloaded''. This indicates that substitutes from
  3337. the configured substitute servers are usable and will be downloaded,
  3338. when possible, for future builds.
  3339. @cindex substitutes, how to disable
  3340. The substitute mechanism can be disabled globally by running
  3341. @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
  3342. guix-daemon}). It can also be disabled temporarily by passing the
  3343. @option{--no-substitutes} option to @command{guix package},
  3344. @command{guix build}, and other command-line tools.
  3345. @node Getting Substitutes from Other Servers
  3346. @subsection Getting Substitutes from Other Servers
  3347. @cindex substitute servers, adding more
  3348. Guix can look up and fetch substitutes from several servers. This is
  3349. useful when you are using packages from additional channels for which
  3350. the official server does not have substitutes but another server
  3351. provides them. Another situation where this is useful is when you would
  3352. prefer to download from your organization's substitute server, resorting
  3353. to the official server only as a fallback or dismissing it altogether.
  3354. You can give Guix a list of substitute server URLs and it will check
  3355. them in the specified order. You also need to explicitly authorize the
  3356. public keys of substitute servers to instruct Guix to accept the
  3357. substitutes they sign.
  3358. On Guix System, this is achieved by modifying the configuration of the
  3359. @code{guix} service. Since the @code{guix} service is part of the
  3360. default lists of services, @code{%base-services} and
  3361. @code{%desktop-services}, you can use @code{modify-services} to change
  3362. its configuration and add the URLs and substitute keys that you want
  3363. (@pxref{Service Reference, @code{modify-services}}).
  3364. As an example, suppose you want to fetch substitutes from
  3365. @code{guix.example.org} and to authorize the signing key of that server,
  3366. in addition to the default @code{@value{SUBSTITUTE-SERVER-1}} and
  3367. @code{@value{SUBSTITUTE-SERVER-2}}. The resulting operating system
  3368. configuration will look something like:
  3369. @lisp
  3370. (operating-system
  3371. ;; @dots{}
  3372. (services
  3373. ;; Assume we're starting from '%desktop-services'. Replace it
  3374. ;; with the list of services you're actually using.
  3375. (modify-services %desktop-services
  3376. (guix-service-type config =>
  3377. (guix-configuration
  3378. (inherit config)
  3379. (substitute-urls
  3380. (append (list "https://guix.example.org")
  3381. %default-substitute-urls))
  3382. (authorized-keys
  3383. (append (list (local-file "./key.pub"))
  3384. %default-authorized-guix-keys)))))))
  3385. @end lisp
  3386. This assumes that the file @file{key.pub} contains the signing key of
  3387. @code{guix.example.org}. With this change in place in your operating
  3388. system configuration file (say @file{/etc/config.scm}), you can
  3389. reconfigure and restart the @code{guix-daemon} service or reboot so the
  3390. changes take effect:
  3391. @example
  3392. $ sudo guix system reconfigure /etc/config.scm
  3393. $ sudo herd restart guix-daemon
  3394. @end example
  3395. If you're running Guix on a ``foreign distro'', you would instead take
  3396. the following steps to get substitutes from additional servers:
  3397. @enumerate
  3398. @item
  3399. Edit the service configuration file for @code{guix-daemon}; when using
  3400. systemd, this is normally
  3401. @file{/etc/systemd/system/guix-daemon.service}. Add the
  3402. @option{--substitute-urls} option on the @command{guix-daemon} command
  3403. line and list the URLs of interest (@pxref{daemon-substitute-urls,
  3404. @code{guix-daemon --substitute-urls}}):
  3405. @example
  3406. @dots{} --substitute-urls='https://guix.example.org @value{SUBSTITUTE-URLS}'
  3407. @end example
  3408. @item
  3409. Restart the daemon. For systemd, it goes like this:
  3410. @example
  3411. systemctl daemon-reload
  3412. systemctl restart guix-daemon.service
  3413. @end example
  3414. @item
  3415. Authorize the key of the new server (@pxref{Invoking guix archive}):
  3416. @example
  3417. guix archive --authorize < key.pub
  3418. @end example
  3419. Again this assumes @file{key.pub} contains the public key that
  3420. @code{guix.example.org} uses to sign substitutes.
  3421. @end enumerate
  3422. Now you're all set! Substitutes will be preferably taken from
  3423. @code{https://guix.example.org}, using
  3424. @code{@value{SUBSTITUTE-SERVER-1}} then
  3425. @code{@value{SUBSTITUTE-SERVER-2}} as fallback options. Of course you
  3426. can list as many substitute servers as you like, with the caveat that
  3427. substitute lookup can be slowed down if too many servers need to be
  3428. contacted.
  3429. Note that there are also situations where one may want to add the URL of
  3430. a substitute server @emph{without} authorizing its key.
  3431. @xref{Substitute Authentication}, to understand this fine point.
  3432. @node Substitute Authentication
  3433. @subsection Substitute Authentication
  3434. @cindex digital signatures
  3435. Guix detects and raises an error when attempting to use a substitute
  3436. that has been tampered with. Likewise, it ignores substitutes that are
  3437. not signed, or that are not signed by one of the keys listed in the ACL.
  3438. There is one exception though: if an unauthorized server provides
  3439. substitutes that are @emph{bit-for-bit identical} to those provided by
  3440. an authorized server, then the unauthorized server becomes eligible for
  3441. downloads. For example, assume we have chosen two substitute servers
  3442. with this option:
  3443. @example
  3444. --substitute-urls="https://a.example.org https://b.example.org"
  3445. @end example
  3446. @noindent
  3447. @cindex reproducible builds
  3448. If the ACL contains only the key for @samp{b.example.org}, and if
  3449. @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
  3450. then Guix will download substitutes from @samp{a.example.org} because it
  3451. comes first in the list and can be considered a mirror of
  3452. @samp{b.example.org}. In practice, independent build machines usually
  3453. produce the same binaries, thanks to bit-reproducible builds (see
  3454. below).
  3455. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  3456. (in other words, the server is not authenticated), contrary to what
  3457. HTTPS clients such as Web browsers usually do. This is because Guix
  3458. authenticates substitute information itself, as explained above, which
  3459. is what we care about (whereas X.509 certificates are about
  3460. authenticating bindings between domain names and public keys).
  3461. @node Proxy Settings
  3462. @subsection Proxy Settings
  3463. @vindex http_proxy
  3464. @vindex https_proxy
  3465. Substitutes are downloaded over HTTP or HTTPS@. The @env{http_proxy} and
  3466. @env{https_proxy} environment variables can be set in the environment of
  3467. @command{guix-daemon} and are honored for downloads of substitutes.
  3468. Note that the value of those environment variables in the environment
  3469. where @command{guix build}, @command{guix package}, and other client
  3470. commands are run has @emph{absolutely no effect}.
  3471. @node Substitution Failure
  3472. @subsection Substitution Failure
  3473. Even when a substitute for a derivation is available, sometimes the
  3474. substitution attempt will fail. This can happen for a variety of
  3475. reasons: the substitute server might be offline, the substitute may
  3476. recently have been deleted, the connection might have been interrupted,
  3477. etc.
  3478. When substitutes are enabled and a substitute for a derivation is
  3479. available, but the substitution attempt fails, Guix will attempt to
  3480. build the derivation locally depending on whether or not
  3481. @option{--fallback} was given (@pxref{fallback-option,, common build
  3482. option @option{--fallback}}). Specifically, if @option{--fallback} was
  3483. omitted, then no local build will be performed, and the derivation is
  3484. considered to have failed. However, if @option{--fallback} was given,
  3485. then Guix will attempt to build the derivation locally, and the success
  3486. or failure of the derivation depends on the success or failure of the
  3487. local build. Note that when substitutes are disabled or no substitute
  3488. is available for the derivation in question, a local build will
  3489. @emph{always} be performed, regardless of whether or not
  3490. @option{--fallback} was given.
  3491. To get an idea of how many substitutes are available right now, you can
  3492. try running the @command{guix weather} command (@pxref{Invoking guix
  3493. weather}). This command provides statistics on the substitutes provided
  3494. by a server.
  3495. @node On Trusting Binaries
  3496. @subsection On Trusting Binaries
  3497. @cindex trust, of pre-built binaries
  3498. Today, each individual's control over their own computing is at the
  3499. mercy of institutions, corporations, and groups with enough power and
  3500. determination to subvert the computing infrastructure and exploit its
  3501. weaknesses. While using substitutes can be convenient, we encourage
  3502. users to also build on their own, or even run their own build farm, such
  3503. that the project run substitute servers are less of an interesting
  3504. target. One way to help is by publishing the software you build using
  3505. @command{guix publish} so that others have one more choice of server to
  3506. download substitutes from (@pxref{Invoking guix publish}).
  3507. Guix has the foundations to maximize build reproducibility
  3508. (@pxref{Features}). In most cases, independent builds of a given
  3509. package or derivation should yield bit-identical results. Thus, through
  3510. a diverse set of independent package builds, we can strengthen the
  3511. integrity of our systems. The @command{guix challenge} command aims to
  3512. help users assess substitute servers, and to assist developers in
  3513. finding out about non-deterministic package builds (@pxref{Invoking guix
  3514. challenge}). Similarly, the @option{--check} option of @command{guix
  3515. build} allows users to check whether previously-installed substitutes
  3516. are genuine by rebuilding them locally (@pxref{build-check,
  3517. @command{guix build --check}}).
  3518. In the future, we want Guix to have support to publish and retrieve
  3519. binaries to/from other users, in a peer-to-peer fashion. If you would
  3520. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  3521. @node Packages with Multiple Outputs
  3522. @section Packages with Multiple Outputs
  3523. @cindex multiple-output packages
  3524. @cindex package outputs
  3525. @cindex outputs
  3526. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  3527. source package leads to exactly one directory in the store. When running
  3528. @command{guix install glibc}, one installs the default output of the
  3529. GNU libc package; the default output is called @code{out}, but its name
  3530. can be omitted as shown in this command. In this particular case, the
  3531. default output of @code{glibc} contains all the C header files, shared
  3532. libraries, static libraries, Info documentation, and other supporting
  3533. files.
  3534. Sometimes it is more appropriate to separate the various types of files
  3535. produced from a single source package into separate outputs. For
  3536. instance, the GLib C library (used by GTK+ and related packages)
  3537. installs more than 20 MiB of reference documentation as HTML pages.
  3538. To save space for users who do not need it, the documentation goes to a
  3539. separate output, called @code{doc}. To install the main GLib output,
  3540. which contains everything but the documentation, one would run:
  3541. @example
  3542. guix install glib
  3543. @end example
  3544. @cindex documentation
  3545. The command to install its documentation is:
  3546. @example
  3547. guix install glib:doc
  3548. @end example
  3549. While the colon syntax works for command-line specification of package
  3550. outputs, it will not work when using a package @emph{variable} in Scheme
  3551. code. For example, to add the documentation of @code{glib} to the
  3552. globally installed packages of an @code{operating-system} (see
  3553. @ref{operating-system Reference}), a list of two items, the first one
  3554. being the package @emph{variable} and the second one the name of the
  3555. output to select (a string), must be used instead:
  3556. @lisp
  3557. (use-modules (gnu packages glib))
  3558. ;; glib-with-documentation is the Guile symbol for the glib package
  3559. (operating-system
  3560. ...
  3561. (packages
  3562. (append
  3563. (list (list glib-with-documentation "doc"))
  3564. %base-packages)))
  3565. @end lisp
  3566. Some packages install programs with different ``dependency footprints''.
  3567. For instance, the WordNet package installs both command-line tools and
  3568. graphical user interfaces (GUIs). The former depend solely on the C
  3569. library, whereas the latter depend on Tcl/Tk and the underlying X
  3570. libraries. In this case, we leave the command-line tools in the default
  3571. output, whereas the GUIs are in a separate output. This allows users
  3572. who do not need the GUIs to save space. The @command{guix size} command
  3573. can help find out about such situations (@pxref{Invoking guix size}).
  3574. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  3575. There are several such multiple-output packages in the GNU distribution.
  3576. Other conventional output names include @code{lib} for libraries and
  3577. possibly header files, @code{bin} for stand-alone programs, and
  3578. @code{debug} for debugging information (@pxref{Installing Debugging
  3579. Files}). The outputs of a packages are listed in the third column of
  3580. the output of @command{guix package --list-available} (@pxref{Invoking
  3581. guix package}).
  3582. @node Invoking guix locate
  3583. @section Invoking @command{guix locate}
  3584. @cindex file, searching in packages
  3585. @cindex file search
  3586. @cindex searching for packages
  3587. There's so much free software out there that sooner or later, you will
  3588. need to search for packages. The @command{guix search} command that
  3589. we've seen before (@pxref{Invoking guix package}) lets you search by
  3590. keywords:
  3591. @example
  3592. guix search video editor
  3593. @end example
  3594. @cindex searching for packages, by file name
  3595. Sometimes, you instead want to find which package provides a given file,
  3596. and this is where @command{guix locate} comes in. Here is how you can
  3597. find which package provides the @command{ls} command:
  3598. @example
  3599. $ guix locate ls
  3600. coreutils@@9.1 /gnu/store/@dots{}-coreutils-9.1/bin/ls
  3601. @end example
  3602. Of course the command works for any file, not just commands:
  3603. @example
  3604. $ guix locate unistr.h
  3605. icu4c@@71.1 /gnu/store/@dots{}/include/unicode/unistr.h
  3606. libunistring@@1.0 /gnu/store/@dots{}/include/unistr.h
  3607. @end example
  3608. You may also specify @dfn{glob patterns} with wildcards. For example,
  3609. here is how you would search for packages providing @file{.service}
  3610. files:
  3611. @example
  3612. $ guix locate -g '*.service'
  3613. man-db@@2.11.1 @dots{}/lib/systemd/system/man-db.service
  3614. wpa-supplicant@@2.10 @dots{}/system-services/fi.w1.wpa_supplicant1.service
  3615. @end example
  3616. The @command{guix locate} command relies on a database that maps file
  3617. names to package names. By default, it automatically creates that
  3618. database if it does not exist yet by traversing packages available
  3619. @emph{locally}, which can take a few minutes (depending on the size of
  3620. your store and the speed of your storage device).
  3621. @quotation Note
  3622. For now, @command{guix locate} builds its database based on purely local
  3623. knowledge---meaning that you will not find packages that never reached
  3624. your store. Eventually it will support downloading a pre-built database
  3625. so you can potentially find more packages.
  3626. @end quotation
  3627. By default, @command{guix locate} first tries to look for a system-wide
  3628. database, usually under @file{/var/cache/guix/locate}; if it does not
  3629. exist or is too old, it falls back to the per-user database, by default
  3630. under @file{~/.cache/guix/locate}. On a multi-user system,
  3631. administrators may want to periodically update the system-wide database
  3632. so that all users can benefit from it, for instance by setting up
  3633. @code{package-database-service-type} (@pxref{File Search Services,
  3634. @code{package-database-service-type}}).
  3635. The general syntax is:
  3636. @example
  3637. guix locate [@var{options}@dots{}] @var{file}@dots{}
  3638. @end example
  3639. @noindent
  3640. ... where @var{file} is the name of a file to search for (specifically,
  3641. the ``base name'' of the file: files whose parent directories are called
  3642. @var{file} are not matched).
  3643. The available options are as follows:
  3644. @table @code
  3645. @item --glob
  3646. @item -g
  3647. Interpret @var{file}@dots{} as @dfn{glob patterns}---patterns that may
  3648. include wildcards, such as @samp{*.scm} to denote all files ending in
  3649. @samp{.scm}.
  3650. @item --stats
  3651. Display database statistics.
  3652. @item --update
  3653. @itemx -u
  3654. Update the file database.
  3655. By default, the database is automatically updated when it is too old.
  3656. @item --clear
  3657. Clear the database and re-populate it.
  3658. This option lets you start anew, ensuring old data is removed from the
  3659. database, which also avoids having an endlessly growing database. By
  3660. default @command{guix locate} automatically does that periodically,
  3661. though infrequently.
  3662. @item --database=@var{file}
  3663. Use @var{file} as the database, creating it if necessary.
  3664. By default, @command{guix locate} picks the database under
  3665. @file{~/.cache/guix} or @file{/var/cache/guix}, whichever is the most
  3666. recent one.
  3667. @item --method=@var{method}
  3668. @itemx -m @var{method}
  3669. Use @var{method} to select the set of packages to index. Possible
  3670. values are:
  3671. @table @code
  3672. @item manifests
  3673. This is the default method: it works by traversing profiles on the
  3674. machine and recording packages it encounters---packages you or other
  3675. users of the machine installed, directly or indirectly. It is fast but
  3676. it can miss other packages available in the store but not referred to by
  3677. any profile.
  3678. @item store
  3679. This is a slower but more exhaustive method: it checks among all the
  3680. existing packages those that are available in the store and records
  3681. them.
  3682. @end table
  3683. @end table
  3684. @node Invoking guix gc
  3685. @section Invoking @command{guix gc}
  3686. @cindex garbage collector
  3687. @cindex disk space
  3688. @cindex @command{guix gc}
  3689. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  3690. The @command{guix gc} command allows users to explicitly run the garbage
  3691. collector to reclaim space from the @file{/gnu/store} directory. It is
  3692. the @emph{only} way to remove files from @file{/gnu/store}---removing
  3693. files or directories manually may break it beyond repair!
  3694. @cindex GC roots
  3695. @cindex garbage collector roots
  3696. The garbage collector has a set of known @dfn{roots}: any file under
  3697. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  3698. cannot be deleted; any other file is considered @dfn{dead} and may be
  3699. deleted. The set of garbage collector roots (``GC roots'' for short)
  3700. includes default user profiles; by default, the symlinks under
  3701. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  3702. added with @command{guix build --root}, for example (@pxref{Invoking
  3703. guix build}). The @command{guix gc --list-roots} command lists them.
  3704. Prior to running @code{guix gc --collect-garbage} to make space, it is
  3705. often useful to remove old generations from user profiles; that way, old
  3706. package builds referenced by those generations can be reclaimed. This
  3707. is achieved by running @code{guix package --delete-generations}
  3708. (@pxref{Invoking guix package}).
  3709. Our recommendation is to run a garbage collection periodically, or when
  3710. you are short on disk space. For instance, to guarantee that at least
  3711. 5@tie{}GB are available on your disk, simply run:
  3712. @example
  3713. guix gc -F 5G
  3714. @end example
  3715. It is perfectly safe to run as a non-interactive periodic job
  3716. (@pxref{Scheduled Job Execution}, for how to set up such a job).
  3717. Running @command{guix gc} with no arguments will collect as
  3718. much garbage as it can, but that is often inconvenient: you may find
  3719. yourself having to rebuild or re-download software that is ``dead'' from
  3720. the GC viewpoint but that is necessary to build other pieces of
  3721. software---e.g., the compiler tool chain.
  3722. The @command{guix gc} command has three modes of operation: it can be
  3723. used to garbage-collect any dead files (the default), to delete specific
  3724. files (the @option{--delete} option), to print garbage-collector
  3725. information, or for more advanced queries. The garbage collection
  3726. options are as follows:
  3727. @table @code
  3728. @item --collect-garbage[=@var{min}]
  3729. @itemx -C [@var{min}]
  3730. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  3731. sub-directories. This is the default operation when no option is
  3732. specified.
  3733. When @var{min} is given, stop once @var{min} bytes have been collected.
  3734. @var{min} may be a number of bytes, or it may include a unit as a
  3735. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  3736. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  3737. When @var{min} is omitted, collect all the garbage.
  3738. @item --free-space=@var{free}
  3739. @itemx -F @var{free}
  3740. Collect garbage until @var{free} space is available under
  3741. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  3742. as @code{500MiB}, as described above.
  3743. When @var{free} or more is already available in @file{/gnu/store}, do
  3744. nothing and exit immediately.
  3745. @item --delete-generations[=@var{duration}]
  3746. @itemx -d [@var{duration}]
  3747. Before starting the garbage collection process, delete all the generations
  3748. older than @var{duration}, for all the user profiles and home environment
  3749. generations; when run as root, this
  3750. applies to all the profiles @emph{of all the users}.
  3751. For example, this command deletes all the generations of all your profiles
  3752. that are older than 2 months (except generations that are current), and then
  3753. proceeds to free space until at least 10 GiB are available:
  3754. @example
  3755. guix gc -d 2m -F 10G
  3756. @end example
  3757. @item --delete
  3758. @itemx -D
  3759. Attempt to delete all the store files and directories specified as
  3760. arguments. This fails if some of the files are not in the store, or if
  3761. they are still live.
  3762. @item --list-failures
  3763. List store items corresponding to cached build failures.
  3764. This prints nothing unless the daemon was started with
  3765. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  3766. @option{--cache-failures}}).
  3767. @item --list-roots
  3768. List the GC roots owned by the user; when run as root, list @emph{all} the GC
  3769. roots.
  3770. @item --list-busy
  3771. List store items in use by currently running processes. These store
  3772. items are effectively considered GC roots: they cannot be deleted.
  3773. @item --clear-failures
  3774. Remove the specified store items from the failed-build cache.
  3775. Again, this option only makes sense when the daemon is started with
  3776. @option{--cache-failures}. Otherwise, it does nothing.
  3777. @item --list-dead
  3778. Show the list of dead files and directories still present in the
  3779. store---i.e., files and directories no longer reachable from any root.
  3780. @item --list-live
  3781. Show the list of live store files and directories.
  3782. @end table
  3783. In addition, the references among existing store files can be queried:
  3784. @table @code
  3785. @item --references
  3786. @itemx --referrers
  3787. @cindex package dependencies
  3788. List the references (respectively, the referrers) of store files given
  3789. as arguments.
  3790. @item --requisites
  3791. @itemx -R
  3792. @cindex closure
  3793. List the requisites of the store files passed as arguments. Requisites
  3794. include the store files themselves, their references, and the references
  3795. of these, recursively. In other words, the returned list is the
  3796. @dfn{transitive closure} of the store files.
  3797. @xref{Invoking guix size}, for a tool to profile the size of the closure
  3798. of an element. @xref{Invoking guix graph}, for a tool to visualize
  3799. the graph of references.
  3800. @item --derivers
  3801. @cindex derivation
  3802. Return the derivation(s) leading to the given store items
  3803. (@pxref{Derivations}).
  3804. For example, this command:
  3805. @example
  3806. guix gc --derivers $(guix package -I ^emacs$ | cut -f4)
  3807. @end example
  3808. @noindent
  3809. returns the @file{.drv} file(s) leading to the @code{emacs} package
  3810. installed in your profile.
  3811. Note that there may be zero matching @file{.drv} files, for instance
  3812. because these files have been garbage-collected. There can also be more
  3813. than one matching @file{.drv} due to fixed-output derivations.
  3814. @end table
  3815. Lastly, the following options allow you to check the integrity of the
  3816. store and to control disk usage.
  3817. @table @option
  3818. @item --verify[=@var{options}]
  3819. @cindex integrity, of the store
  3820. @cindex integrity checking
  3821. Verify the integrity of the store.
  3822. By default, make sure that all the store items marked as valid in the
  3823. database of the daemon actually exist in @file{/gnu/store}.
  3824. When provided, @var{options} must be a comma-separated list containing one
  3825. or more of @code{contents} and @code{repair}.
  3826. When passing @option{--verify=contents}, the daemon computes the
  3827. content hash of each store item and compares it against its hash in the
  3828. database. Hash mismatches are reported as data corruptions. Because it
  3829. traverses @emph{all the files in the store}, this command can take a
  3830. long time, especially on systems with a slow disk drive.
  3831. @cindex repairing the store
  3832. @cindex corruption, recovering from
  3833. Using @option{--verify=repair} or @option{--verify=contents,repair}
  3834. causes the daemon to try to repair corrupt store items by fetching
  3835. substitutes for them (@pxref{Substitutes}). Because repairing is not
  3836. atomic, and thus potentially dangerous, it is available only to the
  3837. system administrator. A lightweight alternative, when you know exactly
  3838. which items in the store are corrupt, is @command{guix build --repair}
  3839. (@pxref{Invoking guix build}).
  3840. @item --optimize
  3841. @cindex deduplication
  3842. Optimize the store by hard-linking identical files---this is
  3843. @dfn{deduplication}.
  3844. The daemon performs deduplication after each successful build or archive
  3845. import, unless it was started with @option{--disable-deduplication}
  3846. (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
  3847. this option is primarily useful when the daemon was running with
  3848. @option{--disable-deduplication}.
  3849. @item --vacuum-database
  3850. @cindex vacuum the store database
  3851. @comment Avoid words like 'repair,' 'compress,' and 'optimize.'
  3852. Guix uses an sqlite database to keep track of the items in (@pxref{The Store}).
  3853. Over time it is possible that the database may grow to a large size and become
  3854. fragmented. As a result, one may wish to clear the freed space and join the
  3855. partially used pages in the database left behind from removed packages or after
  3856. running the garbage collector. Running @command{sudo guix gc
  3857. --vacuum-database} will lock the database and @code{VACUUM} the store,
  3858. defragmenting the database and purging freed pages, unlocking the database when
  3859. it finishes.
  3860. @end table
  3861. @node Invoking guix pull
  3862. @section Invoking @command{guix pull}
  3863. @cindex upgrading Guix
  3864. @cindex updating Guix
  3865. @cindex @command{guix pull}
  3866. @cindex pull
  3867. @cindex security, @command{guix pull}
  3868. @cindex authenticity, of code obtained with @command{guix pull}
  3869. Packages are installed or upgraded to the latest version available in
  3870. the distribution currently available on your local machine. To update
  3871. that distribution, along with the Guix tools, you must run @command{guix
  3872. pull}: the command downloads the latest Guix source code and package
  3873. descriptions, and deploys it. Source code is downloaded from a
  3874. @uref{https://git-scm.com/book/en/, Git} repository, by default the official
  3875. GNU@tie{}Guix repository, though this can be customized. @command{guix
  3876. pull} ensures that the code it downloads is @emph{authentic} by
  3877. verifying that commits are signed by Guix developers.
  3878. Specifically, @command{guix pull} downloads code from the @dfn{channels}
  3879. (@pxref{Channels}) specified by one of the following, in this order:
  3880. @enumerate
  3881. @item
  3882. the @option{--channels} option;
  3883. @item
  3884. the user's @file{~/.config/guix/channels.scm} file, unless @option{-q}
  3885. is passed;
  3886. @item
  3887. the system-wide @file{/etc/guix/channels.scm} file, unless @option{-q}
  3888. is passed;
  3889. @item
  3890. the built-in default channels specified in the @code{%default-channels}
  3891. variable.
  3892. @end enumerate
  3893. On completion, @command{guix package} will use packages and package
  3894. versions from this just-retrieved copy of Guix. Not only that, but all
  3895. the Guix commands and Scheme modules will also be taken from that latest
  3896. version. New @command{guix} sub-commands added by the update also
  3897. become available.
  3898. Any user can update their Guix copy using @command{guix pull}, and the
  3899. effect is limited to the user who ran @command{guix pull}. For
  3900. instance, when user @code{root} runs @command{guix pull}, this has no
  3901. effect on the version of Guix that user @code{alice} sees, and vice
  3902. versa.
  3903. The result of running @command{guix pull} is a @dfn{profile} available
  3904. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  3905. make sure to add it to the beginning of your search path so that you use
  3906. the latest version, and similarly for the Info manual
  3907. (@pxref{Documentation}):
  3908. @example
  3909. export PATH="$HOME/.config/guix/current/bin:$PATH"
  3910. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  3911. @end example
  3912. The @option{--list-generations} or @option{-l} option lists past generations
  3913. produced by @command{guix pull}, along with details about their provenance:
  3914. @example
  3915. $ guix pull -l
  3916. Generation 1 Jun 10 2018 00:18:18
  3917. guix 65956ad
  3918. repository URL: https://git.savannah.gnu.org/git/guix.git
  3919. branch: origin/master
  3920. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  3921. Generation 2 Jun 11 2018 11:02:49
  3922. guix e0cc7f6
  3923. repository URL: https://git.savannah.gnu.org/git/guix.git
  3924. branch: origin/master
  3925. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  3926. Generation 3 Jun 13 2018 23:31:07 (current)
  3927. guix 844cc1c
  3928. repository URL: https://git.savannah.gnu.org/git/guix.git
  3929. branch: origin/master
  3930. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  3931. @end example
  3932. @xref{Invoking guix describe, @command{guix describe}}, for other ways to
  3933. describe the current status of Guix.
  3934. This @code{~/.config/guix/current} profile works exactly like the profiles
  3935. created by @command{guix package} (@pxref{Invoking guix package}). That
  3936. is, you can list generations, roll back to the previous
  3937. generation---i.e., the previous Guix---and so on:
  3938. @example
  3939. $ guix pull --roll-back
  3940. switched from generation 3 to 2
  3941. $ guix pull --delete-generations=1
  3942. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3943. @end example
  3944. You can also use @command{guix package} (@pxref{Invoking guix package})
  3945. to manage the profile by naming it explicitly:
  3946. @example
  3947. $ guix package -p ~/.config/guix/current --roll-back
  3948. switched from generation 3 to 2
  3949. $ guix package -p ~/.config/guix/current --delete-generations=1
  3950. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3951. @end example
  3952. The @command{guix pull} command is usually invoked with no arguments,
  3953. but it supports the following options:
  3954. @table @code
  3955. @item --url=@var{url}
  3956. @itemx --commit=@var{commit}
  3957. @itemx --branch=@var{branch}
  3958. Download code for the @code{guix} channel from the specified @var{url}, at the
  3959. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3960. string or the name of a tag), or @var{branch}.
  3961. @cindex @file{channels.scm}, configuration file
  3962. @cindex configuration file for channels
  3963. These options are provided for convenience, but you can also specify your
  3964. configuration in the @file{~/.config/guix/channels.scm} file or using the
  3965. @option{--channels} option (see below).
  3966. @item --channels=@var{file}
  3967. @itemx -C @var{file}
  3968. Read the list of channels from @var{file} instead of
  3969. @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
  3970. @var{file} must contain Scheme code that
  3971. evaluates to a list of channel objects. @xref{Channels}, for more
  3972. information.
  3973. @item --no-channel-files
  3974. @itemx -q
  3975. Inhibit loading of the user and system channel files,
  3976. @file{~/.config/guix/channels.scm} and @file{/etc/guix/channels.scm}.
  3977. @cindex channel news
  3978. @item --news
  3979. @itemx -N
  3980. Display news written by channel authors for their users for changes made
  3981. since the previous generation (@pxref{Channels, Writing Channel News}).
  3982. When @option{--details} is passed, additionally display new and upgraded
  3983. packages.
  3984. You can view that information for previous generations with
  3985. @command{guix pull -l}.
  3986. @item --list-generations[=@var{pattern}]
  3987. @itemx -l [@var{pattern}]
  3988. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  3989. is provided, the subset of generations that match @var{pattern}.
  3990. The syntax of @var{pattern} is the same as with @code{guix package
  3991. --list-generations} (@pxref{Invoking guix package}).
  3992. By default, this prints information about the channels used in each
  3993. revision as well as the corresponding news entries. If you pass
  3994. @option{--details}, it will also print the list of packages added and
  3995. upgraded in each generation compared to the previous one.
  3996. @item --details
  3997. Instruct @option{--list-generations} or @option{--news} to display more
  3998. information about the differences between subsequent generations---see
  3999. above.
  4000. @item --roll-back
  4001. @cindex rolling back
  4002. @cindex undoing transactions
  4003. @cindex transactions, undoing
  4004. Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
  4005. undo the last transaction.
  4006. @item --switch-generation=@var{pattern}
  4007. @itemx -S @var{pattern}
  4008. @cindex generations
  4009. Switch to a particular generation defined by @var{pattern}.
  4010. @var{pattern} may be either a generation number or a number prefixed
  4011. with ``+'' or ``-''. The latter means: move forward/backward by a
  4012. specified number of generations. For example, if you want to return to
  4013. the latest generation after @option{--roll-back}, use
  4014. @option{--switch-generation=+1}.
  4015. @item --delete-generations[=@var{pattern}]
  4016. @itemx -d [@var{pattern}]
  4017. When @var{pattern} is omitted, delete all generations except the current
  4018. one.
  4019. This command accepts the same patterns as @option{--list-generations}.
  4020. When @var{pattern} is specified, delete the matching generations. When
  4021. @var{pattern} specifies a duration, generations @emph{older} than the
  4022. specified duration match. For instance, @option{--delete-generations=1m}
  4023. deletes generations that are more than one month old.
  4024. If the current generation matches, it is @emph{not} deleted.
  4025. Note that deleting generations prevents rolling back to them.
  4026. Consequently, this command must be used with care.
  4027. @xref{Invoking guix describe}, for a way to display information about the
  4028. current generation only.
  4029. @item --profile=@var{profile}
  4030. @itemx -p @var{profile}
  4031. Use @var{profile} instead of @file{~/.config/guix/current}.
  4032. @item --dry-run
  4033. @itemx -n
  4034. Show which channel commit(s) would be used and what would be built or
  4035. substituted but do not actually do it.
  4036. @item --allow-downgrades
  4037. Allow pulling older or unrelated revisions of channels than those
  4038. currently in use.
  4039. @cindex downgrade attacks, protection against
  4040. By default, @command{guix pull} protects against so-called ``downgrade
  4041. attacks'' whereby the Git repository of a channel would be reset to an
  4042. earlier or unrelated revision of itself, potentially leading you to
  4043. install older, known-vulnerable versions of software packages.
  4044. @quotation Note
  4045. Make sure you understand its security implications before using
  4046. @option{--allow-downgrades}.
  4047. @end quotation
  4048. @item --disable-authentication
  4049. Allow pulling channel code without authenticating it.
  4050. @cindex authentication, of channel code
  4051. By default, @command{guix pull} authenticates code downloaded from
  4052. channels by verifying that its commits are signed by authorized
  4053. developers, and raises an error if this is not the case. This option
  4054. instructs it to not perform any such verification.
  4055. @quotation Note
  4056. Make sure you understand its security implications before using
  4057. @option{--disable-authentication}.
  4058. @end quotation
  4059. @item --system=@var{system}
  4060. @itemx -s @var{system}
  4061. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  4062. the system type of the build host.
  4063. @item --bootstrap
  4064. Use the bootstrap Guile to build the latest Guix. This option is only
  4065. useful to Guix developers.
  4066. @end table
  4067. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  4068. repository and branch to pull from, as well as @emph{additional} repositories
  4069. containing package modules that should be deployed. @xref{Channels}, for more
  4070. information.
  4071. In addition, @command{guix pull} supports all the common build options
  4072. (@pxref{Common Build Options}).
  4073. @node Invoking guix time-machine
  4074. @section Invoking @command{guix time-machine}
  4075. @cindex @command{guix time-machine}
  4076. @cindex pinning, channels
  4077. @cindex replicating Guix
  4078. @cindex reproducibility, of Guix
  4079. The @command{guix time-machine} command provides access to other
  4080. revisions of Guix, for example to install older versions of packages,
  4081. or to reproduce a computation in an identical environment. The revision
  4082. of Guix to be used is defined by a commit or by a channel
  4083. description file created by @command{guix describe}
  4084. (@pxref{Invoking guix describe}).
  4085. Let's assume that you want to travel to those days of November 2020 when
  4086. version 1.2.0 of Guix was released and, once you're there, run the
  4087. @command{guile} of that time:
  4088. @example
  4089. guix time-machine --commit=v1.2.0 -- \
  4090. environment -C --ad-hoc guile -- guile
  4091. @end example
  4092. The command above fetches Guix@tie{}1.2.0 (and possibly other channels
  4093. specified by your @file{channels.scm} configuration files---see
  4094. below) and runs its @command{guix
  4095. environment} command to spawn an environment in a container running
  4096. @command{guile} (@command{guix environment} has since been subsumed by
  4097. @command{guix shell}; @pxref{Invoking guix shell}). It's like driving a
  4098. DeLorean@footnote{If you don't know what a DeLorean is, consider
  4099. traveling back to the 1980's.}! The first @command{guix time-machine}
  4100. invocation can be expensive: it may have to download or even build a
  4101. large number of packages; the result is cached though and subsequent
  4102. commands targeting the same commit are almost instantaneous.
  4103. As for @command{guix pull}, in the absence of any options,
  4104. @command{time-machine} fetches the latest commits of the channels
  4105. specified in @file{~/.config/guix/channels.scm},
  4106. @file{/etc/guix/channels.scm}, or the default channels; the @option{-q}
  4107. option lets you ignore these configuration files. The command:
  4108. @example
  4109. guix time-machine -q -- build hello
  4110. @end example
  4111. will thus build the package @code{hello} as defined in the main branch
  4112. of Guix, without any additional channel, which is in general a newer
  4113. revision of Guix than you have installed. Time travel works in both
  4114. directions!
  4115. @quotation Note
  4116. The history of Guix is immutable and @command{guix time-machine}
  4117. provides the exact same software as they are in a specific Guix
  4118. revision. Naturally, no security fixes are provided for old versions
  4119. of Guix or its channels. A careless use of @command{guix time-machine}
  4120. opens the door to security vulnerabilities. @xref{Invoking guix pull,
  4121. @option{--allow-downgrades}}.
  4122. @end quotation
  4123. Due to @command{guix time-machine} relying on the ``inferiors''
  4124. mechanism (@pxref{Inferiors}), the oldest commit it can travel to is
  4125. commit @samp{6298c3ff} (``v1.0.0''), dated May 1@sup{st}, 2019, which is
  4126. the first release that included the inferiors mechanism. An error is
  4127. returned when attempting to navigate to older commits.
  4128. @quotation Note
  4129. Although it should technically be possible to travel to such an old
  4130. commit, the ease to do so will largely depend on the availability of
  4131. binary substitutes. When traveling to a distant past, some packages may
  4132. not easily build from source anymore. One such example are old versions
  4133. of Python 2 which had time bombs in its test suite, in the form of
  4134. expiring SSL certificates. This particular problem can be worked around
  4135. by setting the hardware clock to a value in the past before attempting
  4136. the build.
  4137. @end quotation
  4138. The general syntax is:
  4139. @example
  4140. guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
  4141. @end example
  4142. where @var{command} and @var{arg}@dots{} are passed unmodified to the
  4143. @command{guix} command of the specified revision. The @var{options} that define
  4144. this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
  4145. @table @code
  4146. @item --url=@var{url}
  4147. @itemx --commit=@var{commit}
  4148. @itemx --branch=@var{branch}
  4149. Use the @code{guix} channel from the specified @var{url}, at the
  4150. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  4151. string or the name of a tag), or @var{branch}.
  4152. @item --channels=@var{file}
  4153. @itemx -C @var{file}
  4154. Read the list of channels from @var{file}. @var{file} must contain
  4155. Scheme code that evaluates to a list of channel objects.
  4156. @xref{Channels} for more information.
  4157. @item --no-channel-files
  4158. @itemx -q
  4159. Inhibit loading of the user and system channel files,
  4160. @file{~/.config/guix/channels.scm} and @file{/etc/guix/channels.scm}.
  4161. Thus, @command{guix time-machine -q} is equivalent to the following Bash
  4162. command, using the ``process substitution'' syntax (@pxref{Process
  4163. Substitution,,, bash, The GNU Bash Reference Manual}):
  4164. @example
  4165. guix time-machine -C <(echo %default-channels) @dots{}
  4166. @end example
  4167. @end table
  4168. Note that @command{guix time-machine} can trigger builds of channels and
  4169. their dependencies, and these are controlled by the standard build
  4170. options (@pxref{Common Build Options}).
  4171. @node Inferiors
  4172. @section Inferiors
  4173. @c TODO: Remove this once we're more confident about API stability.
  4174. @quotation Note
  4175. The functionality described here is a ``technology preview'' as of version
  4176. @value{VERSION}. As such, the interface is subject to change.
  4177. @end quotation
  4178. @cindex inferiors
  4179. @cindex composition of Guix revisions
  4180. Sometimes you might need to mix packages from the revision of Guix you're
  4181. currently running with packages available in a different revision of Guix.
  4182. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  4183. revisions in arbitrary ways.
  4184. @cindex inferior packages
  4185. Technically, an ``inferior'' is essentially a separate Guix process connected
  4186. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  4187. @code{(guix inferior)} module allows you to create inferiors and to
  4188. communicate with them. It also provides a high-level interface to browse and
  4189. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  4190. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  4191. to interact with a separate revision of Guix. For example, let's assume you
  4192. want to install in your profile the current @code{guile} package, along with
  4193. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  4194. because the newer @code{guile-json} has an incompatible API and you want to
  4195. run your code against the old API@. To do that, you could write a manifest for
  4196. use by @code{guix package --manifest} (@pxref{Writing Manifests}); in that
  4197. manifest, you would create an inferior for that old Guix revision you care
  4198. about, and you would look up the @code{guile-json} package in the inferior:
  4199. @lisp
  4200. (use-modules (guix inferior) (guix channels)
  4201. (srfi srfi-1)) ;for 'first'
  4202. (define channels
  4203. ;; This is the old revision from which we want to
  4204. ;; extract guile-json.
  4205. (list (channel
  4206. (name 'guix)
  4207. (url "https://git.savannah.gnu.org/git/guix.git")
  4208. (commit
  4209. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  4210. (define inferior
  4211. ;; An inferior representing the above revision.
  4212. (inferior-for-channels channels))
  4213. ;; Now create a manifest with the current "guile" package
  4214. ;; and the old "guile-json" package.
  4215. (packages->manifest
  4216. (list (first (lookup-inferior-packages inferior "guile-json"))
  4217. (specification->package "guile")))
  4218. @end lisp
  4219. On its first run, @command{guix package --manifest} might have to build the
  4220. channel you specified before it can create the inferior; subsequent runs will
  4221. be much faster because the Guix revision will be cached.
  4222. The @code{(guix inferior)} module provides the following procedures to open an
  4223. inferior:
  4224. @deffn {Procedure} inferior-for-channels channels [#:cache-directory] [#:ttl]
  4225. Return an inferior for @var{channels}, a list of channels. Use the cache at
  4226. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  4227. This procedure opens a new connection to the build daemon.
  4228. As a side effect, this procedure may build or substitute binaries for
  4229. @var{channels}, which can take time.
  4230. @end deffn
  4231. @deffn {Procedure} open-inferior directory [#:command "bin/guix"]
  4232. Open the inferior Guix in @var{directory}, running
  4233. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  4234. the inferior could not be launched.
  4235. @end deffn
  4236. @cindex inferior packages
  4237. The procedures listed below allow you to obtain and manipulate inferior
  4238. packages.
  4239. @deffn {Procedure} inferior-packages inferior
  4240. Return the list of packages known to @var{inferior}.
  4241. @end deffn
  4242. @deffn {Procedure} lookup-inferior-packages inferior name [version]
  4243. Return the sorted list of inferior packages matching @var{name} in
  4244. @var{inferior}, with highest version numbers first. If @var{version} is true,
  4245. return only packages with a version number prefixed by @var{version}.
  4246. @end deffn
  4247. @deffn {Procedure} inferior-package? obj
  4248. Return true if @var{obj} is an inferior package.
  4249. @end deffn
  4250. @deffn {Procedure} inferior-package-name package
  4251. @deffnx {Procedure} inferior-package-version package
  4252. @deffnx {Procedure} inferior-package-synopsis package
  4253. @deffnx {Procedure} inferior-package-description package
  4254. @deffnx {Procedure} inferior-package-home-page package
  4255. @deffnx {Procedure} inferior-package-location package
  4256. @deffnx {Procedure} inferior-package-inputs package
  4257. @deffnx {Procedure} inferior-package-native-inputs package
  4258. @deffnx {Procedure} inferior-package-propagated-inputs package
  4259. @deffnx {Procedure} inferior-package-transitive-propagated-inputs package
  4260. @deffnx {Procedure} inferior-package-native-search-paths package
  4261. @deffnx {Procedure} inferior-package-transitive-native-search-paths package
  4262. @deffnx {Procedure} inferior-package-search-paths package
  4263. These procedures are the counterpart of package record accessors
  4264. (@pxref{package Reference}). Most of them work by querying the inferior
  4265. @var{package} comes from, so the inferior must still be live when you call
  4266. these procedures.
  4267. @end deffn
  4268. Inferior packages can be used transparently like any other package or
  4269. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  4270. transparently handled by the @code{packages->manifest} procedure, which is
  4271. commonly used in manifests (@pxref{Invoking guix package, the
  4272. @option{--manifest} option of @command{guix package}}). Thus you can insert
  4273. an inferior package pretty much anywhere you would insert a regular package:
  4274. in manifests, in the @code{packages} field of your @code{operating-system}
  4275. declaration, and so on.
  4276. @node Invoking guix describe
  4277. @section Invoking @command{guix describe}
  4278. @cindex reproducibility
  4279. @cindex replicating Guix
  4280. @cindex @command{guix describe}
  4281. Often you may want to answer questions like: ``Which revision of Guix am I
  4282. using?'' or ``Which channels am I using?'' This is useful information in many
  4283. situations: if you want to @emph{replicate} an environment on a different
  4284. machine or user account, if you want to report a bug or to determine what
  4285. change in the channels you are using caused it, or if you want to record your
  4286. system state for reproducibility purposes. The @command{guix describe}
  4287. command answers these questions.
  4288. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  4289. displays the channel(s) that it was built from, including their repository URL
  4290. and commit IDs (@pxref{Channels}):
  4291. @example
  4292. $ guix describe
  4293. Generation 10 Sep 03 2018 17:32:44 (current)
  4294. guix e0fa68c
  4295. repository URL: https://git.savannah.gnu.org/git/guix.git
  4296. branch: master
  4297. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  4298. @end example
  4299. If you're familiar with the Git version control system, this is similar in
  4300. spirit to @command{git describe}; the output is also similar to that of
  4301. @command{guix pull --list-generations}, but limited to the current generation
  4302. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  4303. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  4304. information is all it takes to describe the revision of Guix you're using, and
  4305. also to replicate it.
  4306. To make it easier to replicate Guix, @command{guix describe} can also be asked
  4307. to return a list of channels instead of the human-readable description above:
  4308. @example
  4309. $ guix describe -f channels
  4310. (list (channel
  4311. (name 'guix)
  4312. (url "https://git.savannah.gnu.org/git/guix.git")
  4313. (commit
  4314. "e0fa68c7718fffd33d81af415279d6ddb518f727")
  4315. (introduction
  4316. (make-channel-introduction
  4317. "9edb3f66fd807b096b48283debdcddccfea34bad"
  4318. (openpgp-fingerprint
  4319. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
  4320. @end example
  4321. @noindent
  4322. You can save this to a file and feed it to @command{guix pull -C} on some
  4323. other machine or at a later point in time, which will instantiate @emph{this
  4324. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  4325. From there on, since you're able to deploy the same revision of Guix, you can
  4326. just as well @emph{replicate a complete software environment}. We humbly
  4327. think that this is @emph{awesome}, and we hope you'll like it too!
  4328. The details of the options supported by @command{guix describe} are as
  4329. follows:
  4330. @table @code
  4331. @item --format=@var{format}
  4332. @itemx -f @var{format}
  4333. Produce output in the specified @var{format}, one of:
  4334. @table @code
  4335. @item human
  4336. produce human-readable output;
  4337. @item channels
  4338. produce a list of channel specifications that can be passed to @command{guix
  4339. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  4340. guix pull});
  4341. @item channels-sans-intro
  4342. like @code{channels}, but omit the @code{introduction} field; use it to
  4343. produce a channel specification suitable for Guix version 1.1.0 or
  4344. earlier---the @code{introduction} field has to do with channel
  4345. authentication (@pxref{Channels, Channel Authentication}) and is not
  4346. supported by these older versions;
  4347. @item json
  4348. @cindex JSON
  4349. produce a list of channel specifications in JSON format;
  4350. @item recutils
  4351. produce a list of channel specifications in Recutils format.
  4352. @end table
  4353. @item --list-formats
  4354. Display available formats for @option{--format} option.
  4355. @item --profile=@var{profile}
  4356. @itemx -p @var{profile}
  4357. Display information about @var{profile}.
  4358. @end table
  4359. @node Invoking guix archive
  4360. @section Invoking @command{guix archive}
  4361. @cindex @command{guix archive}
  4362. @cindex archive
  4363. @cindex exporting files from the store
  4364. @cindex importing files to the store
  4365. The @command{guix archive} command allows users to @dfn{export} files
  4366. from the store into a single archive, and to later @dfn{import} them on
  4367. a machine that runs Guix.
  4368. In particular, it allows store files to be transferred from one machine
  4369. to the store on another machine.
  4370. @quotation Note
  4371. If you're looking for a way to produce archives in a format suitable for
  4372. tools other than Guix, @pxref{Invoking guix pack}.
  4373. @end quotation
  4374. @cindex exporting store items
  4375. To export store files as an archive to standard output, run:
  4376. @example
  4377. guix archive --export @var{options} @var{specifications}...
  4378. @end example
  4379. @var{specifications} may be either store file names or package
  4380. specifications, as for @command{guix package} (@pxref{Invoking guix
  4381. package}). For instance, the following command creates an archive
  4382. containing the @code{gui} output of the @code{git} package and the main
  4383. output of @code{emacs}:
  4384. @example
  4385. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  4386. @end example
  4387. If the specified packages are not built yet, @command{guix archive}
  4388. automatically builds them. The build process may be controlled with the
  4389. common build options (@pxref{Common Build Options}).
  4390. To transfer the @code{emacs} package to a machine connected over SSH,
  4391. one would run:
  4392. @example
  4393. guix archive --export -r emacs | ssh the-machine guix archive --import
  4394. @end example
  4395. @noindent
  4396. Similarly, a complete user profile may be transferred from one machine
  4397. to another like this:
  4398. @example
  4399. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  4400. ssh the-machine guix archive --import
  4401. @end example
  4402. @noindent
  4403. However, note that, in both examples, all of @code{emacs} and the
  4404. profile as well as all of their dependencies are transferred (due to
  4405. @option{-r}), regardless of what is already available in the store on
  4406. the target machine. The @option{--missing} option can help figure out
  4407. which items are missing from the target store. The @command{guix copy}
  4408. command simplifies and optimizes this whole process, so this is probably
  4409. what you should use in this case (@pxref{Invoking guix copy}).
  4410. @cindex nar, archive format
  4411. @cindex normalized archive (nar)
  4412. @cindex nar bundle, archive format
  4413. Each store item is written in the @dfn{normalized archive} or @dfn{nar}
  4414. format (described below), and the output of @command{guix archive
  4415. --export} (and input of @command{guix archive --import}) is a @dfn{nar
  4416. bundle}.
  4417. The nar format is
  4418. comparable in spirit to `tar', but with differences
  4419. that make it more appropriate for our purposes. First, rather than
  4420. recording all Unix metadata for each file, the nar format only mentions
  4421. the file type (regular, directory, or symbolic link); Unix permissions
  4422. and owner/group are dismissed. Second, the order in which directory
  4423. entries are stored always follows the order of file names according to
  4424. the C locale collation order. This makes archive production fully
  4425. deterministic.
  4426. That nar bundle format is essentially the concatenation of zero or more
  4427. nars along with metadata for each store item it contains: its file name,
  4428. references, corresponding derivation, and a digital signature.
  4429. When exporting, the daemon digitally signs the contents of the archive,
  4430. and that digital signature is appended. When importing, the daemon
  4431. verifies the signature and rejects the import in case of an invalid
  4432. signature or if the signing key is not authorized.
  4433. @c FIXME: Add xref to daemon doc about signatures.
  4434. The main options are:
  4435. @table @code
  4436. @item --export
  4437. Export the specified store files or packages (see below). Write the
  4438. resulting archive to the standard output.
  4439. Dependencies are @emph{not} included in the output, unless
  4440. @option{--recursive} is passed.
  4441. @item -r
  4442. @itemx --recursive
  4443. When combined with @option{--export}, this instructs @command{guix archive}
  4444. to include dependencies of the given items in the archive. Thus, the
  4445. resulting archive is self-contained: it contains the closure of the
  4446. exported store items.
  4447. @item --import
  4448. Read an archive from the standard input, and import the files listed
  4449. therein into the store. Abort if the archive has an invalid digital
  4450. signature, or if it is signed by a public key not among the authorized
  4451. keys (see @option{--authorize} below).
  4452. @item --missing
  4453. Read a list of store file names from the standard input, one per line,
  4454. and write on the standard output the subset of these files missing from
  4455. the store.
  4456. @item --generate-key[=@var{parameters}]
  4457. @cindex signing, archives
  4458. Generate a new key pair for the daemon. This is a prerequisite before
  4459. archives can be exported with @option{--export}. This
  4460. operation is usually instantaneous but it can take time if the system's
  4461. entropy pool needs to be refilled. On Guix System,
  4462. @code{guix-service-type} takes care of generating this key pair the
  4463. first boot.
  4464. The generated key pair is typically stored under @file{/etc/guix}, in
  4465. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  4466. key, which must be kept secret). When @var{parameters} is omitted,
  4467. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  4468. versions before 1.6.0, it is a 4096-bit RSA key.
  4469. Alternatively, @var{parameters} can specify
  4470. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  4471. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  4472. Libgcrypt Reference Manual}).
  4473. @item --authorize
  4474. @cindex authorizing, archives
  4475. Authorize imports signed by the public key passed on standard input.
  4476. The public key must be in ``s-expression advanced format''---i.e., the
  4477. same format as the @file{signing-key.pub} file.
  4478. The list of authorized keys is kept in the human-editable file
  4479. @file{/etc/guix/acl}. The file contains
  4480. @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  4481. s-expressions''} and is structured as an access-control list in the
  4482. @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  4483. (SPKI)}.
  4484. @item --extract=@var{directory}
  4485. @itemx -x @var{directory}
  4486. Read a single-item archive as served by substitute servers
  4487. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  4488. low-level operation needed in only very narrow use cases; see below.
  4489. For example, the following command extracts the substitute for Emacs
  4490. served by @code{@value{SUBSTITUTE-SERVER-1}} to @file{/tmp/emacs}:
  4491. @example
  4492. $ wget -O - \
  4493. https://@value{SUBSTITUTE-SERVER-1}/nar/gzip/@dots{}-emacs-24.5 \
  4494. | gunzip | guix archive -x /tmp/emacs
  4495. @end example
  4496. Single-item archives are different from multiple-item archives produced
  4497. by @command{guix archive --export}; they contain a single store item,
  4498. and they do @emph{not} embed a signature. Thus this operation does
  4499. @emph{no} signature verification and its output should be considered
  4500. unsafe.
  4501. The primary purpose of this operation is to facilitate inspection of
  4502. archive contents coming from possibly untrusted substitute servers
  4503. (@pxref{Invoking guix challenge}).
  4504. @item --list
  4505. @itemx -t
  4506. Read a single-item archive as served by substitute servers
  4507. (@pxref{Substitutes}) and print the list of files it contains, as in
  4508. this example:
  4509. @example
  4510. $ wget -O - \
  4511. https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-emacs-26.3 \
  4512. | lzip -d | guix archive -t
  4513. @end example
  4514. @end table
  4515. @c *********************************************************************
  4516. @node Channels
  4517. @chapter Channels
  4518. @cindex channels
  4519. @cindex @file{channels.scm}, configuration file
  4520. @cindex configuration file for channels
  4521. @cindex @command{guix pull}, configuration file
  4522. @cindex configuration of @command{guix pull}
  4523. Guix and its package collection are updated by running @command{guix pull}
  4524. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  4525. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  4526. customized by defining @dfn{channels} in the
  4527. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  4528. of a Git repository to be deployed, and @command{guix pull} can be instructed
  4529. to pull from one or more channels. In other words, channels can be used
  4530. to @emph{customize} and to @emph{extend} Guix, as we will see below.
  4531. Guix is able to take into account security concerns and deal with authenticated
  4532. updates.
  4533. @menu
  4534. * Specifying Additional Channels:: Extending the package collection.
  4535. * Using a Custom Guix Channel:: Using a customized Guix.
  4536. * Replicating Guix:: Running the @emph{exact same} Guix.
  4537. * Channel Authentication:: How Guix verifies what it fetches.
  4538. * Channels with Substitutes:: Using channels with available substitutes.
  4539. * Creating a Channel:: How to write your custom channel.
  4540. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  4541. * Declaring Channel Dependencies:: How to depend on other channels.
  4542. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  4543. * Primary URL:: Distinguishing mirror to original.
  4544. * Writing Channel News:: Communicating information to channel's users.
  4545. @end menu
  4546. @node Specifying Additional Channels
  4547. @section Specifying Additional Channels
  4548. @cindex extending the package collection (channels)
  4549. @cindex variant packages (channels)
  4550. You can specify @emph{additional channels} to pull from. To use a channel, write
  4551. @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
  4552. @emph{in addition} to the default Guix channel(s):
  4553. @vindex %default-channels
  4554. @lisp
  4555. ;; Add variant packages to those Guix provides.
  4556. (cons (channel
  4557. (name 'variant-packages)
  4558. (url "https://example.org/variant-packages.git"))
  4559. %default-channels)
  4560. @end lisp
  4561. @noindent
  4562. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  4563. add a channel the list of channels that the variable @code{%default-channels}
  4564. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  4565. Manual}). With this file in place, @command{guix pull} builds not only Guix
  4566. but also the package modules from your own repository. The result in
  4567. @file{~/.config/guix/current} is the union of Guix with your own package
  4568. modules:
  4569. @example
  4570. $ guix describe
  4571. Generation 19 Aug 27 2018 16:20:48
  4572. guix d894ab8
  4573. repository URL: https://git.savannah.gnu.org/git/guix.git
  4574. branch: master
  4575. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  4576. variant-packages dd3df5e
  4577. repository URL: https://example.org/variant-packages.git
  4578. branch: master
  4579. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  4580. @end example
  4581. @noindent
  4582. The output of @command{guix describe} above shows that we're now running
  4583. Generation@tie{}19 and that it includes
  4584. both Guix and packages from the @code{variant-personal-packages} channel
  4585. (@pxref{Invoking guix describe}).
  4586. @node Using a Custom Guix Channel
  4587. @section Using a Custom Guix Channel
  4588. The channel called @code{guix} specifies where Guix itself---its command-line
  4589. tools as well as its package collection---should be downloaded. For instance,
  4590. suppose you want to update from another copy of the Guix repository at
  4591. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  4592. write in @code{~/.config/guix/channels.scm} this specification:
  4593. @lisp
  4594. ;; Tell 'guix pull' to use another repo.
  4595. (list (channel
  4596. (name 'guix)
  4597. (url "https://example.org/another-guix.git")
  4598. (branch "super-hacks")))
  4599. @end lisp
  4600. @noindent
  4601. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  4602. branch of the repository at @code{example.org}. The authentication concern is
  4603. addressed below (@pxref{Channel Authentication}).
  4604. Note that you can specify a local directory on the @code{url} field above if
  4605. the channel that you intend to use resides on a local file system. However,
  4606. in this case @command{guix} checks said directory for ownership before any
  4607. further processing. This means that if the user is not the directory owner,
  4608. but wants to use it as their default, they will then need to set it as a safe
  4609. directory in their global git configuration file. Otherwise, @command{guix}
  4610. will refuse to even read it. Supposing your system-wide local directory is at
  4611. @code{/src/guix.git}, you would then create a git configuration file at
  4612. @code{~/.gitconfig} with the following contents:
  4613. @example
  4614. [safe]
  4615. directory = /src/guix.git
  4616. @end example
  4617. @noindent
  4618. This also applies to the root user unless when called with @command{sudo} by
  4619. the directory owner.
  4620. @node Replicating Guix
  4621. @section Replicating Guix
  4622. @cindex pinning, channels
  4623. @cindex replicating Guix
  4624. @cindex reproducibility, of Guix
  4625. The @command{guix describe} command shows precisely which commits were
  4626. used to build the instance of Guix we're using (@pxref{Invoking guix
  4627. describe}). We can replicate this instance on another machine or at a
  4628. different point in time by providing a channel specification ``pinned''
  4629. to these commits that looks like this:
  4630. @lisp
  4631. ;; Deploy specific commits of my channels of interest.
  4632. (list (channel
  4633. (name 'guix)
  4634. (url "https://git.savannah.gnu.org/git/guix.git")
  4635. (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
  4636. (channel
  4637. (name 'variant-packages)
  4638. (url "https://example.org/variant-packages.git")
  4639. (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  4640. @end lisp
  4641. To obtain this pinned channel specification, the easiest way is to run
  4642. @command{guix describe} and to save its output in the @code{channels}
  4643. format in a file, like so:
  4644. @example
  4645. guix describe -f channels > channels.scm
  4646. @end example
  4647. The resulting @file{channels.scm} file can be passed to the @option{-C}
  4648. option of @command{guix pull} (@pxref{Invoking guix pull}) or
  4649. @command{guix time-machine} (@pxref{Invoking guix time-machine}), as in
  4650. this example:
  4651. @example
  4652. guix time-machine -C channels.scm -- shell python -- python3
  4653. @end example
  4654. Given the @file{channels.scm} file, the command above will always fetch
  4655. the @emph{exact same Guix instance}, then use that instance to run the
  4656. exact same Python (@pxref{Invoking guix shell}). On any machine, at any
  4657. time, it ends up running the exact same binaries, bit for bit.
  4658. @cindex lock files
  4659. Pinned channels address a problem similar to ``lock files'' as
  4660. implemented by some deployment tools---they let you pin and reproduce a
  4661. set of packages. In the case of Guix though, you are effectively
  4662. pinning the entire package set as defined at the given channel commits;
  4663. in fact, you are pinning all of Guix, including its core modules and
  4664. command-line tools. You're also getting strong guarantees that you are,
  4665. indeed, obtaining the exact same software.
  4666. This gives you super powers, allowing you to track the provenance of binary
  4667. artifacts with very fine grain, and to reproduce software environments at
  4668. will---some sort of ``meta reproducibility'' capabilities, if you will.
  4669. @xref{Inferiors}, for another way to take advantage of these super powers.
  4670. @node Channel Authentication
  4671. @section Channel Authentication
  4672. @anchor{channel-authentication}
  4673. @cindex authentication, of channel code
  4674. The @command{guix pull} and @command{guix time-machine} commands
  4675. @dfn{authenticate} the code retrieved from channels: they make sure each
  4676. commit that is fetched is signed by an authorized developer. The goal
  4677. is to protect from unauthorized modifications to the channel that would
  4678. lead users to run malicious code.
  4679. As a user, you must provide a @dfn{channel introduction} in your
  4680. channels file so that Guix knows how to authenticate its first commit.
  4681. A channel specification, including its introduction, looks something
  4682. along these lines:
  4683. @lisp
  4684. (channel
  4685. (name 'some-channel)
  4686. (url "https://example.org/some-channel.git")
  4687. (introduction
  4688. (make-channel-introduction
  4689. "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
  4690. (openpgp-fingerprint
  4691. "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4692. @end lisp
  4693. The specification above shows the name and URL of the channel. The call
  4694. to @code{make-channel-introduction} above specifies that authentication
  4695. of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
  4696. by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
  4697. For the main channel, called @code{guix}, you automatically get that
  4698. information from your Guix installation. For other channels, include
  4699. the channel introduction provided by the channel authors in your
  4700. @file{channels.scm} file. Make sure you retrieve the channel
  4701. introduction from a trusted source since that is the root of your trust.
  4702. If you're curious about the authentication mechanics, read on!
  4703. @node Channels with Substitutes
  4704. @section Channels with Substitutes
  4705. When running @command{guix pull}, Guix will first compile the
  4706. definitions of every available package. This is an expensive operation
  4707. for which substitutes (@pxref{Substitutes}) may be available. The
  4708. following snippet in @file{channels.scm} will ensure that @command{guix
  4709. pull} uses the latest commit with available substitutes for the package
  4710. definitions: this is done by querying the continuous integration
  4711. server at @url{https://ci.guix.gnu.org}.
  4712. @lisp
  4713. (use-modules (guix ci))
  4714. (list (channel-with-substitutes-available
  4715. %default-guix-channel
  4716. "https://ci.guix.gnu.org"))
  4717. @end lisp
  4718. Note that this does not mean that all the packages that you will
  4719. install after running @command{guix pull} will have available
  4720. substitutes. It only ensures that @command{guix pull} will not try to
  4721. compile package definitions. This is particularly useful when using
  4722. machines with limited resources.
  4723. @node Creating a Channel
  4724. @section Creating a Channel
  4725. @cindex personal packages (channels)
  4726. @cindex channels, for personal packages
  4727. Let's say you have a bunch of custom package variants or personal packages
  4728. that you think would make little sense to contribute to the Guix project, but
  4729. would like to have these packages transparently available to you at the
  4730. command line. By creating a @dfn{channel}, you can use and publish such
  4731. a package collection. This involves the following steps:
  4732. @enumerate
  4733. @item
  4734. A channel lives in a Git repository so the first step, when creating a
  4735. channel, is to create its repository:
  4736. @example
  4737. mkdir my-channel
  4738. cd my-channel
  4739. git init
  4740. @end example
  4741. @item
  4742. The next step is to create files containing package modules
  4743. (@pxref{Package Modules}), each of which will contain one or more
  4744. package definitions (@pxref{Defining Packages}). A channel can provide
  4745. things other than packages, such as build systems or services; we're
  4746. using packages as it's the most common use case.
  4747. For example, Alice might want to provide a module called @code{(alice
  4748. packages greetings)} that will provide her favorite ``hello world''
  4749. implementations. To do that Alice will create a directory corresponding
  4750. to that module name.
  4751. @example
  4752. mkdir -p alice/packages
  4753. $EDITOR alice/packages/greetings.scm
  4754. git add alice/packages/greetings.scm
  4755. @end example
  4756. You can name your package modules however you like; the main constraint
  4757. to keep in mind is to avoid name clashes with other package collections,
  4758. which is why our hypothetical Alice wisely chose the @code{(alice
  4759. packages @dots{})} name space.
  4760. Note that you can also place modules in a sub-directory of the
  4761. repository; @pxref{Package Modules in a Sub-directory}, for more info on
  4762. that.
  4763. @item
  4764. With this first module in place, the next step is to test the packages
  4765. it provides. This can be done with @command{guix build}, which needs to
  4766. be told to look for modules in the Git checkout. For example, assuming
  4767. @code{(alice packages greetings)} provides a package called
  4768. @code{hi-from-alice}, Alice will run this command from the Git checkout:
  4769. @example
  4770. guix build -L. hi-from-alice
  4771. @end example
  4772. @noindent
  4773. ... where @code{-L.} adds the current directory to Guile's load path
  4774. (@pxref{Load Paths,,, guile, GNU Guile Reference Manual}).
  4775. @item
  4776. It might take Alice a few iterations to obtain satisfying package
  4777. definitions. Eventually Alice will commit this file:
  4778. @example
  4779. git commit
  4780. @end example
  4781. As a channel author, consider bundling authentication material with your
  4782. channel so that users can authenticate it. @xref{Channel
  4783. Authentication}, and @ref{Specifying Channel Authorizations}, for info
  4784. on how to do it.
  4785. @item
  4786. To use Alice's channel, anyone can now add it to their channel file
  4787. (@pxref{Specifying Additional Channels}) and run @command{guix pull}
  4788. (@pxref{Invoking guix pull}):
  4789. @example
  4790. $EDITOR ~/.config/guix/channels.scm
  4791. guix pull
  4792. @end example
  4793. Guix will now behave as if the root directory of that channel's Git
  4794. repository had been permanently added to the Guile load path. In this
  4795. example, @code{(alice packages greetings)} will automatically be found
  4796. by the @command{guix} command.
  4797. @end enumerate
  4798. Voilà!
  4799. @c What follows stems from discussions at
  4800. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  4801. @c earlier discussions on guix-devel@gnu.org.
  4802. @quotation Warning
  4803. Before you publish your channel, we would like to share a few words of
  4804. caution:
  4805. @itemize
  4806. @item
  4807. Before publishing a channel, please consider contributing your package
  4808. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  4809. to free software of all sorts, and packages in Guix proper are readily
  4810. available to all Guix users and benefit from the project's quality assurance
  4811. process.
  4812. @item
  4813. Package modules and package definitions are Scheme code that uses
  4814. various programming interfaces (APIs). We, Guix developers, never
  4815. change APIs gratuitously, but we do @emph{not} commit to freezing APIs
  4816. either. When you maintain package definitions outside Guix, we consider
  4817. that @emph{the compatibility burden is on you}.
  4818. @item
  4819. Corollary: if you're using an external channel and that channel breaks, please
  4820. @emph{report the issue to the channel authors}, not to the Guix project.
  4821. @end itemize
  4822. You've been warned! Having said this, we believe external channels are a
  4823. practical way to exert your freedom to augment Guix' package collection and to
  4824. share your improvements, which are basic tenets of
  4825. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  4826. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  4827. @end quotation
  4828. @node Package Modules in a Sub-directory
  4829. @section Package Modules in a Sub-directory
  4830. @cindex subdirectory, channels
  4831. As a channel author, you may want to keep your channel modules in a
  4832. sub-directory. If your modules are in the sub-directory @file{guix}, you must
  4833. add a meta-data file @file{.guix-channel} that contains:
  4834. @lisp
  4835. (channel
  4836. (version 0)
  4837. (directory "guix"))
  4838. @end lisp
  4839. The modules must be @b{underneath} the specified directory, as the
  4840. @code{directory} changes Guile's @code{load-path}. For example, if
  4841. @file{.guix-channel} has @code{(directory "base")}, then a module
  4842. defined as @code{(define-module (gnu packages fun))} must be located at
  4843. @code{base/gnu/packages/fun.scm}.
  4844. Doing this allows for only parts of a repository to be used as a
  4845. channel, as Guix expects valid Guile modules when pulling. For
  4846. instance, @command{guix deploy} machine configuration files are not
  4847. valid Guile modules, and treating them as such would make @command{guix
  4848. pull} fail.
  4849. @node Declaring Channel Dependencies
  4850. @section Declaring Channel Dependencies
  4851. @cindex dependencies, channels
  4852. @cindex meta-data, channels
  4853. Channel authors may decide to augment a package collection provided by other
  4854. channels. They can declare their channel to be dependent on other channels in
  4855. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  4856. the channel repository.
  4857. The meta-data file should contain a simple S-expression like this:
  4858. @lisp
  4859. (channel
  4860. (version 0)
  4861. (dependencies
  4862. (channel
  4863. (name some-collection)
  4864. (url "https://example.org/first-collection.git")
  4865. ;; The 'introduction' bit below is optional: you would
  4866. ;; provide it for dependencies that can be authenticated.
  4867. (introduction
  4868. (channel-introduction
  4869. (version 0)
  4870. (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
  4871. (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4872. (channel
  4873. (name some-other-collection)
  4874. (url "https://example.org/second-collection.git")
  4875. (branch "testing"))))
  4876. @end lisp
  4877. In the above example this channel is declared to depend on two other channels,
  4878. which will both be fetched automatically. The modules provided by the channel
  4879. will be compiled in an environment where the modules of all these declared
  4880. channels are available.
  4881. For the sake of reliability and maintainability, you should avoid dependencies
  4882. on channels that you don't control, and you should aim to keep the number of
  4883. dependencies to a minimum.
  4884. @node Specifying Channel Authorizations
  4885. @section Specifying Channel Authorizations
  4886. @cindex channel authorizations
  4887. @anchor{channel-authorizations}
  4888. As we saw above, Guix ensures the source code it pulls from channels
  4889. comes from authorized developers. As a channel author, you need to
  4890. specify the list of authorized developers in the
  4891. @file{.guix-authorizations} file in the channel's Git repository. The
  4892. authentication rule is simple: each commit must be signed by a key
  4893. listed in the @file{.guix-authorizations} file of its parent
  4894. commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
  4895. (DAG). Each commit can have zero or more parents; ``regular'' commits
  4896. have one parent and merge commits have two parent commits. Read
  4897. @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
  4898. for Computer Scientists}} for a great overview.} The
  4899. @file{.guix-authorizations} file looks like this:
  4900. @lisp
  4901. ;; Example '.guix-authorizations' file.
  4902. (authorizations
  4903. (version 0) ;current file format version
  4904. (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
  4905. (name "alice"))
  4906. ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
  4907. (name "bob"))
  4908. ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
  4909. (name "charlie"))))
  4910. @end lisp
  4911. Each fingerprint is followed by optional key/value pairs, as in the
  4912. example above. Currently these key/value pairs are ignored.
  4913. This authentication rule creates a chicken-and-egg issue: how do we
  4914. authenticate the first commit? Related to that: how do we deal with
  4915. channels whose repository history contains unsigned commits and lack
  4916. @file{.guix-authorizations}? And how do we fork existing channels?
  4917. @cindex channel introduction
  4918. Channel introductions answer these questions by describing the first
  4919. commit of a channel that should be authenticated. The first time a
  4920. channel is fetched with @command{guix pull} or @command{guix
  4921. time-machine}, the command looks up the introductory commit and verifies
  4922. that it is signed by the specified OpenPGP key. From then on, it
  4923. authenticates commits according to the rule above. Authentication fails
  4924. if the target commit is neither a descendant nor an ancestor of the
  4925. introductory commit.
  4926. Additionally, your channel must provide all the OpenPGP keys that were
  4927. ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
  4928. files, which can be either binary or ``ASCII-armored''. By default,
  4929. those @file{.key} files are searched for in the branch named
  4930. @code{keyring} but you can specify a different branch name in
  4931. @code{.guix-channel} like so:
  4932. @lisp
  4933. (channel
  4934. (version 0)
  4935. (keyring-reference "my-keyring-branch"))
  4936. @end lisp
  4937. To summarize, as the author of a channel, there are three things you have
  4938. to do to allow users to authenticate your code:
  4939. @enumerate
  4940. @item
  4941. Export the OpenPGP keys of past and present committers with @command{gpg
  4942. --export} and store them in @file{.key} files, by default in a branch
  4943. named @code{keyring} (we recommend making it an @dfn{orphan branch}).
  4944. @item
  4945. Introduce an initial @file{.guix-authorizations} in the channel's
  4946. repository. Do that in a signed commit (@pxref{Commit Access}, for
  4947. information on how to sign Git commits.)
  4948. @item
  4949. Advertise the channel introduction, for instance on your channel's web
  4950. page. The channel introduction, as we saw above, is the commit/key
  4951. pair---i.e., the commit that introduced @file{.guix-authorizations}, and
  4952. the fingerprint of the OpenPGP used to sign it.
  4953. @end enumerate
  4954. Before pushing to your public Git repository, you can run @command{guix
  4955. git authenticate} to verify that you did sign all the commits you are
  4956. about to push with an authorized key:
  4957. @example
  4958. guix git authenticate @var{commit} @var{signer}
  4959. @end example
  4960. @noindent
  4961. where @var{commit} and @var{signer} are your channel introduction.
  4962. @xref{Invoking guix git authenticate}, for details.
  4963. Publishing a signed channel requires discipline: any mistake, such as an
  4964. unsigned commit or a commit signed by an unauthorized key, will prevent
  4965. users from pulling from your channel---well, that's the whole point of
  4966. authentication! Pay attention to merges in particular: merge commits
  4967. are considered authentic if and only if they are signed by a key present
  4968. in the @file{.guix-authorizations} file of @emph{both} branches.
  4969. @node Primary URL
  4970. @section Primary URL
  4971. @cindex primary URL, channels
  4972. Channel authors can indicate the primary URL of their channel's Git
  4973. repository in the @file{.guix-channel} file, like so:
  4974. @lisp
  4975. (channel
  4976. (version 0)
  4977. (url "https://example.org/guix.git"))
  4978. @end lisp
  4979. This allows @command{guix pull} to determine whether it is pulling code
  4980. from a mirror of the channel; when that is the case, it warns the user
  4981. that the mirror might be stale and displays the primary URL@. That way,
  4982. users cannot be tricked into fetching code from a stale mirror that does
  4983. not receive security updates.
  4984. This feature only makes sense for authenticated repositories, such as
  4985. the official @code{guix} channel, for which @command{guix pull} ensures
  4986. the code it fetches is authentic.
  4987. @node Writing Channel News
  4988. @section Writing Channel News
  4989. @cindex news, for channels
  4990. Channel authors may occasionally want to communicate to their users
  4991. information about important changes in the channel. You'd send them all
  4992. an email, but that's not convenient.
  4993. Instead, channels can provide a @dfn{news file}; when the channel users
  4994. run @command{guix pull}, that news file is automatically read and
  4995. @command{guix pull --news} can display the announcements that correspond
  4996. to the new commits that have been pulled, if any.
  4997. To do that, channel authors must first declare the name of the news file
  4998. in their @file{.guix-channel} file:
  4999. @lisp
  5000. (channel
  5001. (version 0)
  5002. (news-file "etc/news.txt"))
  5003. @end lisp
  5004. The news file itself, @file{etc/news.txt} in this example, must look
  5005. something like this:
  5006. @lisp
  5007. (channel-news
  5008. (version 0)
  5009. (entry (tag "the-bug-fix")
  5010. (title (en "Fixed terrible bug")
  5011. (fr "Oh la la"))
  5012. (body (en "@@emph@{Good news@}! It's fixed!")
  5013. (eo "Certe ĝi pli bone funkcias nun!")))
  5014. (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
  5015. (title (en "Added a great package")
  5016. (ca "Què vol dir guix?"))
  5017. (body (en "Don't miss the @@code@{hello@} package!"))))
  5018. @end lisp
  5019. While the news file is using the Scheme syntax, avoid naming it with a
  5020. @file{.scm} extension or else it will get picked up when building the
  5021. channel and yield an error since it is not a valid module.
  5022. Alternatively, you can move the channel module to a subdirectory and
  5023. store the news file in another directory.
  5024. The file consists of a list of @dfn{news entries}. Each entry is
  5025. associated with a commit or tag: it describes changes made in this
  5026. commit, possibly in preceding commits as well. Users see entries only
  5027. the first time they obtain the commit the entry refers to.
  5028. The @code{title} field should be a one-line summary while @code{body}
  5029. can be arbitrarily long, and both can contain Texinfo markup
  5030. (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
  5031. a list of language tag/message tuples, which allows @command{guix pull}
  5032. to display news in the language that corresponds to the user's locale.
  5033. If you want to translate news using a gettext-based workflow, you can
  5034. extract translatable strings with @command{xgettext} (@pxref{xgettext
  5035. Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
  5036. you write news entries in English first, the command below creates a PO
  5037. file containing the strings to translate:
  5038. @example
  5039. xgettext -o news.po -l scheme -ken etc/news.txt
  5040. @end example
  5041. To sum up, yes, you could use your channel as a blog. But beware, this
  5042. is @emph{not quite} what your users might expect.
  5043. @c *********************************************************************
  5044. @node Development
  5045. @chapter Development
  5046. @cindex software development
  5047. If you are a software developer, Guix provides tools that you should find
  5048. helpful---independently of the language you're developing in. This is what
  5049. this chapter is about.
  5050. The @command{guix shell} command provides a convenient way to set up
  5051. one-off software environments, be it for development purposes or to run
  5052. a command without installing it in your profile. The @command{guix
  5053. pack} command allows you to create @dfn{application bundles} that can be
  5054. easily distributed to users who do not run Guix.
  5055. @menu
  5056. * Invoking guix shell:: Spawning one-off software environments.
  5057. * Invoking guix environment:: Setting up development environments.
  5058. * Invoking guix pack:: Creating software bundles.
  5059. * The GCC toolchain:: Working with languages supported by GCC.
  5060. * Invoking guix git authenticate:: Authenticating Git repositories.
  5061. @end menu
  5062. @node Invoking guix shell
  5063. @section Invoking @command{guix shell}
  5064. @cindex reproducible build environments
  5065. @cindex development environments
  5066. @cindex @command{guix environment}
  5067. @cindex @command{guix shell}
  5068. @cindex environment, package build environment
  5069. The purpose of @command{guix shell} is to make it easy to create one-off
  5070. software environments, without changing one's profile. It is typically
  5071. used to create development environments; it is also a convenient way to
  5072. run applications without ``polluting'' your profile.
  5073. @quotation Note
  5074. The @command{guix shell} command was recently introduced to supersede
  5075. @command{guix environment} (@pxref{Invoking guix environment}). If you
  5076. are familiar with @command{guix environment}, you will notice that it is
  5077. similar but also---we hope!---more convenient.
  5078. @end quotation
  5079. The general syntax is:
  5080. @example
  5081. guix shell [@var{options}] [@var{package}@dots{}]
  5082. @end example
  5083. The following example creates an environment containing Python and NumPy,
  5084. building or downloading any missing package, and runs the
  5085. @command{python3} command in that environment:
  5086. @example
  5087. guix shell python python-numpy -- python3
  5088. @end example
  5089. Note that it is necessary to include the main @code{python} package in
  5090. this command even if it is already installed into your environment.
  5091. This is so that the shell environment knows to set @env{PYTHONPATH} and
  5092. other related variables. The shell environment cannot check the
  5093. previously installed environment, because then it would be
  5094. non-deterministic. This is true for most libraries: their corresponding
  5095. language package should be included in the shell invocation.
  5096. @quotation Note
  5097. @cindex shebang, for @command{guix shell}
  5098. @command{guix shell} can be also be used as a script interpreter, also
  5099. known as @dfn{shebang}. Here is an example self-contained Python script
  5100. making use of this feature:
  5101. @example
  5102. #!/usr/bin/env -S guix shell python python-numpy -- python3
  5103. import numpy
  5104. print("This is numpy", numpy.version.version)
  5105. @end example
  5106. You may pass any @command{guix shell} option, but there's one caveat:
  5107. the Linux kernel has a limit of 127 bytes on shebang length.
  5108. @end quotation
  5109. Development environments can be created as in the example below, which
  5110. spawns an interactive shell containing all the dependencies and
  5111. environment variables needed to work on Inkscape:
  5112. @example
  5113. guix shell --development inkscape
  5114. @end example
  5115. Exiting the shell places the user back in the original environment
  5116. before @command{guix shell} was invoked. The next garbage collection
  5117. (@pxref{Invoking guix gc}) may clean up packages that were installed in
  5118. the environment and that are no longer used outside of it.
  5119. As an added convenience, @command{guix shell} will try to do what you
  5120. mean when it is invoked interactively without any other arguments
  5121. as in:
  5122. @example
  5123. guix shell
  5124. @end example
  5125. If it finds a @file{manifest.scm} in the current working directory or
  5126. any of its parents, it uses this manifest as though it was given via @code{--manifest}.
  5127. Likewise, if it finds a @file{guix.scm} in the same directories, it uses
  5128. it to build a development profile as though both @code{--development}
  5129. and @code{--file} were present.
  5130. In either case, the file will only be loaded if the directory it
  5131. resides in is listed in
  5132. @file{~/.config/guix/shell-authorized-directories}.
  5133. This provides an easy way to define, share, and enter development
  5134. environments.
  5135. By default, the shell session or command runs in an @emph{augmented}
  5136. environment, where the new packages are added to search path environment
  5137. variables such as @code{PATH}. You can, instead, choose to create an
  5138. @emph{isolated} environment containing nothing but the packages you
  5139. asked for. Passing the @option{--pure} option clears environment
  5140. variable definitions found in the parent environment@footnote{Be sure to
  5141. use the @option{--check} option the first time you use @command{guix
  5142. shell} interactively to make sure the shell does not undo the effect of
  5143. @option{--pure}.}; passing @option{--container} goes one step further by
  5144. spawning a @dfn{container} isolated from the rest of the system:
  5145. @example
  5146. guix shell --container emacs gcc-toolchain
  5147. @end example
  5148. The command above spawns an interactive shell in a container where
  5149. nothing but @code{emacs}, @code{gcc-toolchain}, and their dependencies
  5150. is available. The container lacks network access and shares no files
  5151. other than the current working directory with the surrounding
  5152. environment. This is useful to prevent access to system-wide resources
  5153. such as @file{/usr/bin} on foreign distros.
  5154. This @option{--container} option can also prove useful if you wish to
  5155. run a security-sensitive application, such as a web browser, in an
  5156. isolated environment. For example, the command below launches
  5157. Ungoogled-Chromium in an isolated environment, this time sharing network
  5158. access with the host and preserving its @code{DISPLAY} environment
  5159. variable, but without even sharing the current directory:
  5160. @example
  5161. guix shell --container --network --no-cwd ungoogled-chromium \
  5162. --preserve='^DISPLAY$' -- chromium
  5163. @end example
  5164. @vindex GUIX_ENVIRONMENT
  5165. @command{guix shell} defines the @env{GUIX_ENVIRONMENT}
  5166. variable in the shell it spawns; its value is the file name of the
  5167. profile of this environment. This allows users to, say, define a
  5168. specific prompt for development environments in their @file{.bashrc}
  5169. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  5170. @example
  5171. if [ -n "$GUIX_ENVIRONMENT" ]
  5172. then
  5173. export PS1="\u@@\h \w [dev]\$ "
  5174. fi
  5175. @end example
  5176. @noindent
  5177. ...@: or to browse the profile:
  5178. @example
  5179. $ ls "$GUIX_ENVIRONMENT/bin"
  5180. @end example
  5181. The available options are summarized below.
  5182. @table @code
  5183. @item --check
  5184. Set up the environment and check whether the shell would clobber
  5185. environment variables. It's a good idea to use this option the first
  5186. time you run @command{guix shell} for an interactive session to make
  5187. sure your setup is correct.
  5188. For example, if the shell modifies the @env{PATH} environment variable,
  5189. report it since you would get a different environment than what you
  5190. asked for.
  5191. Such problems usually indicate that the shell startup files are
  5192. unexpectedly modifying those environment variables. For example, if you
  5193. are using Bash, make sure that environment variables are set or modified
  5194. in @file{~/.bash_profile} and @emph{not} in @file{~/.bashrc}---the
  5195. former is sourced only by log-in shells. @xref{Bash Startup Files,,,
  5196. bash, The GNU Bash Reference Manual}, for details on Bash start-up
  5197. files.
  5198. @anchor{shell-development-option}
  5199. @item --development
  5200. @itemx -D
  5201. Cause @command{guix shell} to include in the environment the
  5202. dependencies of the following package rather than the package itself.
  5203. This can be combined with other packages. For instance, the command
  5204. below starts an interactive shell containing the build-time dependencies
  5205. of GNU@tie{}Guile, plus Autoconf, Automake, and Libtool:
  5206. @example
  5207. guix shell -D guile autoconf automake libtool
  5208. @end example
  5209. @item --expression=@var{expr}
  5210. @itemx -e @var{expr}
  5211. Create an environment for the package or list of packages that
  5212. @var{expr} evaluates to.
  5213. For example, running:
  5214. @example
  5215. guix shell -D -e '(@@ (gnu packages maths) petsc-openmpi)'
  5216. @end example
  5217. starts a shell with the environment for this specific variant of the
  5218. PETSc package.
  5219. Running:
  5220. @example
  5221. guix shell -e '(@@ (gnu) %base-packages)'
  5222. @end example
  5223. starts a shell with all the base system packages available.
  5224. The above commands only use the default output of the given packages.
  5225. To select other outputs, two element tuples can be specified:
  5226. @example
  5227. guix shell -e '(list (@@ (gnu packages bash) bash) "include")'
  5228. @end example
  5229. @xref{package-development-manifest,
  5230. @code{package->development-manifest}}, for information on how to write a
  5231. manifest for the development environment of a package.
  5232. @item --file=@var{file}
  5233. @itemx -f @var{file}
  5234. Create an environment containing the package or list of packages that
  5235. the code within @var{file} evaluates to.
  5236. As an example, @var{file} might contain a definition like this
  5237. (@pxref{Defining Packages}):
  5238. @lisp
  5239. @verbatiminclude environment-gdb.scm
  5240. @end lisp
  5241. With the file above, you can enter a development environment for GDB by
  5242. running:
  5243. @example
  5244. guix shell -D -f gdb-devel.scm
  5245. @end example
  5246. @anchor{shell-manifest}
  5247. @item --manifest=@var{file}
  5248. @itemx -m @var{file}
  5249. Create an environment for the packages contained in the manifest object
  5250. returned by the Scheme code in @var{file}. This option can be repeated
  5251. several times, in which case the manifests are concatenated.
  5252. This is similar to the same-named option in @command{guix package}
  5253. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  5254. manifest files.
  5255. @xref{Writing Manifests}, for information on how to write a manifest.
  5256. See @option{--export-manifest} below on how to obtain a first manifest.
  5257. @cindex manifest, exporting
  5258. @anchor{shell-export-manifest}
  5259. @item --export-manifest
  5260. Write to standard output a manifest suitable for @option{--manifest}
  5261. corresponding to given command-line options.
  5262. This is a way to ``convert'' command-line arguments into a manifest.
  5263. For example, imagine you are tired of typing long lines and would like
  5264. to get a manifest equivalent to this command line:
  5265. @example
  5266. guix shell -D guile git emacs emacs-geiser emacs-geiser-guile
  5267. @end example
  5268. Just add @option{--export-manifest} to the command line above:
  5269. @example
  5270. guix shell --export-manifest \
  5271. -D guile git emacs emacs-geiser emacs-geiser-guile
  5272. @end example
  5273. @noindent
  5274. ... and you get a manifest along these lines:
  5275. @lisp
  5276. (concatenate-manifests
  5277. (list (specifications->manifest
  5278. (list "git"
  5279. "emacs"
  5280. "emacs-geiser"
  5281. "emacs-geiser-guile"))
  5282. (package->development-manifest
  5283. (specification->package "guile"))))
  5284. @end lisp
  5285. You can store it into a file, say @file{manifest.scm}, and from there
  5286. pass it to @command{guix shell} or indeed pretty much any @command{guix}
  5287. command:
  5288. @example
  5289. guix shell -m manifest.scm
  5290. @end example
  5291. Voilà, you've converted a long command line into a manifest! That
  5292. conversion process honors package transformation options (@pxref{Package
  5293. Transformation Options}) so it should be lossless.
  5294. @item --profile=@var{profile}
  5295. @itemx -p @var{profile}
  5296. Create an environment containing the packages installed in @var{profile}.
  5297. Use @command{guix package} (@pxref{Invoking guix package}) to create
  5298. and manage profiles.
  5299. @item --pure
  5300. Unset existing environment variables when building the new environment, except
  5301. those specified with @option{--preserve} (see below). This has the effect of
  5302. creating an environment in which search paths only contain package inputs.
  5303. @item --preserve=@var{regexp}
  5304. @itemx -E @var{regexp}
  5305. When used alongside @option{--pure}, preserve the environment variables
  5306. matching @var{regexp}---in other words, put them on a ``white list'' of
  5307. environment variables that must be preserved. This option can be repeated
  5308. several times.
  5309. @example
  5310. guix shell --pure --preserve=^SLURM openmpi @dots{} \
  5311. -- mpirun @dots{}
  5312. @end example
  5313. This example runs @command{mpirun} in a context where the only environment
  5314. variables defined are @env{PATH}, environment variables whose name starts
  5315. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  5316. @env{USER}, etc.).
  5317. @item --search-paths
  5318. Display the environment variable definitions that make up the
  5319. environment.
  5320. @item --system=@var{system}
  5321. @itemx -s @var{system}
  5322. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  5323. @item --container
  5324. @itemx -C
  5325. @cindex container
  5326. Run @var{command} within an isolated container. The current working
  5327. directory outside the container is mapped inside the container.
  5328. Additionally, unless overridden with @option{--user}, a dummy home
  5329. directory is created that matches the current user's home directory, and
  5330. @file{/etc/passwd} is configured accordingly.
  5331. The spawned process runs as the current user outside the container. Inside
  5332. the container, it has the same UID and GID as the current user, unless
  5333. @option{--user} is passed (see below).
  5334. @item --network
  5335. @itemx -N
  5336. For containers, share the network namespace with the host system.
  5337. Containers created without this flag only have access to the loopback
  5338. device.
  5339. @item --link-profile
  5340. @itemx -P
  5341. For containers, link the environment profile to @file{~/.guix-profile}
  5342. within the container and set @code{GUIX_ENVIRONMENT} to that.
  5343. This is equivalent to making @file{~/.guix-profile} a symlink to the
  5344. actual profile within the container.
  5345. Linking will fail and abort the environment if the directory already
  5346. exists, which will certainly be the case if @command{guix shell}
  5347. was invoked in the user's home directory.
  5348. Certain packages are configured to look in @file{~/.guix-profile} for
  5349. configuration files and data;@footnote{For example, the
  5350. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  5351. for additional fonts.} @option{--link-profile} allows these programs to
  5352. behave as expected within the environment.
  5353. @item --user=@var{user}
  5354. @itemx -u @var{user}
  5355. For containers, use the username @var{user} in place of the current
  5356. user. The generated @file{/etc/passwd} entry within the container will
  5357. contain the name @var{user}, the home directory will be
  5358. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  5359. the UID and GID inside the container are 1000. @var{user}
  5360. need not exist on the system.
  5361. Additionally, any shared or exposed path (see @option{--share} and
  5362. @option{--expose} respectively) whose target is within the current user's
  5363. home directory will be remapped relative to @file{/home/USER}; this
  5364. includes the automatic mapping of the current working directory.
  5365. @example
  5366. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  5367. cd $HOME/wd
  5368. guix shell --container --user=foo \
  5369. --expose=$HOME/test \
  5370. --expose=/tmp/target=$HOME/target
  5371. @end example
  5372. While this will limit the leaking of user identity through home paths
  5373. and each of the user fields, this is only one useful component of a
  5374. broader privacy/anonymity solution---not one in and of itself.
  5375. @item --no-cwd
  5376. For containers, the default behavior is to share the current working
  5377. directory with the isolated container and immediately change to that
  5378. directory within the container. If this is undesirable,
  5379. @option{--no-cwd} will cause the current working directory to @emph{not}
  5380. be automatically shared and will change to the user's home directory
  5381. within the container instead. See also @option{--user}.
  5382. @item --expose=@var{source}[=@var{target}]
  5383. @itemx --share=@var{source}[=@var{target}]
  5384. For containers, @option{--expose} (resp. @option{--share}) exposes the
  5385. file system @var{source} from the host system as the read-only
  5386. (resp. writable) file system @var{target} within the container. If
  5387. @var{target} is not specified, @var{source} is used as the target mount
  5388. point in the container.
  5389. The example below spawns a Guile REPL in a container in which the user's
  5390. home directory is accessible read-only via the @file{/exchange}
  5391. directory:
  5392. @example
  5393. guix shell --container --expose=$HOME=/exchange guile -- guile
  5394. @end example
  5395. @cindex symbolic links, guix shell
  5396. @item --symlink=@var{spec}
  5397. @itemx -S @var{spec}
  5398. For containers, create the symbolic links specified by @var{spec}, as
  5399. documented in @ref{pack-symlink-option}.
  5400. @cindex file system hierarchy standard (FHS)
  5401. @cindex FHS (file system hierarchy standard)
  5402. @item --emulate-fhs
  5403. @itemx -F
  5404. When used with @option{--container}, emulate a
  5405. @uref{https://refspecs.linuxfoundation.org/fhs.shtml, Filesystem
  5406. Hierarchy Standard (FHS)} configuration within the container, providing
  5407. @file{/bin}, @file{/lib}, and other directories and files specified by
  5408. the FHS.
  5409. As Guix deviates from the FHS specification, this
  5410. option sets up the container to more closely mimic that of other
  5411. GNU/Linux distributions. This is useful for reproducing other
  5412. development environments, testing, and using programs which expect the
  5413. FHS specification to be followed. With this option, the container will
  5414. include a version of glibc that will read
  5415. @file{/etc/ld.so.cache} within the container for the shared library
  5416. cache (contrary to glibc in regular Guix usage) and set up the
  5417. expected FHS directories: @file{/bin}, @file{/etc}, @file{/lib}, and
  5418. @file{/usr} from the container's profile.
  5419. @cindex nested containers, for @command{guix shell}
  5420. @cindex container nesting, for @command{guix shell}
  5421. @item --nesting
  5422. @itemx -W
  5423. When used with @option{--container}, provide Guix @emph{inside} the
  5424. container and arrange so that it can interact with the build daemon that
  5425. runs outside the container. This is useful if you want, within your
  5426. isolated container, to create other containers, as in this sample
  5427. session:
  5428. @example
  5429. $ guix shell -CW coreutils
  5430. [env]$ guix shell -C guile -- guile -c '(display "hello!\n")'
  5431. hello!
  5432. [env]$ exit
  5433. @end example
  5434. The session above starts a container with @code{coreutils} programs
  5435. available in @env{PATH}. From there, we spawn @command{guix shell} to
  5436. create a @emph{nested} container that provides nothing but Guile.
  5437. Another example is evaluating a @file{guix.scm} file that is untrusted,
  5438. as shown here:
  5439. @example
  5440. guix shell -CW -- guix build -f guix.scm
  5441. @end example
  5442. The @command{guix build} command as executed above can only access the
  5443. current directory.
  5444. Under the hood, the @option{-W} option does several things:
  5445. @itemize
  5446. @item
  5447. map the daemon's socket (by default
  5448. @file{/var/guix/daemon-socket/socket}) inside the container;
  5449. @item
  5450. map the whole store (by default @file{/gnu/store}) inside the container
  5451. such that store items made available by nested @command{guix}
  5452. invocations are visible;
  5453. @item
  5454. add the currently-used @command{guix} command to the profile in the
  5455. container, such that @command{guix describe} returns the same state
  5456. inside and outside the container;
  5457. @item
  5458. share the cache (by default @file{~/.cache/guix}) with the host, to
  5459. speed up operations such as @command{guix time-machine} and
  5460. @command{guix shell}.
  5461. @end itemize
  5462. @item --rebuild-cache
  5463. @cindex caching, of profiles
  5464. @cindex caching, in @command{guix shell}
  5465. In most cases, @command{guix shell} caches the environment so that
  5466. subsequent uses are instantaneous. Least-recently used cache entries
  5467. are periodically removed. The cache is also invalidated, when using
  5468. @option{--file} or @option{--manifest}, anytime the corresponding file
  5469. is modified.
  5470. The @option{--rebuild-cache} forces the cached environment to be
  5471. refreshed. This is useful when using @option{--file} or
  5472. @option{--manifest} and the @command{guix.scm} or @command{manifest.scm}
  5473. file has external dependencies, or if its behavior depends, say, on
  5474. environment variables.
  5475. @item --root=@var{file}
  5476. @itemx -r @var{file}
  5477. @cindex persistent environment
  5478. @cindex garbage collector root, for environments
  5479. Make @var{file} a symlink to the profile for this environment, and
  5480. register it as a garbage collector root.
  5481. This is useful if you want to protect your environment from garbage
  5482. collection, to make it ``persistent''.
  5483. When this option is omitted, @command{guix shell} caches profiles so
  5484. that subsequent uses of the same environment are instantaneous---this is
  5485. comparable to using @option{--root} except that @command{guix shell}
  5486. takes care of periodically removing the least-recently used garbage
  5487. collector roots.
  5488. In some cases, @command{guix shell} does not cache profiles---e.g., if
  5489. transformation options such as @option{--with-latest} are used. In
  5490. those cases, the environment is protected from garbage collection only
  5491. for the duration of the @command{guix shell} session. This means that
  5492. next time you recreate the same environment, you could have to rebuild
  5493. or re-download packages.
  5494. @xref{Invoking guix gc}, for more on GC roots.
  5495. @end table
  5496. @command{guix shell} also supports all of the common build options that
  5497. @command{guix build} supports (@pxref{Common Build Options}) as well as
  5498. package transformation options (@pxref{Package Transformation Options}).
  5499. @node Invoking guix environment
  5500. @section Invoking @command{guix environment}
  5501. @cindex @command{guix environment}
  5502. The purpose of @command{guix environment} is to assist in creating
  5503. development environments.
  5504. @quotation Deprecation warning
  5505. The @command{guix environment} command is deprecated in favor of
  5506. @command{guix shell}, which performs similar functions but is more
  5507. convenient to use. @xref{Invoking guix shell}.
  5508. Being deprecated, @command{guix environment} is slated for eventual
  5509. removal, but the Guix project is committed to keeping it until May 1st,
  5510. 2023. Please get in touch with us at @email{guix-devel@@gnu.org} if you
  5511. would like to discuss it.
  5512. @end quotation
  5513. The general syntax is:
  5514. @example
  5515. guix environment @var{options} @var{package}@dots{}
  5516. @end example
  5517. The following example spawns a new shell set up for the development of
  5518. GNU@tie{}Guile:
  5519. @example
  5520. guix environment guile
  5521. @end example
  5522. If the needed dependencies are not built yet, @command{guix environment}
  5523. automatically builds them. The environment of the new shell is an
  5524. augmented version of the environment that @command{guix environment} was
  5525. run in. It contains the necessary search paths for building the given
  5526. package added to the existing environment variables. To create
  5527. a ``pure'' environment, in which the original environment variables have
  5528. been unset, use the @option{--pure} option@footnote{Users sometimes
  5529. wrongfully augment environment variables such as @env{PATH} in their
  5530. @file{~/.bashrc} file. As a consequence, when @command{guix
  5531. environment} launches it, Bash may read @file{~/.bashrc}, thereby
  5532. introducing ``impurities'' in these environment variables. It is an
  5533. error to define such environment variables in @file{.bashrc}; instead,
  5534. they should be defined in @file{.bash_profile}, which is sourced only by
  5535. log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
  5536. Manual}, for details on Bash start-up files.}.
  5537. Exiting from a Guix environment is the same as exiting from the shell,
  5538. and will place the user back in the old environment before @command{guix
  5539. environment} was invoked. The next garbage collection (@pxref{Invoking
  5540. guix gc}) will clean up packages that were installed from within the
  5541. environment and are no longer used outside of it.
  5542. @vindex GUIX_ENVIRONMENT
  5543. @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
  5544. variable in the shell it spawns; its value is the file name of the
  5545. profile of this environment. This allows users to, say, define a
  5546. specific prompt for development environments in their @file{.bashrc}
  5547. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  5548. @example
  5549. if [ -n "$GUIX_ENVIRONMENT" ]
  5550. then
  5551. export PS1="\u@@\h \w [dev]\$ "
  5552. fi
  5553. @end example
  5554. @noindent
  5555. ...@: or to browse the profile:
  5556. @example
  5557. $ ls "$GUIX_ENVIRONMENT/bin"
  5558. @end example
  5559. Additionally, more than one package may be specified, in which case the
  5560. union of the inputs for the given packages are used. For example, the
  5561. command below spawns a shell where all of the dependencies of both Guile
  5562. and Emacs are available:
  5563. @example
  5564. guix environment guile emacs
  5565. @end example
  5566. Sometimes an interactive shell session is not desired. An arbitrary
  5567. command may be invoked by placing the @code{--} token to separate the
  5568. command from the rest of the arguments:
  5569. @example
  5570. guix environment guile -- make -j4
  5571. @end example
  5572. In other situations, it is more convenient to specify the list of
  5573. packages needed in the environment. For example, the following command
  5574. runs @command{python} from an environment containing Python@tie{}3 and
  5575. NumPy:
  5576. @example
  5577. guix environment --ad-hoc python-numpy python -- python3
  5578. @end example
  5579. Furthermore, one might want the dependencies of a package and also some
  5580. additional packages that are not build-time or runtime dependencies, but
  5581. are useful when developing nonetheless. Because of this, the
  5582. @option{--ad-hoc} flag is positional. Packages appearing before
  5583. @option{--ad-hoc} are interpreted as packages whose dependencies will be
  5584. added to the environment. Packages appearing after are interpreted as
  5585. packages that will be added to the environment directly. For example,
  5586. the following command creates a Guix development environment that
  5587. additionally includes Git and strace:
  5588. @example
  5589. guix environment --pure guix --ad-hoc git strace
  5590. @end example
  5591. @cindex container
  5592. Sometimes it is desirable to isolate the environment as much as
  5593. possible, for maximal purity and reproducibility. In particular, when
  5594. using Guix on a host distro that is not Guix System, it is desirable to
  5595. prevent access to @file{/usr/bin} and other system-wide resources from
  5596. the development environment. For example, the following command spawns
  5597. a Guile REPL in a ``container'' where only the store and the current
  5598. working directory are mounted:
  5599. @example
  5600. guix environment --ad-hoc --container guile -- guile
  5601. @end example
  5602. @quotation Note
  5603. The @option{--container} option requires Linux-libre 3.19 or newer.
  5604. @end quotation
  5605. @cindex certificates
  5606. Another typical use case for containers is to run security-sensitive
  5607. applications such as a web browser. To run Eolie, we must expose and
  5608. share some files and directories; we include @code{nss-certs} and expose
  5609. @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
  5610. @env{DISPLAY} environment variable since containerized graphical
  5611. applications won't display without it.
  5612. @example
  5613. guix environment --preserve='^DISPLAY$' --container --network \
  5614. --expose=/etc/machine-id \
  5615. --expose=/etc/ssl/certs/ \
  5616. --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
  5617. --ad-hoc eolie nss-certs dbus -- eolie
  5618. @end example
  5619. The available options are summarized below.
  5620. @table @code
  5621. @item --check
  5622. Set up the environment and check whether the shell would clobber
  5623. environment variables. @xref{Invoking guix shell, @option{--check}},
  5624. for more info.
  5625. @item --root=@var{file}
  5626. @itemx -r @var{file}
  5627. @cindex persistent environment
  5628. @cindex garbage collector root, for environments
  5629. Make @var{file} a symlink to the profile for this environment, and
  5630. register it as a garbage collector root.
  5631. This is useful if you want to protect your environment from garbage
  5632. collection, to make it ``persistent''.
  5633. When this option is omitted, the environment is protected from garbage
  5634. collection only for the duration of the @command{guix environment}
  5635. session. This means that next time you recreate the same environment,
  5636. you could have to rebuild or re-download packages. @xref{Invoking guix
  5637. gc}, for more on GC roots.
  5638. @item --expression=@var{expr}
  5639. @itemx -e @var{expr}
  5640. Create an environment for the package or list of packages that
  5641. @var{expr} evaluates to.
  5642. For example, running:
  5643. @example
  5644. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  5645. @end example
  5646. starts a shell with the environment for this specific variant of the
  5647. PETSc package.
  5648. Running:
  5649. @example
  5650. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  5651. @end example
  5652. starts a shell with all the base system packages available.
  5653. The above commands only use the default output of the given packages.
  5654. To select other outputs, two element tuples can be specified:
  5655. @example
  5656. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  5657. @end example
  5658. @item --load=@var{file}
  5659. @itemx -l @var{file}
  5660. Create an environment for the package or list of packages that the code
  5661. within @var{file} evaluates to.
  5662. As an example, @var{file} might contain a definition like this
  5663. (@pxref{Defining Packages}):
  5664. @lisp
  5665. @verbatiminclude environment-gdb.scm
  5666. @end lisp
  5667. @item --manifest=@var{file}
  5668. @itemx -m @var{file}
  5669. Create an environment for the packages contained in the manifest object
  5670. returned by the Scheme code in @var{file}. This option can be repeated
  5671. several times, in which case the manifests are concatenated.
  5672. This is similar to the same-named option in @command{guix package}
  5673. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  5674. manifest files.
  5675. @xref{shell-export-manifest, @command{guix shell --export-manifest}},
  5676. for information on how to ``convert'' command-line options into a
  5677. manifest.
  5678. @item --ad-hoc
  5679. Include all specified packages in the resulting environment, as if an
  5680. @i{ad hoc} package were defined with them as inputs. This option is
  5681. useful for quickly creating an environment without having to write a
  5682. package expression to contain the desired inputs.
  5683. For instance, the command:
  5684. @example
  5685. guix environment --ad-hoc guile guile-sdl -- guile
  5686. @end example
  5687. runs @command{guile} in an environment where Guile and Guile-SDL are
  5688. available.
  5689. Note that this example implicitly asks for the default output of
  5690. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  5691. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  5692. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  5693. This option may be composed with the default behavior of @command{guix
  5694. environment}. Packages appearing before @option{--ad-hoc} are
  5695. interpreted as packages whose dependencies will be added to the
  5696. environment, the default behavior. Packages appearing after are
  5697. interpreted as packages that will be added to the environment directly.
  5698. @item --profile=@var{profile}
  5699. @itemx -p @var{profile}
  5700. Create an environment containing the packages installed in @var{profile}.
  5701. Use @command{guix package} (@pxref{Invoking guix package}) to create
  5702. and manage profiles.
  5703. @item --pure
  5704. Unset existing environment variables when building the new environment, except
  5705. those specified with @option{--preserve} (see below). This has the effect of
  5706. creating an environment in which search paths only contain package inputs.
  5707. @item --preserve=@var{regexp}
  5708. @itemx -E @var{regexp}
  5709. When used alongside @option{--pure}, preserve the environment variables
  5710. matching @var{regexp}---in other words, put them on a ``white list'' of
  5711. environment variables that must be preserved. This option can be repeated
  5712. several times.
  5713. @example
  5714. guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
  5715. -- mpirun @dots{}
  5716. @end example
  5717. This example runs @command{mpirun} in a context where the only environment
  5718. variables defined are @env{PATH}, environment variables whose name starts
  5719. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  5720. @env{USER}, etc.).
  5721. @item --search-paths
  5722. Display the environment variable definitions that make up the
  5723. environment.
  5724. @item --system=@var{system}
  5725. @itemx -s @var{system}
  5726. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  5727. @item --container
  5728. @itemx -C
  5729. @cindex container
  5730. Run @var{command} within an isolated container. The current working
  5731. directory outside the container is mapped inside the container.
  5732. Additionally, unless overridden with @option{--user}, a dummy home
  5733. directory is created that matches the current user's home directory, and
  5734. @file{/etc/passwd} is configured accordingly.
  5735. The spawned process runs as the current user outside the container. Inside
  5736. the container, it has the same UID and GID as the current user, unless
  5737. @option{--user} is passed (see below).
  5738. @item --network
  5739. @itemx -N
  5740. For containers, share the network namespace with the host system.
  5741. Containers created without this flag only have access to the loopback
  5742. device.
  5743. @item --link-profile
  5744. @itemx -P
  5745. For containers, link the environment profile to @file{~/.guix-profile}
  5746. within the container and set @code{GUIX_ENVIRONMENT} to that.
  5747. This is equivalent to making @file{~/.guix-profile} a symlink to the
  5748. actual profile within the container.
  5749. Linking will fail and abort the environment if the directory already
  5750. exists, which will certainly be the case if @command{guix environment}
  5751. was invoked in the user's home directory.
  5752. Certain packages are configured to look in @file{~/.guix-profile} for
  5753. configuration files and data;@footnote{For example, the
  5754. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  5755. for additional fonts.} @option{--link-profile} allows these programs to
  5756. behave as expected within the environment.
  5757. @item --user=@var{user}
  5758. @itemx -u @var{user}
  5759. For containers, use the username @var{user} in place of the current
  5760. user. The generated @file{/etc/passwd} entry within the container will
  5761. contain the name @var{user}, the home directory will be
  5762. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  5763. the UID and GID inside the container are 1000. @var{user}
  5764. need not exist on the system.
  5765. Additionally, any shared or exposed path (see @option{--share} and
  5766. @option{--expose} respectively) whose target is within the current user's
  5767. home directory will be remapped relative to @file{/home/USER}; this
  5768. includes the automatic mapping of the current working directory.
  5769. @example
  5770. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  5771. cd $HOME/wd
  5772. guix environment --container --user=foo \
  5773. --expose=$HOME/test \
  5774. --expose=/tmp/target=$HOME/target
  5775. @end example
  5776. While this will limit the leaking of user identity through home paths
  5777. and each of the user fields, this is only one useful component of a
  5778. broader privacy/anonymity solution---not one in and of itself.
  5779. @item --no-cwd
  5780. For containers, the default behavior is to share the current working
  5781. directory with the isolated container and immediately change to that
  5782. directory within the container. If this is undesirable,
  5783. @option{--no-cwd} will cause the current working directory to @emph{not}
  5784. be automatically shared and will change to the user's home directory
  5785. within the container instead. See also @option{--user}.
  5786. @item --expose=@var{source}[=@var{target}]
  5787. @itemx --share=@var{source}[=@var{target}]
  5788. For containers, @option{--expose} (resp. @option{--share}) exposes the
  5789. file system @var{source} from the host system as the read-only
  5790. (resp. writable) file system @var{target} within the container. If
  5791. @var{target} is not specified, @var{source} is used as the target mount
  5792. point in the container.
  5793. The example below spawns a Guile REPL in a container in which the user's
  5794. home directory is accessible read-only via the @file{/exchange}
  5795. directory:
  5796. @example
  5797. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  5798. @end example
  5799. @item --emulate-fhs
  5800. @item -F
  5801. For containers, emulate a Filesystem Hierarchy Standard (FHS)
  5802. configuration within the container, see
  5803. @uref{https://refspecs.linuxfoundation.org/fhs.shtml, the official
  5804. specification}. As Guix deviates from the FHS specification, this
  5805. option sets up the container to more closely mimic that of other
  5806. GNU/Linux distributions. This is useful for reproducing other
  5807. development environments, testing, and using programs which expect the
  5808. FHS specification to be followed. With this option, the container will
  5809. include a version of @code{glibc} which will read
  5810. @code{/etc/ld.so.cache} within the container for the shared library
  5811. cache (contrary to @code{glibc} in regular Guix usage) and set up the
  5812. expected FHS directories: @code{/bin}, @code{/etc}, @code{/lib}, and
  5813. @code{/usr} from the container's profile.
  5814. @end table
  5815. @command{guix environment}
  5816. also supports all of the common build options that @command{guix
  5817. build} supports (@pxref{Common Build Options}) as well as package
  5818. transformation options (@pxref{Package Transformation Options}).
  5819. @node Invoking guix pack
  5820. @section Invoking @command{guix pack}
  5821. @cindex @command{guix pack}
  5822. Occasionally you want to pass software to people who are not (yet!)
  5823. lucky enough to be using Guix. You'd tell them to run @command{guix
  5824. package -i @var{something}}, but that's not possible in this case. This
  5825. is where @command{guix pack} comes in.
  5826. @quotation Note
  5827. If you are looking for ways to exchange binaries among machines that
  5828. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  5829. publish}, and @ref{Invoking guix archive}.
  5830. @end quotation
  5831. @cindex pack
  5832. @cindex bundle
  5833. @cindex application bundle
  5834. @cindex software bundle
  5835. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  5836. @dfn{software bundle}: it creates a tarball or some other archive
  5837. containing the binaries of the software you're interested in, and all
  5838. its dependencies. The resulting archive can be used on any machine that
  5839. does not have Guix, and people can run the exact same binaries as those
  5840. you have with Guix. The pack itself is created in a bit-reproducible
  5841. fashion, so anyone can verify that it really contains the build results
  5842. that you pretend to be shipping.
  5843. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  5844. their dependencies, you can run:
  5845. @example
  5846. $ guix pack guile emacs emacs-geiser
  5847. @dots{}
  5848. /gnu/store/@dots{}-pack.tar.gz
  5849. @end example
  5850. The result here is a tarball containing a @file{/gnu/store} directory
  5851. with all the relevant packages. The resulting tarball contains a
  5852. @dfn{profile} with the three packages of interest; the profile is the
  5853. same as would be created by @command{guix package -i}. It is this
  5854. mechanism that is used to create Guix's own standalone binary tarball
  5855. (@pxref{Binary Installation}).
  5856. Users of this pack would have to run
  5857. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  5858. find inconvenient. To work around it, you can create, say, a
  5859. @file{/opt/gnu/bin} symlink to the profile:
  5860. @example
  5861. guix pack -S /opt/gnu/bin=bin guile emacs emacs-geiser
  5862. @end example
  5863. @noindent
  5864. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  5865. @cindex relocatable binaries, with @command{guix pack}
  5866. What if the recipient of your pack does not have root privileges on
  5867. their machine, and thus cannot unpack it in the root file system? In
  5868. that case, you will want to use the @option{--relocatable} option (see
  5869. below). This option produces @dfn{relocatable binaries}, meaning they
  5870. they can be placed anywhere in the file system hierarchy: in the example
  5871. above, users can unpack your tarball in their home directory and
  5872. directly run @file{./opt/gnu/bin/guile}.
  5873. @cindex Docker, build an image with guix pack
  5874. Alternatively, you can produce a pack in the Docker image format using
  5875. the following command:
  5876. @example
  5877. guix pack -f docker -S /bin=bin guile guile-readline
  5878. @end example
  5879. @noindent
  5880. The result is a tarball that can be passed to the @command{docker load}
  5881. command, followed by @code{docker run}:
  5882. @example
  5883. docker load < @var{file}
  5884. docker run -ti guile-guile-readline /bin/guile
  5885. @end example
  5886. @noindent
  5887. where @var{file} is the image returned by @command{guix pack}, and
  5888. @code{guile-guile-readline} is its ``image tag''. See the
  5889. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  5890. documentation} for more information.
  5891. @cindex Singularity, build an image with guix pack
  5892. @cindex SquashFS, build an image with guix pack
  5893. Yet another option is to produce a SquashFS image with the following
  5894. command:
  5895. @example
  5896. guix pack -f squashfs bash guile emacs emacs-geiser
  5897. @end example
  5898. @noindent
  5899. The result is a SquashFS file system image that can either be mounted or
  5900. directly be used as a file system container image with the
  5901. @uref{https://www.sylabs.io/docs/, Singularity container execution
  5902. environment}, using commands like @command{singularity shell} or
  5903. @command{singularity exec}.
  5904. Several command-line options allow you to customize your pack:
  5905. @table @code
  5906. @item --format=@var{format}
  5907. @itemx -f @var{format}
  5908. Produce a pack in the given @var{format}.
  5909. The available formats are:
  5910. @table @code
  5911. @item tarball
  5912. This is the default format. It produces a tarball containing all the
  5913. specified binaries and symlinks.
  5914. @item docker
  5915. This produces a tarball that follows the
  5916. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  5917. Docker Image Specification}. The ``repository name'' as it appears in
  5918. the output of the @command{docker images} command is computed from
  5919. package names passed on the command line or in the manifest file.
  5920. @item squashfs
  5921. This produces a SquashFS image containing all the specified binaries and
  5922. symlinks, as well as empty mount points for virtual file systems like
  5923. procfs.
  5924. @quotation Note
  5925. Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
  5926. For that reason, @command{guix pack -f squashfs} always implies @code{-S
  5927. /bin=bin}. Thus, your @command{guix pack} invocation must always start
  5928. with something like:
  5929. @example
  5930. guix pack -f squashfs bash @dots{}
  5931. @end example
  5932. If you forget the @code{bash} (or similar) package, @command{singularity
  5933. run} and @command{singularity exec} will fail with an unhelpful ``no
  5934. such file or directory'' message.
  5935. @end quotation
  5936. @item deb
  5937. @cindex Debian, build a .deb package with guix pack
  5938. This produces a Debian archive (a package with the @samp{.deb} file
  5939. extension) containing all the specified binaries and symbolic links,
  5940. that can be installed on top of any dpkg-based GNU(/Linux) distribution.
  5941. Advanced options can be revealed via the @option{--help-deb-format}
  5942. option. They allow embedding control files for more fine-grained
  5943. control, such as activating specific triggers or providing a maintainer
  5944. configure script to run arbitrary setup code upon installation.
  5945. @example
  5946. guix pack -f deb -C xz -S /usr/bin/hello=bin/hello hello
  5947. @end example
  5948. @quotation Note
  5949. Because archives produced with @command{guix pack} contain a collection
  5950. of store items and because each @command{dpkg} package must not have
  5951. conflicting files, in practice that means you likely won't be able to
  5952. install more than one such archive on a given system. You can
  5953. nonetheless pack as many Guix packages as you want in one such archive.
  5954. @end quotation
  5955. @quotation Warning
  5956. @command{dpkg} will assume ownership of any files contained in the pack
  5957. that it does @emph{not} know about. It is unwise to install
  5958. Guix-produced @samp{.deb} files on a system where @file{/gnu/store} is
  5959. shared by other software, such as a Guix installation or other, non-deb
  5960. packs.
  5961. @end quotation
  5962. @item rpm
  5963. @cindex RPM, build an RPM archive with guix pack
  5964. This produces an RPM archive (a package with the @samp{.rpm} file
  5965. extension) containing all the specified binaries and symbolic links,
  5966. that can be installed on top of any RPM-based GNU/Linux distribution.
  5967. The RPM format embeds checksums for every file it contains, which the
  5968. @command{rpm} command uses to validate the integrity of the archive.
  5969. Advanced RPM-related options are revealed via the
  5970. @option{--help-rpm-format} option. These options allow embedding
  5971. maintainer scripts that can run before or after the installation of the
  5972. RPM archive, for example.
  5973. The RPM format supports relocatable packages via the @option{--prefix}
  5974. option of the @command{rpm} command, which can be handy to install an
  5975. RPM package to a specific prefix.
  5976. @example
  5977. guix pack -f rpm -R -C xz -S /usr/bin/hello=bin/hello hello
  5978. @end example
  5979. @example
  5980. sudo rpm --install --prefix=/opt /gnu/store/...-hello.rpm
  5981. @end example
  5982. @quotation Note
  5983. Contrary to Debian packages, conflicting but @emph{identical} files in
  5984. RPM packages can be installed simultaneously, which means multiple
  5985. @command{guix pack}-produced RPM packages can usually be installed side
  5986. by side without any problem.
  5987. @end quotation
  5988. @quotation Warning
  5989. @command{rpm} assumes ownership of any files contained in the pack,
  5990. which means it will remove @file{/gnu/store} upon uninstalling a
  5991. Guix-generated RPM package, unless the RPM package was installed with
  5992. the @option{--prefix} option of the @command{rpm} command. It is unwise
  5993. to install Guix-produced @samp{.rpm} packages on a system where
  5994. @file{/gnu/store} is shared by other software, such as a Guix
  5995. installation or other, non-rpm packs.
  5996. @end quotation
  5997. @end table
  5998. @cindex relocatable binaries
  5999. @item --relocatable
  6000. @itemx -R
  6001. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  6002. anywhere in the file system hierarchy and run from there.
  6003. When this option is passed once, the resulting binaries require support for
  6004. @dfn{user namespaces} in the kernel Linux; when passed
  6005. @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
  6006. PRoot support, can be thought of as the abbreviation of ``Really
  6007. Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
  6008. other techniques if user namespaces are unavailable, and essentially
  6009. work anywhere---see below for the implications.
  6010. For example, if you create a pack containing Bash with:
  6011. @example
  6012. guix pack -RR -S /mybin=bin bash
  6013. @end example
  6014. @noindent
  6015. ...@: you can copy that pack to a machine that lacks Guix, and from your
  6016. home directory as a normal user, run:
  6017. @example
  6018. tar xf pack.tar.gz
  6019. ./mybin/sh
  6020. @end example
  6021. @noindent
  6022. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  6023. @file{/gnu/store} shows up and contains all the dependencies of
  6024. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  6025. altogether! That is probably the simplest way to deploy Guix-built
  6026. software on a non-Guix machine.
  6027. @quotation Note
  6028. By default, relocatable binaries rely on the @dfn{user namespace} feature of
  6029. the kernel Linux, which allows unprivileged users to mount or change root.
  6030. Old versions of Linux did not support it, and some GNU/Linux distributions
  6031. turn it off.
  6032. To produce relocatable binaries that work even in the absence of user
  6033. namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
  6034. case, binaries will try user namespace support and fall back to another
  6035. @dfn{execution engine} if user namespaces are not supported. The
  6036. following execution engines are supported:
  6037. @table @code
  6038. @item default
  6039. Try user namespaces and fall back to PRoot if user namespaces are not
  6040. supported (see below).
  6041. @item performance
  6042. Try user namespaces and fall back to Fakechroot if user namespaces are
  6043. not supported (see below).
  6044. @item userns
  6045. Run the program through user namespaces and abort if they are not
  6046. supported.
  6047. @item proot
  6048. Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
  6049. provides the necessary
  6050. support for file system virtualization. It achieves that by using the
  6051. @code{ptrace} system call on the running program. This approach has the
  6052. advantage to work without requiring special kernel support, but it incurs
  6053. run-time overhead every time a system call is made.
  6054. @item fakechroot
  6055. Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
  6056. Fakechroot} virtualizes file system accesses by intercepting calls to C
  6057. library functions such as @code{open}, @code{stat}, @code{exec}, and so
  6058. on. Unlike PRoot, it incurs very little overhead. However, it does not
  6059. always work: for example, some file system accesses made from within the
  6060. C library are not intercepted, and file system accesses made @i{via}
  6061. direct syscalls are not intercepted either, leading to erratic behavior.
  6062. @end table
  6063. @vindex GUIX_EXECUTION_ENGINE
  6064. When running a wrapped program, you can explicitly request one of the
  6065. execution engines listed above by setting the
  6066. @env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
  6067. @end quotation
  6068. @cindex entry point, for Docker images
  6069. @item --entry-point=@var{command}
  6070. Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
  6071. format supports it---currently @code{docker} and @code{squashfs} (Singularity)
  6072. support it. @var{command} must be relative to the profile contained in the
  6073. pack.
  6074. The entry point specifies the command that tools like @code{docker run} or
  6075. @code{singularity run} automatically start by default. For example, you can
  6076. do:
  6077. @example
  6078. guix pack -f docker --entry-point=bin/guile guile
  6079. @end example
  6080. The resulting pack can easily be loaded and @code{docker run} with no extra
  6081. arguments will spawn @code{bin/guile}:
  6082. @example
  6083. docker load -i pack.tar.gz
  6084. docker run @var{image-id}
  6085. @end example
  6086. @item --expression=@var{expr}
  6087. @itemx -e @var{expr}
  6088. Consider the package @var{expr} evaluates to.
  6089. This has the same purpose as the same-named option in @command{guix
  6090. build} (@pxref{Additional Build Options, @option{--expression} in
  6091. @command{guix build}}).
  6092. @anchor{pack-manifest}
  6093. @item --manifest=@var{file}
  6094. @itemx -m @var{file}
  6095. Use the packages contained in the manifest object returned by the Scheme
  6096. code in @var{file}. This option can be repeated several times, in which
  6097. case the manifests are concatenated.
  6098. This has a similar purpose as the same-named option in @command{guix
  6099. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  6100. same manifest files. It allows you to define a collection of packages
  6101. once and use it both for creating profiles and for creating archives
  6102. for use on machines that do not have Guix installed. Note that you can
  6103. specify @emph{either} a manifest file @emph{or} a list of packages,
  6104. but not both.
  6105. @xref{Writing Manifests}, for information on how to write a manifest.
  6106. @xref{shell-export-manifest, @command{guix shell --export-manifest}},
  6107. for information on how to ``convert'' command-line options into a
  6108. manifest.
  6109. @item --system=@var{system}
  6110. @itemx -s @var{system}
  6111. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  6112. the system type of the build host.
  6113. @item --target=@var{triplet}
  6114. @cindex cross-compilation
  6115. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  6116. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  6117. configuration triplets,, autoconf, Autoconf}).
  6118. @item --compression=@var{tool}
  6119. @itemx -C @var{tool}
  6120. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  6121. @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
  6122. compression.
  6123. @anchor{pack-symlink-option}
  6124. @item --symlink=@var{spec}
  6125. @itemx -S @var{spec}
  6126. Add the symlinks specified by @var{spec} to the pack. This option can
  6127. appear several times.
  6128. @var{spec} has the form @code{@var{source}=@var{target}}, where
  6129. @var{source} is the symlink that will be created and @var{target} is the
  6130. symlink target.
  6131. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  6132. symlink pointing to the @file{bin} sub-directory of the profile.
  6133. @item --save-provenance
  6134. Save provenance information for the packages passed on the command line.
  6135. Provenance information includes the URL and commit of the channels in use
  6136. (@pxref{Channels}).
  6137. Provenance information is saved in the
  6138. @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
  6139. usual package metadata---the name and version of each package, their
  6140. propagated inputs, and so on. It is useful information to the recipient of
  6141. the pack, who then knows how the pack was (supposedly) obtained.
  6142. This option is not enabled by default because, like timestamps, provenance
  6143. information contributes nothing to the build process. In other words, there
  6144. is an infinity of channel URLs and commit IDs that can lead to the same pack.
  6145. Recording such ``silent'' metadata in the output thus potentially breaks the
  6146. source-to-binary bitwise reproducibility property.
  6147. @item --root=@var{file}
  6148. @itemx -r @var{file}
  6149. @cindex garbage collector root, for packs
  6150. Make @var{file} a symlink to the resulting pack, and register it as a garbage
  6151. collector root.
  6152. @item --localstatedir
  6153. @itemx --profile-name=@var{name}
  6154. Include the ``local state directory'', @file{/var/guix}, in the resulting
  6155. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  6156. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  6157. @file{~root/.guix-profile}.
  6158. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  6159. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  6160. the pack means that the store is ``complete'' and manageable by Guix;
  6161. not providing it pack means that the store is ``dead'': items cannot be
  6162. added to it or removed from it after extraction of the pack.
  6163. One use case for this is the Guix self-contained binary tarball
  6164. (@pxref{Binary Installation}).
  6165. @item --derivation
  6166. @itemx -d
  6167. Print the name of the derivation that builds the pack.
  6168. @item --bootstrap
  6169. Use the bootstrap binaries to build the pack. This option is only
  6170. useful to Guix developers.
  6171. @end table
  6172. In addition, @command{guix pack} supports all the common build options
  6173. (@pxref{Common Build Options}) and all the package transformation
  6174. options (@pxref{Package Transformation Options}).
  6175. @node The GCC toolchain
  6176. @section The GCC toolchain
  6177. @cindex GCC
  6178. @cindex ld-wrapper
  6179. @cindex linker wrapper
  6180. @cindex toolchain, for C development
  6181. @cindex toolchain, for Fortran development
  6182. If you need a complete toolchain for compiling and linking C or C++
  6183. source code, use the @code{gcc-toolchain} package. This package
  6184. provides a complete GCC toolchain for C/C++ development, including GCC
  6185. itself, the GNU C Library (headers and binaries, plus debugging symbols
  6186. in the @code{debug} output), Binutils, and a linker wrapper.
  6187. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  6188. passed to the linker, add corresponding @code{-rpath} arguments, and
  6189. invoke the actual linker with this new set of arguments. You can instruct the
  6190. wrapper to refuse to link against libraries not in the store by setting the
  6191. @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
  6192. The package @code{gfortran-toolchain} provides a complete GCC toolchain
  6193. for Fortran development. For other languages, please use
  6194. @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
  6195. @node Invoking guix git authenticate
  6196. @section Invoking @command{guix git authenticate}
  6197. @cindex @command{guix git authenticate}
  6198. The @command{guix git authenticate} command authenticates a Git checkout
  6199. following the same rule as for channels (@pxref{channel-authentication,
  6200. channel authentication}). That is, starting from a given commit, it
  6201. ensures that all subsequent commits are signed by an OpenPGP key whose
  6202. fingerprint appears in the @file{.guix-authorizations} file of its
  6203. parent commit(s).
  6204. You will find this command useful if you maintain a channel. But in
  6205. fact, this authentication mechanism is useful in a broader context, so
  6206. you might want to use it for Git repositories that have nothing to do
  6207. with Guix.
  6208. The general syntax is:
  6209. @example
  6210. guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
  6211. @end example
  6212. By default, this command authenticates the Git checkout in the current
  6213. directory; it outputs nothing and exits with exit code zero on success
  6214. and non-zero on failure. @var{commit} above denotes the first commit
  6215. where authentication takes place, and @var{signer} is the OpenPGP
  6216. fingerprint of public key used to sign @var{commit}. Together, they
  6217. form a ``channel introduction'' (@pxref{channel-authentication, channel
  6218. introduction}). The options below allow you to fine-tune the process.
  6219. @table @code
  6220. @item --repository=@var{directory}
  6221. @itemx -r @var{directory}
  6222. Open the Git repository in @var{directory} instead of the current
  6223. directory.
  6224. @item --keyring=@var{reference}
  6225. @itemx -k @var{reference}
  6226. Load OpenPGP keyring from @var{reference}, the reference of a branch
  6227. such as @code{origin/keyring} or @code{my-keyring}. The branch must
  6228. contain OpenPGP public keys in @file{.key} files, either in binary form
  6229. or ``ASCII-armored''. By default the keyring is loaded from the branch
  6230. named @code{keyring}.
  6231. @item --stats
  6232. Display commit signing statistics upon completion.
  6233. @item --cache-key=@var{key}
  6234. Previously-authenticated commits are cached in a file under
  6235. @file{~/.cache/guix/authentication}. This option forces the cache to be
  6236. stored in file @var{key} in that directory.
  6237. @item --historical-authorizations=@var{file}
  6238. By default, any commit whose parent commit(s) lack the
  6239. @file{.guix-authorizations} file is considered inauthentic. In
  6240. contrast, this option considers the authorizations in @var{file} for any
  6241. commit that lacks @file{.guix-authorizations}. The format of @var{file}
  6242. is the same as that of @file{.guix-authorizations}
  6243. (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
  6244. @end table
  6245. @c *********************************************************************
  6246. @node Programming Interface
  6247. @chapter Programming Interface
  6248. GNU Guix provides several Scheme programming interfaces (APIs) to
  6249. define, build, and query packages. The first interface allows users to
  6250. write high-level package definitions. These definitions refer to
  6251. familiar packaging concepts, such as the name and version of a package,
  6252. its build system, and its dependencies. These definitions can then be
  6253. turned into concrete build actions.
  6254. Build actions are performed by the Guix daemon, on behalf of users. In a
  6255. standard setup, the daemon has write access to the store---the
  6256. @file{/gnu/store} directory---whereas users do not. The recommended
  6257. setup also has the daemon perform builds in chroots, under specific
  6258. build users, to minimize interference with the rest of the system.
  6259. @cindex derivation
  6260. Lower-level APIs are available to interact with the daemon and the
  6261. store. To instruct the daemon to perform a build action, users actually
  6262. provide it with a @dfn{derivation}. A derivation is a low-level
  6263. representation of the build actions to be taken, and the environment in
  6264. which they should occur---derivations are to package definitions what
  6265. assembly is to C programs. The term ``derivation'' comes from the fact
  6266. that build results @emph{derive} from them.
  6267. This chapter describes all these APIs in turn, starting from high-level
  6268. package definitions.
  6269. @menu
  6270. * Package Modules:: Packages from the programmer's viewpoint.
  6271. * Defining Packages:: Defining new packages.
  6272. * Defining Package Variants:: Customizing packages.
  6273. * Writing Manifests:: The bill of materials of your environment.
  6274. * Build Systems:: Specifying how packages are built.
  6275. * Build Phases:: Phases of the build process of a package.
  6276. * Build Utilities:: Helpers for your package definitions and more.
  6277. * Search Paths:: Declaring search path environment variables.
  6278. * The Store:: Manipulating the package store.
  6279. * Derivations:: Low-level interface to package derivations.
  6280. * The Store Monad:: Purely functional interface to the store.
  6281. * G-Expressions:: Manipulating build expressions.
  6282. * Invoking guix repl:: Programming Guix in Guile
  6283. * Using Guix Interactively:: Fine-grain interaction at the REPL.
  6284. @end menu
  6285. @node Package Modules
  6286. @section Package Modules
  6287. From a programming viewpoint, the package definitions of the
  6288. GNU distribution are provided by Guile modules in the @code{(gnu packages
  6289. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  6290. packages @dots{})} module name space are not necessarily ``GNU
  6291. packages''. This module naming scheme follows the usual Guile module
  6292. naming convention: @code{gnu} means that these modules are distributed
  6293. as part of the GNU system, and @code{packages} identifies modules that
  6294. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  6295. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  6296. module exports a variable named @code{emacs}, which is bound to a
  6297. @code{<package>} object (@pxref{Defining Packages}).
  6298. The @code{(gnu packages @dots{})} module name space is
  6299. automatically scanned for packages by the command-line tools. For
  6300. instance, when running @code{guix install emacs}, all the @code{(gnu
  6301. packages @dots{})} modules are scanned until one that exports a package
  6302. object whose name is @code{emacs} is found. This package search
  6303. facility is implemented in the @code{(gnu packages)} module.
  6304. @cindex customization, of packages
  6305. @cindex package module search path
  6306. Users can store package definitions in modules with different
  6307. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  6308. name and module name must match. For instance, the @code{(my-packages
  6309. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  6310. relative to the load path specified with @option{--load-path} or
  6311. @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  6312. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  6313. these package definitions visible to the user interfaces:
  6314. @enumerate
  6315. @item
  6316. By adding the directory containing your package modules to the search path
  6317. with the @code{-L} flag of @command{guix package} and other commands
  6318. (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
  6319. environment variable described below.
  6320. @item
  6321. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  6322. pulls from it. A channel is essentially a Git repository containing package
  6323. modules. @xref{Channels}, for more information on how to define and use
  6324. channels.
  6325. @end enumerate
  6326. @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  6327. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  6328. This is a colon-separated list of directories to search for additional
  6329. package modules. Directories listed in this variable take precedence
  6330. over the own modules of the distribution.
  6331. @end defvr
  6332. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  6333. each package is built based solely on other packages in the
  6334. distribution. The root of this dependency graph is a small set of
  6335. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  6336. bootstrap)} module. For more information on bootstrapping,
  6337. @pxref{Bootstrapping}.
  6338. @node Defining Packages
  6339. @section Defining Packages
  6340. The high-level interface to package definitions is implemented in the
  6341. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  6342. example, the package definition, or @dfn{recipe}, for the GNU Hello
  6343. package looks like this:
  6344. @lisp
  6345. (define-module (gnu packages hello)
  6346. #:use-module (guix packages)
  6347. #:use-module (guix download)
  6348. #:use-module (guix build-system gnu)
  6349. #:use-module (guix licenses)
  6350. #:use-module (gnu packages gawk))
  6351. (define-public hello
  6352. (package
  6353. (name "hello")
  6354. (version "2.10")
  6355. (source (origin
  6356. (method url-fetch)
  6357. (uri (string-append "mirror://gnu/hello/hello-" version
  6358. ".tar.gz"))
  6359. (sha256
  6360. (base32
  6361. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  6362. (build-system gnu-build-system)
  6363. (arguments '(#:configure-flags '("--enable-silent-rules")))
  6364. (inputs (list gawk))
  6365. (synopsis "Hello, GNU world: An example GNU package")
  6366. (description "Guess what GNU Hello prints!")
  6367. (home-page "https://www.gnu.org/software/hello/")
  6368. (license gpl3+)))
  6369. @end lisp
  6370. @noindent
  6371. Without being a Scheme expert, the reader may have guessed the meaning
  6372. of the various fields here. This expression binds the variable
  6373. @code{hello} to a @code{<package>} object, which is essentially a record
  6374. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  6375. This package object can be inspected using procedures found in the
  6376. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  6377. returns---surprise!---@code{"hello"}.
  6378. With luck, you may be able to import part or all of the definition of
  6379. the package you are interested in from another repository, using the
  6380. @code{guix import} command (@pxref{Invoking guix import}).
  6381. In the example above, @code{hello} is defined in a module of its own,
  6382. @code{(gnu packages hello)}. Technically, this is not strictly
  6383. necessary, but it is convenient to do so: all the packages defined in
  6384. modules under @code{(gnu packages @dots{})} are automatically known to
  6385. the command-line tools (@pxref{Package Modules}).
  6386. There are a few points worth noting in the above package definition:
  6387. @itemize
  6388. @item
  6389. The @code{source} field of the package is an @code{<origin>} object
  6390. (@pxref{origin Reference}, for the complete reference).
  6391. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  6392. meaning that the source is a file to be downloaded over FTP or HTTP.
  6393. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  6394. the GNU mirrors defined in @code{(guix download)}.
  6395. The @code{sha256} field specifies the expected SHA256 hash of the file
  6396. being downloaded. It is mandatory, and allows Guix to check the
  6397. integrity of the file. The @code{(base32 @dots{})} form introduces the
  6398. base32 representation of the hash. You can obtain this information with
  6399. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  6400. hash} (@pxref{Invoking guix hash}).
  6401. @cindex patches
  6402. When needed, the @code{origin} form can also have a @code{patches} field
  6403. listing patches to be applied, and a @code{snippet} field giving a
  6404. Scheme expression to modify the source code.
  6405. @item
  6406. @cindex GNU Build System
  6407. The @code{build-system} field specifies the procedure to build the
  6408. package (@pxref{Build Systems}). Here, @code{gnu-build-system}
  6409. represents the familiar GNU Build System, where packages may be
  6410. configured, built, and installed with the usual @code{./configure &&
  6411. make && make check && make install} command sequence.
  6412. When you start packaging non-trivial software, you may need tools to
  6413. manipulate those build phases, manipulate files, and so on. @xref{Build
  6414. Utilities}, for more on this.
  6415. @item
  6416. The @code{arguments} field specifies options for the build system
  6417. (@pxref{Build Systems}). Here it is interpreted by
  6418. @code{gnu-build-system} as a request run @file{configure} with the
  6419. @option{--enable-silent-rules} flag.
  6420. @cindex quote
  6421. @cindex quoting
  6422. @findex '
  6423. @findex quote
  6424. @cindex backquote (quasiquote)
  6425. @findex `
  6426. @findex quasiquote
  6427. @cindex comma (unquote)
  6428. @findex ,
  6429. @findex unquote
  6430. What about these quote (@code{'}) characters? They are Scheme syntax to
  6431. introduce a literal list; @code{'} is synonymous with @code{quote}.
  6432. Sometimes you'll also see @code{`} (a backquote, synonymous with
  6433. @code{quasiquote}) and @code{,} (a comma, synonymous with @code{unquote}).
  6434. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  6435. for details. Here the value of the @code{arguments} field is a list of
  6436. arguments passed to the build system down the road, as with @code{apply}
  6437. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  6438. Manual}).
  6439. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  6440. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  6441. @code{#:configure-flags} is a keyword used to pass a keyword argument
  6442. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  6443. Reference Manual}).
  6444. @item
  6445. The @code{inputs} field specifies inputs to the build process---i.e.,
  6446. build-time or run-time dependencies of the package. Here, we add
  6447. an input, a reference to the @code{gawk}
  6448. variable; @code{gawk} is itself bound to a @code{<package>} object.
  6449. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  6450. be specified as inputs here. Instead, @code{gnu-build-system} takes care
  6451. of ensuring that they are present (@pxref{Build Systems}).
  6452. However, any other dependencies need to be specified in the
  6453. @code{inputs} field. Any dependency not specified here will simply be
  6454. unavailable to the build process, possibly leading to a build failure.
  6455. @end itemize
  6456. @xref{package Reference}, for a full description of possible fields.
  6457. @quotation Going further
  6458. @cindex Scheme programming language, getting started
  6459. Intimidated by the Scheme language or curious about it? The Cookbook
  6460. has a short section to get started that recaps some of the things shown
  6461. above and explains the fundamentals. @xref{A Scheme Crash Course,,,
  6462. guix-cookbook, GNU Guix Cookbook}, for more information.
  6463. @end quotation
  6464. Once a package definition is in place, the
  6465. package may actually be built using the @code{guix build} command-line
  6466. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  6467. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  6468. package definition using the @command{guix edit} command
  6469. (@pxref{Invoking guix edit}).
  6470. @xref{Packaging Guidelines}, for
  6471. more information on how to test package definitions, and
  6472. @ref{Invoking guix lint}, for information on how to check a definition
  6473. for style conformance.
  6474. @vindex GUIX_PACKAGE_PATH
  6475. Lastly, @pxref{Channels}, for information
  6476. on how to extend the distribution by adding your own package definitions
  6477. in a ``channel''.
  6478. Finally, updating the package definition to a new upstream version
  6479. can be partly automated by the @command{guix refresh} command
  6480. (@pxref{Invoking guix refresh}).
  6481. Behind the scenes, a derivation corresponding to the @code{<package>}
  6482. object is first computed by the @code{package-derivation} procedure.
  6483. That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
  6484. The build actions it prescribes may then be realized by using the
  6485. @code{build-derivations} procedure (@pxref{The Store}).
  6486. @deffn {Procedure} package-derivation store package [system]
  6487. Return the @code{<derivation>} object of @var{package} for @var{system}
  6488. (@pxref{Derivations}).
  6489. @var{package} must be a valid @code{<package>} object, and @var{system}
  6490. must be a string denoting the target system type---e.g.,
  6491. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  6492. must be a connection to the daemon, which operates on the store
  6493. (@pxref{The Store}).
  6494. @end deffn
  6495. @noindent
  6496. @cindex cross-compilation
  6497. Similarly, it is possible to compute a derivation that cross-builds a
  6498. package for some other system:
  6499. @deffn {Procedure} package-cross-derivation store package target [system]
  6500. Return the @code{<derivation>} object of @var{package} cross-built from
  6501. @var{system} to @var{target}.
  6502. @var{target} must be a valid GNU triplet denoting the target hardware
  6503. and operating system, such as @code{"aarch64-linux-gnu"}
  6504. (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
  6505. @end deffn
  6506. Once you have package definitions, you can easily define @emph{variants}
  6507. of those packages. @xref{Defining Package Variants}, for more on that.
  6508. @menu
  6509. * package Reference:: The package data type.
  6510. * origin Reference:: The origin data type.
  6511. @end menu
  6512. @node package Reference
  6513. @subsection @code{package} Reference
  6514. This section summarizes all the options available in @code{package}
  6515. declarations (@pxref{Defining Packages}).
  6516. @deftp {Data Type} package
  6517. This is the data type representing a package recipe.
  6518. @table @asis
  6519. @item @code{name}
  6520. The name of the package, as a string.
  6521. @item @code{version}
  6522. The version of the package, as a string. @xref{Version Numbers}, for
  6523. guidelines.
  6524. @item @code{source}
  6525. An object telling how the source code for the package should be
  6526. acquired. Most of the time, this is an @code{origin} object, which
  6527. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  6528. can also be any other ``file-like'' object such as a @code{local-file},
  6529. which denotes a file from the local file system (@pxref{G-Expressions,
  6530. @code{local-file}}).
  6531. @item @code{build-system}
  6532. The build system that should be used to build the package (@pxref{Build
  6533. Systems}).
  6534. @item @code{arguments} (default: @code{'()})
  6535. The arguments that should be passed to the build system (@pxref{Build
  6536. Systems}). This is a list, typically containing sequential
  6537. keyword-value pairs, as in this example:
  6538. @lisp
  6539. (package
  6540. (name "example")
  6541. ;; several fields omitted
  6542. (arguments
  6543. (list #:tests? #f ;skip tests
  6544. #:make-flags #~'("VERBOSE=1") ;pass flags to 'make'
  6545. #:configure-flags #~'("--enable-frobbing"))))
  6546. @end lisp
  6547. The exact set of supported keywords depends on the build system
  6548. (@pxref{Build Systems}), but you will find that almost all of them honor
  6549. @code{#:configure-flags}, @code{#:make-flags}, @code{#:tests?}, and
  6550. @code{#:phases}. The @code{#:phases} keyword in particular lets you
  6551. modify the set of build phases for your package (@pxref{Build Phases}).
  6552. @quotation Compatibility Note
  6553. Until version 1.3.0, the @code{arguments} field would typically use
  6554. @code{quote} (@code{'}) or @code{quasiquote} (@code{`}) and no
  6555. G-expressions, like so:
  6556. @lisp
  6557. (package
  6558. ;; several fields omitted
  6559. (arguments ;old-style quoted arguments
  6560. '(#:tests? #f
  6561. #:configure-flags '("--enable-frobbing"))))
  6562. @end lisp
  6563. To convert from that style to the one shown above, you can run
  6564. @code{guix style -S arguments @var{package}} (@pxref{Invoking guix
  6565. style}).
  6566. @end quotation
  6567. @item @code{inputs} (default: @code{'()})
  6568. @itemx @code{native-inputs} (default: @code{'()})
  6569. @itemx @code{propagated-inputs} (default: @code{'()})
  6570. @cindex inputs, of packages
  6571. These fields list dependencies of the package. Each element of these
  6572. lists is either a package, origin, or other ``file-like object''
  6573. (@pxref{G-Expressions}); to specify the output of that file-like object
  6574. that should be used, pass a two-element list where the second element is
  6575. the output (@pxref{Packages with Multiple Outputs}, for more on package
  6576. outputs). For example, the list below specifies three inputs:
  6577. @lisp
  6578. (list libffi libunistring
  6579. `(,glib "bin")) ;the "bin" output of GLib
  6580. @end lisp
  6581. In the example above, the @code{"out"} output of @code{libffi} and
  6582. @code{libunistring} is used.
  6583. @quotation Compatibility Note
  6584. Until version 1.3.0, input lists were a list of tuples,
  6585. where each tuple has a label for the input (a string) as its
  6586. first element, a package, origin, or derivation as its second element,
  6587. and optionally the name of the output thereof that should be used, which
  6588. defaults to @code{"out"}. For example, the list below is equivalent to
  6589. the one above, but using the @dfn{old input style}:
  6590. @lisp
  6591. ;; Old input style (deprecated).
  6592. `(("libffi" ,libffi)
  6593. ("libunistring" ,libunistring)
  6594. ("glib:bin" ,glib "bin")) ;the "bin" output of GLib
  6595. @end lisp
  6596. This style is now deprecated; it is still supported but support will be
  6597. removed in a future version. It should not be used for new package
  6598. definitions. @xref{Invoking guix style}, on how to migrate to the new
  6599. style.
  6600. @end quotation
  6601. @cindex cross compilation, package dependencies
  6602. The distinction between @code{native-inputs} and @code{inputs} is
  6603. necessary when considering cross-compilation. When cross-compiling,
  6604. dependencies listed in @code{inputs} are built for the @emph{target}
  6605. architecture; conversely, dependencies listed in @code{native-inputs}
  6606. are built for the architecture of the @emph{build} machine.
  6607. @code{native-inputs} is typically used to list tools needed at
  6608. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  6609. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  6610. this area (@pxref{Invoking guix lint}).
  6611. @anchor{package-propagated-inputs}
  6612. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  6613. specified packages will be automatically installed to profiles
  6614. (@pxref{Features, the role of profiles in Guix}) alongside the package
  6615. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  6616. package}}, for information on how @command{guix package} deals with
  6617. propagated inputs).
  6618. For example this is necessary when packaging a C/C++ library that needs
  6619. headers of another library to compile, or when a pkg-config file refers
  6620. to another one @i{via} its @code{Requires} field.
  6621. Another example where @code{propagated-inputs} is useful is for languages
  6622. that lack a facility to record the run-time search path akin to the
  6623. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  6624. more. When packaging libraries written in those languages, ensure they
  6625. can find library code they depend on at run time by listing run-time
  6626. dependencies in @code{propagated-inputs} rather than @code{inputs}.
  6627. @item @code{outputs} (default: @code{'("out")})
  6628. The list of output names of the package. @xref{Packages with Multiple
  6629. Outputs}, for typical uses of additional outputs.
  6630. @item @code{native-search-paths} (default: @code{'()})
  6631. @itemx @code{search-paths} (default: @code{'()})
  6632. A list of @code{search-path-specification} objects describing
  6633. search-path environment variables honored by the package. @xref{Search
  6634. Paths}, for more on search path specifications.
  6635. As for inputs, the distinction between @code{native-search-paths} and
  6636. @code{search-paths} only matters when cross-compiling. In a
  6637. cross-compilation context, @code{native-search-paths} applies
  6638. exclusively to native inputs whereas @code{search-paths} applies only to
  6639. host inputs.
  6640. Packages such as cross-compilers care about target inputs---for
  6641. instance, our (modified) GCC cross-compiler has
  6642. @env{CROSS_C_INCLUDE_PATH} in @code{search-paths}, which allows it to
  6643. pick @file{.h} files for the target system and @emph{not} those of
  6644. native inputs. For the majority of packages though, only
  6645. @code{native-search-paths} makes sense.
  6646. @item @code{replacement} (default: @code{#f})
  6647. This must be either @code{#f} or a package object that will be used as a
  6648. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  6649. for details.
  6650. @item @code{synopsis}
  6651. A one-line description of the package.
  6652. @item @code{description}
  6653. A more elaborate description of the package, as a string in Texinfo
  6654. syntax.
  6655. @item @code{license}
  6656. @cindex license, of packages
  6657. The license of the package; a value from @code{(guix licenses)},
  6658. or a list of such values.
  6659. @item @code{home-page}
  6660. The URL to the home-page of the package, as a string.
  6661. @item @code{supported-systems} (default: @code{%supported-systems})
  6662. The list of systems supported by the package, as strings of the form
  6663. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  6664. @item @code{location} (default: source location of the @code{package} form)
  6665. The source location of the package. It is useful to override this when
  6666. inheriting from another package, in which case this field is not
  6667. automatically corrected.
  6668. @end table
  6669. @end deftp
  6670. @defmac this-package
  6671. When used in the @emph{lexical scope} of a package field definition, this
  6672. identifier resolves to the package being defined.
  6673. The example below shows how to add a package as a native input of itself when
  6674. cross-compiling:
  6675. @lisp
  6676. (package
  6677. (name "guile")
  6678. ;; ...
  6679. ;; When cross-compiled, Guile, for example, depends on
  6680. ;; a native version of itself. Add it here.
  6681. (native-inputs (if (%current-target-system)
  6682. (list this-package)
  6683. '())))
  6684. @end lisp
  6685. It is an error to refer to @code{this-package} outside a package definition.
  6686. @end defmac
  6687. The following helper procedures are provided to help deal with package
  6688. inputs.
  6689. @deffn {Procedure} lookup-package-input package name
  6690. @deffnx {Procedure} lookup-package-native-input package name
  6691. @deffnx {Procedure} lookup-package-propagated-input package name
  6692. @deffnx {Procedure} lookup-package-direct-input package name
  6693. Look up @var{name} among @var{package}'s inputs (or native, propagated,
  6694. or direct inputs). Return it if found, @code{#f} otherwise.
  6695. @var{name} is the name of a package depended on. Here's how you might
  6696. use it:
  6697. @lisp
  6698. (use-modules (guix packages) (gnu packages base))
  6699. (lookup-package-direct-input coreutils "gmp")
  6700. @result{} #<package gmp@@6.2.1 @dots{}>
  6701. @end lisp
  6702. In this example we obtain the @code{gmp} package that is among the
  6703. direct inputs of @code{coreutils}.
  6704. @end deffn
  6705. @cindex development inputs, of a package
  6706. @cindex implicit inputs, of a package
  6707. Sometimes you will want to obtain the list of inputs needed to
  6708. @emph{develop} a package---all the inputs that are visible when the
  6709. package is compiled. This is what the @code{package-development-inputs}
  6710. procedure returns.
  6711. @deffn {Procedure} package-development-inputs package [system] [#:target #f]
  6712. Return the list of inputs required by @var{package} for development
  6713. purposes on @var{system}. When @var{target} is true, return the inputs
  6714. needed to cross-compile @var{package} from @var{system} to
  6715. @var{target}, where @var{target} is a triplet such as
  6716. @code{"aarch64-linux-gnu"}.
  6717. Note that the result includes both explicit inputs and implicit
  6718. inputs---inputs automatically added by the build system (@pxref{Build
  6719. Systems}). Let us take the @code{hello} package to illustrate that:
  6720. @lisp
  6721. (use-modules (gnu packages base) (guix packages))
  6722. hello
  6723. @result{} #<package hello@@2.10 gnu/packages/base.scm:79 7f585d4f6790>
  6724. (package-direct-inputs hello)
  6725. @result{} ()
  6726. (package-development-inputs hello)
  6727. @result{} (("source" @dots{}) ("tar" #<package tar@@1.32 @dots{}>) @dots{})
  6728. @end lisp
  6729. In this example, @code{package-direct-inputs} returns the empty list,
  6730. because @code{hello} has zero explicit dependencies. Conversely,
  6731. @code{package-development-inputs} includes inputs implicitly added by
  6732. @code{gnu-build-system} that are required to build @code{hello}: tar,
  6733. gzip, GCC, libc, Bash, and more. To visualize it, @command{guix graph
  6734. hello} would show you explicit inputs, whereas @command{guix graph -t
  6735. bag hello} would include implicit inputs (@pxref{Invoking guix graph}).
  6736. @end deffn
  6737. Because packages are regular Scheme objects that capture a complete
  6738. dependency graph and associated build procedures, it is often useful to
  6739. write procedures that take a package and return a modified version
  6740. thereof according to some parameters. Below are a few examples.
  6741. @cindex tool chain, choosing a package's tool chain
  6742. @deffn {Procedure} package-with-c-toolchain package toolchain
  6743. Return a variant of @var{package} that uses @var{toolchain} instead of
  6744. the default GNU C/C++ toolchain. @var{toolchain} must be a list of
  6745. inputs (label/package tuples) providing equivalent functionality, such
  6746. as the @code{gcc-toolchain} package.
  6747. The example below returns a variant of the @code{hello} package built
  6748. with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the
  6749. GNU C Library) instead of the default tool chain:
  6750. @lisp
  6751. (let ((toolchain (specification->package "gcc-toolchain@@10")))
  6752. (package-with-c-toolchain hello `(("toolchain" ,toolchain))))
  6753. @end lisp
  6754. The build tool chain is part of the @dfn{implicit inputs} of
  6755. packages---it's usually not listed as part of the various ``inputs''
  6756. fields and is instead pulled in by the build system. Consequently, this
  6757. procedure works by changing the build system of @var{package} so that it
  6758. pulls in @var{toolchain} instead of the defaults. @ref{Build Systems},
  6759. for more on build systems.
  6760. @end deffn
  6761. @node origin Reference
  6762. @subsection @code{origin} Reference
  6763. This section documents @dfn{origins}. An @code{origin} declaration
  6764. specifies data that must be ``produced''---downloaded, usually---and
  6765. whose content hash is known in advance. Origins are primarily used to
  6766. represent the source code of packages (@pxref{Defining Packages}). For
  6767. that reason, the @code{origin} form allows you to declare patches to
  6768. apply to the original source code as well as code snippets to modify it.
  6769. @deftp {Data Type} origin
  6770. This is the data type representing a source code origin.
  6771. @table @asis
  6772. @item @code{uri}
  6773. An object containing the URI of the source. The object type depends on
  6774. the @code{method} (see below). For example, when using the
  6775. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  6776. values are: a URL represented as a string, or a list thereof.
  6777. @cindex fixed-output derivations, for download
  6778. @item @code{method}
  6779. A monadic procedure that handles the given URI@. The procedure must
  6780. accept at least three arguments: the value of the @code{uri} field and
  6781. the hash algorithm and hash value specified by the @code{hash} field.
  6782. It must return a store item or a derivation in the store monad
  6783. (@pxref{The Store Monad}); most methods return a fixed-output derivation
  6784. (@pxref{Derivations}).
  6785. Commonly used methods include @code{url-fetch}, which fetches data from
  6786. a URL, and @code{git-fetch}, which fetches data from a Git repository
  6787. (see below).
  6788. @item @code{sha256}
  6789. A bytevector containing the SHA-256 hash of the source. This is
  6790. equivalent to providing a @code{content-hash} SHA256 object in the
  6791. @code{hash} field described below.
  6792. @item @code{hash}
  6793. The @code{content-hash} object of the source---see below for how to use
  6794. @code{content-hash}.
  6795. You can obtain this information using @code{guix download}
  6796. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  6797. guix hash}).
  6798. @item @code{file-name} (default: @code{#f})
  6799. The file name under which the source code should be saved. When this is
  6800. @code{#f}, a sensible default value will be used in most cases. In case
  6801. the source is fetched from a URL, the file name from the URL will be
  6802. used. For version control checkouts, it is recommended to provide the
  6803. file name explicitly because the default is not very descriptive.
  6804. @item @code{patches} (default: @code{'()})
  6805. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  6806. file-like objects}) pointing to patches to be applied to the source.
  6807. This list of patches must be unconditional. In particular, it cannot
  6808. depend on the value of @code{%current-system} or
  6809. @code{%current-target-system}.
  6810. @item @code{snippet} (default: @code{#f})
  6811. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  6812. in the source directory. This is a convenient way to modify the source,
  6813. sometimes more convenient than a patch.
  6814. @item @code{patch-flags} (default: @code{'("-p1")})
  6815. A list of command-line flags that should be passed to the @code{patch}
  6816. command.
  6817. @item @code{patch-inputs} (default: @code{#f})
  6818. Input packages or derivations to the patching process. When this is
  6819. @code{#f}, the usual set of inputs necessary for patching are provided,
  6820. such as GNU@tie{}Patch.
  6821. @item @code{modules} (default: @code{'()})
  6822. A list of Guile modules that should be loaded during the patching
  6823. process and while running the code in the @code{snippet} field.
  6824. @item @code{patch-guile} (default: @code{#f})
  6825. The Guile package that should be used in the patching process. When
  6826. this is @code{#f}, a sensible default is used.
  6827. @end table
  6828. @end deftp
  6829. @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
  6830. Construct a content hash object for the given @var{algorithm}, and with
  6831. @var{value} as its hash value. When @var{algorithm} is omitted, assume
  6832. it is @code{sha256}.
  6833. @var{value} can be a literal string, in which case it is base32-decoded,
  6834. or it can be a bytevector.
  6835. The following forms are all equivalent:
  6836. @lisp
  6837. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
  6838. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
  6839. sha256)
  6840. (content-hash (base32
  6841. "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
  6842. (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
  6843. sha256)
  6844. @end lisp
  6845. Technically, @code{content-hash} is currently implemented as a macro.
  6846. It performs sanity checks at macro-expansion time, when possible, such
  6847. as ensuring that @var{value} has the right size for @var{algorithm}.
  6848. @end deftp
  6849. As we have seen above, how exactly the data an origin refers to is
  6850. retrieved is determined by its @code{method} field. The @code{(guix
  6851. download)} module provides the most common method, @code{url-fetch},
  6852. described below.
  6853. @deffn {Procedure} url-fetch url hash-algo hash [name] [#:executable? #f]
  6854. Return a fixed-output derivation that fetches data from @var{url} (a
  6855. string, or a list of strings denoting alternate URLs), which is expected
  6856. to have hash @var{hash} of type @var{hash-algo} (a symbol). By default,
  6857. the file name is the base name of URL; optionally, @var{name} can
  6858. specify a different file name. When @var{executable?} is true, make the
  6859. downloaded file executable.
  6860. When one of the URL starts with @code{mirror://}, then its host part is
  6861. interpreted as the name of a mirror scheme, taken from @file{%mirror-file}.
  6862. Alternatively, when URL starts with @code{file://}, return the
  6863. corresponding file name in the store.
  6864. @end deffn
  6865. Likewise, the @code{(guix git-download)} module defines the
  6866. @code{git-fetch} origin method, which fetches data from a Git version
  6867. control repository, and the @code{git-reference} data type to describe
  6868. the repository and revision to fetch.
  6869. @deffn {Procedure} git-fetch ref hash-algo hash
  6870. Return a fixed-output derivation that fetches @var{ref}, a
  6871. @code{<git-reference>} object. The output is expected to have recursive
  6872. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  6873. the file name, or a generic name if @code{#f}.
  6874. @end deffn
  6875. @deftp {Data Type} git-reference
  6876. This data type represents a Git reference for @code{git-fetch} to
  6877. retrieve.
  6878. @table @asis
  6879. @item @code{url}
  6880. The URL of the Git repository to clone.
  6881. @item @code{commit}
  6882. This string denotes either the commit to fetch (a hexadecimal string),
  6883. or the tag to fetch. You can also use a ``short'' commit ID or a
  6884. @command{git describe} style identifier such as
  6885. @code{v1.0.1-10-g58d7909c97}.
  6886. @item @code{recursive?} (default: @code{#f})
  6887. This Boolean indicates whether to recursively fetch Git sub-modules.
  6888. @end table
  6889. The example below denotes the @code{v2.10} tag of the GNU@tie{}Hello
  6890. repository:
  6891. @lisp
  6892. (git-reference
  6893. (url "https://git.savannah.gnu.org/git/hello.git")
  6894. (commit "v2.10"))
  6895. @end lisp
  6896. This is equivalent to the reference below, which explicitly names the
  6897. commit:
  6898. @lisp
  6899. (git-reference
  6900. (url "https://git.savannah.gnu.org/git/hello.git")
  6901. (commit "dc7dc56a00e48fe6f231a58f6537139fe2908fb9"))
  6902. @end lisp
  6903. @end deftp
  6904. For Mercurial repositories, the module @code{(guix hg-download)} defines
  6905. the @code{hg-fetch} origin method and @code{hg-reference} data type for
  6906. support of the Mercurial version control system.
  6907. @deffn {Procedure} hg-fetch ref hash-algo hash [name]
  6908. Return a fixed-output derivation that fetches @var{ref}, a
  6909. @code{<hg-reference>} object. The output is expected to have recursive
  6910. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  6911. the file name, or a generic name if @code{#false}.
  6912. @end deffn
  6913. @node Defining Package Variants
  6914. @section Defining Package Variants
  6915. @cindex customizing packages
  6916. @cindex variants, of packages
  6917. One of the nice things with Guix is that, given a package definition,
  6918. you can easily @emph{derive} variants of that package---for a different
  6919. upstream version, with different dependencies, different compilation
  6920. options, and so on. Some of these custom packages can be defined
  6921. straight from the command line (@pxref{Package Transformation Options}).
  6922. This section describes how to define package variants in code. This can
  6923. be useful in ``manifests'' (@pxref{Writing Manifests})
  6924. and in your own package collection
  6925. (@pxref{Creating a Channel}), among others!
  6926. @cindex inherit, for package definitions
  6927. As discussed earlier, packages are first-class objects in the Scheme
  6928. language. The @code{(guix packages)} module provides the @code{package}
  6929. construct to define new package objects (@pxref{package Reference}).
  6930. The easiest way to define a package variant is using the @code{inherit}
  6931. keyword together with @code{package}. This allows you to inherit from a
  6932. package definition while overriding the fields you want.
  6933. For example, given the @code{hello} variable, which contains a
  6934. definition for the current version of GNU@tie{}Hello, here's how you
  6935. would define a variant for version 2.2 (released in 2006, it's
  6936. vintage!):
  6937. @lisp
  6938. (use-modules (gnu packages base)) ;for 'hello'
  6939. (define hello-2.2
  6940. (package
  6941. (inherit hello)
  6942. (version "2.2")
  6943. (source (origin
  6944. (method url-fetch)
  6945. (uri (string-append "mirror://gnu/hello/hello-" version
  6946. ".tar.gz"))
  6947. (sha256
  6948. (base32
  6949. "0lappv4slgb5spyqbh6yl5r013zv72yqg2pcl30mginf3wdqd8k9"))))))
  6950. @end lisp
  6951. The example above corresponds to what the @option{--with-version}
  6952. or @option{--with-source} package transformations option do.
  6953. Essentially @code{hello-2.2} preserves all
  6954. the fields of @code{hello}, except @code{version} and @code{source},
  6955. which it overrides. Note that the original @code{hello} variable is
  6956. still there, in the @code{(gnu packages base)} module, unchanged. When
  6957. you define a custom package like this, you are really @emph{adding} a
  6958. new package definition; the original one remains available.
  6959. You can just as well define variants with a different set of
  6960. dependencies than the original package. For example, the default
  6961. @code{gdb} package depends on @code{guile}, but since that is an
  6962. optional dependency, you can define a variant that removes that
  6963. dependency like so:
  6964. @lisp
  6965. (use-modules (gnu packages gdb)) ;for 'gdb'
  6966. (define gdb-sans-guile
  6967. (package
  6968. (inherit gdb)
  6969. (inputs (modify-inputs (package-inputs gdb)
  6970. (delete "guile")))))
  6971. @end lisp
  6972. The @code{modify-inputs} form above removes the @code{"guile"} package
  6973. from the @code{inputs} field of @code{gdb}. The @code{modify-inputs}
  6974. macro is a helper that can prove useful anytime you want to remove, add,
  6975. or replace package inputs.
  6976. @defmac modify-inputs inputs clauses
  6977. Modify the given package inputs, as returned by @code{package-inputs} & co.,
  6978. according to the given clauses. Each clause must have one of the
  6979. following forms:
  6980. @table @code
  6981. @item (delete @var{name}@dots{})
  6982. Delete from the inputs packages with the given @var{name}s (strings).
  6983. @item (prepend @var{package}@dots{})
  6984. Add @var{package}s to the front of the input list.
  6985. @item (append @var{package}@dots{})
  6986. Add @var{package}s to the end of the input list.
  6987. @item (replace @var{name} @var{replacement})
  6988. Replace the package called @var{name} with @var{replacement}.
  6989. @end table
  6990. The example below removes the GMP and ACL inputs of Coreutils and adds
  6991. libcap to the front of the input list:
  6992. @lisp
  6993. (modify-inputs (package-inputs coreutils)
  6994. (delete "gmp" "acl")
  6995. (prepend libcap))
  6996. @end lisp
  6997. The example below replaces the @code{guile} package from the inputs of
  6998. @code{guile-redis} with @code{guile-2.2}:
  6999. @lisp
  7000. (modify-inputs (package-inputs guile-redis)
  7001. (replace "guile" guile-2.2))
  7002. @end lisp
  7003. The last type of clause is @code{append}, to add inputs at the back of
  7004. the list.
  7005. @end defmac
  7006. In some cases, you may find it useful to write functions
  7007. (``procedures'', in Scheme parlance) that return a package based on some
  7008. parameters. For example, consider the @code{luasocket} library for the
  7009. Lua programming language. We want to create @code{luasocket} packages
  7010. for major versions of Lua. One way to do that is to define a procedure
  7011. that takes a Lua package and returns a @code{luasocket} package that
  7012. depends on it:
  7013. @lisp
  7014. (define (make-lua-socket name lua)
  7015. ;; Return a luasocket package built with LUA.
  7016. (package
  7017. (name name)
  7018. (version "3.0")
  7019. ;; several fields omitted
  7020. (inputs (list lua))
  7021. (synopsis "Socket library for Lua")))
  7022. (define-public lua5.1-socket
  7023. (make-lua-socket "lua5.1-socket" lua-5.1))
  7024. (define-public lua5.2-socket
  7025. (make-lua-socket "lua5.2-socket" lua-5.2))
  7026. @end lisp
  7027. Here we have defined packages @code{lua5.1-socket} and
  7028. @code{lua5.2-socket} by calling @code{make-lua-socket} with different
  7029. arguments. @xref{Procedures,,, guile, GNU Guile Reference Manual}, for
  7030. more info on procedures. Having top-level public definitions for these
  7031. two packages means that they can be referred to from the command line
  7032. (@pxref{Package Modules}).
  7033. @cindex package transformations
  7034. These are pretty simple package variants. As a convenience, the
  7035. @code{(guix transformations)} module provides a high-level interface
  7036. that directly maps to the more sophisticated package transformation
  7037. options (@pxref{Package Transformation Options}):
  7038. @deffn {Procedure} options->transformation opts
  7039. Return a procedure that, when passed an object to build (package,
  7040. derivation, etc.), applies the transformations specified by @var{opts} and returns
  7041. the resulting objects. @var{opts} must be a list of symbol/string pairs such as:
  7042. @lisp
  7043. ((with-branch . "guile-gcrypt=master")
  7044. (without-tests . "libgcrypt"))
  7045. @end lisp
  7046. Each symbol names a transformation and the corresponding string is an argument
  7047. to that transformation.
  7048. @end deffn
  7049. For instance, a manifest equivalent to this command:
  7050. @example
  7051. guix build guix \
  7052. --with-branch=guile-gcrypt=master \
  7053. --with-debug-info=zlib
  7054. @end example
  7055. @noindent
  7056. ... would look like this:
  7057. @lisp
  7058. (use-modules (guix transformations))
  7059. (define transform
  7060. ;; The package transformation procedure.
  7061. (options->transformation
  7062. '((with-branch . "guile-gcrypt=master")
  7063. (with-debug-info . "zlib"))))
  7064. (packages->manifest
  7065. (list (transform (specification->package "guix"))))
  7066. @end lisp
  7067. @cindex input rewriting
  7068. @cindex dependency graph rewriting
  7069. The @code{options->transformation} procedure is convenient, but it's
  7070. perhaps also not as flexible as you may like. How is it implemented?
  7071. The astute reader probably noticed that most package transformation
  7072. options go beyond the superficial changes shown in the first examples of
  7073. this section: they involve @dfn{input rewriting}, whereby the dependency
  7074. graph of a package is rewritten by replacing specific inputs by others.
  7075. Dependency graph rewriting, for the purposes of swapping packages in the
  7076. graph, is what the @code{package-input-rewriting} procedure in
  7077. @code{(guix packages)} implements.
  7078. @deffn {Procedure} package-input-rewriting replacements [rewrite-name] [#:deep? #t]
  7079. Return a procedure that, when passed a package, replaces its direct and
  7080. indirect dependencies, including implicit inputs when @var{deep?} is
  7081. true, according to @var{replacements}. @var{replacements} is a list of
  7082. package pairs; the first element of each pair is the package to replace,
  7083. and the second one is the replacement.
  7084. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  7085. the name of a package and returns its new name after rewrite.
  7086. @end deffn
  7087. @noindent
  7088. Consider this example:
  7089. @lisp
  7090. (define libressl-instead-of-openssl
  7091. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  7092. ;; recursively.
  7093. (package-input-rewriting `((,openssl . ,libressl))))
  7094. (define git-with-libressl
  7095. (libressl-instead-of-openssl git))
  7096. @end lisp
  7097. @noindent
  7098. Here we first define a rewriting procedure that replaces @var{openssl}
  7099. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  7100. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  7101. This is exactly what the @option{--with-input} command-line option does
  7102. (@pxref{Package Transformation Options, @option{--with-input}}).
  7103. The following variant of @code{package-input-rewriting} can match packages to
  7104. be replaced by name rather than by identity.
  7105. @deffn {Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
  7106. Return a procedure that, given a package, applies the given
  7107. @var{replacements} to all the package graph, including implicit inputs
  7108. unless @var{deep?} is false.
  7109. @var{replacements} is a list of spec/procedures pair; each spec is a
  7110. package specification such as @code{"gcc"} or @code{"guile@@2"}, and
  7111. each procedure takes a matching package and returns a replacement for
  7112. that package. Matching packages that have the @code{hidden?} property
  7113. set are not replaced.
  7114. @end deffn
  7115. The example above could be rewritten this way:
  7116. @lisp
  7117. (define libressl-instead-of-openssl
  7118. ;; Replace all the packages called "openssl" with LibreSSL.
  7119. (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
  7120. @end lisp
  7121. The key difference here is that, this time, packages are matched by spec and
  7122. not by identity. In other words, any package in the graph that is called
  7123. @code{openssl} will be replaced.
  7124. A more generic procedure to rewrite a package dependency graph is
  7125. @code{package-mapping}: it supports arbitrary changes to nodes in the
  7126. graph.
  7127. @deffn {Procedure} package-mapping proc [cut?] [#:deep? #f]
  7128. Return a procedure that, given a package, applies @var{proc} to all the packages
  7129. depended on and returns the resulting package. The procedure stops recursion
  7130. when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
  7131. applied to implicit inputs as well.
  7132. @end deffn
  7133. @node Writing Manifests
  7134. @section Writing Manifests
  7135. @cindex manifest
  7136. @cindex bill of materials (manifests)
  7137. @command{guix} commands let you specify package lists on the command
  7138. line. This is convenient, but as the command line becomes longer and
  7139. less trivial, it quickly becomes more convenient to have that package
  7140. list in what we call a @dfn{manifest}. A manifest is some sort of a
  7141. ``bill of materials'' that defines a package set. You would typically
  7142. come up with a code snippet that builds the manifest, store it in a
  7143. file, say @file{manifest.scm}, and then pass that file to the
  7144. @option{-m} (or @option{--manifest}) option that many @command{guix}
  7145. commands support. For example, here's what a manifest for a simple
  7146. package set might look like:
  7147. @lisp
  7148. ;; Manifest for three packages.
  7149. (specifications->manifest '("gcc-toolchain" "make" "git"))
  7150. @end lisp
  7151. Once you have that manifest, you can pass it, for example, to
  7152. @command{guix package} to install just those three packages to your
  7153. profile (@pxref{profile-manifest, @option{-m} option of @command{guix
  7154. package}}):
  7155. @example
  7156. guix package -m manifest.scm
  7157. @end example
  7158. @noindent
  7159. ... or you can pass it to @command{guix shell} (@pxref{shell-manifest,
  7160. @command{-m} option of @command{guix shell}}) to spawn an ephemeral
  7161. environment:
  7162. @example
  7163. guix shell -m manifest.scm
  7164. @end example
  7165. @noindent
  7166. ... or you can pass it to @command{guix pack} in pretty much the same
  7167. way (@pxref{pack-manifest, @option{-m} option of @command{guix pack}}).
  7168. You can store the manifest under version control, share it with others
  7169. so they can easily get set up, etc.
  7170. But how do you write your first manifest? To get started, maybe you'll
  7171. want to write a manifest that mirrors what you already have in a
  7172. profile. Rather than start from a blank page, @command{guix package}
  7173. can generate a manifest for you (@pxref{export-manifest, @command{guix
  7174. package --export-manifest}}):
  7175. @example
  7176. # Write to 'manifest.scm' a manifest corresponding to the
  7177. # default profile, ~/.guix-profile.
  7178. guix package --export-manifest > manifest.scm
  7179. @end example
  7180. Or maybe you'll want to ``translate'' command-line arguments into a
  7181. manifest. In that case, @command{guix shell} can help
  7182. (@pxref{shell-export-manifest, @command{guix shell --export-manifest}}):
  7183. @example
  7184. # Write a manifest for the packages specified on the command line.
  7185. guix shell --export-manifest gcc-toolchain make git > manifest.scm
  7186. @end example
  7187. In both cases, the @option{--export-manifest} option tries hard to
  7188. generate a faithful manifest; in particular, it takes package
  7189. transformation options into account (@pxref{Package Transformation
  7190. Options}).
  7191. @quotation Note
  7192. Manifests are @emph{symbolic}: they refer to packages of the channels
  7193. @emph{currently in use} (@pxref{Channels}). In the example above,
  7194. @code{gcc-toolchain} might refer to version 11 today, but it might refer
  7195. to version 13 two years from now.
  7196. If you want to ``pin'' your software environment to specific package
  7197. versions and variants, you need an additional piece of information: the
  7198. list of channel revisions in use, as returned by @command{guix
  7199. describe}. @xref{Replicating Guix}, for more information.
  7200. @end quotation
  7201. Once you've obtained your first manifest, perhaps you'll want to
  7202. customize it. Since your manifest is code, you now have access to all
  7203. the Guix programming interfaces!
  7204. Let's assume you want a manifest to deploy a custom variant of GDB, the
  7205. GNU Debugger, that does not depend on Guile, together with another
  7206. package. Building on the example seen in the previous section
  7207. (@pxref{Defining Package Variants}), you can write a manifest along
  7208. these lines:
  7209. @lisp
  7210. (use-modules (guix packages)
  7211. (gnu packages gdb) ;for 'gdb'
  7212. (gnu packages version-control)) ;for 'git'
  7213. ;; Define a variant of GDB without a dependency on Guile.
  7214. (define gdb-sans-guile
  7215. (package
  7216. (inherit gdb)
  7217. (inputs (modify-inputs (package-inputs gdb)
  7218. (delete "guile")))))
  7219. ;; Return a manifest containing that one package plus Git.
  7220. (packages->manifest (list gdb-sans-guile git))
  7221. @end lisp
  7222. Note that in this example, the manifest directly refers to the
  7223. @code{gdb} and @code{git} variables, which are bound to a @code{package}
  7224. object (@pxref{package Reference}), instead of calling
  7225. @code{specifications->manifest} to look up packages by name as we did
  7226. before. The @code{use-modules} form at the top lets us access the core
  7227. package interface (@pxref{Defining Packages}) and the modules that
  7228. define @code{gdb} and @code{git} (@pxref{Package Modules}). Seamlessly,
  7229. we're weaving all this together---the possibilities are endless, unleash
  7230. your creativity!
  7231. The data type for manifests as well as supporting procedures are defined
  7232. in the @code{(guix profiles)} module, which is automatically available
  7233. to code passed to @option{-m}. The reference follows.
  7234. @deftp {Data Type} manifest
  7235. Data type representing a manifest.
  7236. It currently has one field:
  7237. @table @code
  7238. @item entries
  7239. This must be a list of @code{manifest-entry} records---see below.
  7240. @end table
  7241. @end deftp
  7242. @deftp {Data Type} manifest-entry
  7243. Data type representing a manifest entry. A manifest entry contains
  7244. essential metadata: a name and version string, the object (usually a
  7245. package) for that entry, the desired output (@pxref{Packages with
  7246. Multiple Outputs}), and a number of optional pieces of information
  7247. detailed below.
  7248. Most of the time, you won't build a manifest entry directly; instead,
  7249. you will pass a package to @code{package->manifest-entry}, described
  7250. below. In some unusual cases though, you might want to create manifest
  7251. entries for things that are @emph{not} packages, as in this example:
  7252. @lisp
  7253. ;; Manually build a single manifest entry for a non-package object.
  7254. (let ((hello (program-file "hello" #~(display "Hi!"))))
  7255. (manifest-entry
  7256. (name "foo")
  7257. (version "42")
  7258. (item
  7259. (computed-file "hello-directory"
  7260. #~(let ((bin (string-append #$output "/bin")))
  7261. (mkdir #$output) (mkdir bin)
  7262. (symlink #$hello
  7263. (string-append bin "/hello")))))))
  7264. @end lisp
  7265. The available fields are the following:
  7266. @table @asis
  7267. @item @code{name}
  7268. @itemx @code{version}
  7269. Name and version string for this entry.
  7270. @item @code{item}
  7271. A package or other file-like object (@pxref{G-Expressions, file-like
  7272. objects}).
  7273. @item @code{output} (default: @code{"out"})
  7274. Output of @code{item} to use, in case @code{item} has multiple outputs
  7275. (@pxref{Packages with Multiple Outputs}).
  7276. @item @code{dependencies} (default: @code{'()})
  7277. List of manifest entries this entry depends on. When building a
  7278. profile, dependencies are added to the profile.
  7279. Typically, the propagated inputs of a package (@pxref{package Reference,
  7280. @code{propagated-inputs}}) end up having a corresponding manifest entry
  7281. in among the dependencies of the package's own manifest entry.
  7282. @item @code{search-paths} (default: @code{'()})
  7283. The list of search path specifications honored by this entry
  7284. (@pxref{Search Paths}).
  7285. @item @code{properties} (default: @code{'()})
  7286. List of symbol/value pairs. When building a profile, those properties
  7287. get serialized.
  7288. This can be used to piggyback additional metadata---e.g., the
  7289. transformations applied to a package (@pxref{Package Transformation
  7290. Options}).
  7291. @item @code{parent} (default: @code{(delay #f)})
  7292. A promise pointing to the ``parent'' manifest entry.
  7293. This is used as a hint to provide context when reporting an error
  7294. related to a manifest entry coming from a @code{dependencies} field.
  7295. @end table
  7296. @end deftp
  7297. @deffn {Procedure} concatenate-manifests lst
  7298. Concatenate the manifests listed in @var{lst} and return the resulting
  7299. manifest.
  7300. @end deffn
  7301. @c TODO: <manifest-pattern>, manifest-lookup, manifest-remove, etc.
  7302. @deffn {Procedure} package->manifest-entry package [output] [#:properties]
  7303. Return a manifest entry for the @var{output} of package @var{package},
  7304. where @var{output} defaults to @code{"out"}, and with the given
  7305. @var{properties}. By default @var{properties} is the empty list or, if
  7306. one or more package transformations were applied to @var{package}, it is
  7307. an association list representing those transformations, suitable as an
  7308. argument to @code{options->transformation} (@pxref{Defining Package
  7309. Variants, @code{options->transformation}}).
  7310. The code snippet below builds a manifest with an entry for the default
  7311. output and the @code{send-email} output of the @code{git} package:
  7312. @lisp
  7313. (use-modules (gnu packages version-control))
  7314. (manifest (list (package->manifest-entry git)
  7315. (package->manifest-entry git "send-email")))
  7316. @end lisp
  7317. @end deffn
  7318. @deffn {Procedure} packages->manifest packages
  7319. Return a list of manifest entries, one for each item listed in
  7320. @var{packages}. Elements of @var{packages} can be either package
  7321. objects or package/string tuples denoting a specific output of a
  7322. package.
  7323. Using this procedure, the manifest above may be rewritten more
  7324. concisely:
  7325. @lisp
  7326. (use-modules (gnu packages version-control))
  7327. (packages->manifest (list git `(,git "send-email")))
  7328. @end lisp
  7329. @end deffn
  7330. @anchor{package-development-manifest}
  7331. @deffn {Procedure} package->development-manifest package [system] [#:target]
  7332. Return a manifest for the @dfn{development inputs} of @var{package} for
  7333. @var{system}, optionally when cross-compiling to @var{target}.
  7334. Development inputs include both explicit and implicit inputs of
  7335. @var{package}.
  7336. Like the @option{-D} option of @command{guix shell}
  7337. (@pxref{shell-development-option, @command{guix shell -D}}), the
  7338. resulting manifest describes the environment in which one can develop
  7339. @var{package}. For example, suppose you're willing to set up a
  7340. development environment for Inkscape, with the addition of Git for
  7341. version control; you can describe that ``bill of materials'' with the
  7342. following manifest:
  7343. @lisp
  7344. (use-modules (gnu packages inkscape) ;for 'inkscape'
  7345. (gnu packages version-control)) ;for 'git'
  7346. (concatenate-manifests
  7347. (list (package->development-manifest inkscape)
  7348. (packages->manifest (list git))))
  7349. @end lisp
  7350. In this example, the development manifest that
  7351. @code{package->development-manifest} returns includes the compiler
  7352. (GCC), the many supporting libraries (Boost, GLib, GTK, etc.), and a
  7353. couple of additional development tools---these are the dependencies
  7354. @command{guix show inkscape} lists.
  7355. @end deffn
  7356. @c TODO: Move (gnu packages) interface to a section of its own.
  7357. Last, the @code{(gnu packages)} module provides higher-level facilities
  7358. to build manifests. In particular, it lets you look up packages by
  7359. name---see below.
  7360. @deffn {Procedure} specifications->manifest specs
  7361. Given @var{specs}, a list of specifications such as @code{"emacs@@25.2"}
  7362. or @code{"guile:debug"}, return a manifest. Specs have the format that
  7363. command-line tools such as @command{guix install} and @command{guix
  7364. package} understand (@pxref{Invoking guix package}).
  7365. As an example, it lets you rewrite the Git manifest that we saw earlier
  7366. like this:
  7367. @lisp
  7368. (specifications->manifest '("git" "git:send-email"))
  7369. @end lisp
  7370. Notice that we do not need to worry about @code{use-modules}, importing
  7371. the right set of modules, and referring to the right variables.
  7372. Instead, we directly refer to packages in the same way as on the command
  7373. line, which can often be more convenient.
  7374. @end deffn
  7375. @c TODO: specifications->package, etc.
  7376. @node Build Systems
  7377. @section Build Systems
  7378. @cindex build system
  7379. Each package definition specifies a @dfn{build system} and arguments for
  7380. that build system (@pxref{Defining Packages}). This @code{build-system}
  7381. field represents the build procedure of the package, as well as implicit
  7382. dependencies of that build procedure.
  7383. Build systems are @code{<build-system>} objects. The interface to
  7384. create and manipulate them is provided by the @code{(guix build-system)}
  7385. module, and actual build systems are exported by specific modules.
  7386. @cindex bag (low-level package representation)
  7387. Under the hood, build systems first compile package objects to
  7388. @dfn{bags}. A @dfn{bag} is like a package, but with less
  7389. ornamentation---in other words, a bag is a lower-level representation of
  7390. a package, which includes all the inputs of that package, including some
  7391. that were implicitly added by the build system. This intermediate
  7392. representation is then compiled to a derivation (@pxref{Derivations}).
  7393. The @code{package-with-c-toolchain} is an example of a way to change the
  7394. implicit inputs that a package's build system pulls in (@pxref{package
  7395. Reference, @code{package-with-c-toolchain}}).
  7396. Build systems accept an optional list of @dfn{arguments}. In package
  7397. definitions, these are passed @i{via} the @code{arguments} field
  7398. (@pxref{Defining Packages}). They are typically keyword arguments
  7399. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  7400. Guile Reference Manual}). The value of these arguments is usually
  7401. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  7402. by the daemon (@pxref{Derivations}).
  7403. The main build system is @code{gnu-build-system}, which implements the
  7404. standard build procedure for GNU and many other packages. It
  7405. is provided by the @code{(guix build-system gnu)} module.
  7406. @defvar gnu-build-system
  7407. @code{gnu-build-system} represents the GNU Build System, and variants
  7408. thereof (@pxref{Configuration, configuration and makefile conventions,,
  7409. standards, GNU Coding Standards}).
  7410. @cindex build phases
  7411. In a nutshell, packages using it are configured, built, and installed with
  7412. the usual @code{./configure && make && make check && make install}
  7413. command sequence. In practice, a few additional steps are often needed.
  7414. All these steps are split up in separate @dfn{phases}.
  7415. @xref{Build Phases}, for more info on build phases and ways to customize
  7416. them.
  7417. In addition, this build system ensures that the ``standard'' environment
  7418. for GNU packages is available. This includes tools such as GCC, libc,
  7419. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  7420. build-system gnu)} module for a complete list). We call these the
  7421. @dfn{implicit inputs} of a package, because package definitions do not
  7422. have to mention them.
  7423. This build system supports a number of keyword arguments, which can be
  7424. passed @i{via} the @code{arguments} field of a package. Here are some
  7425. of the main parameters:
  7426. @table @code
  7427. @item #:phases
  7428. This argument specifies build-side code that evaluates to an alist of
  7429. build phases. @xref{Build Phases}, for more information.
  7430. @item #:configure-flags
  7431. This is a list of flags (strings) passed to the @command{configure}
  7432. script. @xref{Defining Packages}, for an example.
  7433. @item #:make-flags
  7434. This list of strings contains flags passed as arguments to
  7435. @command{make} invocations in the @code{build}, @code{check}, and
  7436. @code{install} phases.
  7437. @item #:out-of-source?
  7438. This Boolean, @code{#f} by default, indicates whether to run builds in a
  7439. build directory separate from the source tree.
  7440. When it is true, the @code{configure} phase creates a separate build
  7441. directory, changes to that directory, and runs the @code{configure}
  7442. script from there. This is useful for packages that require it, such as
  7443. @code{glibc}.
  7444. @item #:tests?
  7445. This Boolean, @code{#t} by default, indicates whether the @code{check}
  7446. phase should run the package's test suite.
  7447. @item #:test-target
  7448. This string, @code{"check"} by default, gives the name of the makefile
  7449. target used by the @code{check} phase.
  7450. @item #:parallel-build?
  7451. @itemx #:parallel-tests?
  7452. These Boolean values specify whether to build, respectively run the test
  7453. suite, in parallel, with the @code{-j} flag of @command{make}. When
  7454. they are true, @code{make} is passed @code{-j@var{n}}, where @var{n} is
  7455. the number specified as the @option{--cores} option of
  7456. @command{guix-daemon} or that of the @command{guix} client command
  7457. (@pxref{Common Build Options, @option{--cores}}).
  7458. @cindex RUNPATH, validation
  7459. @item #:validate-runpath?
  7460. This Boolean, @code{#t} by default, determines whether to ``validate''
  7461. the @code{RUNPATH} of ELF binaries (@code{.so} shared libraries as well
  7462. as executables) previously installed by the @code{install} phase.
  7463. @xref{phase-validate-runpath, the @code{validate-runpath} phase}, for
  7464. details.
  7465. @item #:substitutable?
  7466. This Boolean, @code{#t} by default, tells whether the package outputs
  7467. should be substitutable---i.e., whether users should be able to obtain
  7468. substitutes for them instead of building locally (@pxref{Substitutes}).
  7469. @item #:allowed-references
  7470. @itemx #:disallowed-references
  7471. When true, these arguments must be a list of dependencies that must not
  7472. appear among the references of the build results. If, upon build
  7473. completion, some of these references are retained, the build process
  7474. fails.
  7475. This is useful to ensure that a package does not erroneously keep a
  7476. reference to some of it build-time inputs, in cases where doing so
  7477. would, for example, unnecessarily increase its size (@pxref{Invoking
  7478. guix size}).
  7479. @end table
  7480. Most other build systems support these keyword arguments.
  7481. @end defvar
  7482. Other @code{<build-system>} objects are defined to support other
  7483. conventions and tools used by free software packages. They inherit most
  7484. of @code{gnu-build-system}, and differ mainly in the set of inputs
  7485. implicitly added to the build process, and in the list of phases
  7486. executed. Some of these build systems are listed below.
  7487. @defvar agda-build-system
  7488. This variable is exported by @code{(guix build-system agda)}. It
  7489. implements a build procedure for Agda libraries.
  7490. It adds @code{agda} to the set of inputs. A different Agda can be
  7491. specified with the @code{#:agda} key.
  7492. The @code{#:plan} key is a list of cons cells @code{(@var{regexp}
  7493. . @var{parameters})}, where @var{regexp} is a regexp that should match
  7494. the @code{.agda} files to build, and @var{parameters} is an optional
  7495. list of parameters that will be passed to @code{agda} when type-checking
  7496. it.
  7497. When the library uses Haskell to generate a file containing all imports,
  7498. the convenience @code{#:gnu-and-haskell?} can be set to @code{#t} to add
  7499. @code{ghc} and the standard inputs of @code{gnu-build-system} to the
  7500. input list. You will still need to manually add a phase or tweak the
  7501. @code{'build} phase, as in the definition of @code{agda-stdlib}.
  7502. @end defvar
  7503. @defvar ant-build-system
  7504. This variable is exported by @code{(guix build-system ant)}. It
  7505. implements the build procedure for Java packages that can be built with
  7506. @url{https://ant.apache.org/, Ant build tool}.
  7507. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  7508. provided by the @code{icedtea} package to the set of inputs. Different
  7509. packages can be specified with the @code{#:ant} and @code{#:jdk}
  7510. parameters, respectively.
  7511. When the original package does not provide a suitable Ant build file,
  7512. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  7513. build file @file{build.xml} with tasks to build the specified jar
  7514. archive. In this case the parameter @code{#:source-dir} can be used to
  7515. specify the source sub-directory, defaulting to ``src''.
  7516. The @code{#:main-class} parameter can be used with the minimal ant
  7517. buildfile to specify the main class of the resulting jar. This makes the
  7518. jar file executable. The @code{#:test-include} parameter can be used to
  7519. specify the list of junit tests to run. It defaults to
  7520. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  7521. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  7522. because abstract classes cannot be run as tests.
  7523. The parameter @code{#:build-target} can be used to specify the Ant task
  7524. that should be run during the @code{build} phase. By default the
  7525. ``jar'' task will be run.
  7526. @end defvar
  7527. @defvar android-ndk-build-system
  7528. @cindex Android distribution
  7529. @cindex Android NDK build system
  7530. This variable is exported by @code{(guix build-system android-ndk)}. It
  7531. implements a build procedure for Android NDK (native development kit)
  7532. packages using a Guix-specific build process.
  7533. The build system assumes that packages install their public interface
  7534. (header) files to the subdirectory @file{include} of the @code{out} output and
  7535. their libraries to the subdirectory @file{lib} the @code{out} output.
  7536. It's also assumed that the union of all the dependencies of a package
  7537. has no conflicting files.
  7538. For the time being, cross-compilation is not supported - so right now
  7539. the libraries and header files are assumed to be host tools.
  7540. @end defvar
  7541. @defvar asdf-build-system/source
  7542. @defvarx asdf-build-system/sbcl
  7543. @defvarx asdf-build-system/ecl
  7544. These variables, exported by @code{(guix build-system asdf)}, implement
  7545. build procedures for Common Lisp packages using
  7546. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  7547. definition facility for Common Lisp programs and libraries.
  7548. The @code{asdf-build-system/source} system installs the packages in
  7549. source form, and can be loaded using any common lisp implementation, via
  7550. ASDF@. The others, such as @code{asdf-build-system/sbcl}, install binary
  7551. systems in the format which a particular implementation understands.
  7552. These build systems can also be used to produce executable programs, or
  7553. lisp images which contain a set of packages pre-loaded.
  7554. The build system uses naming conventions. For binary packages, the
  7555. package name should be prefixed with the lisp implementation, such as
  7556. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  7557. Additionally, the corresponding source package should be labeled using
  7558. the same convention as python packages (see @ref{Python Modules}), using
  7559. the @code{cl-} prefix.
  7560. In order to create executable programs and images, the build-side
  7561. procedures @code{build-program} and @code{build-image} can be used.
  7562. They should be called in a build phase after the
  7563. @code{create-asdf-configuration} phase, so that the system which was
  7564. just built can be used within the resulting image. @code{build-program}
  7565. requires a list of Common Lisp expressions to be passed as the
  7566. @code{#:entry-program} argument.
  7567. By default, all the @file{.asd} files present in the sources are read to
  7568. find system definitions. The @code{#:asd-files} parameter can be used
  7569. to specify the list of @file{.asd} files to read. Furthermore, if the
  7570. package defines a system for its tests in a separate file, it will be
  7571. loaded before the tests are run if it is specified by the
  7572. @code{#:test-asd-file} parameter. If it is not set, the files
  7573. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  7574. and @code{test.asd} will be tried if they exist.
  7575. If for some reason the package must be named in a different way than the
  7576. naming conventions suggest, or if several systems must be compiled, the
  7577. @code{#:asd-systems} parameter can be used to specify the list of system
  7578. names.
  7579. @end defvar
  7580. @defvar cargo-build-system
  7581. @cindex Rust programming language
  7582. @cindex Cargo (Rust build system)
  7583. This variable is exported by @code{(guix build-system cargo)}. It
  7584. supports builds of packages using Cargo, the build tool of the
  7585. @uref{https://www.rust-lang.org, Rust programming language}.
  7586. It adds @code{rustc} and @code{cargo} to the set of inputs.
  7587. A different Rust package can be specified with the @code{#:rust} parameter.
  7588. Regular cargo dependencies should be added to the package definition similarly
  7589. to other packages; those needed only at build time to native-inputs, others to
  7590. inputs. If you need to add source-only crates then you should add them to via
  7591. the @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
  7592. spec can be a package or a source definition. Note that the spec must
  7593. evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
  7594. file at its root, or it will be ignored. Similarly, cargo dev-dependencies
  7595. should be added to the package definition via the
  7596. @code{#:cargo-development-inputs} parameter.
  7597. In its @code{configure} phase, this build system will make any source inputs
  7598. specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
  7599. parameters available to cargo. It will also remove an included
  7600. @code{Cargo.lock} file to be recreated by @code{cargo} during the
  7601. @code{build} phase. The @code{package} phase will run @code{cargo package}
  7602. to create a source crate for future use. The @code{install} phase installs
  7603. the binaries defined by the crate. Unless @code{install-source? #f} is
  7604. defined it will also install a source crate repository of itself and unpacked
  7605. sources, to ease in future hacking on rust packages.
  7606. @end defvar
  7607. @defvar chicken-build-system
  7608. This variable is exported by @code{(guix build-system chicken)}. It
  7609. builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called
  7610. ``eggs'' or ``extensions''. CHICKEN generates C source code, which then
  7611. gets compiled by a C compiler, in this case GCC.
  7612. This build system adds @code{chicken} to the package inputs, as well as
  7613. the packages of @code{gnu-build-system}.
  7614. The build system can't (yet) deduce the egg's name automatically, so just like
  7615. with @code{go-build-system} and its @code{#:import-path}, you should define
  7616. @code{#:egg-name} in the package's @code{arguments} field.
  7617. For example, if you are packaging the @code{srfi-1} egg:
  7618. @lisp
  7619. (arguments '(#:egg-name "srfi-1"))
  7620. @end lisp
  7621. Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs}
  7622. because CHICKEN doesn't embed absolute references in compiled eggs.
  7623. Test dependencies should go to @code{native-inputs}, as usual.
  7624. @end defvar
  7625. @defvar copy-build-system
  7626. This variable is exported by @code{(guix build-system copy)}. It
  7627. supports builds of simple packages that don't require much compiling,
  7628. mostly just moving files around.
  7629. It adds much of the @code{gnu-build-system} packages to the set of
  7630. inputs. Because of this, the @code{copy-build-system} does not require
  7631. all the boilerplate code often needed for the
  7632. @code{trivial-build-system}.
  7633. To further simplify the file installation process, an
  7634. @code{#:install-plan} argument is exposed to let the packager specify
  7635. which files go where. The install plan is a list of @code{(@var{source}
  7636. @var{target} [@var{filters}])}. @var{filters} are optional.
  7637. @itemize
  7638. @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
  7639. @itemize
  7640. @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
  7641. @item Otherwise install @var{source} as @var{target}.
  7642. @end itemize
  7643. @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
  7644. the trailing slash of @var{target} is implied with the same meaning
  7645. as above.
  7646. @itemize
  7647. @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
  7648. @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
  7649. @code{#:exclude-regexp}, only select files are installed depending on
  7650. the filters. Each filters is specified by a list of strings.
  7651. @itemize
  7652. @item With @code{#:include}, install all the files which the path suffix matches
  7653. at least one of the elements in the given list.
  7654. @item With @code{#:include-regexp}, install all the files which the
  7655. subpaths match at least one of the regular expressions in the given
  7656. list.
  7657. @item The @code{#:exclude} and @code{#:exclude-regexp} filters
  7658. are the complement of their inclusion counterpart. Without @code{#:include} flags,
  7659. install all files but those matching the exclusion filters.
  7660. If both inclusions and exclusions are specified, the exclusions are done
  7661. on top of the inclusions.
  7662. @end itemize
  7663. @end itemize
  7664. In all cases, the paths relative to @var{source} are preserved within
  7665. @var{target}.
  7666. @end itemize
  7667. Examples:
  7668. @itemize
  7669. @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
  7670. @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
  7671. @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
  7672. e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
  7673. @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
  7674. @file{share/my-app/sub/file}.
  7675. @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
  7676. @file{share/my-app/file}.
  7677. @end itemize
  7678. @end defvar
  7679. @cindex Clojure (programming language)
  7680. @cindex simple Clojure build system
  7681. @defvar clojure-build-system
  7682. This variable is exported by @code{(guix build-system clojure)}. It implements
  7683. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  7684. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  7685. yet.
  7686. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  7687. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  7688. @code{#:zip} parameters, respectively.
  7689. A list of source directories, test directories and jar names can be specified
  7690. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  7691. parameters, respectively. Compile directory and main class can be specified
  7692. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  7693. Other parameters are documented below.
  7694. This build system is an extension of @code{ant-build-system}, but with the
  7695. following phases changed:
  7696. @table @code
  7697. @item build
  7698. This phase calls @code{compile} in Clojure to compile source files and runs
  7699. @command{jar} to create jars from both source files and compiled files
  7700. according to the include list and exclude list specified in
  7701. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  7702. has priority over the include list. These lists consist of symbols
  7703. representing Clojure libraries or the special keyword @code{#:all} representing
  7704. all Clojure libraries found under the source directories. The parameter
  7705. @code{#:omit-source?} decides if source should be included into the jars.
  7706. @item check
  7707. This phase runs tests according to the include list and exclude list specified
  7708. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  7709. meanings are analogous to that of @code{#:aot-include} and
  7710. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  7711. stands for all Clojure libraries found under the test directories. The
  7712. parameter @code{#:tests?} decides if tests should be run.
  7713. @item install
  7714. This phase installs all jars built previously.
  7715. @end table
  7716. Apart from the above, this build system also contains an additional phase:
  7717. @table @code
  7718. @item install-doc
  7719. This phase installs all top-level files with base name matching
  7720. @code{%doc-regex}. A different regex can be specified with the
  7721. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  7722. directories specified in @code{#:doc-dirs} are installed as well.
  7723. @end table
  7724. @end defvar
  7725. @defvar cmake-build-system
  7726. This variable is exported by @code{(guix build-system cmake)}. It
  7727. implements the build procedure for packages using the
  7728. @url{https://www.cmake.org, CMake build tool}.
  7729. It automatically adds the @code{cmake} package to the set of inputs.
  7730. Which package is used can be specified with the @code{#:cmake}
  7731. parameter.
  7732. The @code{#:configure-flags} parameter is taken as a list of flags
  7733. passed to the @command{cmake} command. The @code{#:build-type}
  7734. parameter specifies in abstract terms the flags passed to the compiler;
  7735. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  7736. debugging information''), which roughly means that code is compiled with
  7737. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  7738. @end defvar
  7739. @defvar dune-build-system
  7740. This variable is exported by @code{(guix build-system dune)}. It
  7741. supports builds of packages using @uref{https://dune.build/, Dune}, a build
  7742. tool for the OCaml programming language. It is implemented as an extension
  7743. of the @code{ocaml-build-system} which is described below. As such, the
  7744. @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
  7745. system.
  7746. It automatically adds the @code{dune} package to the set of inputs.
  7747. Which package is used can be specified with the @code{#:dune}
  7748. parameter.
  7749. There is no @code{configure} phase because dune packages typically don't
  7750. need to be configured. The @code{#:build-flags} parameter is taken as a
  7751. list of flags passed to the @code{dune} command during the build.
  7752. The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
  7753. command instead of the more recent @code{dune} command while building
  7754. a package. Its default value is @code{#f}.
  7755. The @code{#:package} parameter can be passed to specify a package name, which
  7756. is useful when a package contains multiple packages and you want to build
  7757. only one of them. This is equivalent to passing the @code{-p} argument to
  7758. @code{dune}.
  7759. @end defvar
  7760. @defvar elm-build-system
  7761. This variable is exported by @code{(guix build-system elm)}. It implements a
  7762. build procedure for @url{https://elm-lang.org, Elm} packages similar to
  7763. @samp{elm install}.
  7764. The build system adds an Elm compiler package to the set of inputs. The
  7765. default compiler package (currently @code{elm-sans-reactor}) can be overridden
  7766. using the @code{#:elm} argument. Additionally, Elm packages needed by the
  7767. build system itself are added as implicit inputs if they are not already
  7768. present: to suppress this behavior, use the
  7769. @code{#:implicit-elm-package-inputs?} argument, which is primarily useful for
  7770. bootstrapping.
  7771. The @code{"dependencies"} and @code{"test-dependencies"} in an Elm package's
  7772. @file{elm.json} file correspond to @code{propagated-inputs} and @code{inputs},
  7773. respectively.
  7774. Elm requires a particular structure for package names: @pxref{Elm Packages}
  7775. for more details, including utilities provided by @code{(guix build-system
  7776. elm)}.
  7777. There are currently a few noteworthy limitations to @code{elm-build-system}:
  7778. @itemize
  7779. @item
  7780. The build system is focused on @dfn{packages} in the Elm sense of the word:
  7781. Elm @dfn{projects} which declare @code{@{ "type": "package" @}} in their
  7782. @file{elm.json} files. Using @code{elm-build-system} to build Elm
  7783. @dfn{applications} (which declare @code{@{ "type": "application" @}}) is
  7784. possible, but requires ad-hoc modifications to the build phases. For
  7785. examples, see the definitions of the @code{elm-todomvc} example application and
  7786. the @code{elm} package itself (because the front-end for the
  7787. @samp{elm reactor} command is an Elm application).
  7788. @item
  7789. Elm supports multiple versions of a package coexisting simultaneously under
  7790. @env{ELM_HOME}, but this does not yet work well with @code{elm-build-system}.
  7791. This limitation primarily affects Elm applications, because they specify
  7792. exact versions for their dependencies, whereas Elm packages specify supported
  7793. version ranges. As a workaround, the example applications mentioned above use
  7794. the @code{patch-application-dependencies} procedure provided by
  7795. @code{(guix build elm-build-system)} to rewrite their @file{elm.json} files to
  7796. refer to the package versions actually present in the build environment.
  7797. Alternatively, Guix package transformations (@pxref{Defining Package
  7798. Variants}) could be used to rewrite an application's entire dependency graph.
  7799. @item
  7800. We are not yet able to run tests for Elm projects because neither
  7801. @url{https://github.com/mpizenberg/elm-test-rs, @command{elm-test-rs}} nor the
  7802. Node.js-based @url{https://github.com/rtfeldman/node-test-runner,
  7803. @command{elm-test}} runner has been packaged for Guix yet.
  7804. @end itemize
  7805. @end defvar
  7806. @defvar go-build-system
  7807. This variable is exported by @code{(guix build-system go)}. It
  7808. implements a build procedure for Go packages using the standard
  7809. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  7810. Go build mechanisms}.
  7811. The user is expected to provide a value for the key @code{#:import-path}
  7812. and, in some cases, @code{#:unpack-path}. The
  7813. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  7814. corresponds to the file system path expected by the package's build
  7815. scripts and any referring packages, and provides a unique way to
  7816. refer to a Go package. It is typically based on a combination of the
  7817. package source code's remote URI and file system hierarchy structure. In
  7818. some cases, you will need to unpack the package's source code to a
  7819. different directory structure than the one indicated by the import path,
  7820. and @code{#:unpack-path} should be used in such cases.
  7821. Packages that provide Go libraries should install their source code into
  7822. the built output. The key @code{#:install-source?}, which defaults to
  7823. @code{#t}, controls whether or not the source code is installed. It can
  7824. be set to @code{#f} for packages that only provide executable files.
  7825. Packages can be cross-built, and if a specific architecture or operating
  7826. system is desired then the keywords @code{#:goarch} and @code{#:goos}
  7827. can be used to force the package to be built for that architecture and
  7828. operating system. The combinations known to Go can be found
  7829. @url{https://golang.org/doc/install/source#environment,
  7830. in their documentation}.
  7831. The key @code{#:go} can be used to specify the Go compiler package with
  7832. which to build the package.
  7833. @end defvar
  7834. @defvar glib-or-gtk-build-system
  7835. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  7836. is intended for use with packages making use of GLib or GTK+.
  7837. This build system adds the following two phases to the ones defined by
  7838. @code{gnu-build-system}:
  7839. @table @code
  7840. @item glib-or-gtk-wrap
  7841. The phase @code{glib-or-gtk-wrap} ensures that programs in
  7842. @file{bin/} are able to find GLib ``schemas'' and
  7843. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  7844. modules}. This is achieved by wrapping the programs in launch scripts
  7845. that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
  7846. environment variables.
  7847. It is possible to exclude specific package outputs from that wrapping
  7848. process by listing their names in the
  7849. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  7850. when an output is known not to contain any GLib or GTK+ binaries, and
  7851. where wrapping would gratuitously add a dependency of that output on
  7852. GLib and GTK+.
  7853. @item glib-or-gtk-compile-schemas
  7854. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  7855. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  7856. GSettings schemas} of GLib are compiled. Compilation is performed by the
  7857. @command{glib-compile-schemas} program. It is provided by the package
  7858. @code{glib:bin} which is automatically imported by the build system.
  7859. The @code{glib} package providing @command{glib-compile-schemas} can be
  7860. specified with the @code{#:glib} parameter.
  7861. @end table
  7862. Both phases are executed after the @code{install} phase.
  7863. @end defvar
  7864. @defvar guile-build-system
  7865. This build system is for Guile packages that consist exclusively of Scheme
  7866. code and that are so lean that they don't even have a makefile, let alone a
  7867. @file{configure} script. It compiles Scheme code using @command{guild
  7868. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  7869. installs the @file{.scm} and @file{.go} files in the right place. It also
  7870. installs documentation.
  7871. This build system supports cross-compilation by using the
  7872. @option{--target} option of @samp{guild compile}.
  7873. Packages built with @code{guile-build-system} must provide a Guile package in
  7874. their @code{native-inputs} field.
  7875. @end defvar
  7876. @defvar julia-build-system
  7877. This variable is exported by @code{(guix build-system julia)}. It
  7878. implements the build procedure used by @uref{https://julialang.org/,
  7879. julia} packages, which essentially is similar to running @samp{julia -e
  7880. 'using Pkg; Pkg.add(package)'} in an environment where
  7881. @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
  7882. Tests are run by calling @code{/test/runtests.jl}.
  7883. The Julia package name and uuid is read from the file
  7884. @file{Project.toml}. These values can be overridden by passing the
  7885. argument @code{#:julia-package-name} (which must be correctly
  7886. capitalized) or @code{#:julia-package-uuid}.
  7887. Julia packages usually manage their binary dependencies via
  7888. @code{JLLWrappers.jl}, a Julia package that creates a module (named
  7889. after the wrapped library followed by @code{_jll.jl}.
  7890. To add the binary path @code{_jll.jl} packages, you need to patch the
  7891. files under @file{src/wrappers/}, replacing the call to the macro
  7892. @code{JLLWrappers.@@generate_wrapper_header}, adding as a second
  7893. argument containing the store path the binary.
  7894. As an example, in the MbedTLS Julia package, we add a build phase
  7895. (@pxref{Build Phases}) to insert the absolute file name of the wrapped
  7896. MbedTLS package:
  7897. @lisp
  7898. (add-after 'unpack 'override-binary-path
  7899. (lambda* (#:key inputs #:allow-other-keys)
  7900. (for-each (lambda (wrapper)
  7901. (substitute* wrapper
  7902. (("generate_wrapper_header.*")
  7903. (string-append
  7904. "generate_wrapper_header(\"MbedTLS\", \""
  7905. (assoc-ref inputs "mbedtls-apache") "\")\n"))))
  7906. ;; There's a Julia file for each platform, override them all.
  7907. (find-files "src/wrappers/" "\\.jl$"))))
  7908. @end lisp
  7909. Some older packages that aren't using @file{Project.toml} yet, will
  7910. require this file to be created, too. It is internally done if the
  7911. arguments @code{#:julia-package-name} and @code{#:julia-package-uuid}
  7912. are provided.
  7913. @end defvar
  7914. @defvar maven-build-system
  7915. This variable is exported by @code{(guix build-system maven)}. It implements
  7916. a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
  7917. is a dependency and lifecycle management tool for Java. A user of Maven
  7918. specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
  7919. When Maven does not have one of the dependencies or plugins in its repository,
  7920. it will download them and use them to build the package.
  7921. The maven build system ensures that maven will not try to download any
  7922. dependency by running in offline mode. Maven will fail if a dependency is
  7923. missing. Before running Maven, the @file{pom.xml} (and subprojects) are
  7924. modified to specify the version of dependencies and plugins that match the
  7925. versions available in the guix build environment. Dependencies and plugins
  7926. must be installed in the fake maven repository at @file{lib/m2}, and are
  7927. symlinked into a proper repository before maven is run. Maven is instructed
  7928. to use that repository for the build and installs built artifacts there.
  7929. Changed files are copied to the @file{lib/m2} directory of the package output.
  7930. You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
  7931. or let the build system use the default @file{pom.xml} file in the sources.
  7932. In case you need to specify a dependency's version manually, you can use the
  7933. @code{#:local-packages} argument. It takes an association list where the key
  7934. is the groupId of the package and its value is an association list where the
  7935. key is the artifactId of the package and its value is the version you want to
  7936. override in the @file{pom.xml}.
  7937. Some packages use dependencies or plugins that are not useful at runtime nor
  7938. at build time in Guix. You can alter the @file{pom.xml} file to remove them
  7939. using the @code{#:exclude} argument. Its value is an association list where
  7940. the key is the groupId of the plugin or dependency you want to remove, and
  7941. the value is a list of artifactId you want to remove.
  7942. You can override the default @code{jdk} and @code{maven} packages with the
  7943. corresponding argument, @code{#:jdk} and @code{#:maven}.
  7944. The @code{#:maven-plugins} argument is a list of maven plugins used during
  7945. the build, with the same format as the @code{inputs} fields of the package
  7946. declaration. Its default value is @code{(default-maven-plugins)} which is
  7947. also exported.
  7948. @end defvar
  7949. @defvar minetest-mod-build-system
  7950. This variable is exported by @code{(guix build-system minetest)}. It
  7951. implements a build procedure for @uref{https://www.minetest.net, Minetest}
  7952. mods, which consists of copying Lua code, images and other resources to
  7953. the location Minetest searches for mods. The build system also minimises
  7954. PNG images and verifies that Minetest can load the mod without errors.
  7955. @end defvar
  7956. @defvar minify-build-system
  7957. This variable is exported by @code{(guix build-system minify)}. It
  7958. implements a minification procedure for simple JavaScript packages.
  7959. It adds @code{uglify-js} to the set of inputs and uses it to compress
  7960. all JavaScript files in the @file{src} directory. A different minifier
  7961. package can be specified with the @code{#:uglify-js} parameter, but it
  7962. is expected that the package writes the minified code to the standard
  7963. output.
  7964. When the input JavaScript files are not all located in the @file{src}
  7965. directory, the parameter @code{#:javascript-files} can be used to
  7966. specify a list of file names to feed to the minifier.
  7967. @end defvar
  7968. @defvar mozilla-build-system
  7969. This variable is exported by @code{(guix build-system mozilla)}. It
  7970. sets the @code{--target} and @code{--host} configuration flags to what
  7971. software developed by Mozilla expects -- due to historical reasons,
  7972. Mozilla software expects @code{--host} to be the system that is
  7973. cross-compiled from and @code{--target} to be the system that is
  7974. cross-compiled to, contrary to the standard Autotools conventions.
  7975. @end defvar
  7976. @defvar ocaml-build-system
  7977. This variable is exported by @code{(guix build-system ocaml)}. It implements
  7978. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  7979. of choosing the correct set of commands to run for each package. OCaml
  7980. packages can expect many different commands to be run. This build system will
  7981. try some of them.
  7982. When the package has a @file{setup.ml} file present at the top-level, it will
  7983. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  7984. @code{ocaml setup.ml -install}. The build system will assume that this file
  7985. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  7986. care of setting the prefix and enabling tests if they are not disabled. You
  7987. can pass configure and build flags with the @code{#:configure-flags} and
  7988. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  7989. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  7990. bypass this system in the build and install phases.
  7991. When the package has a @file{configure} file, it is assumed that it is a
  7992. hand-made configure script that requires a different argument format than
  7993. in the @code{gnu-build-system}. You can add more flags with the
  7994. @code{#:configure-flags} key.
  7995. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  7996. @code{#t}), it will be used and more flags can be passed to the build and
  7997. install phases with the @code{#:make-flags} key.
  7998. Finally, some packages do not have these files and use a somewhat standard
  7999. location for its build system. In that case, the build system will run
  8000. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  8001. providing the path to the required findlib module. Additional flags can
  8002. be passed via the @code{#:build-flags} key. Install is taken care of by
  8003. @command{opam-installer}. In this case, the @code{opam} package must
  8004. be added to the @code{native-inputs} field of the package definition.
  8005. Note that most OCaml packages assume they will be installed in the same
  8006. directory as OCaml, which is not what we want in guix. In particular, they
  8007. will install @file{.so} files in their module's directory, which is usually
  8008. fine because it is in the OCaml compiler directory. In guix though, these
  8009. libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
  8010. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  8011. @file{.so} libraries should be installed.
  8012. @end defvar
  8013. @defvar python-build-system
  8014. This variable is exported by @code{(guix build-system python)}. It
  8015. implements the more or less standard build procedure used by Python
  8016. packages, which consists in running @code{python setup.py build} and
  8017. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  8018. For packages that install stand-alone Python programs under @code{bin/},
  8019. it takes care of wrapping these programs so that their
  8020. @env{GUIX_PYTHONPATH} environment variable points to all the Python
  8021. libraries they depend on.
  8022. Which Python package is used to perform the build can be specified with
  8023. the @code{#:python} parameter. This is a useful way to force a package
  8024. to be built for a specific version of the Python interpreter, which
  8025. might be necessary if the package is only compatible with a single
  8026. interpreter version.
  8027. By default guix calls @code{setup.py} under control of
  8028. @code{setuptools}, much like @command{pip} does. Some packages are not
  8029. compatible with setuptools (and pip), thus you can disable this by
  8030. setting the @code{#:use-setuptools?} parameter to @code{#f}.
  8031. If a @code{"python"} output is available, the package is installed into it
  8032. instead of the default @code{"out"} output. This is useful for packages that
  8033. include a Python package as only a part of the software, and thus want to
  8034. combine the phases of @code{python-build-system} with another build system.
  8035. Python bindings are a common usecase.
  8036. @end defvar
  8037. @defvar pyproject-build-system
  8038. This is a variable exported by @code{guix build-system pyproject}. It
  8039. is based on @var{python-build-system}, and adds support for
  8040. @file{pyproject.toml} and @url{https://peps.python.org/pep-0517/, PEP 517}.
  8041. It also supports a variety of build backends and test frameworks.
  8042. The API is slightly different from @var{python-build-system}:
  8043. @itemize
  8044. @item
  8045. @code{#:use-setuptools?} and @code{#:test-target} is removed.
  8046. @item
  8047. @code{#:build-backend} is added. It defaults to @code{#false} and will try
  8048. to guess the appropriate backend based on @file{pyproject.toml}.
  8049. @item
  8050. @code{#:test-backend} is added. It defaults to @code{#false} and will guess
  8051. an appropriate test backend based on what is available in package inputs.
  8052. @item
  8053. @code{#:test-flags} is added. The default is @code{'()}. These flags are
  8054. passed as arguments to the test command. Note that flags for verbose output
  8055. is always enabled on supported backends.
  8056. @end itemize
  8057. It is considered ``experimental'' in that the implementation details are
  8058. not set in stone yet, however users are encouraged to try it for new
  8059. Python projects (even those using @file{setup.py}). The API is subject to
  8060. change, but any breaking changes in the Guix channel will be dealt with.
  8061. Eventually this build system will be deprecated and merged back into
  8062. @var{python-build-system}, probably some time in 2024.
  8063. @end defvar
  8064. @defvar perl-build-system
  8065. This variable is exported by @code{(guix build-system perl)}. It
  8066. implements the standard build procedure for Perl packages, which either
  8067. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  8068. followed by @code{Build} and @code{Build install}; or in running
  8069. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  8070. @code{make} and @code{make install}, depending on which of
  8071. @code{Build.PL} or @code{Makefile.PL} is present in the package
  8072. distribution. Preference is given to the former if both @code{Build.PL}
  8073. and @code{Makefile.PL} exist in the package distribution. This
  8074. preference can be reversed by specifying @code{#t} for the
  8075. @code{#:make-maker?} parameter.
  8076. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  8077. passes flags specified by the @code{#:make-maker-flags} or
  8078. @code{#:module-build-flags} parameter, respectively.
  8079. Which Perl package is used can be specified with @code{#:perl}.
  8080. @end defvar
  8081. @defvar renpy-build-system
  8082. This variable is exported by @code{(guix build-system renpy)}. It implements
  8083. the more or less standard build procedure used by Ren'py games, which consists
  8084. of loading @code{#:game} once, thereby creating bytecode for it.
  8085. It further creates a wrapper script in @code{bin/} and a desktop entry in
  8086. @code{share/applications}, both of which can be used to launch the game.
  8087. Which Ren'py package is used can be specified with @code{#:renpy}.
  8088. Games can also be installed in outputs other than ``out'' by using
  8089. @code{#:output}.
  8090. @end defvar
  8091. @defvar qt-build-system
  8092. This variable is exported by @code{(guix build-system qt)}. It
  8093. is intended for use with applications using Qt or KDE.
  8094. This build system adds the following two phases to the ones defined by
  8095. @code{cmake-build-system}:
  8096. @table @code
  8097. @item check-setup
  8098. The phase @code{check-setup} prepares the environment for running
  8099. the checks as commonly used by Qt test programs.
  8100. For now this only sets some environment variables:
  8101. @code{QT_QPA_PLATFORM=offscreen},
  8102. @code{DBUS_FATAL_WARNINGS=0} and
  8103. @code{CTEST_OUTPUT_ON_FAILURE=1}.
  8104. This phase is added before the @code{check} phase.
  8105. It's a separate phase to ease adjusting if necessary.
  8106. @item qt-wrap
  8107. The phase @code{qt-wrap}
  8108. searches for Qt5 plugin paths, QML paths and some XDG in the inputs
  8109. and output. In case some path is found, all programs in the output's
  8110. @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
  8111. are wrapped in scripts defining the necessary environment variables.
  8112. It is possible to exclude specific package outputs from that wrapping process
  8113. by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
  8114. This is useful when an output is known not to contain any Qt binaries, and
  8115. where wrapping would gratuitously add a dependency of that output on Qt, KDE,
  8116. or such.
  8117. This phase is added after the @code{install} phase.
  8118. @end table
  8119. @end defvar
  8120. @defvar r-build-system
  8121. This variable is exported by @code{(guix build-system r)}. It
  8122. implements the build procedure used by @uref{https://r-project.org, R}
  8123. packages, which essentially is little more than running @samp{R CMD
  8124. INSTALL --library=/gnu/store/@dots{}} in an environment where
  8125. @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
  8126. run after installation using the R function
  8127. @code{tools::testInstalledPackage}.
  8128. @end defvar
  8129. @defvar rakudo-build-system
  8130. This variable is exported by @code{(guix build-system rakudo)}. It
  8131. implements the build procedure used by @uref{https://rakudo.org/,
  8132. Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
  8133. package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
  8134. installs the binaries, library files and the resources, as well as wrap
  8135. the files under the @code{bin/} directory. Tests can be skipped by
  8136. passing @code{#f} to the @code{tests?} parameter.
  8137. Which rakudo package is used can be specified with @code{rakudo}.
  8138. Which perl6-tap-harness package used for the tests can be specified with
  8139. @code{#:prove6} or removed by passing @code{#f} to the
  8140. @code{with-prove6?} parameter.
  8141. Which perl6-zef package used for tests and installing can be specified
  8142. with @code{#:zef} or removed by passing @code{#f} to the
  8143. @code{with-zef?} parameter.
  8144. @end defvar
  8145. @defvar rebar-build-system
  8146. This variable is exported by @code{(guix build-system rebar)}. It
  8147. implements a build procedure around @uref{https://rebar3.org,rebar3},
  8148. a build system for programs written in the Erlang language.
  8149. It adds both @code{rebar3} and the @code{erlang} to the set of inputs.
  8150. Different packages can be specified with the @code{#:rebar} and
  8151. @code{#:erlang} parameters, respectively.
  8152. This build system is based on @code{gnu-build-system}, but with the
  8153. following phases changed:
  8154. @table @code
  8155. @item unpack
  8156. This phase, after unpacking the source like the @code{gnu-build-system}
  8157. does, checks for a file @code{contents.tar.gz} at the top-level of the
  8158. source. If this file exists, it will be unpacked, too. This eases
  8159. handling of package hosted at @uref{https://hex.pm/},
  8160. the Erlang and Elixir package repository.
  8161. @item bootstrap
  8162. @item configure
  8163. There are no @code{bootstrap} and @code{configure} phase because erlang
  8164. packages typically don’t need to be configured.
  8165. @item build
  8166. This phase runs @code{rebar3 compile}
  8167. with the flags listed in @code{#:rebar-flags}.
  8168. @item check
  8169. Unless @code{#:tests? #f} is passed,
  8170. this phase runs @code{rebar3 eunit},
  8171. or some other target specified with @code{#:test-target},
  8172. with the flags listed in @code{#:rebar-flags},
  8173. @item install
  8174. This installs the files created in the @i{default} profile, or some
  8175. other profile specified with @code{#:install-profile}.
  8176. @end table
  8177. @end defvar
  8178. @defvar texlive-build-system
  8179. This variable is exported by @code{(guix build-system texlive)}. It is
  8180. used to build TeX packages in batch mode with a specified engine. The
  8181. build system sets the @env{TEXINPUTS} variable to find all TeX source
  8182. files in the inputs.
  8183. By default it tries to run @code{luatex} on all @file{.ins} files, and
  8184. if it fails to find any, on all @file{.dtx} files. A different engine
  8185. and format can be specified with, respectively, the @code{#:tex-engine}
  8186. and @code{#:tex-format} arguments. Different build targets can be
  8187. specified with the @code{#:build-targets} argument, which expects a list
  8188. of file names.
  8189. It also generates font metrics (i.e., @file{.tfm} files) out of Metafont
  8190. files whenever possible. Likewise, it can also create TeX formats
  8191. (i.e., @file{.fmt} files) listed in the @code{#:create-formats}
  8192. argument, and generate a symbolic link from @file{bin/} directory to any
  8193. script located in located in @file{texmf-dist/scripts/}, provided its
  8194. file name is listed in @code{#:link-scripts} argument.
  8195. The build system adds @code{texlive-bin} from @code{(gnu packages tex)}
  8196. to the native inputs. It can be overridden with the
  8197. @code{#:texlive-bin} argument.
  8198. The package @code{texlive-latex-bin}, from the same module, contains
  8199. most of the tools for building TeX Live packages; for convenience, it is
  8200. also added by default to the native inputs. However, this can be
  8201. troublesome when building a dependency of @code{texlive-latex-bin}
  8202. itself. In this particular situation, the @code{#:texlive-latex-bin?}
  8203. argument should be set to @code{#f}.
  8204. @end defvar
  8205. @defvar ruby-build-system
  8206. This variable is exported by @code{(guix build-system ruby)}. It
  8207. implements the RubyGems build procedure used by Ruby packages, which
  8208. involves running @code{gem build} followed by @code{gem install}.
  8209. The @code{source} field of a package that uses this build system
  8210. typically references a gem archive, since this is the format that Ruby
  8211. developers use when releasing their software. The build system unpacks
  8212. the gem archive, potentially patches the source, runs the test suite,
  8213. repackages the gem, and installs it. Additionally, directories and
  8214. tarballs may be referenced to allow building unreleased gems from Git or
  8215. a traditional source release tarball.
  8216. Which Ruby package is used can be specified with the @code{#:ruby}
  8217. parameter. A list of additional flags to be passed to the @command{gem}
  8218. command can be specified with the @code{#:gem-flags} parameter.
  8219. @end defvar
  8220. @defvar waf-build-system
  8221. This variable is exported by @code{(guix build-system waf)}. It
  8222. implements a build procedure around the @code{waf} script. The common
  8223. phases---@code{configure}, @code{build}, and @code{install}---are
  8224. implemented by passing their names as arguments to the @code{waf}
  8225. script.
  8226. The @code{waf} script is executed by the Python interpreter. Which
  8227. Python package is used to run the script can be specified with the
  8228. @code{#:python} parameter.
  8229. @end defvar
  8230. @defvar scons-build-system
  8231. This variable is exported by @code{(guix build-system scons)}. It
  8232. implements the build procedure used by the SCons software construction
  8233. tool. This build system runs @code{scons} to build the package,
  8234. @code{scons test} to run tests, and then @code{scons install} to install
  8235. the package.
  8236. Additional flags to be passed to @code{scons} can be specified with the
  8237. @code{#:scons-flags} parameter. The default build and install targets
  8238. can be overridden with @code{#:build-targets} and
  8239. @code{#:install-targets} respectively. The version of Python used to
  8240. run SCons can be specified by selecting the appropriate SCons package
  8241. with the @code{#:scons} parameter.
  8242. @end defvar
  8243. @defvar haskell-build-system
  8244. This variable is exported by @code{(guix build-system haskell)}. It
  8245. implements the Cabal build procedure used by Haskell packages, which
  8246. involves running @code{runhaskell Setup.hs configure
  8247. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  8248. Instead of installing the package by running @code{runhaskell Setup.hs
  8249. install}, to avoid trying to register libraries in the read-only
  8250. compiler store directory, the build system uses @code{runhaskell
  8251. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  8252. addition, the build system generates the package documentation by
  8253. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  8254. is passed. Optional Haddock parameters can be passed with the help of
  8255. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  8256. not found, the build system looks for @code{Setup.lhs} instead.
  8257. Which Haskell compiler is used can be specified with the @code{#:haskell}
  8258. parameter which defaults to @code{ghc}.
  8259. @end defvar
  8260. @defvar dub-build-system
  8261. This variable is exported by @code{(guix build-system dub)}. It
  8262. implements the Dub build procedure used by D packages, which
  8263. involves running @code{dub build} and @code{dub run}.
  8264. Installation is done by copying the files manually.
  8265. Which D compiler is used can be specified with the @code{#:ldc}
  8266. parameter which defaults to @code{ldc}.
  8267. @end defvar
  8268. @anchor{emacs-build-system}
  8269. @defvar emacs-build-system
  8270. This variable is exported by @code{(guix build-system emacs)}. It
  8271. implements an installation procedure similar to the packaging system
  8272. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  8273. It first creates the @code{@code{package}-autoloads.el} file, then it
  8274. byte compiles all Emacs Lisp files. Differently from the Emacs
  8275. packaging system, the Info documentation files are moved to the standard
  8276. documentation directory and the @file{dir} file is deleted. The Elisp
  8277. package files are installed directly under @file{share/emacs/site-lisp}.
  8278. @end defvar
  8279. @defvar font-build-system
  8280. This variable is exported by @code{(guix build-system font)}. It
  8281. implements an installation procedure for font packages where upstream
  8282. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  8283. need to be copied into place. It copies font files to standard
  8284. locations in the output directory.
  8285. @end defvar
  8286. @defvar meson-build-system
  8287. This variable is exported by @code{(guix build-system meson)}. It
  8288. implements the build procedure for packages that use
  8289. @url{https://mesonbuild.com, Meson} as their build system.
  8290. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  8291. of inputs, and they can be changed with the parameters @code{#:meson}
  8292. and @code{#:ninja} if needed.
  8293. This build system is an extension of @code{gnu-build-system}, but with the
  8294. following phases changed to some specific for Meson:
  8295. @table @code
  8296. @item configure
  8297. The phase runs @code{meson} with the flags specified in
  8298. @code{#:configure-flags}. The flag @option{--buildtype} is always set to
  8299. @code{debugoptimized} unless something else is specified in
  8300. @code{#:build-type}.
  8301. @item build
  8302. The phase runs @code{ninja} to build the package in parallel by default, but
  8303. this can be changed with @code{#:parallel-build?}.
  8304. @item check
  8305. The phase runs @samp{meson test} with a base set of options that cannot
  8306. be overridden. This base set of options can be extended via the
  8307. @code{#:test-options} argument, for example to select or skip a specific
  8308. test suite.
  8309. @item install
  8310. The phase runs @code{ninja install} and can not be changed.
  8311. @end table
  8312. Apart from that, the build system also adds the following phases:
  8313. @table @code
  8314. @item fix-runpath
  8315. This phase ensures that all binaries can find the libraries they need.
  8316. It searches for required libraries in subdirectories of the package
  8317. being built, and adds those to @code{RUNPATH} where needed. It also
  8318. removes references to libraries left over from the build phase by
  8319. @code{meson}, such as test dependencies, that aren't actually required
  8320. for the program to run.
  8321. @item glib-or-gtk-wrap
  8322. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  8323. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  8324. @item glib-or-gtk-compile-schemas
  8325. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  8326. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  8327. @end table
  8328. @end defvar
  8329. @defvar linux-module-build-system
  8330. @code{linux-module-build-system} allows building Linux kernel modules.
  8331. @cindex build phases
  8332. This build system is an extension of @code{gnu-build-system}, but with the
  8333. following phases changed:
  8334. @table @code
  8335. @item configure
  8336. This phase configures the environment so that the Linux kernel's Makefile
  8337. can be used to build the external kernel module.
  8338. @item build
  8339. This phase uses the Linux kernel's Makefile in order to build the external
  8340. kernel module.
  8341. @item install
  8342. This phase uses the Linux kernel's Makefile in order to install the external
  8343. kernel module.
  8344. @end table
  8345. It is possible and useful to specify the Linux kernel to use for building
  8346. the module (in the @code{arguments} form of a package using the
  8347. @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
  8348. @end defvar
  8349. @defvar node-build-system
  8350. This variable is exported by @code{(guix build-system node)}. It
  8351. implements the build procedure used by @uref{https://nodejs.org,
  8352. Node.js}, which implements an approximation of the @code{npm install}
  8353. command, followed by an @code{npm test} command.
  8354. Which Node.js package is used to interpret the @code{npm} commands can
  8355. be specified with the @code{#:node} parameter which defaults to
  8356. @code{node}.
  8357. @end defvar
  8358. @defvar tree-sitter-build-system
  8359. This variable is exported by @code{(guix build-system tree-sitter)}. It
  8360. implements procedures to compile grammars for the
  8361. @url{https://tree-sitter.github.io/tree-sitter/, Tree-sitter} parsing
  8362. library. It essentially runs @code{tree-sitter generate} to translate
  8363. @code{grammar.js} grammars to JSON and then to C. Which it then
  8364. compiles to native code.
  8365. Tree-sitter packages may support multiple grammars, so this build system
  8366. supports a @code{#:grammar-directories} keyword to specify a list of
  8367. locations where a @code{grammar.js} file may be found.
  8368. Grammars sometimes depend on each other, such as C++ depending on C and
  8369. TypeScript depending on JavaScript. You may use inputs to declare such
  8370. dependencies.
  8371. @end defvar
  8372. Lastly, for packages that do not need anything as sophisticated, a
  8373. ``trivial'' build system is provided. It is trivial in the sense that
  8374. it provides basically no support: it does not pull any implicit inputs,
  8375. and does not have a notion of build phases.
  8376. @defvar trivial-build-system
  8377. This variable is exported by @code{(guix build-system trivial)}.
  8378. This build system requires a @code{#:builder} argument. This argument
  8379. must be a Scheme expression that builds the package output(s)---as
  8380. with @code{build-expression->derivation} (@pxref{Derivations,
  8381. @code{build-expression->derivation}}).
  8382. @end defvar
  8383. @defvar channel-build-system
  8384. This variable is exported by @code{(guix build-system channel)}.
  8385. This build system is meant primarily for internal use. A package using
  8386. this build system must have a channel specification as its @code{source}
  8387. field (@pxref{Channels}); alternatively, its source can be a directory
  8388. name, in which case an additional @code{#:commit} argument must be
  8389. supplied to specify the commit being built (a hexadecimal string).
  8390. The resulting package is a Guix instance of the given channel, similar
  8391. to how @command{guix time-machine} would build it.
  8392. @end defvar
  8393. @node Build Phases
  8394. @section Build Phases
  8395. @cindex build phases, for packages
  8396. Almost all package build systems implement a notion @dfn{build phases}:
  8397. a sequence of actions that the build system executes, when you build the
  8398. package, leading to the installed byproducts in the store. A notable
  8399. exception is the ``bare-bones'' @code{trivial-build-system}
  8400. (@pxref{Build Systems}).
  8401. As discussed in the previous section, those build systems provide a
  8402. standard list of phases. For @code{gnu-build-system}, the main build
  8403. phases are the following:
  8404. @table @code
  8405. @item set-paths
  8406. Define search path environment variables for all the input packages,
  8407. including @env{PATH} (@pxref{Search Paths}).
  8408. @item unpack
  8409. Unpack the source tarball, and change the current directory to the
  8410. extracted source tree. If the source is actually a directory, copy it
  8411. to the build tree, and enter that directory.
  8412. @item patch-source-shebangs
  8413. Patch shebangs encountered in source files so they refer to the right
  8414. store file names. For instance, this changes @code{#!/bin/sh} to
  8415. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  8416. @item configure
  8417. Run the @file{configure} script with a number of default options, such
  8418. as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
  8419. by the @code{#:configure-flags} argument.
  8420. @item build
  8421. Run @code{make} with the list of flags specified with
  8422. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  8423. (the default), build with @code{make -j}.
  8424. @item check
  8425. Run @code{make check}, or some other target specified with
  8426. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  8427. @code{#:parallel-tests?} argument is true (the default), run @code{make
  8428. check -j}.
  8429. @item install
  8430. Run @code{make install} with the flags listed in @code{#:make-flags}.
  8431. @item patch-shebangs
  8432. Patch shebangs on the installed executable files.
  8433. @item strip
  8434. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  8435. is false), copying them to the @code{debug} output when available
  8436. (@pxref{Installing Debugging Files}).
  8437. @cindex RUNPATH, validation
  8438. @anchor{phase-validate-runpath}
  8439. @item validate-runpath
  8440. Validate the @code{RUNPATH} of ELF binaries, unless
  8441. @code{#:validate-runpath?} is false (@pxref{Build Systems}).
  8442. This validation step consists in making sure that all the shared
  8443. libraries needed by an ELF binary, which are listed as @code{DT_NEEDED}
  8444. entries in its @code{PT_DYNAMIC} segment, appear in the
  8445. @code{DT_RUNPATH} entry of that binary. In other words, it ensures that
  8446. running or using those binaries will not result in a ``file not found''
  8447. error at run time. @xref{Options, @option{-rpath},, ld, The GNU
  8448. Linker}, for more information on @code{RUNPATH}.
  8449. @end table
  8450. Other build systems have similar phases, with some variations. For
  8451. example, @code{cmake-build-system} has same-named phases but its
  8452. @code{configure} phases runs @code{cmake} instead of @code{./configure}.
  8453. Others, such as @code{python-build-system}, have a wholly different list
  8454. of standard phases. All this code runs on the @dfn{build side}: it is
  8455. evaluated when you actually build the package, in a dedicated build
  8456. process spawned by the build daemon (@pxref{Invoking guix-daemon}).
  8457. Build phases are represented as association lists or ``alists''
  8458. (@pxref{Association Lists,,, guile, GNU Guile Reference Manual}) where
  8459. each key is a symbol for the name of the phase and the associated value
  8460. is a procedure that accepts an arbitrary number of arguments. By
  8461. convention, those procedures receive information about the build in the
  8462. form of @dfn{keyword parameters}, which they can use or ignore.
  8463. @vindex %standard-phases
  8464. For example, here is how @code{(guix build gnu-build-system)} defines
  8465. @code{%standard-phases}, the variable holding its alist of build
  8466. phases@footnote{We present a simplified view of those build phases, but
  8467. do take a look at @code{(guix build gnu-build-system)} to see all the
  8468. details!}:
  8469. @lisp
  8470. ;; The build phases of 'gnu-build-system'.
  8471. (define* (unpack #:key source #:allow-other-keys)
  8472. ;; Extract the source tarball.
  8473. (invoke "tar" "xvf" source))
  8474. (define* (configure #:key outputs #:allow-other-keys)
  8475. ;; Run the 'configure' script. Install to output "out".
  8476. (let ((out (assoc-ref outputs "out")))
  8477. (invoke "./configure"
  8478. (string-append "--prefix=" out))))
  8479. (define* (build #:allow-other-keys)
  8480. ;; Compile.
  8481. (invoke "make"))
  8482. (define* (check #:key (test-target "check") (tests? #true)
  8483. #:allow-other-keys)
  8484. ;; Run the test suite.
  8485. (if tests?
  8486. (invoke "make" test-target)
  8487. (display "test suite not run\n")))
  8488. (define* (install #:allow-other-keys)
  8489. ;; Install files to the prefix 'configure' specified.
  8490. (invoke "make" "install"))
  8491. (define %standard-phases
  8492. ;; The list of standard phases (quite a few are omitted
  8493. ;; for brevity). Each element is a symbol/procedure pair.
  8494. (list (cons 'unpack unpack)
  8495. (cons 'configure configure)
  8496. (cons 'build build)
  8497. (cons 'check check)
  8498. (cons 'install install)))
  8499. @end lisp
  8500. This shows how @code{%standard-phases} is defined as a list of
  8501. symbol/procedure pairs (@pxref{Pairs,,, guile, GNU Guile Reference
  8502. Manual}). The first pair associates the @code{unpack} procedure with
  8503. the @code{unpack} symbol---a name; the second pair defines the
  8504. @code{configure} phase similarly, and so on. When building a package
  8505. that uses @code{gnu-build-system} with its default list of phases, those
  8506. phases are executed sequentially. You can see the name of each phase
  8507. started and completed in the build log of packages that you build.
  8508. Let's now look at the procedures themselves. Each one is defined with
  8509. @code{define*}: @code{#:key} lists keyword parameters the procedure
  8510. accepts, possibly with a default value, and @code{#:allow-other-keys}
  8511. specifies that other keyword parameters are ignored (@pxref{Optional
  8512. Arguments,,, guile, GNU Guile Reference Manual}).
  8513. The @code{unpack} procedure honors the @code{source} parameter, which
  8514. the build system uses to pass the file name of the source tarball (or
  8515. version control checkout), and it ignores other parameters. The
  8516. @code{configure} phase only cares about the @code{outputs} parameter, an
  8517. alist mapping package output names to their store file name
  8518. (@pxref{Packages with Multiple Outputs}). It extracts the file name of
  8519. for @code{out}, the default output, and passes it to
  8520. @command{./configure} as the installation prefix, meaning that
  8521. @command{make install} will eventually copy all the files in that
  8522. directory (@pxref{Configuration, configuration and makefile
  8523. conventions,, standards, GNU Coding Standards}). @code{build} and
  8524. @code{install} ignore all their arguments. @code{check} honors the
  8525. @code{test-target} argument, which specifies the name of the Makefile
  8526. target to run tests; it prints a message and skips tests when
  8527. @code{tests?} is false.
  8528. @cindex build phases, customizing
  8529. The list of phases used for a particular package can be changed with the
  8530. @code{#:phases} parameter of the build system. Changing the set of
  8531. build phases boils down to building a new alist of phases based on the
  8532. @code{%standard-phases} alist described above. This can be done with
  8533. standard alist procedures such as @code{alist-delete} (@pxref{SRFI-1
  8534. Association Lists,,, guile, GNU Guile Reference Manual}); however, it is
  8535. more convenient to do so with @code{modify-phases} (@pxref{Build
  8536. Utilities, @code{modify-phases}}).
  8537. Here is an example of a package definition that removes the
  8538. @code{configure} phase of @code{%standard-phases} and inserts a new
  8539. phase before the @code{build} phase, called
  8540. @code{set-prefix-in-makefile}:
  8541. @lisp
  8542. (define-public example
  8543. (package
  8544. (name "example")
  8545. ;; other fields omitted
  8546. (build-system gnu-build-system)
  8547. (arguments
  8548. (list
  8549. #:phases
  8550. #~(modify-phases %standard-phases
  8551. (delete 'configure)
  8552. (add-before 'build 'set-prefix-in-makefile
  8553. (lambda* (#:key inputs #:allow-other-keys)
  8554. ;; Modify the makefile so that its
  8555. ;; 'PREFIX' variable points to #$output and
  8556. ;; 'XMLLINT' points to the correct path.
  8557. (substitute* "Makefile"
  8558. (("PREFIX =.*")
  8559. (string-append "PREFIX = " #$output "\n"))
  8560. (("XMLLINT =.*")
  8561. (string-append "XMLLINT = "
  8562. (search-input-file inputs "/bin/xmllint")
  8563. "\n"))))))))))
  8564. @end lisp
  8565. The new phase that is inserted is written as an anonymous procedure,
  8566. introduced with @code{lambda*}; it looks for the @file{xmllint}
  8567. executable under a @file{/bin} directory among the package's inputs
  8568. (@pxref{package Reference}). It also honors the @code{outputs} parameter
  8569. we have seen before. @xref{Build Utilities}, for more about
  8570. the helpers used by this phase, and for more examples of
  8571. @code{modify-phases}.
  8572. @cindex code staging
  8573. @cindex staging, of code
  8574. Keep in mind that build phases are code evaluated at the time the
  8575. package is actually built. This explains why the whole
  8576. @code{modify-phases} expression above is quoted (it comes after the
  8577. @code{'} or apostrophe): it is @dfn{staged} for later execution.
  8578. @xref{G-Expressions}, for an explanation of code staging and the
  8579. @dfn{code strata} involved.
  8580. @node Build Utilities
  8581. @section Build Utilities
  8582. As soon as you start writing non-trivial package definitions
  8583. (@pxref{Defining Packages}) or other build actions
  8584. (@pxref{G-Expressions}), you will likely start looking for helpers for
  8585. ``shell-like'' actions---creating directories, copying and deleting
  8586. files recursively, manipulating build phases, and so on. The
  8587. @code{(guix build utils)} module provides such utility procedures.
  8588. Most build systems load @code{(guix build utils)} (@pxref{Build
  8589. Systems}). Thus, when writing custom build phases for your package
  8590. definitions, you can usually assume those procedures are in scope.
  8591. When writing G-expressions, you can import @code{(guix build utils)} on
  8592. the ``build side'' using @code{with-imported-modules} and then put it in
  8593. scope with the @code{use-modules} form (@pxref{Using Guile Modules,,,
  8594. guile, GNU Guile Reference Manual}):
  8595. @lisp
  8596. (with-imported-modules '((guix build utils)) ;import it
  8597. (computed-file "empty-tree"
  8598. #~(begin
  8599. ;; Put it in scope.
  8600. (use-modules (guix build utils))
  8601. ;; Happily use its 'mkdir-p' procedure.
  8602. (mkdir-p (string-append #$output "/a/b/c")))))
  8603. @end lisp
  8604. The remainder of this section is the reference for most of the utility
  8605. procedures provided by @code{(guix build utils)}.
  8606. @c TODO Document what's missing.
  8607. @subsection Dealing with Store File Names
  8608. This section documents procedures that deal with store file names.
  8609. @deffn {Procedure} %store-directory
  8610. Return the directory name of the store.
  8611. @end deffn
  8612. @deffn {Procedure} store-file-name? file
  8613. Return true if @var{file} is in the store.
  8614. @end deffn
  8615. @deffn {Procedure} strip-store-file-name file
  8616. Strip the @file{/gnu/store} and hash from @var{file}, a store file name.
  8617. The result is typically a @code{"@var{package}-@var{version}"} string.
  8618. @end deffn
  8619. @deffn {Procedure} package-name->name+version name
  8620. Given @var{name}, a package name like @code{"foo-0.9.1b"}, return two
  8621. values: @code{"foo"} and @code{"0.9.1b"}. When the version part is
  8622. unavailable, @var{name} and @code{#f} are returned. The first hyphen
  8623. followed by a digit is considered to introduce the version part.
  8624. @end deffn
  8625. @subsection File Types
  8626. The procedures below deal with files and file types.
  8627. @deffn {Procedure} directory-exists? dir
  8628. Return @code{#t} if @var{dir} exists and is a directory.
  8629. @end deffn
  8630. @deffn {Procedure} executable-file? file
  8631. Return @code{#t} if @var{file} exists and is executable.
  8632. @end deffn
  8633. @deffn {Procedure} symbolic-link? file
  8634. Return @code{#t} if @var{file} is a symbolic link (aka. a ``symlink'').
  8635. @end deffn
  8636. @deffn {Procedure} elf-file? file
  8637. @deffnx {Procedure} ar-file? file
  8638. @deffnx {Procedure} gzip-file? file
  8639. Return @code{#t} if @var{file} is, respectively, an ELF file, an
  8640. @code{ar} archive (such as a @file{.a} static library), or a gzip file.
  8641. @end deffn
  8642. @deffn {Procedure} reset-gzip-timestamp file [#:keep-mtime? #t]
  8643. If @var{file} is a gzip file, reset its embedded timestamp (as with
  8644. @command{gzip --no-name}) and return true. Otherwise return @code{#f}.
  8645. When @var{keep-mtime?} is true, preserve @var{file}'s modification time.
  8646. @end deffn
  8647. @subsection File Manipulation
  8648. The following procedures and macros help create, modify, and delete
  8649. files. They provide functionality comparable to common shell utilities
  8650. such as @command{mkdir -p}, @command{cp -r}, @command{rm -r}, and
  8651. @command{sed}. They complement Guile's extensive, but low-level, file
  8652. system interface (@pxref{POSIX,,, guile, GNU Guile Reference Manual}).
  8653. @defmac with-directory-excursion directory body @dots{}
  8654. Run @var{body} with @var{directory} as the process's current directory.
  8655. Essentially, this macro changes the current directory to @var{directory}
  8656. before evaluating @var{body}, using @code{chdir} (@pxref{Processes,,,
  8657. guile, GNU Guile Reference Manual}). It changes back to the initial
  8658. directory when the dynamic extent of @var{body} is left, be it @i{via}
  8659. normal procedure return or @i{via} a non-local exit such as an
  8660. exception.
  8661. @end defmac
  8662. @deffn {Procedure} mkdir-p dir
  8663. Create directory @var{dir} and all its ancestors.
  8664. @end deffn
  8665. @deffn {Procedure} install-file file directory
  8666. Create @var{directory} if it does not exist and copy @var{file} in there
  8667. under the same name.
  8668. @end deffn
  8669. @deffn {Procedure} make-file-writable file
  8670. Make @var{file} writable for its owner.
  8671. @end deffn
  8672. @deffn {Procedure} copy-recursively source destination @
  8673. [#:log (current-output-port)] [#:follow-symlinks? #f] @
  8674. [#:copy-file copy-file] [#:keep-mtime? #f] [#:keep-permissions? #t]
  8675. Copy @var{source} directory to @var{destination}. Follow symlinks if
  8676. @var{follow-symlinks?} is true; otherwise, just preserve them. Call
  8677. @var{copy-file} to copy regular files. When @var{keep-mtime?} is true,
  8678. keep the modification time of the files in @var{source} on those of
  8679. @var{destination}. When @var{keep-permissions?} is true, preserve file
  8680. permissions. Write verbose output to the @var{log} port.
  8681. @end deffn
  8682. @deffn {Procedure} delete-file-recursively dir [#:follow-mounts? #f]
  8683. Delete @var{dir} recursively, like @command{rm -rf}, without following
  8684. symlinks. Don't follow mount points either, unless @var{follow-mounts?}
  8685. is true. Report but ignore errors.
  8686. @end deffn
  8687. @defmac substitute* file @
  8688. ((regexp match-var@dots{}) body@dots{}) @dots{}
  8689. Substitute @var{regexp} in @var{file} by the string returned by
  8690. @var{body}. @var{body} is evaluated with each @var{match-var} bound to
  8691. the corresponding positional regexp sub-expression. For example:
  8692. @lisp
  8693. (substitute* file
  8694. (("hello")
  8695. "good morning\n")
  8696. (("foo([a-z]+)bar(.*)$" all letters end)
  8697. (string-append "baz" letters end)))
  8698. @end lisp
  8699. Here, anytime a line of @var{file} contains @code{hello}, it is replaced
  8700. by @code{good morning}. Anytime a line of @var{file} matches the second
  8701. regexp, @code{all} is bound to the complete match, @code{letters} is bound
  8702. to the first sub-expression, and @code{end} is bound to the last one.
  8703. When one of the @var{match-var} is @code{_}, no variable is bound to the
  8704. corresponding match substring.
  8705. Alternatively, @var{file} may be a list of file names, in which case
  8706. they are all subject to the substitutions.
  8707. Be careful about using @code{$} to match the end of a line; by itself it
  8708. won't match the terminating newline of a line. For example, to match a
  8709. whole line ending with a backslash, one needs a regex like
  8710. @code{"(.*)\\\\\n$"}.
  8711. @end defmac
  8712. @subsection File Search
  8713. @cindex file, searching
  8714. This section documents procedures to search and filter files.
  8715. @deffn {Procedure} file-name-predicate regexp
  8716. Return a predicate that returns true when passed a file name whose base
  8717. name matches @var{regexp}.
  8718. @end deffn
  8719. @deffn {Procedure} find-files dir [pred] @
  8720. [#:stat lstat] [#:directories? #f] [#:fail-on-error? #f]
  8721. Return the lexicographically sorted list of files under @var{dir} for
  8722. which @var{pred} returns true. @var{pred} is passed two arguments: the
  8723. absolute file name, and its stat buffer; the default predicate always
  8724. returns true. @var{pred} can also be a regular expression, in which
  8725. case it is equivalent to @code{(file-name-predicate @var{pred})}.
  8726. @var{stat} is used to obtain file information; using @code{lstat} means
  8727. that symlinks are not followed. If @var{directories?} is true, then
  8728. directories will also be included. If @var{fail-on-error?} is true,
  8729. raise an exception upon error.
  8730. @end deffn
  8731. Here are a few examples where we assume that the current directory is
  8732. the root of the Guix source tree:
  8733. @lisp
  8734. ;; List all the regular files in the current directory.
  8735. (find-files ".")
  8736. @result{} ("./.dir-locals.el" "./.gitignore" @dots{})
  8737. ;; List all the .scm files under gnu/services.
  8738. (find-files "gnu/services" "\\.scm$")
  8739. @result{} ("gnu/services/admin.scm" "gnu/services/audio.scm" @dots{})
  8740. ;; List ar files in the current directory.
  8741. (find-files "." (lambda (file stat) (ar-file? file)))
  8742. @result{} ("./libformat.a" "./libstore.a" @dots{})
  8743. @end lisp
  8744. @deffn {Procedure} which program
  8745. Return the complete file name for @var{program} as found in
  8746. @code{$PATH}, or @code{#f} if @var{program} could not be found.
  8747. @end deffn
  8748. @deffn {Procedure} search-input-file inputs name
  8749. @deffnx {Procedure} search-input-directory inputs name
  8750. Return the complete file name for @var{name} as found in @var{inputs};
  8751. @code{search-input-file} searches for a regular file and
  8752. @code{search-input-directory} searches for a directory. If @var{name}
  8753. could not be found, an exception is raised.
  8754. Here, @var{inputs} must be an association list like @code{inputs} and
  8755. @code{native-inputs} as available to build phases (@pxref{Build
  8756. Phases}).
  8757. @end deffn
  8758. Here is a (simplified) example of how @code{search-input-file} is used
  8759. in a build phase of the @code{wireguard-tools} package:
  8760. @lisp
  8761. (add-after 'install 'wrap-wg-quick
  8762. (lambda* (#:key inputs outputs #:allow-other-keys)
  8763. (let ((coreutils (string-append (assoc-ref inputs "coreutils")
  8764. "/bin")))
  8765. (wrap-program (search-input-file outputs "bin/wg-quick")
  8766. #:sh (search-input-file inputs "bin/bash")
  8767. `("PATH" ":" prefix ,(list coreutils))))))
  8768. @end lisp
  8769. @subsection Program Invocation
  8770. @cindex program invocation, from Scheme
  8771. @cindex invoking programs, from Scheme
  8772. You'll find handy procedures to spawn processes in this module,
  8773. essentially convenient wrappers around Guile's @code{system*}
  8774. (@pxref{Processes, @code{system*},, guile, GNU Guile Reference Manual}).
  8775. @deffn {Procedure} invoke program args@dots{}
  8776. Invoke @var{program} with the given @var{args}. Raise an
  8777. @code{&invoke-error} exception if the exit code is non-zero; otherwise
  8778. return @code{#t}.
  8779. The advantage compared to @code{system*} is that you do not need to
  8780. check the return value. This reduces boilerplate in shell-script-like
  8781. snippets for instance in package build phases.
  8782. @end deffn
  8783. @deffn {Procedure} invoke-error? c
  8784. Return true if @var{c} is an @code{&invoke-error} condition.
  8785. @end deffn
  8786. @deffn {Procedure} invoke-error-program c
  8787. @deffnx {Procedure} invoke-error-arguments c
  8788. @deffnx {Procedure} invoke-error-exit-status c
  8789. @deffnx {Procedure} invoke-error-term-signal c
  8790. @deffnx {Procedure} invoke-error-stop-signal c
  8791. Access specific fields of @var{c}, an @code{&invoke-error} condition.
  8792. @end deffn
  8793. @deffn {Procedure} report-invoke-error c [port]
  8794. Report to @var{port} (by default the current error port) about @var{c},
  8795. an @code{&invoke-error} condition, in a human-friendly way.
  8796. Typical usage would look like this:
  8797. @lisp
  8798. (use-modules (srfi srfi-34) ;for 'guard'
  8799. (guix build utils))
  8800. (guard (c ((invoke-error? c)
  8801. (report-invoke-error c)))
  8802. (invoke "date" "--imaginary-option"))
  8803. @print{} command "date" "--imaginary-option" failed with status 1
  8804. @end lisp
  8805. @end deffn
  8806. @deffn {Procedure} invoke/quiet program args@dots{}
  8807. Invoke @var{program} with @var{args} and capture @var{program}'s
  8808. standard output and standard error. If @var{program} succeeds, print
  8809. nothing and return the unspecified value; otherwise, raise a
  8810. @code{&message} error condition that includes the status code and the
  8811. output of @var{program}.
  8812. Here's an example:
  8813. @lisp
  8814. (use-modules (srfi srfi-34) ;for 'guard'
  8815. (srfi srfi-35) ;for 'message-condition?'
  8816. (guix build utils))
  8817. (guard (c ((message-condition? c)
  8818. (display (condition-message c))))
  8819. (invoke/quiet "date") ;all is fine
  8820. (invoke/quiet "date" "--imaginary-option"))
  8821. @print{} 'date --imaginary-option' exited with status 1; output follows:
  8822. date: unrecognized option '--imaginary-option'
  8823. Try 'date --help' for more information.
  8824. @end lisp
  8825. @end deffn
  8826. @subsection Build Phases
  8827. @cindex build phases
  8828. The @code{(guix build utils)} also contains tools to manipulate build
  8829. phases as used by build systems (@pxref{Build Systems}). Build phases
  8830. are represented as association lists or ``alists'' (@pxref{Association
  8831. Lists,,, guile, GNU Guile Reference Manual}) where each key is a symbol
  8832. naming the phase and the associated value is a procedure (@pxref{Build
  8833. Phases}).
  8834. Guile core and the @code{(srfi srfi-1)} module both provide tools to
  8835. manipulate alists. The @code{(guix build utils)} module complements
  8836. those with tools written with build phases in mind.
  8837. @cindex build phases, modifying
  8838. @defmac modify-phases phases clause@dots{}
  8839. Modify @var{phases} sequentially as per each @var{clause}, which may
  8840. have one of the following forms:
  8841. @lisp
  8842. (delete @var{old-phase-name})
  8843. (replace @var{old-phase-name} @var{new-phase})
  8844. (add-before @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  8845. (add-after @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  8846. @end lisp
  8847. Where every @var{phase-name} above is an expression evaluating to a
  8848. symbol, and @var{new-phase} an expression evaluating to a procedure.
  8849. @end defmac
  8850. The example below is taken from the definition of the @code{grep}
  8851. package. It adds a phase to run after the @code{install} phase, called
  8852. @code{fix-egrep-and-fgrep}. That phase is a procedure (@code{lambda*}
  8853. is for anonymous procedures) that takes a @code{#:outputs} keyword
  8854. argument and ignores extra keyword arguments (@pxref{Optional
  8855. Arguments,,, guile, GNU Guile Reference Manual}, for more on
  8856. @code{lambda*} and optional and keyword arguments.) The phase uses
  8857. @code{substitute*} to modify the installed @file{egrep} and @file{fgrep}
  8858. scripts so that they refer to @code{grep} by its absolute file name:
  8859. @lisp
  8860. (modify-phases %standard-phases
  8861. (add-after 'install 'fix-egrep-and-fgrep
  8862. ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
  8863. ;; absolute file name instead of searching for it in $PATH.
  8864. (lambda* (#:key outputs #:allow-other-keys)
  8865. (let* ((out (assoc-ref outputs "out"))
  8866. (bin (string-append out "/bin")))
  8867. (substitute* (list (string-append bin "/egrep")
  8868. (string-append bin "/fgrep"))
  8869. (("^exec grep")
  8870. (string-append "exec " bin "/grep")))))))
  8871. @end lisp
  8872. In the example below, phases are modified in two ways: the standard
  8873. @code{configure} phase is deleted, presumably because the package does
  8874. not have a @file{configure} script or anything similar, and the default
  8875. @code{install} phase is replaced by one that manually copies the
  8876. executable files to be installed:
  8877. @lisp
  8878. (modify-phases %standard-phases
  8879. (delete 'configure) ;no 'configure' script
  8880. (replace 'install
  8881. (lambda* (#:key outputs #:allow-other-keys)
  8882. ;; The package's Makefile doesn't provide an "install"
  8883. ;; rule so do it by ourselves.
  8884. (let ((bin (string-append (assoc-ref outputs "out")
  8885. "/bin")))
  8886. (install-file "footswitch" bin)
  8887. (install-file "scythe" bin)))))
  8888. @end lisp
  8889. @c TODO: Add more examples.
  8890. @subsection Wrappers
  8891. @cindex program wrappers
  8892. @cindex wrapping programs
  8893. It is not unusual for a command to require certain environment variables
  8894. to be set for proper functioning, typically search paths (@pxref{Search
  8895. Paths}). Failing to do that, the command might fail to find files or
  8896. other commands it relies on, or it might pick the ``wrong''
  8897. ones---depending on the environment in which it runs. Examples include:
  8898. @itemize
  8899. @item
  8900. a shell script that assumes all the commands it uses are in @env{PATH};
  8901. @item
  8902. a Guile program that assumes all its modules are in @env{GUILE_LOAD_PATH}
  8903. and @env{GUILE_LOAD_COMPILED_PATH};
  8904. @item
  8905. a Qt application that expects to find certain plugins in
  8906. @env{QT_PLUGIN_PATH}.
  8907. @end itemize
  8908. For a package writer, the goal is to make sure commands always work the
  8909. same rather than depend on some external settings. One way to achieve
  8910. that is to @dfn{wrap} commands in a thin script that sets those
  8911. environment variables, thereby ensuring that those run-time dependencies
  8912. are always found. The wrapper would be used to set @env{PATH},
  8913. @env{GUILE_LOAD_PATH}, or @env{QT_PLUGIN_PATH} in the examples above.
  8914. To ease that task, the @code{(guix build utils)} module provides a
  8915. couple of helpers to wrap commands.
  8916. @deffn {Procedure} wrap-program program [#:sh sh] [#:rest variables]
  8917. Make a wrapper for @var{program}. @var{variables} should look like this:
  8918. @lisp
  8919. '(@var{variable} @var{delimiter} @var{position} @var{list-of-directories})
  8920. @end lisp
  8921. where @var{delimiter} is optional. @code{:} will be used if
  8922. @var{delimiter} is not given.
  8923. For example, this call:
  8924. @lisp
  8925. (wrap-program "foo"
  8926. '("PATH" ":" = ("/gnu/.../bar/bin"))
  8927. '("CERT_PATH" suffix ("/gnu/.../baz/certs"
  8928. "/qux/certs")))
  8929. @end lisp
  8930. will copy @file{foo} to @file{.foo-real} and create the file @file{foo}
  8931. with the following contents:
  8932. @example
  8933. #!location/of/bin/bash
  8934. export PATH="/gnu/.../bar/bin"
  8935. export CERT_PATH="$CERT_PATH$@{CERT_PATH:+:@}/gnu/.../baz/certs:/qux/certs"
  8936. exec -a $0 location/of/.foo-real "$@@"
  8937. @end example
  8938. If @var{program} has previously been wrapped by @code{wrap-program}, the
  8939. wrapper is extended with definitions for @var{variables}. If it is not,
  8940. @var{sh} will be used as the interpreter.
  8941. @end deffn
  8942. @deffn {Procedure} wrap-script program [#:guile guile] [#:rest variables]
  8943. Wrap the script @var{program} such that @var{variables} are set first.
  8944. The format of @var{variables} is the same as in the @code{wrap-program}
  8945. procedure. This procedure differs from @code{wrap-program} in that it
  8946. does not create a separate shell script. Instead, @var{program} is
  8947. modified directly by prepending a Guile script, which is interpreted as
  8948. a comment in the script's language.
  8949. Special encoding comments as supported by Python are recreated on the
  8950. second line.
  8951. Note that this procedure can only be used once per file as Guile scripts are
  8952. not supported.
  8953. @end deffn
  8954. @node Search Paths
  8955. @section Search Paths
  8956. @cindex search path
  8957. Many programs and libraries look for input data in a @dfn{search path},
  8958. a list of directories: shells like Bash look for executables in the
  8959. command search path, a C compiler looks for @file{.h} files in its
  8960. header search path, the Python interpreter looks for @file{.py}
  8961. files in its search path, the spell checker has a search path for
  8962. dictionaries, and so on.
  8963. Search paths can usually be defined or overridden @i{via} environment
  8964. variables (@pxref{Environment Variables,,, libc, The GNU C Library
  8965. Reference Manual}). For example, the search paths mentioned above can
  8966. be changed by defining the @env{PATH}, @env{C_INCLUDE_PATH},
  8967. @env{PYTHONPATH} (or @env{GUIX_PYTHONPATH}), and @env{DICPATH}
  8968. environment variables---you know, all these something-PATH variables
  8969. that you need to get right or things ``won't be found''.
  8970. You may have noticed from the command line that Guix ``knows'' which
  8971. search path environment variables should be defined, and how. When you
  8972. install packages in your default profile, the file
  8973. @file{~/.guix-profile/etc/profile} is created, which you can ``source''
  8974. from the shell to set those variables. Likewise, if you ask
  8975. @command{guix shell} to create an environment containing Python and
  8976. NumPy, a Python library, and if you pass it the @option{--search-paths}
  8977. option, it will tell you about @env{PATH} and @env{GUIX_PYTHONPATH}
  8978. (@pxref{Invoking guix shell}):
  8979. @example
  8980. $ guix shell python python-numpy --pure --search-paths
  8981. export PATH="/gnu/store/@dots{}-profile/bin"
  8982. export GUIX_PYTHONPATH="/gnu/store/@dots{}-profile/lib/python3.9/site-packages"
  8983. @end example
  8984. When you omit @option{--search-paths}, it defines these environment
  8985. variables right away, such that Python can readily find NumPy:
  8986. @example
  8987. $ guix shell python python-numpy -- python3
  8988. Python 3.9.6 (default, Jan 1 1970, 00:00:01)
  8989. [GCC 10.3.0] on linux
  8990. Type "help", "copyright", "credits" or "license" for more information.
  8991. >>> import numpy
  8992. >>> numpy.version.version
  8993. '1.20.3'
  8994. @end example
  8995. For this to work, the definition of the @code{python} package
  8996. @emph{declares} the search path it cares about and its associated
  8997. environment variable, @env{GUIX_PYTHONPATH}. It looks like this:
  8998. @lisp
  8999. (package
  9000. (name "python")
  9001. (version "3.9.9")
  9002. ;; some fields omitted...
  9003. (native-search-paths
  9004. (list (search-path-specification
  9005. (variable "GUIX_PYTHONPATH")
  9006. (files (list "lib/python/3.9/site-packages"))))))
  9007. @end lisp
  9008. What this @code{native-search-paths} field says is that, when the
  9009. @code{python} package is used, the @env{GUIX_PYTHONPATH} environment
  9010. variable must be defined to include all the
  9011. @file{lib/python/3.9/site-packages} sub-directories encountered in its
  9012. environment. (The @code{native-} bit means that, if we are in a
  9013. cross-compilation environment, only native inputs may be added to the
  9014. search path; @pxref{package Reference, @code{search-paths}}.)
  9015. In the NumPy example above, the profile where
  9016. @code{python} appears contains exactly one such sub-directory, and
  9017. @env{GUIX_PYTHONPATH} is set to that. When there are several
  9018. @file{lib/python/3.9/site-packages}---this is the case in package build
  9019. environments---they are all added to @env{GUIX_PYTHONPATH}, separated by
  9020. colons (@code{:}).
  9021. @quotation Note
  9022. Notice that @env{GUIX_PYTHONPATH} is specified as part of the definition
  9023. of the @code{python} package, and @emph{not} as part of that of
  9024. @code{python-numpy}. This is because this environment variable
  9025. ``belongs'' to Python, not NumPy: Python actually reads the value of
  9026. that variable and honors it.
  9027. Corollary: if you create a profile that does not contain @code{python},
  9028. @code{GUIX_PYTHONPATH} will @emph{not} be defined, even if it contains
  9029. packages that provide @file{.py} files:
  9030. @example
  9031. $ guix shell python-numpy --search-paths --pure
  9032. export PATH="/gnu/store/@dots{}-profile/bin"
  9033. @end example
  9034. This makes a lot of sense if we look at this profile in isolation: no
  9035. software in this profile would read @env{GUIX_PYTHONPATH}.
  9036. @end quotation
  9037. Of course, there are many variations on that theme: some packages honor
  9038. more than one search path, some use separators other than colon, some
  9039. accumulate several directories in their search path, and so on. A more
  9040. complex example is the search path of libxml2: the value of the
  9041. @env{XML_CATALOG_FILES} environment variable is space-separated, it must
  9042. contain a list of @file{catalog.xml} files (not directories), which are
  9043. to be found in @file{xml} sub-directories---nothing less. The search
  9044. path specification looks like this:
  9045. @lisp
  9046. (package
  9047. (name "libxml2")
  9048. ;; some fields omitted
  9049. (native-search-paths
  9050. (list (search-path-specification
  9051. (variable "XML_CATALOG_FILES")
  9052. (separator " ")
  9053. (files '("xml"))
  9054. (file-pattern "^catalog\\.xml$")
  9055. (file-type 'regular)))))
  9056. @end lisp
  9057. Worry not, search path specifications are usually not this tricky.
  9058. The @code{(guix search-paths)} module defines the data type of search
  9059. path specifications and a number of helper procedures. Below is the
  9060. reference of search path specifications.
  9061. @deftp {Data Type} search-path-specification
  9062. The data type for search path specifications.
  9063. @table @asis
  9064. @item @code{variable}
  9065. The name of the environment variable for this search path (a string).
  9066. @item @code{files}
  9067. The list of sub-directories (strings) that should be added to the search
  9068. path.
  9069. @item @code{separator} (default: @code{":"})
  9070. The string used to separate search path components.
  9071. As a special case, a @code{separator} value of @code{#f} specifies a
  9072. ``single-component search path''---in other words, a search path that
  9073. cannot contain more than one element. This is useful in some cases,
  9074. such as the @code{SSL_CERT_DIR} variable (honored by OpenSSL, cURL, and
  9075. a few other packages) or the @code{ASPELL_DICT_DIR} variable (honored by
  9076. the GNU Aspell spell checker), both of which must point to a single
  9077. directory.
  9078. @item @code{file-type} (default: @code{'directory})
  9079. The type of file being matched---@code{'directory} or @code{'regular},
  9080. though it can be any symbol returned by @code{stat:type} (@pxref{File
  9081. System, @code{stat},, guile, GNU Guile Reference Manual}).
  9082. In the libxml2 example above, we would match regular files; in the
  9083. Python example, we would match directories.
  9084. @item @code{file-pattern} (default: @code{#f})
  9085. This must be either @code{#f} or a regular expression specifying
  9086. files to be matched @emph{within} the sub-directories specified by the
  9087. @code{files} field.
  9088. Again, the libxml2 example shows a situation where this is needed.
  9089. @end table
  9090. @end deftp
  9091. Some search paths are not tied by a single package but to many packages.
  9092. To reduce duplications, some of them are pre-defined in @code{(guix
  9093. search-paths)}.
  9094. @defvar $SSL_CERT_DIR
  9095. @defvarx $SSL_CERT_FILE
  9096. These two search paths indicate where X.509 certificates can be found
  9097. (@pxref{X.509 Certificates}).
  9098. @end defvar
  9099. These pre-defined search paths can be used as in the following example:
  9100. @lisp
  9101. (package
  9102. (name "curl")
  9103. ;; some fields omitted ...
  9104. (native-search-paths (list $SSL_CERT_DIR $SSL_CERT_FILE)))
  9105. @end lisp
  9106. How do you turn search path specifications on one hand and a bunch of
  9107. directories on the other hand in a set of environment variable
  9108. definitions? That's the job of @code{evaluate-search-paths}.
  9109. @deffn {Procedure} evaluate-search-paths search-paths directories [getenv]
  9110. Evaluate @var{search-paths}, a list of search-path specifications, for
  9111. @var{directories}, a list of directory names, and return a list of
  9112. specification/value pairs. Use @var{getenv} to determine the current
  9113. settings and report only settings not already effective.
  9114. @end deffn
  9115. The @code{(guix profiles)} provides a higher-level helper procedure,
  9116. @code{load-profile}, that sets the environment variables of a profile.
  9117. @node The Store
  9118. @section The Store
  9119. @cindex store
  9120. @cindex store items
  9121. @cindex store paths
  9122. Conceptually, the @dfn{store} is the place where derivations that have
  9123. been built successfully are stored---by default, @file{/gnu/store}.
  9124. Sub-directories in the store are referred to as @dfn{store items} or
  9125. sometimes @dfn{store paths}. The store has an associated database that
  9126. contains information such as the store paths referred to by each store
  9127. path, and the list of @emph{valid} store items---results of successful
  9128. builds. This database resides in @file{@var{localstatedir}/guix/db},
  9129. where @var{localstatedir} is the state directory specified @i{via}
  9130. @option{--localstatedir} at configure time, usually @file{/var}.
  9131. The store is @emph{always} accessed by the daemon on behalf of its clients
  9132. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  9133. connect to the daemon over a Unix-domain socket, send requests to it,
  9134. and read the result---these are remote procedure calls, or RPCs.
  9135. @quotation Note
  9136. Users must @emph{never} modify files under @file{/gnu/store} directly.
  9137. This would lead to inconsistencies and break the immutability
  9138. assumptions of Guix's functional model (@pxref{Introduction}).
  9139. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  9140. how to check the integrity of the store and attempt recovery from
  9141. accidental modifications.
  9142. @end quotation
  9143. The @code{(guix store)} module provides procedures to connect to the
  9144. daemon, and to perform RPCs. These are described below. By default,
  9145. @code{open-connection}, and thus all the @command{guix} commands,
  9146. connect to the local daemon or to the URI specified by the
  9147. @env{GUIX_DAEMON_SOCKET} environment variable.
  9148. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  9149. When set, the value of this variable should be a file name or a URI
  9150. designating the daemon endpoint. When it is a file name, it denotes a
  9151. Unix-domain socket to connect to. In addition to file names, the
  9152. supported URI schemes are:
  9153. @table @code
  9154. @item file
  9155. @itemx unix
  9156. These are for Unix-domain sockets.
  9157. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  9158. @file{/var/guix/daemon-socket/socket}.
  9159. @item guix
  9160. @cindex daemon, remote access
  9161. @cindex remote access to the daemon
  9162. @cindex daemon, cluster setup
  9163. @cindex clusters, daemon setup
  9164. These URIs denote connections over TCP/IP, without encryption nor
  9165. authentication of the remote host. The URI must specify the host name
  9166. and optionally a port number (by default port 44146 is used):
  9167. @example
  9168. guix://master.guix.example.org:1234
  9169. @end example
  9170. This setup is suitable on local networks, such as clusters, where only
  9171. trusted nodes may connect to the build daemon at
  9172. @code{master.guix.example.org}.
  9173. The @option{--listen} option of @command{guix-daemon} can be used to
  9174. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  9175. @option{--listen}}).
  9176. @item ssh
  9177. @cindex SSH access to build daemons
  9178. These URIs allow you to connect to a remote daemon over SSH@. This
  9179. feature requires Guile-SSH (@pxref{Requirements}) and a working
  9180. @command{guile} binary in @env{PATH} on the destination machine. It
  9181. supports public key and GSSAPI authentication. A typical URL might look
  9182. like this:
  9183. @example
  9184. ssh://charlie@@guix.example.org:22
  9185. @end example
  9186. As for @command{guix copy}, the usual OpenSSH client configuration files
  9187. are honored (@pxref{Invoking guix copy}).
  9188. @end table
  9189. Additional URI schemes may be supported in the future.
  9190. @c XXX: Remove this note when the protocol incurs fewer round trips
  9191. @c and when (guix derivations) no longer relies on file system access.
  9192. @quotation Note
  9193. The ability to connect to remote build daemons is considered
  9194. experimental as of @value{VERSION}. Please get in touch with us to
  9195. share any problems or suggestions you may have (@pxref{Contributing}).
  9196. @end quotation
  9197. @end defvr
  9198. @deffn {Procedure} open-connection [uri] [#:reserve-space? #t]
  9199. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  9200. @var{reserve-space?} is true, instruct it to reserve a little bit of
  9201. extra space on the file system so that the garbage collector can still
  9202. operate should the disk become full. Return a server object.
  9203. @var{file} defaults to @code{%default-socket-path}, which is the normal
  9204. location given the options that were passed to @command{configure}.
  9205. @end deffn
  9206. @deffn {Procedure} close-connection server
  9207. Close the connection to @var{server}.
  9208. @end deffn
  9209. @defvar current-build-output-port
  9210. This variable is bound to a SRFI-39 parameter, which refers to the port
  9211. where build and error logs sent by the daemon should be written.
  9212. @end defvar
  9213. Procedures that make RPCs all take a server object as their first
  9214. argument.
  9215. @cindex invalid store items
  9216. @deffn {Procedure} valid-path? server path
  9217. Return @code{#t} when @var{path} designates a valid store item and
  9218. @code{#f} otherwise (an invalid item may exist on disk but still be
  9219. invalid, for instance because it is the result of an aborted or failed
  9220. build).
  9221. A @code{&store-protocol-error} condition is raised if @var{path} is not
  9222. prefixed by the store directory (@file{/gnu/store}).
  9223. @end deffn
  9224. @deffn {Procedure} add-text-to-store server name text [references]
  9225. Add @var{text} under file @var{name} in the store, and return its store
  9226. path. @var{references} is the list of store paths referred to by the
  9227. resulting store path.
  9228. @end deffn
  9229. @deffn {Procedure} build-derivations store derivations [mode]
  9230. Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
  9231. file names, or derivation/output pairs, using the specified
  9232. @var{mode}---@code{(build-mode normal)} by default.
  9233. @end deffn
  9234. Note that the @code{(guix monads)} module provides a monad as well as
  9235. monadic versions of the above procedures, with the goal of making it
  9236. more convenient to work with code that accesses the store (@pxref{The
  9237. Store Monad}).
  9238. @c FIXME
  9239. @i{This section is currently incomplete.}
  9240. @node Derivations
  9241. @section Derivations
  9242. @cindex derivations
  9243. Low-level build actions and the environment in which they are performed
  9244. are represented by @dfn{derivations}. A derivation contains the
  9245. following pieces of information:
  9246. @itemize
  9247. @item
  9248. The outputs of the derivation---derivations produce at least one file or
  9249. directory in the store, but may produce more.
  9250. @item
  9251. @cindex build-time dependencies
  9252. @cindex dependencies, build-time
  9253. The inputs of the derivations---i.e., its build-time dependencies---which may
  9254. be other derivations or plain files in the store (patches, build scripts,
  9255. etc.).
  9256. @item
  9257. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  9258. @item
  9259. The file name of a build script in the store, along with the arguments
  9260. to be passed.
  9261. @item
  9262. A list of environment variables to be defined.
  9263. @end itemize
  9264. @cindex derivation path
  9265. Derivations allow clients of the daemon to communicate build actions to
  9266. the store. They exist in two forms: as an in-memory representation,
  9267. both on the client- and daemon-side, and as files in the store whose
  9268. name end in @file{.drv}---these files are referred to as @dfn{derivation
  9269. paths}. Derivations paths can be passed to the @code{build-derivations}
  9270. procedure to perform the build actions they prescribe (@pxref{The
  9271. Store}).
  9272. @cindex fixed-output derivations
  9273. Operations such as file downloads and version-control checkouts for
  9274. which the expected content hash is known in advance are modeled as
  9275. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  9276. of a fixed-output derivation are independent of its inputs---e.g., a
  9277. source code download produces the same result regardless of the download
  9278. method and tools being used.
  9279. @cindex references
  9280. @cindex run-time dependencies
  9281. @cindex dependencies, run-time
  9282. The outputs of derivations---i.e., the build results---have a set of
  9283. @dfn{references}, as reported by the @code{references} RPC or the
  9284. @command{guix gc --references} command (@pxref{Invoking guix gc}). References
  9285. are the set of run-time dependencies of the build results. References are a
  9286. subset of the inputs of the derivation; this subset is automatically computed
  9287. by the build daemon by scanning all the files in the outputs.
  9288. The @code{(guix derivations)} module provides a representation of
  9289. derivations as Scheme objects, along with procedures to create and
  9290. otherwise manipulate derivations. The lowest-level primitive to create
  9291. a derivation is the @code{derivation} procedure:
  9292. @deffn {Procedure} derivation store name builder args @
  9293. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  9294. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  9295. [#:system (%current-system)] [#:references-graphs #f] @
  9296. [#:allowed-references #f] [#:disallowed-references #f] @
  9297. [#:leaked-env-vars #f] [#:local-build? #f] @
  9298. [#:substitutable? #t] [#:properties '()]
  9299. Build a derivation with the given arguments, and return the resulting
  9300. @code{<derivation>} object.
  9301. When @var{hash} and @var{hash-algo} are given, a
  9302. @dfn{fixed-output derivation} is created---i.e., one whose result is
  9303. known in advance, such as a file download. If, in addition,
  9304. @var{recursive?} is true, then that fixed output may be an executable
  9305. file or a directory and @var{hash} must be the hash of an archive
  9306. containing this output.
  9307. When @var{references-graphs} is true, it must be a list of file
  9308. name/store path pairs. In that case, the reference graph of each store
  9309. path is exported in the build environment in the corresponding file, in
  9310. a simple text format.
  9311. When @var{allowed-references} is true, it must be a list of store items
  9312. or outputs that the derivation's output may refer to. Likewise,
  9313. @var{disallowed-references}, if true, must be a list of things the
  9314. outputs may @emph{not} refer to.
  9315. When @var{leaked-env-vars} is true, it must be a list of strings
  9316. denoting environment variables that are allowed to ``leak'' from the
  9317. daemon's environment to the build environment. This is only applicable
  9318. to fixed-output derivations---i.e., when @var{hash} is true. The main
  9319. use is to allow variables such as @code{http_proxy} to be passed to
  9320. derivations that download files.
  9321. When @var{local-build?} is true, declare that the derivation is not a
  9322. good candidate for offloading and should rather be built locally
  9323. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  9324. where the costs of data transfers would outweigh the benefits.
  9325. When @var{substitutable?} is false, declare that substitutes of the
  9326. derivation's output should not be used (@pxref{Substitutes}). This is
  9327. useful, for instance, when building packages that capture details of the
  9328. host CPU instruction set.
  9329. @var{properties} must be an association list describing ``properties'' of the
  9330. derivation. It is kept as-is, uninterpreted, in the derivation.
  9331. @end deffn
  9332. @noindent
  9333. Here's an example with a shell script as its builder, assuming
  9334. @var{store} is an open connection to the daemon, and @var{bash} points
  9335. to a Bash executable in the store:
  9336. @lisp
  9337. (use-modules (guix utils)
  9338. (guix store)
  9339. (guix derivations))
  9340. (let ((builder ; add the Bash script to the store
  9341. (add-text-to-store store "my-builder.sh"
  9342. "echo hello world > $out\n" '())))
  9343. (derivation store "foo"
  9344. bash `("-e" ,builder)
  9345. #:inputs `((,bash) (,builder))
  9346. #:env-vars '(("HOME" . "/homeless"))))
  9347. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  9348. @end lisp
  9349. As can be guessed, this primitive is cumbersome to use directly. A
  9350. better approach is to write build scripts in Scheme, of course! The
  9351. best course of action for that is to write the build code as a
  9352. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  9353. information, @pxref{G-Expressions}.
  9354. Once upon a time, @code{gexp->derivation} did not exist and constructing
  9355. derivations with build code written in Scheme was achieved with
  9356. @code{build-expression->derivation}, documented below. This procedure
  9357. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  9358. @deffn {Procedure} build-expression->derivation store name exp @
  9359. [#:system (%current-system)] [#:inputs '()] @
  9360. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  9361. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  9362. [#:references-graphs #f] [#:allowed-references #f] @
  9363. [#:disallowed-references #f] @
  9364. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  9365. Return a derivation that executes Scheme expression @var{exp} as a
  9366. builder for derivation @var{name}. @var{inputs} must be a list of
  9367. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  9368. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  9369. modules from the current search path to be copied in the store,
  9370. compiled, and made available in the load path during the execution of
  9371. @var{exp}---e.g., @code{((guix build utils) (guix build
  9372. gnu-build-system))}.
  9373. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  9374. to a list of output/path pairs, and where @code{%build-inputs} is bound
  9375. to a list of string/output-path pairs made from @var{inputs}.
  9376. Optionally, @var{env-vars} is a list of string pairs specifying the name
  9377. and value of environment variables visible to the builder. The builder
  9378. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  9379. @var{exp} returns @code{#f}, the build is considered to have failed.
  9380. @var{exp} is built using @var{guile-for-build} (a derivation). When
  9381. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  9382. @code{%guile-for-build} fluid is used instead.
  9383. See the @code{derivation} procedure for the meaning of
  9384. @var{references-graphs}, @var{allowed-references},
  9385. @var{disallowed-references}, @var{local-build?}, and
  9386. @var{substitutable?}.
  9387. @end deffn
  9388. @noindent
  9389. Here's an example of a single-output derivation that creates a directory
  9390. containing one file:
  9391. @lisp
  9392. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  9393. (mkdir out) ; create /gnu/store/@dots{}-goo
  9394. (call-with-output-file (string-append out "/test")
  9395. (lambda (p)
  9396. (display '(hello guix) p))))))
  9397. (build-expression->derivation store "goo" builder))
  9398. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  9399. @end lisp
  9400. @node The Store Monad
  9401. @section The Store Monad
  9402. @cindex monad
  9403. The procedures that operate on the store described in the previous
  9404. sections all take an open connection to the build daemon as their first
  9405. argument. Although the underlying model is functional, they either have
  9406. side effects or depend on the current state of the store.
  9407. The former is inconvenient: the connection to the build daemon has to be
  9408. carried around in all those functions, making it impossible to compose
  9409. functions that do not take that parameter with functions that do. The
  9410. latter can be problematic: since store operations have side effects
  9411. and/or depend on external state, they have to be properly sequenced.
  9412. @cindex monadic values
  9413. @cindex monadic functions
  9414. This is where the @code{(guix monads)} module comes in. This module
  9415. provides a framework for working with @dfn{monads}, and a particularly
  9416. useful monad for our uses, the @dfn{store monad}. Monads are a
  9417. construct that allows two things: associating ``context'' with values
  9418. (in our case, the context is the store), and building sequences of
  9419. computations (here computations include accesses to the store). Values
  9420. in a monad---values that carry this additional context---are called
  9421. @dfn{monadic values}; procedures that return such values are called
  9422. @dfn{monadic procedures}.
  9423. Consider this ``normal'' procedure:
  9424. @lisp
  9425. (define (sh-symlink store)
  9426. ;; Return a derivation that symlinks the 'bash' executable.
  9427. (let* ((drv (package-derivation store bash))
  9428. (out (derivation->output-path drv))
  9429. (sh (string-append out "/bin/bash")))
  9430. (build-expression->derivation store "sh"
  9431. `(symlink ,sh %output))))
  9432. @end lisp
  9433. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  9434. as a monadic function:
  9435. @lisp
  9436. (define (sh-symlink)
  9437. ;; Same, but return a monadic value.
  9438. (mlet %store-monad ((drv (package->derivation bash)))
  9439. (gexp->derivation "sh"
  9440. #~(symlink (string-append #$drv "/bin/bash")
  9441. #$output))))
  9442. @end lisp
  9443. There are several things to note in the second version: the @code{store}
  9444. parameter is now implicit and is ``threaded'' in the calls to the
  9445. @code{package->derivation} and @code{gexp->derivation} monadic
  9446. procedures, and the monadic value returned by @code{package->derivation}
  9447. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  9448. As it turns out, the call to @code{package->derivation} can even be
  9449. omitted since it will take place implicitly, as we will see later
  9450. (@pxref{G-Expressions}):
  9451. @lisp
  9452. (define (sh-symlink)
  9453. (gexp->derivation "sh"
  9454. #~(symlink (string-append #$bash "/bin/bash")
  9455. #$output)))
  9456. @end lisp
  9457. @c See
  9458. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  9459. @c for the funny quote.
  9460. Calling the monadic @code{sh-symlink} has no effect. As someone once
  9461. said, ``you exit a monad like you exit a building on fire: by running''.
  9462. So, to exit the monad and get the desired effect, one must use
  9463. @code{run-with-store}:
  9464. @lisp
  9465. (run-with-store (open-connection) (sh-symlink))
  9466. @result{} /gnu/store/...-sh-symlink
  9467. @end lisp
  9468. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  9469. new ``commands'' to make it easier to deal with monadic procedures:
  9470. @code{run-in-store}, and @code{enter-store-monad} (@pxref{Using Guix
  9471. Interactively}). The former is used
  9472. to ``run'' a single monadic value through the store:
  9473. @example
  9474. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  9475. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  9476. @end example
  9477. The latter enters a recursive REPL, where all the return values are
  9478. automatically run through the store:
  9479. @example
  9480. scheme@@(guile-user)> ,enter-store-monad
  9481. store-monad@@(guile-user) [1]> (package->derivation hello)
  9482. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  9483. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  9484. $3 = "/gnu/store/@dots{}-foo"
  9485. store-monad@@(guile-user) [1]> ,q
  9486. scheme@@(guile-user)>
  9487. @end example
  9488. @noindent
  9489. Note that non-monadic values cannot be returned in the
  9490. @code{store-monad} REPL.
  9491. Other meta-commands are available at the REPL, such as @code{,build} to
  9492. build a file-like object (@pxref{Using Guix Interactively}).
  9493. The main syntactic forms to deal with monads in general are provided by
  9494. the @code{(guix monads)} module and are described below.
  9495. @defmac with-monad monad body @dots{}
  9496. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  9497. in @var{monad}.
  9498. @end defmac
  9499. @defmac return val
  9500. Return a monadic value that encapsulates @var{val}.
  9501. @end defmac
  9502. @defmac >>= mval mproc @dots{}
  9503. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  9504. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  9505. referred to as ``bind'', but that name denotes an unrelated procedure in
  9506. Guile. Thus we use this somewhat cryptic symbol inherited from the
  9507. Haskell language.}. There can be one @var{mproc} or several of them, as
  9508. in this example:
  9509. @lisp
  9510. (run-with-state
  9511. (with-monad %state-monad
  9512. (>>= (return 1)
  9513. (lambda (x) (return (+ 1 x)))
  9514. (lambda (x) (return (* 2 x)))))
  9515. 'some-state)
  9516. @result{} 4
  9517. @result{} some-state
  9518. @end lisp
  9519. @end defmac
  9520. @defmac mlet monad ((var mval) @dots{}) body @dots{}
  9521. @defmacx mlet* monad ((var mval) @dots{}) body @dots{}
  9522. Bind the variables @var{var} to the monadic values @var{mval} in
  9523. @var{body}, which is a sequence of expressions. As with the bind
  9524. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  9525. value ``contained'' in @var{mval} and making @var{var} refer to that
  9526. raw, non-monadic value within the scope of the @var{body}. The form
  9527. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  9528. @var{val}, as per @code{let}. The binding operations occur in sequence
  9529. from left to right. The last expression of @var{body} must be a monadic
  9530. expression, and its result will become the result of the @code{mlet} or
  9531. @code{mlet*} when run in the @var{monad}.
  9532. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  9533. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  9534. @end defmac
  9535. @defmac mbegin monad mexp @dots{}
  9536. Bind @var{mexp} and the following monadic expressions in sequence,
  9537. returning the result of the last expression. Every expression in the
  9538. sequence must be a monadic expression.
  9539. This is akin to @code{mlet}, except that the return values of the
  9540. monadic expressions are ignored. In that sense, it is analogous to
  9541. @code{begin}, but applied to monadic expressions.
  9542. @end defmac
  9543. @defmac mwhen condition mexp0 mexp* @dots{}
  9544. When @var{condition} is true, evaluate the sequence of monadic
  9545. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  9546. @var{condition} is false, return @code{*unspecified*} in the current
  9547. monad. Every expression in the sequence must be a monadic expression.
  9548. @end defmac
  9549. @defmac munless condition mexp0 mexp* @dots{}
  9550. When @var{condition} is false, evaluate the sequence of monadic
  9551. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  9552. @var{condition} is true, return @code{*unspecified*} in the current
  9553. monad. Every expression in the sequence must be a monadic expression.
  9554. @end defmac
  9555. @cindex state monad
  9556. The @code{(guix monads)} module provides the @dfn{state monad}, which
  9557. allows an additional value---the state---to be @emph{threaded} through
  9558. monadic procedure calls.
  9559. @defvar %state-monad
  9560. The state monad. Procedures in the state monad can access and change
  9561. the state that is threaded.
  9562. Consider the example below. The @code{square} procedure returns a value
  9563. in the state monad. It returns the square of its argument, but also
  9564. increments the current state value:
  9565. @lisp
  9566. (define (square x)
  9567. (mlet %state-monad ((count (current-state)))
  9568. (mbegin %state-monad
  9569. (set-current-state (+ 1 count))
  9570. (return (* x x)))))
  9571. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  9572. @result{} (0 1 4)
  9573. @result{} 3
  9574. @end lisp
  9575. When ``run'' through @code{%state-monad}, we obtain that additional state
  9576. value, which is the number of @code{square} calls.
  9577. @end defvar
  9578. @deffn {Monadic Procedure} current-state
  9579. Return the current state as a monadic value.
  9580. @end deffn
  9581. @deffn {Monadic Procedure} set-current-state @var{value}
  9582. Set the current state to @var{value} and return the previous state as a
  9583. monadic value.
  9584. @end deffn
  9585. @deffn {Monadic Procedure} state-push @var{value}
  9586. Push @var{value} to the current state, which is assumed to be a list,
  9587. and return the previous state as a monadic value.
  9588. @end deffn
  9589. @deffn {Monadic Procedure} state-pop
  9590. Pop a value from the current state and return it as a monadic value.
  9591. The state is assumed to be a list.
  9592. @end deffn
  9593. @deffn {Procedure} run-with-state mval [state]
  9594. Run monadic value @var{mval} starting with @var{state} as the initial
  9595. state. Return two values: the resulting value, and the resulting state.
  9596. @end deffn
  9597. The main interface to the store monad, provided by the @code{(guix
  9598. store)} module, is as follows.
  9599. @defvar %store-monad
  9600. The store monad---an alias for @code{%state-monad}.
  9601. Values in the store monad encapsulate accesses to the store. When its
  9602. effect is needed, a value of the store monad must be ``evaluated'' by
  9603. passing it to the @code{run-with-store} procedure (see below).
  9604. @end defvar
  9605. @deffn {Procedure} run-with-store store mval @
  9606. [#:guile-for-build] [#:system (%current-system)]
  9607. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  9608. open store connection.
  9609. @end deffn
  9610. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  9611. Return as a monadic value the absolute file name in the store of the file
  9612. containing @var{text}, a string. @var{references} is a list of store items that the
  9613. resulting text file refers to; it defaults to the empty list.
  9614. @end deffn
  9615. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  9616. Return as a monadic value the absolute file name in the store of the file
  9617. containing @var{data}, a bytevector. @var{references} is a list of store
  9618. items that the resulting binary file refers to; it defaults to the empty list.
  9619. @end deffn
  9620. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  9621. [#:recursive? #t] [#:select? (const #t)]
  9622. Return the name of @var{file} once interned in the store. Use
  9623. @var{name} as its store name, or the basename of @var{file} if
  9624. @var{name} is omitted.
  9625. When @var{recursive?} is true, the contents of @var{file} are added
  9626. recursively; if @var{file} designates a flat file and @var{recursive?}
  9627. is true, its contents are added, and its permission bits are kept.
  9628. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  9629. @var{stat})} for each directory entry, where @var{file} is the entry's
  9630. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  9631. entries for which @var{select?} does not return true.
  9632. The example below adds a file to the store, under two different names:
  9633. @lisp
  9634. (run-with-store (open-connection)
  9635. (mlet %store-monad ((a (interned-file "README"))
  9636. (b (interned-file "README" "LEGU-MIN")))
  9637. (return (list a b))))
  9638. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  9639. @end lisp
  9640. @end deffn
  9641. The @code{(guix packages)} module exports the following package-related
  9642. monadic procedures:
  9643. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  9644. [#:system (%current-system)] [#:target #f] @
  9645. [#:output "out"]
  9646. Return as a monadic
  9647. value in the absolute file name of @var{file} within the @var{output}
  9648. directory of @var{package}. When @var{file} is omitted, return the name
  9649. of the @var{output} directory of @var{package}. When @var{target} is
  9650. true, use it as a cross-compilation target triplet.
  9651. Note that this procedure does @emph{not} build @var{package}. Thus, the
  9652. result might or might not designate an existing file. We recommend not
  9653. using this procedure unless you know what you are doing.
  9654. @end deffn
  9655. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  9656. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  9657. @var{target} [@var{system}]
  9658. Monadic version of @code{package-derivation} and
  9659. @code{package-cross-derivation} (@pxref{Defining Packages}).
  9660. @end deffn
  9661. @node G-Expressions
  9662. @section G-Expressions
  9663. @cindex G-expression
  9664. @cindex build code quoting
  9665. So we have ``derivations'', which represent a sequence of build actions
  9666. to be performed to produce an item in the store (@pxref{Derivations}).
  9667. These build actions are performed when asking the daemon to actually
  9668. build the derivations; they are run by the daemon in a container
  9669. (@pxref{Invoking guix-daemon}).
  9670. @cindex code staging
  9671. @cindex staging, of code
  9672. @cindex strata of code
  9673. It should come as no surprise that we like to write these build actions
  9674. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  9675. code@footnote{The term @dfn{stratum} in this context was coined by
  9676. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  9677. Kiselyov, who has written insightful
  9678. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  9679. on this topic}, refers to this kind of code generation as
  9680. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  9681. to the daemon, etc.---and the ``build code''---code that actually
  9682. performs build actions, such as making directories, invoking
  9683. @command{make}, and so on (@pxref{Build Phases}).
  9684. To describe a derivation and its build actions, one typically needs to
  9685. embed build code inside host code. It boils down to manipulating build
  9686. code as data, and the homoiconicity of Scheme---code has a direct
  9687. representation as data---comes in handy for that. But we need more than
  9688. the normal @code{quasiquote} mechanism in Scheme to construct build
  9689. expressions.
  9690. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  9691. S-expressions adapted to build expressions. G-expressions, or
  9692. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  9693. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  9694. @code{#$}, and @code{#$@@}), which are comparable to
  9695. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  9696. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  9697. GNU Guile Reference Manual}). However, there are major differences:
  9698. @itemize
  9699. @item
  9700. Gexps are meant to be written to a file and run or manipulated by other
  9701. processes.
  9702. @item
  9703. When a high-level object such as a package or derivation is unquoted
  9704. inside a gexp, the result is as if its output file name had been
  9705. introduced.
  9706. @item
  9707. Gexps carry information about the packages or derivations they refer to,
  9708. and these dependencies are automatically added as inputs to the build
  9709. processes that use them.
  9710. @end itemize
  9711. @cindex lowering, of high-level objects in gexps
  9712. This mechanism is not limited to package and derivation
  9713. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  9714. derivations or files in the store can be defined,
  9715. such that these objects can also be inserted
  9716. into gexps. For example, a useful type of high-level objects that can be
  9717. inserted in a gexp is ``file-like objects'', which make it easy to
  9718. add files to the store and to refer to them in
  9719. derivations and such (see @code{local-file} and @code{plain-file}
  9720. below).
  9721. To illustrate the idea, here is an example of a gexp:
  9722. @lisp
  9723. (define build-exp
  9724. #~(begin
  9725. (mkdir #$output)
  9726. (chdir #$output)
  9727. (symlink (string-append #$coreutils "/bin/ls")
  9728. "list-files")))
  9729. @end lisp
  9730. This gexp can be passed to @code{gexp->derivation}; we obtain a
  9731. derivation that builds a directory containing exactly one symlink to
  9732. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  9733. @lisp
  9734. (gexp->derivation "the-thing" build-exp)
  9735. @end lisp
  9736. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  9737. substituted to the reference to the @var{coreutils} package in the
  9738. actual build code, and @var{coreutils} is automatically made an input to
  9739. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  9740. output)}) is replaced by a string containing the directory name of the
  9741. output of the derivation.
  9742. @cindex cross compilation
  9743. In a cross-compilation context, it is useful to distinguish between
  9744. references to the @emph{native} build of a package---that can run on the
  9745. host---versus references to cross builds of a package. To that end, the
  9746. @code{#+} plays the same role as @code{#$}, but is a reference to a
  9747. native package build:
  9748. @lisp
  9749. (gexp->derivation "vi"
  9750. #~(begin
  9751. (mkdir #$output)
  9752. (mkdir (string-append #$output "/bin"))
  9753. (system* (string-append #+coreutils "/bin/ln")
  9754. "-s"
  9755. (string-append #$emacs "/bin/emacs")
  9756. (string-append #$output "/bin/vi")))
  9757. #:target "aarch64-linux-gnu")
  9758. @end lisp
  9759. @noindent
  9760. In the example above, the native build of @var{coreutils} is used, so
  9761. that @command{ln} can actually run on the host; but then the
  9762. cross-compiled build of @var{emacs} is referenced.
  9763. @cindex imported modules, for gexps
  9764. @findex with-imported-modules
  9765. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  9766. able to use certain Guile modules from the ``host environment'' in the
  9767. gexp, so those modules should be imported in the ``build environment''.
  9768. The @code{with-imported-modules} form allows you to express that:
  9769. @lisp
  9770. (let ((build (with-imported-modules '((guix build utils))
  9771. #~(begin
  9772. (use-modules (guix build utils))
  9773. (mkdir-p (string-append #$output "/bin"))))))
  9774. (gexp->derivation "empty-dir"
  9775. #~(begin
  9776. #$build
  9777. (display "success!\n")
  9778. #t)))
  9779. @end lisp
  9780. @noindent
  9781. In this example, the @code{(guix build utils)} module is automatically
  9782. pulled into the isolated build environment of our gexp, such that
  9783. @code{(use-modules (guix build utils))} works as expected.
  9784. @cindex module closure
  9785. @findex source-module-closure
  9786. Usually you want the @emph{closure} of the module to be imported---i.e.,
  9787. the module itself and all the modules it depends on---rather than just
  9788. the module; failing to do that, attempts to use the module will fail
  9789. because of missing dependent modules. The @code{source-module-closure}
  9790. procedure computes the closure of a module by looking at its source file
  9791. headers, which comes in handy in this case:
  9792. @lisp
  9793. (use-modules (guix modules)) ;for 'source-module-closure'
  9794. (with-imported-modules (source-module-closure
  9795. '((guix build utils)
  9796. (gnu build image)))
  9797. (gexp->derivation "something-with-vms"
  9798. #~(begin
  9799. (use-modules (guix build utils)
  9800. (gnu build image))
  9801. @dots{})))
  9802. @end lisp
  9803. @cindex extensions, for gexps
  9804. @findex with-extensions
  9805. In the same vein, sometimes you want to import not just pure-Scheme
  9806. modules, but also ``extensions'' such as Guile bindings to C libraries
  9807. or other ``full-blown'' packages. Say you need the @code{guile-json}
  9808. package available on the build side, here's how you would do it:
  9809. @lisp
  9810. (use-modules (gnu packages guile)) ;for 'guile-json'
  9811. (with-extensions (list guile-json)
  9812. (gexp->derivation "something-with-json"
  9813. #~(begin
  9814. (use-modules (json))
  9815. @dots{})))
  9816. @end lisp
  9817. The syntactic form to construct gexps is summarized below.
  9818. @defmac #~@var{exp}
  9819. @defmacx (gexp @var{exp})
  9820. Return a G-expression containing @var{exp}. @var{exp} may contain one
  9821. or more of the following forms:
  9822. @table @code
  9823. @item #$@var{obj}
  9824. @itemx (ungexp @var{obj})
  9825. Introduce a reference to @var{obj}. @var{obj} may have one of the
  9826. supported types, for example a package or a
  9827. derivation, in which case the @code{ungexp} form is replaced by its
  9828. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  9829. If @var{obj} is a list, it is traversed and references to supported
  9830. objects are substituted similarly.
  9831. If @var{obj} is another gexp, its contents are inserted and its
  9832. dependencies are added to those of the containing gexp.
  9833. If @var{obj} is another kind of object, it is inserted as is.
  9834. @item #$@var{obj}:@var{output}
  9835. @itemx (ungexp @var{obj} @var{output})
  9836. This is like the form above, but referring explicitly to the
  9837. @var{output} of @var{obj}---this is useful when @var{obj} produces
  9838. multiple outputs (@pxref{Packages with Multiple Outputs}).
  9839. @item #+@var{obj}
  9840. @itemx #+@var{obj}:output
  9841. @itemx (ungexp-native @var{obj})
  9842. @itemx (ungexp-native @var{obj} @var{output})
  9843. Same as @code{ungexp}, but produces a reference to the @emph{native}
  9844. build of @var{obj} when used in a cross compilation context.
  9845. @item #$output[:@var{output}]
  9846. @itemx (ungexp output [@var{output}])
  9847. Insert a reference to derivation output @var{output}, or to the main
  9848. output when @var{output} is omitted.
  9849. This only makes sense for gexps passed to @code{gexp->derivation}.
  9850. @item #$@@@var{lst}
  9851. @itemx (ungexp-splicing @var{lst})
  9852. Like the above, but splices the contents of @var{lst} inside the
  9853. containing list.
  9854. @item #+@@@var{lst}
  9855. @itemx (ungexp-native-splicing @var{lst})
  9856. Like the above, but refers to native builds of the objects listed in
  9857. @var{lst}.
  9858. @end table
  9859. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  9860. of the @code{gexp?} type (see below).
  9861. @end defmac
  9862. @defmac with-imported-modules modules body@dots{}
  9863. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  9864. in their execution environment.
  9865. Each item in @var{modules} can be the name of a module, such as
  9866. @code{(guix build utils)}, or it can be a module name, followed by an
  9867. arrow, followed by a file-like object:
  9868. @lisp
  9869. `((guix build utils)
  9870. (guix gcrypt)
  9871. ((guix config) => ,(scheme-file "config.scm"
  9872. #~(define-module @dots{}))))
  9873. @end lisp
  9874. @noindent
  9875. In the example above, the first two modules are taken from the search
  9876. path, and the last one is created from the given file-like object.
  9877. This form has @emph{lexical} scope: it has an effect on the gexps
  9878. directly defined in @var{body}@dots{}, but not on those defined, say, in
  9879. procedures called from @var{body}@dots{}.
  9880. @end defmac
  9881. @defmac with-extensions extensions body@dots{}
  9882. Mark the gexps defined in @var{body}@dots{} as requiring
  9883. @var{extensions} in their build and execution environment.
  9884. @var{extensions} is typically a list of package objects such as those
  9885. defined in the @code{(gnu packages guile)} module.
  9886. Concretely, the packages listed in @var{extensions} are added to the
  9887. load path while compiling imported modules in @var{body}@dots{}; they
  9888. are also added to the load path of the gexp returned by
  9889. @var{body}@dots{}.
  9890. @end defmac
  9891. @deffn {Procedure} gexp? obj
  9892. Return @code{#t} if @var{obj} is a G-expression.
  9893. @end deffn
  9894. G-expressions are meant to be written to disk, either as code building
  9895. some derivation, or as plain files in the store. The monadic procedures
  9896. below allow you to do that (@pxref{The Store Monad}, for more
  9897. information about monads).
  9898. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  9899. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  9900. [#:hash #f] [#:hash-algo #f] @
  9901. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  9902. [#:module-path @code{%load-path}] @
  9903. [#:effective-version "2.2"] @
  9904. [#:references-graphs #f] [#:allowed-references #f] @
  9905. [#:disallowed-references #f] @
  9906. [#:leaked-env-vars #f] @
  9907. [#:script-name (string-append @var{name} "-builder")] @
  9908. [#:deprecation-warnings #f] @
  9909. [#:local-build? #f] [#:substitutable? #t] @
  9910. [#:properties '()] [#:guile-for-build #f]
  9911. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  9912. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  9913. stored in a file called @var{script-name}. When @var{target} is true,
  9914. it is used as the cross-compilation target triplet for packages referred
  9915. to by @var{exp}.
  9916. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  9917. Its meaning is to
  9918. make @var{modules} available in the evaluation context of @var{exp};
  9919. @var{modules} is a list of names of Guile modules searched in
  9920. @var{module-path} to be copied in the store, compiled, and made available in
  9921. the load path during the execution of @var{exp}---e.g., @code{((guix
  9922. build utils) (guix build gnu-build-system))}.
  9923. @var{effective-version} determines the string to use when adding extensions of
  9924. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  9925. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  9926. applicable.
  9927. When @var{references-graphs} is true, it must be a list of tuples of one of the
  9928. following forms:
  9929. @example
  9930. (@var{file-name} @var{package})
  9931. (@var{file-name} @var{package} @var{output})
  9932. (@var{file-name} @var{derivation})
  9933. (@var{file-name} @var{derivation} @var{output})
  9934. (@var{file-name} @var{store-item})
  9935. @end example
  9936. The right-hand-side of each element of @var{references-graphs} is automatically made
  9937. an input of the build process of @var{exp}. In the build environment, each
  9938. @var{file-name} contains the reference graph of the corresponding item, in a simple
  9939. text format.
  9940. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  9941. In the latter case, the list denotes store items that the result is allowed to
  9942. refer to. Any reference to another store item will lead to a build error.
  9943. Similarly for @var{disallowed-references}, which can list items that must not be
  9944. referenced by the outputs.
  9945. @var{deprecation-warnings} determines whether to show deprecation warnings while
  9946. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  9947. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  9948. @end deffn
  9949. @cindex file-like objects
  9950. The @code{local-file}, @code{plain-file}, @code{computed-file},
  9951. @code{program-file}, and @code{scheme-file} procedures below return
  9952. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  9953. these objects lead to a file in the store. Consider this G-expression:
  9954. @lisp
  9955. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  9956. #$(local-file "/tmp/my-nscd.conf"))
  9957. @end lisp
  9958. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  9959. to the store. Once expanded, for instance @i{via}
  9960. @code{gexp->derivation}, the G-expression refers to that copy under
  9961. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  9962. does not have any effect on what the G-expression does.
  9963. @code{plain-file} can be used similarly; it differs in that the file
  9964. content is directly passed as a string.
  9965. @deffn {Procedure} local-file file [name] [#:recursive? #f] [#:select? (const #t)]
  9966. Return an object representing local file @var{file} to add to the store;
  9967. this object can be used in a gexp. If @var{file} is a literal string
  9968. denoting a relative file name, it is looked up relative to the source
  9969. file where it appears; if @var{file} is not a literal string, it is
  9970. looked up relative to the current working directory at run time.
  9971. @var{file} will be added to the store under @var{name}--by default the
  9972. base name of @var{file}.
  9973. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  9974. designates a flat file and @var{recursive?} is true, its contents are added, and its
  9975. permission bits are kept.
  9976. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  9977. @var{stat})} for each directory entry, where @var{file} is the entry's
  9978. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  9979. entries for which @var{select?} does not return true.
  9980. This is the declarative counterpart of the @code{interned-file} monadic
  9981. procedure (@pxref{The Store Monad, @code{interned-file}}).
  9982. @end deffn
  9983. @deffn {Procedure} plain-file name content
  9984. Return an object representing a text file called @var{name} with the given
  9985. @var{content} (a string or a bytevector) to be added to the store.
  9986. This is the declarative counterpart of @code{text-file}.
  9987. @end deffn
  9988. @deffn {Procedure} computed-file name gexp [#:local-build? #t] [#:options '()]
  9989. Return an object representing the store item @var{name}, a file or
  9990. directory computed by @var{gexp}. When @var{local-build?} is true (the
  9991. default), the derivation is built locally. @var{options} is a list of
  9992. additional arguments to pass to @code{gexp->derivation}.
  9993. This is the declarative counterpart of @code{gexp->derivation}.
  9994. @end deffn
  9995. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  9996. [#:guile (default-guile)] [#:module-path %load-path] @
  9997. [#:system (%current-system)] [#:target #f]
  9998. Return an executable script @var{name} that runs @var{exp} using
  9999. @var{guile}, with @var{exp}'s imported modules in its search path.
  10000. Look up @var{exp}'s modules in @var{module-path}.
  10001. The example below builds a script that simply invokes the @command{ls}
  10002. command:
  10003. @lisp
  10004. (use-modules (guix gexp) (gnu packages base))
  10005. (gexp->script "list-files"
  10006. #~(execl #$(file-append coreutils "/bin/ls")
  10007. "ls"))
  10008. @end lisp
  10009. When ``running'' it through the store (@pxref{The Store Monad,
  10010. @code{run-with-store}}), we obtain a derivation that produces an
  10011. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  10012. @example
  10013. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  10014. !#
  10015. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  10016. @end example
  10017. @end deffn
  10018. @deffn {Procedure} program-file name exp [#:guile #f] [#:module-path %load-path]
  10019. Return an object representing the executable store item @var{name} that
  10020. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  10021. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  10022. This is the declarative counterpart of @code{gexp->script}.
  10023. @end deffn
  10024. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  10025. [#:set-load-path? #t] [#:module-path %load-path] @
  10026. [#:splice? #f] @
  10027. [#:guile (default-guile)]
  10028. Return a derivation that builds a file @var{name} containing @var{exp}.
  10029. When @var{splice?} is true, @var{exp} is considered to be a list of
  10030. expressions that will be spliced in the resulting file.
  10031. When @var{set-load-path?} is true, emit code in the resulting file to
  10032. set @code{%load-path} and @code{%load-compiled-path} to honor
  10033. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  10034. @var{module-path}.
  10035. The resulting file holds references to all the dependencies of @var{exp}
  10036. or a subset thereof.
  10037. @end deffn
  10038. @deffn {Procedure} scheme-file name exp [#:splice? #f] [#:set-load-path? #t]
  10039. Return an object representing the Scheme file @var{name} that contains
  10040. @var{exp}.
  10041. This is the declarative counterpart of @code{gexp->file}.
  10042. @end deffn
  10043. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  10044. Return as a monadic value a derivation that builds a text file
  10045. containing all of @var{text}. @var{text} may list, in addition to
  10046. strings, objects of any type that can be used in a gexp: packages,
  10047. derivations, local file objects, etc. The resulting store file holds
  10048. references to all these.
  10049. This variant should be preferred over @code{text-file} anytime the file
  10050. to create will reference items from the store. This is typically the
  10051. case when building a configuration file that embeds store file names,
  10052. like this:
  10053. @lisp
  10054. (define (profile.sh)
  10055. ;; Return the name of a shell script in the store that
  10056. ;; initializes the 'PATH' environment variable.
  10057. (text-file* "profile.sh"
  10058. "export PATH=" coreutils "/bin:"
  10059. grep "/bin:" sed "/bin\n"))
  10060. @end lisp
  10061. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  10062. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  10063. preventing them from being garbage-collected during its lifetime.
  10064. @end deffn
  10065. @deffn {Procedure} mixed-text-file name text @dots{}
  10066. Return an object representing store file @var{name} containing
  10067. @var{text}. @var{text} is a sequence of strings and file-like objects,
  10068. as in:
  10069. @lisp
  10070. (mixed-text-file "profile"
  10071. "export PATH=" coreutils "/bin:" grep "/bin")
  10072. @end lisp
  10073. This is the declarative counterpart of @code{text-file*}.
  10074. @end deffn
  10075. @deffn {Procedure} file-union name files
  10076. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  10077. Each item in @var{files} must be a two-element list where the first element is the
  10078. file name to use in the new directory, and the second element is a gexp
  10079. denoting the target file. Here's an example:
  10080. @lisp
  10081. (file-union "etc"
  10082. `(("hosts" ,(plain-file "hosts"
  10083. "127.0.0.1 localhost"))
  10084. ("bashrc" ,(plain-file "bashrc"
  10085. "alias ls='ls --color=auto'"))))
  10086. @end lisp
  10087. This yields an @code{etc} directory containing these two files.
  10088. @end deffn
  10089. @deffn {Procedure} directory-union name things
  10090. Return a directory that is the union of @var{things}, where @var{things} is a list of
  10091. file-like objects denoting directories. For example:
  10092. @lisp
  10093. (directory-union "guile+emacs" (list guile emacs))
  10094. @end lisp
  10095. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  10096. @end deffn
  10097. @deffn {Procedure} file-append obj suffix @dots{}
  10098. Return a file-like object that expands to the concatenation of @var{obj}
  10099. and @var{suffix}, where @var{obj} is a lowerable object and each
  10100. @var{suffix} is a string.
  10101. As an example, consider this gexp:
  10102. @lisp
  10103. (gexp->script "run-uname"
  10104. #~(system* #$(file-append coreutils
  10105. "/bin/uname")))
  10106. @end lisp
  10107. The same effect could be achieved with:
  10108. @lisp
  10109. (gexp->script "run-uname"
  10110. #~(system* (string-append #$coreutils
  10111. "/bin/uname")))
  10112. @end lisp
  10113. There is one difference though: in the @code{file-append} case, the
  10114. resulting script contains the absolute file name as a string, whereas in
  10115. the second case, the resulting script contains a @code{(string-append
  10116. @dots{})} expression to construct the file name @emph{at run time}.
  10117. @end deffn
  10118. @defmac let-system system body@dots{}
  10119. @defmacx let-system (system target) body@dots{}
  10120. Bind @var{system} to the currently targeted system---e.g.,
  10121. @code{"x86_64-linux"}---within @var{body}.
  10122. In the second case, additionally bind @var{target} to the current
  10123. cross-compilation target---a GNU triplet such as
  10124. @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
  10125. cross-compiling.
  10126. @code{let-system} is useful in the occasional case where the object
  10127. spliced into the gexp depends on the target system, as in this example:
  10128. @lisp
  10129. #~(system*
  10130. #+(let-system system
  10131. (cond ((string-prefix? "armhf-" system)
  10132. (file-append qemu "/bin/qemu-system-arm"))
  10133. ((string-prefix? "x86_64-" system)
  10134. (file-append qemu "/bin/qemu-system-x86_64"))
  10135. (else
  10136. (error "dunno!"))))
  10137. "-net" "user" #$image)
  10138. @end lisp
  10139. @end defmac
  10140. @defmac with-parameters ((parameter value) @dots{}) exp
  10141. This macro is similar to the @code{parameterize} form for
  10142. dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
  10143. Guile Reference Manual}). The key difference is that it takes effect
  10144. when the file-like object returned by @var{exp} is lowered to a
  10145. derivation or store item.
  10146. A typical use of @code{with-parameters} is to force the system in effect
  10147. for a given object:
  10148. @lisp
  10149. (with-parameters ((%current-system "i686-linux"))
  10150. coreutils)
  10151. @end lisp
  10152. The example above returns an object that corresponds to the i686 build
  10153. of Coreutils, regardless of the current value of @code{%current-system}.
  10154. @end defmac
  10155. Of course, in addition to gexps embedded in ``host'' code, there are
  10156. also modules containing build tools. To make it clear that they are
  10157. meant to be used in the build stratum, these modules are kept in the
  10158. @code{(guix build @dots{})} name space.
  10159. @cindex lowering, of high-level objects in gexps
  10160. Internally, high-level objects are @dfn{lowered}, using their compiler,
  10161. to either derivations or store items. For instance, lowering a package
  10162. yields a derivation, and lowering a @code{plain-file} yields a store
  10163. item. This is achieved using the @code{lower-object} monadic procedure.
  10164. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  10165. [#:target #f]
  10166. Return as a value in @code{%store-monad} the derivation or store item
  10167. corresponding to @var{obj} for @var{system}, cross-compiling for
  10168. @var{target} if @var{target} is true. @var{obj} must be an object that
  10169. has an associated gexp compiler, such as a @code{<package>}.
  10170. @end deffn
  10171. @deffn {Procedure} gexp->approximate-sexp gexp
  10172. Sometimes, it may be useful to convert a G-exp into a S-exp. For
  10173. example, some linters (@pxref{Invoking guix lint}) peek into the build
  10174. phases of a package to detect potential problems. This conversion can
  10175. be achieved with this procedure. However, some information can be lost
  10176. in the process. More specifically, lowerable objects will be silently
  10177. replaced with some arbitrary object -- currently the list
  10178. @code{(*approximate*)}, but this may change.
  10179. @end deffn
  10180. @node Invoking guix repl
  10181. @section Invoking @command{guix repl}
  10182. @cindex @command{guix repl}
  10183. @cindex REPL, read-eval-print loop, script
  10184. The @command{guix repl} command makes it easier to program Guix in Guile
  10185. by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
  10186. programming (@pxref{Using Guile Interactively,,, guile,
  10187. GNU Guile Reference Manual}), or by running Guile scripts
  10188. (@pxref{Running Guile Scripts,,, guile,
  10189. GNU Guile Reference Manual}).
  10190. Compared to just launching the @command{guile}
  10191. command, @command{guix repl} guarantees that all the Guix modules and all its
  10192. dependencies are available in the search path.
  10193. The general syntax is:
  10194. @example
  10195. guix repl @var{options} [@var{file} @var{args}]
  10196. @end example
  10197. When a @var{file} argument is provided, @var{file} is
  10198. executed as a Guile scripts:
  10199. @example
  10200. guix repl my-script.scm
  10201. @end example
  10202. To pass arguments to the script, use @code{--} to prevent them from
  10203. being interpreted as arguments to @command{guix repl} itself:
  10204. @example
  10205. guix repl -- my-script.scm --input=foo.txt
  10206. @end example
  10207. To make a script executable directly from the shell, using the guix
  10208. executable that is on the user's search path, add the following two
  10209. lines at the top of the script:
  10210. @example
  10211. @code{#!/usr/bin/env -S guix repl --}
  10212. @code{!#}
  10213. @end example
  10214. To make a script that launches an interactive REPL directly from the
  10215. shell, use the @code{--interactive} flag:
  10216. @example
  10217. @code{#!/usr/bin/env -S guix repl --interactive}
  10218. @code{!#}
  10219. @end example
  10220. Without a file name argument, a Guile REPL is started, allowing for
  10221. interactive use (@pxref{Using Guix Interactively}):
  10222. @example
  10223. $ guix repl
  10224. scheme@@(guile-user)> ,use (gnu packages base)
  10225. scheme@@(guile-user)> coreutils
  10226. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  10227. @end example
  10228. @cindex inferiors
  10229. In addition, @command{guix repl} implements a simple machine-readable REPL
  10230. protocol for use by @code{(guix inferior)}, a facility to interact with
  10231. @dfn{inferiors}, separate processes running a potentially different revision
  10232. of Guix.
  10233. The available options are as follows:
  10234. @table @code
  10235. @item --list-types
  10236. Display the @var{TYPE} options for @command{guix repl --type=TYPE} and
  10237. exit.
  10238. @item --type=@var{type}
  10239. @itemx -t @var{type}
  10240. Start a REPL of the given @var{TYPE}, which can be one of the following:
  10241. @table @code
  10242. @item guile
  10243. This is default, and it spawns a standard full-featured Guile REPL.
  10244. @item machine
  10245. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  10246. that the @code{(guix inferior)} module speaks.
  10247. @end table
  10248. @item --listen=@var{endpoint}
  10249. By default, @command{guix repl} reads from standard input and writes to
  10250. standard output. When this option is passed, it will instead listen for
  10251. connections on @var{endpoint}. Here are examples of valid options:
  10252. @table @code
  10253. @item --listen=tcp:37146
  10254. Accept connections on localhost on port 37146.
  10255. @item --listen=unix:/tmp/socket
  10256. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  10257. @end table
  10258. @item --interactive
  10259. @itemx -i
  10260. Launch the interactive REPL after @var{file} is executed.
  10261. @item --load-path=@var{directory}
  10262. @itemx -L @var{directory}
  10263. Add @var{directory} to the front of the package module search path
  10264. (@pxref{Package Modules}).
  10265. This allows users to define their own packages and make them visible to
  10266. the script or REPL.
  10267. @item -q
  10268. Inhibit loading of the @file{~/.guile} file. By default, that
  10269. configuration file is loaded when spawning a @code{guile} REPL.
  10270. @end table
  10271. @node Using Guix Interactively
  10272. @section Using Guix Interactively
  10273. @cindex interactive use
  10274. @cindex REPL, read-eval-print loop
  10275. The @command{guix repl} command gives you access to a warm and friendly
  10276. @dfn{read-eval-print loop} (REPL) (@pxref{Invoking guix repl}). If
  10277. you're getting into Guix programming---defining your own packages,
  10278. writing manifests, defining services for Guix System or Guix Home,
  10279. etc.---you will surely find it convenient to toy with ideas at the REPL.
  10280. If you use Emacs, the most convenient way to do that is with Geiser
  10281. (@pxref{The Perfect Setup}), but you do not have to use Emacs to enjoy
  10282. the REPL@. When using @command{guix repl} or @command{guile} in the
  10283. terminal, we recommend using Readline for completion and Colorized to
  10284. get colorful output. To do that, you can run:
  10285. @example
  10286. guix install guile guile-readline guile-colorized
  10287. @end example
  10288. @noindent
  10289. ... and then create a @file{.guile} file in your home directory containing
  10290. this:
  10291. @lisp
  10292. (use-modules (ice-9 readline) (ice-9 colorized))
  10293. (activate-readline)
  10294. (activate-colorized)
  10295. @end lisp
  10296. The REPL lets you evaluate Scheme code; you type a Scheme expression at
  10297. the prompt, and the REPL prints what it evaluates to:
  10298. @example
  10299. $ guix repl
  10300. scheme@@(guix-user)> (+ 2 3)
  10301. $1 = 5
  10302. scheme@@(guix-user)> (string-append "a" "b")
  10303. $2 = "ab"
  10304. @end example
  10305. It becomes interesting when you start fiddling with Guix at the REPL.
  10306. The first thing you'll want to do is to ``import'' the @code{(guix)}
  10307. module, which gives access to the main part of the programming
  10308. interface, and perhaps a bunch of useful Guix modules. You could type
  10309. @code{(use-modules (guix))}, which is valid Scheme code to import a
  10310. module (@pxref{Using Guile Modules,,, guile, GNU Guile Reference
  10311. Manual}), but the REPL provides the @code{use} @dfn{command} as a
  10312. shorthand notation (@pxref{REPL Commands,,, guile, GNU Guile Reference
  10313. Manual}):
  10314. @example
  10315. scheme@@(guix-user)> ,use (guix)
  10316. scheme@@(guix-user)> ,use (gnu packages base)
  10317. @end example
  10318. Notice that REPL commands are introduced by a leading comma. A REPL
  10319. command like @code{use} is not valid Scheme code; it's interpreted
  10320. specially by the REPL.
  10321. Guix extends the Guile REPL with additional commands for convenience.
  10322. Among those, the @code{build} command comes in handy: it ensures that
  10323. the given file-like object is built, building it if needed, and returns
  10324. its output file name(s). In the example below, we build the
  10325. @code{coreutils} and @code{grep} packages, as well as a ``computed
  10326. file'' (@pxref{G-Expressions, @code{computed-file}}), and we use the
  10327. @code{scandir} procedure to list the files in Grep's @code{/bin}
  10328. directory:
  10329. @example
  10330. scheme@@(guix-user)> ,build coreutils
  10331. $1 = "/gnu/store/@dots{}-coreutils-8.32-debug"
  10332. $2 = "/gnu/store/@dots{}-coreutils-8.32"
  10333. scheme@@(guix-user)> ,build grep
  10334. $3 = "/gnu/store/@dots{}-grep-3.6"
  10335. scheme@@(guix-user)> ,build (computed-file "x" #~(mkdir #$output))
  10336. building /gnu/store/@dots{}-x.drv...
  10337. $4 = "/gnu/store/@dots{}-x"
  10338. scheme@@(guix-user)> ,use(ice-9 ftw)
  10339. scheme@@(guix-user)> (scandir (string-append $3 "/bin"))
  10340. $5 = ("." ".." "egrep" "fgrep" "grep")
  10341. @end example
  10342. At a lower-level, a useful command is @code{lower}: it takes a file-like
  10343. object and ``lowers'' it into a derivation (@pxref{Derivations}) or a
  10344. store file:
  10345. @example
  10346. scheme@@(guix-user)> ,lower grep
  10347. $6 = #<derivation /gnu/store/@dots{}-grep-3.6.drv => /gnu/store/@dots{}-grep-3.6 7f0e639115f0>
  10348. scheme@@(guix-user)> ,lower (plain-file "x" "Hello!")
  10349. $7 = "/gnu/store/@dots{}-x"
  10350. @end example
  10351. The full list of REPL commands can be seen by typing @code{,help guix}
  10352. and is given below for reference.
  10353. @deffn {REPL command} build @var{object}
  10354. Lower @var{object} and build it if it's not already built, returning its
  10355. output file name(s).
  10356. @end deffn
  10357. @deffn {REPL command} lower @var{object}
  10358. Lower @var{object} into a derivation or store file name and return it.
  10359. @end deffn
  10360. @deffn {REPL command} verbosity @var{level}
  10361. Change build verbosity to @var{level}.
  10362. This is similar to the @option{--verbosity} command-line option
  10363. (@pxref{Common Build Options}): level 0 means total silence, level 1
  10364. shows build events only, and higher levels print build logs.
  10365. @end deffn
  10366. @deffn {REPL command} run-in-store @var{exp}
  10367. Run @var{exp}, a monadic expression, through the store monad.
  10368. @xref{The Store Monad}, for more information.
  10369. @end deffn
  10370. @deffn {REPL command} enter-store-monad
  10371. Enter a new REPL to evaluate monadic expressions (@pxref{The Store
  10372. Monad}). You can quit this ``inner'' REPL by typing @code{,q}.
  10373. @end deffn
  10374. @c *********************************************************************
  10375. @node Utilities
  10376. @chapter Utilities
  10377. This section describes Guix command-line utilities. Some of them are
  10378. primarily targeted at developers and users who write new package
  10379. definitions, while others are more generally useful. They complement
  10380. the Scheme programming interface of Guix in a convenient way.
  10381. @menu
  10382. * Invoking guix build:: Building packages from the command line.
  10383. * Invoking guix edit:: Editing package definitions.
  10384. * Invoking guix download:: Downloading a file and printing its hash.
  10385. * Invoking guix hash:: Computing the cryptographic hash of a file.
  10386. * Invoking guix import:: Importing package definitions.
  10387. * Invoking guix refresh:: Updating package definitions.
  10388. * Invoking guix style:: Styling package definitions.
  10389. * Invoking guix lint:: Finding errors in package definitions.
  10390. * Invoking guix size:: Profiling disk usage.
  10391. * Invoking guix graph:: Visualizing the graph of packages.
  10392. * Invoking guix publish:: Sharing substitutes.
  10393. * Invoking guix challenge:: Challenging substitute servers.
  10394. * Invoking guix copy:: Copying to and from a remote store.
  10395. * Invoking guix container:: Process isolation.
  10396. * Invoking guix weather:: Assessing substitute availability.
  10397. * Invoking guix processes:: Listing client processes.
  10398. @end menu
  10399. @node Invoking guix build
  10400. @section Invoking @command{guix build}
  10401. @cindex package building
  10402. @cindex @command{guix build}
  10403. The @command{guix build} command builds packages or derivations and
  10404. their dependencies, and prints the resulting store paths. Note that it
  10405. does not modify the user's profile---this is the job of the
  10406. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  10407. it is mainly useful for distribution developers.
  10408. The general syntax is:
  10409. @example
  10410. guix build @var{options} @var{package-or-derivation}@dots{}
  10411. @end example
  10412. As an example, the following command builds the latest versions of Emacs
  10413. and of Guile, displays their build logs, and finally displays the
  10414. resulting directories:
  10415. @example
  10416. guix build emacs guile
  10417. @end example
  10418. Similarly, the following command builds all the available packages:
  10419. @example
  10420. guix build --quiet --keep-going \
  10421. $(guix package -A | awk '@{ print $1 "@@" $2 @}')
  10422. @end example
  10423. @var{package-or-derivation} may be either the name of a package found in
  10424. the software distribution such as @code{coreutils} or
  10425. @code{coreutils@@8.20}, or a derivation such as
  10426. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  10427. package with the corresponding name (and optionally version) is searched
  10428. for among the GNU distribution modules (@pxref{Package Modules}).
  10429. Alternatively, the @option{--expression} option may be used to specify a
  10430. Scheme expression that evaluates to a package; this is useful when
  10431. disambiguating among several same-named packages or package variants is
  10432. needed.
  10433. There may be zero or more @var{options}. The available options are
  10434. described in the subsections below.
  10435. @menu
  10436. * Common Build Options:: Build options for most commands.
  10437. * Package Transformation Options:: Creating variants of packages.
  10438. * Additional Build Options:: Options specific to 'guix build'.
  10439. * Debugging Build Failures:: Real life packaging experience.
  10440. @end menu
  10441. @node Common Build Options
  10442. @subsection Common Build Options
  10443. A number of options that control the build process are common to
  10444. @command{guix build} and other commands that can spawn builds, such as
  10445. @command{guix package} or @command{guix archive}. These are the
  10446. following:
  10447. @table @code
  10448. @item --load-path=@var{directory}
  10449. @itemx -L @var{directory}
  10450. Add @var{directory} to the front of the package module search path
  10451. (@pxref{Package Modules}).
  10452. This allows users to define their own packages and make them visible to
  10453. the command-line tools.
  10454. @item --keep-failed
  10455. @itemx -K
  10456. Keep the build tree of failed builds. Thus, if a build fails, its build
  10457. tree is kept under @file{/tmp}, in a directory whose name is shown at
  10458. the end of the build log. This is useful when debugging build issues.
  10459. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  10460. build issues.
  10461. This option implies @option{--no-offload}, and it has no effect when
  10462. connecting to a remote daemon with a @code{guix://} URI (@pxref{The
  10463. Store, the @env{GUIX_DAEMON_SOCKET} variable}).
  10464. @item --keep-going
  10465. @itemx -k
  10466. Keep going when some of the derivations fail to build; return only once
  10467. all the builds have either completed or failed.
  10468. The default behavior is to stop as soon as one of the specified
  10469. derivations has failed.
  10470. @item --dry-run
  10471. @itemx -n
  10472. Do not build the derivations.
  10473. @anchor{fallback-option}
  10474. @item --fallback
  10475. When substituting a pre-built binary fails, fall back to building
  10476. packages locally (@pxref{Substitution Failure}).
  10477. @item --substitute-urls=@var{urls}
  10478. @anchor{client-substitute-urls}
  10479. Consider @var{urls} the whitespace-separated list of substitute source
  10480. URLs, overriding the default list of URLs of @command{guix-daemon}
  10481. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  10482. This means that substitutes may be downloaded from @var{urls}, provided
  10483. they are signed by a key authorized by the system administrator
  10484. (@pxref{Substitutes}).
  10485. When @var{urls} is the empty string, substitutes are effectively
  10486. disabled.
  10487. @item --no-substitutes
  10488. Do not use substitutes for build products. That is, always build things
  10489. locally instead of allowing downloads of pre-built binaries
  10490. (@pxref{Substitutes}).
  10491. @item --no-grafts
  10492. Do not ``graft'' packages. In practice, this means that package updates
  10493. available as grafts are not applied. @xref{Security Updates}, for more
  10494. information on grafts.
  10495. @item --rounds=@var{n}
  10496. Build each derivation @var{n} times in a row, and raise an error if
  10497. consecutive build results are not bit-for-bit identical.
  10498. This is a useful way to detect non-deterministic builds processes.
  10499. Non-deterministic build processes are a problem because they make it
  10500. practically impossible for users to @emph{verify} whether third-party
  10501. binaries are genuine. @xref{Invoking guix challenge}, for more.
  10502. When used in conjunction with @option{--keep-failed}, the differing
  10503. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  10504. This makes it easy to look for differences between the two results.
  10505. @item --no-offload
  10506. Do not use offload builds to other machines (@pxref{Daemon Offload
  10507. Setup}). That is, always build things locally instead of offloading
  10508. builds to remote machines.
  10509. @item --max-silent-time=@var{seconds}
  10510. When the build or substitution process remains silent for more than
  10511. @var{seconds}, terminate it and report a build failure.
  10512. By default, the daemon's setting is honored (@pxref{Invoking
  10513. guix-daemon, @option{--max-silent-time}}).
  10514. @item --timeout=@var{seconds}
  10515. Likewise, when the build or substitution process lasts for more than
  10516. @var{seconds}, terminate it and report a build failure.
  10517. By default, the daemon's setting is honored (@pxref{Invoking
  10518. guix-daemon, @option{--timeout}}).
  10519. @c Note: This option is actually not part of %standard-build-options but
  10520. @c most programs honor it.
  10521. @cindex verbosity, of the command-line tools
  10522. @cindex build logs, verbosity
  10523. @item -v @var{level}
  10524. @itemx --verbosity=@var{level}
  10525. Use the given verbosity @var{level}, an integer. Choosing 0 means that
  10526. no output is produced, 1 is for quiet output; 2 is similar to 1 but it
  10527. additionally displays download URLs; 3 shows all the build log output on
  10528. standard error.
  10529. @item --cores=@var{n}
  10530. @itemx -c @var{n}
  10531. Allow the use of up to @var{n} CPU cores for the build. The special
  10532. value @code{0} means to use as many CPU cores as available.
  10533. @item --max-jobs=@var{n}
  10534. @itemx -M @var{n}
  10535. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  10536. guix-daemon, @option{--max-jobs}}, for details about this option and the
  10537. equivalent @command{guix-daemon} option.
  10538. @item --debug=@var{level}
  10539. Produce debugging output coming from the build daemon. @var{level} must be an
  10540. integer between 0 and 5; higher means more verbose output. Setting a level of
  10541. 4 or more may be helpful when debugging setup issues with the build daemon.
  10542. @end table
  10543. Behind the scenes, @command{guix build} is essentially an interface to
  10544. the @code{package-derivation} procedure of the @code{(guix packages)}
  10545. module, and to the @code{build-derivations} procedure of the @code{(guix
  10546. derivations)} module.
  10547. In addition to options explicitly passed on the command line,
  10548. @command{guix build} and other @command{guix} commands that support
  10549. building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
  10550. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  10551. Users can define this variable to a list of command line options that
  10552. will automatically be used by @command{guix build} and other
  10553. @command{guix} commands that can perform builds, as in the example
  10554. below:
  10555. @example
  10556. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  10557. @end example
  10558. These options are parsed independently, and the result is appended to
  10559. the parsed command-line options.
  10560. @end defvr
  10561. @node Package Transformation Options
  10562. @subsection Package Transformation Options
  10563. @cindex package variants
  10564. Another set of command-line options supported by @command{guix build}
  10565. and also @command{guix package} are @dfn{package transformation
  10566. options}. These are options that make it possible to define @dfn{package
  10567. variants}---for instance, packages built from different source code.
  10568. This is a convenient way to create customized packages on the fly
  10569. without having to type in the definitions of package variants
  10570. (@pxref{Defining Packages}).
  10571. Package transformation options are preserved across upgrades:
  10572. @command{guix upgrade} attempts to apply transformation options
  10573. initially used when creating the profile to the upgraded packages.
  10574. The available options are listed below. Most commands support them and
  10575. also support a @option{--help-transform} option that lists all the
  10576. available options and a synopsis (these options are not shown in the
  10577. @option{--help} output for brevity).
  10578. @table @code
  10579. @cindex performance, tuning code
  10580. @cindex optimization, of package code
  10581. @cindex tuning, of package code
  10582. @cindex SIMD support
  10583. @cindex tunable packages
  10584. @cindex package multi-versioning
  10585. @item --tune[=@var{cpu}]
  10586. Use versions of the packages marked as ``tunable'' optimized for
  10587. @var{cpu}. When @var{cpu} is @code{native}, or when it is omitted, tune
  10588. for the CPU on which the @command{guix} command is running.
  10589. Valid @var{cpu} names are those recognized by the underlying compiler,
  10590. by default the GNU Compiler Collection. On x86_64 processors, this
  10591. includes CPU names such as @code{nehalem}, @code{haswell}, and
  10592. @code{skylake} (@pxref{x86 Options, @code{-march},, gcc, Using the GNU
  10593. Compiler Collection (GCC)}).
  10594. As new generations of CPUs come out, they augment the standard
  10595. instruction set architecture (ISA) with additional instructions, in
  10596. particular instructions for single-instruction/multiple-data (SIMD)
  10597. parallel processing. For example, while Core2 and Skylake CPUs both
  10598. implement the x86_64 ISA, only the latter supports AVX2 SIMD
  10599. instructions.
  10600. The primary gain one can expect from @option{--tune} is for programs
  10601. that can make use of those SIMD capabilities @emph{and} that do not
  10602. already have a mechanism to select the right optimized code at run time.
  10603. Packages that have the @code{tunable?} property set are considered
  10604. @dfn{tunable packages} by the @option{--tune} option; a package
  10605. definition with the property set looks like this:
  10606. @lisp
  10607. (package
  10608. (name "hello-simd")
  10609. ;; ...
  10610. ;; This package may benefit from SIMD extensions so
  10611. ;; mark it as "tunable".
  10612. (properties '((tunable? . #t))))
  10613. @end lisp
  10614. Other packages are not considered tunable. This allows Guix to use
  10615. generic binaries in the cases where tuning for a specific CPU is
  10616. unlikely to provide any gain.
  10617. Tuned packages are built with @code{-march=@var{CPU}}; under the hood,
  10618. the @option{-march} option is passed to the actual wrapper by a compiler
  10619. wrapper. Since the build machine may not be able to run code for the
  10620. target CPU micro-architecture, the test suite is not run when building a
  10621. tuned package.
  10622. To reduce rebuilds to the minimum, tuned packages are @emph{grafted}
  10623. onto packages that depend on them (@pxref{Security Updates, grafts}).
  10624. Thus, using @option{--no-grafts} cancels the effect of @option{--tune}.
  10625. We call this technique @dfn{package multi-versioning}: several variants
  10626. of tunable packages may be built, one for each CPU variant. It is the
  10627. coarse-grain counterpart of @dfn{function multi-versioning} as
  10628. implemented by the GNU tool chain (@pxref{Function Multiversioning,,,
  10629. gcc, Using the GNU Compiler Collection (GCC)}).
  10630. @item --with-source=@var{source}
  10631. @itemx --with-source=@var{package}=@var{source}
  10632. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  10633. Use @var{source} as the source of @var{package}, and @var{version} as
  10634. its version number.
  10635. @var{source} must be a file name or a URL, as for @command{guix
  10636. download} (@pxref{Invoking guix download}).
  10637. When @var{package} is omitted,
  10638. it is taken to be the package name specified on the
  10639. command line that matches the base of @var{source}---e.g.,
  10640. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  10641. package is @code{guile}.
  10642. Likewise, when @var{version} is omitted, the version string is inferred from
  10643. @var{source}; in the previous example, it is @code{2.0.10}.
  10644. This option allows users to try out versions of packages other than the
  10645. one provided by the distribution. The example below downloads
  10646. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  10647. the @code{ed} package:
  10648. @example
  10649. guix build ed --with-source=mirror://gnu/ed/ed-1.4.tar.gz
  10650. @end example
  10651. As a developer, @option{--with-source} makes it easy to test release
  10652. candidates, and even to test their impact on packages that depend on
  10653. them:
  10654. @example
  10655. guix build elogind --with-source=@dots{}/shepherd-0.9.0rc1.tar.gz
  10656. @end example
  10657. @dots{} or to build from a checkout in a pristine environment:
  10658. @example
  10659. $ git clone git://git.sv.gnu.org/guix.git
  10660. $ guix build guix --with-source=guix@@1.0=./guix
  10661. @end example
  10662. @item --with-input=@var{package}=@var{replacement}
  10663. Replace dependency on @var{package} by a dependency on
  10664. @var{replacement}. @var{package} must be a package name, and
  10665. @var{replacement} must be a package specification such as @code{guile}
  10666. or @code{guile@@1.8}.
  10667. For instance, the following command builds Guix, but replaces its
  10668. dependency on the current stable version of Guile with a dependency on
  10669. the legacy version of Guile, @code{guile@@2.2}:
  10670. @example
  10671. guix build --with-input=guile=guile@@2.2 guix
  10672. @end example
  10673. This is a recursive, deep replacement. So in this example, both
  10674. @code{guix} and its dependency @code{guile-json} (which also depends on
  10675. @code{guile}) get rebuilt against @code{guile@@2.2}.
  10676. This is implemented using the @code{package-input-rewriting/spec} Scheme
  10677. procedure (@pxref{Defining Packages, @code{package-input-rewriting/spec}}).
  10678. @item --with-graft=@var{package}=@var{replacement}
  10679. This is similar to @option{--with-input} but with an important difference:
  10680. instead of rebuilding the whole dependency chain, @var{replacement} is
  10681. built and then @dfn{grafted} onto the binaries that were initially
  10682. referring to @var{package}. @xref{Security Updates}, for more
  10683. information on grafts.
  10684. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  10685. and all its dependencies, replacing references to the version of GnuTLS
  10686. they currently refer to:
  10687. @example
  10688. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  10689. @end example
  10690. This has the advantage of being much faster than rebuilding everything.
  10691. But there is a caveat: it works if and only if @var{package} and
  10692. @var{replacement} are strictly compatible---for example, if they provide
  10693. a library, the application binary interface (ABI) of those libraries
  10694. must be compatible. If @var{replacement} is somehow incompatible with
  10695. @var{package}, then the resulting package may be unusable. Use with
  10696. care!
  10697. @cindex debugging info, rebuilding
  10698. @item --with-debug-info=@var{package}
  10699. Build @var{package} in a way that preserves its debugging info and graft
  10700. it onto packages that depend on it. This is useful if @var{package}
  10701. does not already provide debugging info as a @code{debug} output
  10702. (@pxref{Installing Debugging Files}).
  10703. For example, suppose you're experiencing a crash in Inkscape and would
  10704. like to see what's up in GLib, a library deep down in Inkscape's
  10705. dependency graph. GLib lacks a @code{debug} output, so debugging is
  10706. tough. Fortunately, you rebuild GLib with debugging info and tack it on
  10707. Inkscape:
  10708. @example
  10709. guix install inkscape --with-debug-info=glib
  10710. @end example
  10711. Only GLib needs to be recompiled so this takes a reasonable amount of
  10712. time. @xref{Installing Debugging Files}, for more info.
  10713. @quotation Note
  10714. Under the hood, this option works by passing the @samp{#:strip-binaries?
  10715. #f} to the build system of the package of interest (@pxref{Build
  10716. Systems}). Most build systems support that option but some do not. In
  10717. that case, an error is raised.
  10718. Likewise, if a C/C++ package is built without @code{-g} (which is rarely
  10719. the case), debugging info will remain unavailable even when
  10720. @code{#:strip-binaries?} is false.
  10721. @end quotation
  10722. @cindex tool chain, changing the build tool chain of a package
  10723. @item --with-c-toolchain=@var{package}=@var{toolchain}
  10724. This option changes the compilation of @var{package} and everything that
  10725. depends on it so that they get built with @var{toolchain} instead of the
  10726. default GNU tool chain for C/C++.
  10727. Consider this example:
  10728. @example
  10729. guix build octave-cli \
  10730. --with-c-toolchain=fftw=gcc-toolchain@@10 \
  10731. --with-c-toolchain=fftwf=gcc-toolchain@@10
  10732. @end example
  10733. The command above builds a variant of the @code{fftw} and @code{fftwf}
  10734. packages using version 10 of @code{gcc-toolchain} instead of the default
  10735. tool chain, and then builds a variant of the GNU@tie{}Octave
  10736. command-line interface using them. GNU@tie{}Octave itself is also built
  10737. with @code{gcc-toolchain@@10}.
  10738. This other example builds the Hardware Locality (@code{hwloc}) library
  10739. and its dependents up to @code{intel-mpi-benchmarks} with the Clang C
  10740. compiler:
  10741. @example
  10742. guix build --with-c-toolchain=hwloc=clang-toolchain \
  10743. intel-mpi-benchmarks
  10744. @end example
  10745. @quotation Note
  10746. There can be application binary interface (ABI) incompatibilities among
  10747. tool chains. This is particularly true of the C++ standard library and
  10748. run-time support libraries such as that of OpenMP@. By rebuilding all
  10749. dependents with the same tool chain, @option{--with-c-toolchain} minimizes
  10750. the risks of incompatibility but cannot entirely eliminate them. Choose
  10751. @var{package} wisely.
  10752. @end quotation
  10753. @item --with-git-url=@var{package}=@var{url}
  10754. @cindex Git, using the latest commit
  10755. @cindex latest commit, building
  10756. Build @var{package} from the latest commit of the @code{master} branch of the
  10757. Git repository at @var{url}. Git sub-modules of the repository are fetched,
  10758. recursively.
  10759. For example, the following command builds the NumPy Python library against the
  10760. latest commit of the master branch of Python itself:
  10761. @example
  10762. guix build python-numpy \
  10763. --with-git-url=python=https://github.com/python/cpython
  10764. @end example
  10765. This option can also be combined with @option{--with-branch} or
  10766. @option{--with-commit} (see below).
  10767. @cindex continuous integration
  10768. Obviously, since it uses the latest commit of the given branch, the result of
  10769. such a command varies over time. Nevertheless it is a convenient way to
  10770. rebuild entire software stacks against the latest commit of one or more
  10771. packages. This is particularly useful in the context of continuous
  10772. integration (CI).
  10773. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  10774. consecutive accesses to the same repository. You may want to clean it up once
  10775. in a while to save disk space.
  10776. @item --with-branch=@var{package}=@var{branch}
  10777. Build @var{package} from the latest commit of @var{branch}. If the
  10778. @code{source} field of @var{package} is an origin with the @code{git-fetch}
  10779. method (@pxref{origin Reference}) or a @code{git-checkout} object, the
  10780. repository URL is taken from that @code{source}. Otherwise you have to use
  10781. @option{--with-git-url} to specify the URL of the Git repository.
  10782. For instance, the following command builds @code{guile-sqlite3} from the
  10783. latest commit of its @code{master} branch, and then builds @code{guix} (which
  10784. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  10785. specific @code{guile-sqlite3} build:
  10786. @example
  10787. guix build --with-branch=guile-sqlite3=master cuirass
  10788. @end example
  10789. @item --with-commit=@var{package}=@var{commit}
  10790. This is similar to @option{--with-branch}, except that it builds from
  10791. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  10792. Git commit SHA1 identifier, a tag, or a @command{git describe} style
  10793. identifier such as @code{1.0-3-gabc123}.
  10794. @item --with-patch=@var{package}=@var{file}
  10795. Add @var{file} to the list of patches applied to @var{package}, where
  10796. @var{package} is a spec such as @code{python@@3.8} or @code{glibc}.
  10797. @var{file} must contain a patch; it is applied with the flags specified
  10798. in the @code{origin} of @var{package} (@pxref{origin Reference}), which
  10799. by default includes @code{-p1} (@pxref{patch Directories,,, diffutils,
  10800. Comparing and Merging Files}).
  10801. As an example, the command below rebuilds Coreutils with the GNU C
  10802. Library (glibc) patched with the given patch:
  10803. @example
  10804. guix build coreutils --with-patch=glibc=./glibc-frob.patch
  10805. @end example
  10806. In this example, glibc itself as well as everything that leads to
  10807. Coreutils in the dependency graph is rebuilt.
  10808. @cindex configure flags, changing them
  10809. @item --with-configure-flag=@var{package}=@var{flag}
  10810. Append @var{flag} to the configure flags of @var{package}, where
  10811. @var{package} is a spec such as @code{guile@@3.0} or @code{glibc}. The
  10812. build system of @var{package} must support the @code{#:configure-flags}
  10813. argument.
  10814. For example, the command below builds GNU@tie{}Hello with the
  10815. configure flag @code{--disable-nls}:
  10816. @example
  10817. guix build hello --with-configure-flag=hello=--disable-nls
  10818. @end example
  10819. The following command passes an extra flag to @command{cmake} as it
  10820. builds @code{lapack}:
  10821. @example
  10822. guix build lapack \
  10823. --with-configure-flag=lapack=-DBUILD_SHARED_LIBS=OFF
  10824. @end example
  10825. @quotation Note
  10826. Under the hood, this option works by passing the
  10827. @samp{#:configure-flags} argument to the build system of the package of
  10828. interest (@pxref{Build Systems}). Most build systems support that
  10829. option but some do not. In that case, an error is raised.
  10830. @end quotation
  10831. @cindex upstream, latest version
  10832. @item --with-latest=@var{package}
  10833. @itemx --with-version=@var{package}=@var{version}
  10834. So you like living on the bleeding edge? The @option{--with-latest}
  10835. option is for you! It
  10836. replaces occurrences of @var{package} in the dependency graph with its
  10837. latest upstream version, as reported by @command{guix refresh}
  10838. (@pxref{Invoking guix refresh}).
  10839. It does so by determining the latest upstream release of @var{package}
  10840. (if possible), downloading it, and authenticating it @emph{if} it comes
  10841. with an OpenPGP signature.
  10842. As an example, the command below builds Guix against the latest version
  10843. of Guile-JSON:
  10844. @example
  10845. guix build guix --with-latest=guile-json
  10846. @end example
  10847. The @option{--with-version} works similarly except that it lets you
  10848. specify that you want precisely @var{version}, assuming that version
  10849. exists upstream. For example, to spawn a development environment with
  10850. SciPy built against version 1.22.4 of NumPy (skipping its test suite
  10851. because hey, we're not gonna wait this long), you would run:
  10852. @example
  10853. guix shell python python-scipy --with-version=python-numpy=1.22.4
  10854. @end example
  10855. @quotation Warning
  10856. Because they depend on source code published at a given point in time on
  10857. upstream servers, deployments made with @option{--with-latest} and
  10858. @option{--with-version} may be non-reproducible: source might disappear
  10859. or be modified in place on the servers.
  10860. To deploy old software versions without compromising on reproducibility,
  10861. @pxref{Invoking guix time-machine, @command{guix time-machine}}.
  10862. @end quotation
  10863. There are limitations. First, in cases where the tool cannot or does
  10864. not know how to authenticate source code, you are at risk of running
  10865. malicious code; a warning is emitted in this case. Second, this option
  10866. simply changes the source used in the existing package definitions,
  10867. which is not always sufficient: there might be additional dependencies
  10868. that need to be added, patches to apply, and more generally the quality
  10869. assurance work that Guix developers normally do will be missing.
  10870. You've been warned! When those limitations are acceptable, it's a
  10871. snappy way to stay on top. We encourage you to submit patches updating
  10872. the actual package definitions once you have successfully tested an
  10873. upgrade with @option{--with-latest} (@pxref{Contributing}).
  10874. @cindex test suite, skipping
  10875. @item --without-tests=@var{package}
  10876. Build @var{package} without running its tests. This can be useful in
  10877. situations where you want to skip the lengthy test suite of a
  10878. intermediate package, or if a package's test suite fails in a
  10879. non-deterministic fashion. It should be used with care because running
  10880. the test suite is a good way to ensure a package is working as intended.
  10881. Turning off tests leads to a different store item. Consequently, when
  10882. using this option, anything that depends on @var{package} must be
  10883. rebuilt, as in this example:
  10884. @example
  10885. guix install --without-tests=python python-notebook
  10886. @end example
  10887. The command above installs @code{python-notebook} on top of
  10888. @code{python} built without running its test suite. To do so, it also
  10889. rebuilds everything that depends on @code{python}, including
  10890. @code{python-notebook} itself.
  10891. Internally, @option{--without-tests} relies on changing the
  10892. @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
  10893. Systems}). Note that some packages use a customized @code{check} phase
  10894. that does not respect a @code{#:tests? #f} setting. Therefore,
  10895. @option{--without-tests} has no effect on these packages.
  10896. @end table
  10897. Wondering how to achieve the same effect using Scheme code, for example
  10898. in your manifest, or how to write your own package transformation?
  10899. @xref{Defining Package Variants}, for an overview of the programming
  10900. interfaces available.
  10901. @node Additional Build Options
  10902. @subsection Additional Build Options
  10903. The command-line options presented below are specific to @command{guix
  10904. build}.
  10905. @table @code
  10906. @item --quiet
  10907. @itemx -q
  10908. Build quietly, without displaying the build log; this is equivalent to
  10909. @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
  10910. (or similar) and can always be retrieved using the @option{--log-file} option.
  10911. @item --file=@var{file}
  10912. @itemx -f @var{file}
  10913. Build the package, derivation, or other file-like object that the code within
  10914. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  10915. As an example, @var{file} might contain a package definition like this
  10916. (@pxref{Defining Packages}):
  10917. @lisp
  10918. @include package-hello.scm
  10919. @end lisp
  10920. The @var{file} may also contain a JSON representation of one or more
  10921. package definitions. Running @code{guix build -f} on @file{hello.json}
  10922. with the following contents would result in building the packages
  10923. @code{myhello} and @code{greeter}:
  10924. @example
  10925. @verbatiminclude package-hello.json
  10926. @end example
  10927. @item --manifest=@var{manifest}
  10928. @itemx -m @var{manifest}
  10929. Build all packages listed in the given @var{manifest}
  10930. (@pxref{profile-manifest, @option{--manifest}}).
  10931. @item --expression=@var{expr}
  10932. @itemx -e @var{expr}
  10933. Build the package or derivation @var{expr} evaluates to.
  10934. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  10935. guile-1.8)}, which unambiguously designates this specific variant of
  10936. version 1.8 of Guile.
  10937. Alternatively, @var{expr} may be a G-expression, in which case it is used
  10938. as a build program passed to @code{gexp->derivation}
  10939. (@pxref{G-Expressions}).
  10940. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  10941. (@pxref{The Store Monad}). The procedure must return a derivation as a
  10942. monadic value, which is then passed through @code{run-with-store}.
  10943. @item --source
  10944. @itemx -S
  10945. Build the source derivations of the packages, rather than the packages
  10946. themselves.
  10947. For instance, @code{guix build -S gcc} returns something like
  10948. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  10949. source tarball.
  10950. The returned source tarball is the result of applying any patches and
  10951. code snippets specified in the package @code{origin} (@pxref{Defining
  10952. Packages}).
  10953. @cindex source, verification
  10954. As with other derivations, the result of building a source derivation
  10955. can be verified using the @option{--check} option (@pxref{build-check}).
  10956. This is useful to validate that a (potentially already built or
  10957. substituted, thus cached) package source matches against its declared
  10958. hash.
  10959. Note that @command{guix build -S} compiles the sources only of the
  10960. specified packages. They do not include the sources of statically
  10961. linked dependencies and by themselves are insufficient for reproducing
  10962. the packages.
  10963. @item --sources
  10964. Fetch and return the source of @var{package-or-derivation} and all their
  10965. dependencies, recursively. This is a handy way to obtain a local copy
  10966. of all the source code needed to build @var{packages}, allowing you to
  10967. eventually build them even without network access. It is an extension
  10968. of the @option{--source} option and can accept one of the following
  10969. optional argument values:
  10970. @table @code
  10971. @item package
  10972. This value causes the @option{--sources} option to behave in the same way
  10973. as the @option{--source} option.
  10974. @item all
  10975. Build the source derivations of all packages, including any source that
  10976. might be listed as @code{inputs}. This is the default value.
  10977. @example
  10978. $ guix build --sources tzdata
  10979. The following derivations will be built:
  10980. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  10981. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  10982. @end example
  10983. @item transitive
  10984. Build the source derivations of all packages, as well of all transitive
  10985. inputs to the packages. This can be used e.g.@: to
  10986. prefetch package source for later offline building.
  10987. @example
  10988. $ guix build --sources=transitive tzdata
  10989. The following derivations will be built:
  10990. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  10991. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  10992. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  10993. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  10994. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  10995. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  10996. @dots{}
  10997. @end example
  10998. @end table
  10999. @item --system=@var{system}
  11000. @itemx -s @var{system}
  11001. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  11002. the system type of the build host. The @command{guix build} command allows
  11003. you to repeat this option several times, in which case it builds for all the
  11004. specified systems; other commands ignore extraneous @option{-s} options.
  11005. @quotation Note
  11006. The @option{--system} flag is for @emph{native} compilation and must not
  11007. be confused with cross-compilation. See @option{--target} below for
  11008. information on cross-compilation.
  11009. @end quotation
  11010. An example use of this is on Linux-based systems, which can emulate
  11011. different personalities. For instance, passing
  11012. @option{--system=i686-linux} on an @code{x86_64-linux} system or
  11013. @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
  11014. you to build packages in a complete 32-bit environment.
  11015. @quotation Note
  11016. Building for an @code{armhf-linux} system is unconditionally enabled on
  11017. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  11018. allow for this functionality, notably the ThunderX.
  11019. @end quotation
  11020. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  11021. is enabled (@pxref{Virtualization Services,
  11022. @code{qemu-binfmt-service-type}}), you can build for any system for
  11023. which a QEMU @code{binfmt_misc} handler is installed.
  11024. Builds for a system other than that of the machine you are using can
  11025. also be offloaded to a remote machine of the right architecture.
  11026. @xref{Daemon Offload Setup}, for more information on offloading.
  11027. @item --target=@var{triplet}
  11028. @cindex cross-compilation
  11029. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  11030. as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
  11031. configuration triplets,, autoconf, Autoconf}).
  11032. @item --list-systems
  11033. List all the supported systems, that can be passed as an argument to
  11034. @option{--system}.
  11035. @item --list-targets
  11036. List all the supported targets, that can be passed as an argument to
  11037. @option{--target}.
  11038. @anchor{build-check}
  11039. @item --check
  11040. @cindex determinism, checking
  11041. @cindex reproducibility, checking
  11042. Rebuild @var{package-or-derivation}, which are already available in the
  11043. store, and raise an error if the build results are not bit-for-bit
  11044. identical.
  11045. This mechanism allows you to check whether previously installed
  11046. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  11047. of a package is deterministic. @xref{Invoking guix challenge}, for more
  11048. background information and tools.
  11049. When used in conjunction with @option{--keep-failed}, the differing
  11050. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  11051. This makes it easy to look for differences between the two results.
  11052. @item --repair
  11053. @cindex repairing store items
  11054. @cindex corruption, recovering from
  11055. Attempt to repair the specified store items, if they are corrupt, by
  11056. re-downloading or rebuilding them.
  11057. This operation is not atomic and thus restricted to @code{root}.
  11058. @item --derivations
  11059. @itemx -d
  11060. Return the derivation paths, not the output paths, of the given
  11061. packages.
  11062. @item --root=@var{file}
  11063. @itemx -r @var{file}
  11064. @cindex GC roots, adding
  11065. @cindex garbage collector roots, adding
  11066. Make @var{file} a symlink to the result, and register it as a garbage
  11067. collector root.
  11068. Consequently, the results of this @command{guix build} invocation are
  11069. protected from garbage collection until @var{file} is removed. When
  11070. that option is omitted, build results are eligible for garbage
  11071. collection as soon as the build completes. @xref{Invoking guix gc}, for
  11072. more on GC roots.
  11073. @item --log-file
  11074. @cindex build logs, access
  11075. Return the build log file names or URLs for the given
  11076. @var{package-or-derivation}, or raise an error if build logs are
  11077. missing.
  11078. This works regardless of how packages or derivations are specified. For
  11079. instance, the following invocations are equivalent:
  11080. @example
  11081. guix build --log-file $(guix build -d guile)
  11082. guix build --log-file $(guix build guile)
  11083. guix build --log-file guile
  11084. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  11085. @end example
  11086. If a log is unavailable locally, and unless @option{--no-substitutes} is
  11087. passed, the command looks for a corresponding log on one of the
  11088. substitute servers (as specified with @option{--substitute-urls}).
  11089. So for instance, imagine you want to see the build log of GDB on
  11090. @code{aarch64}, but you are actually on an @code{x86_64} machine:
  11091. @example
  11092. $ guix build --log-file gdb -s aarch64-linux
  11093. https://@value{SUBSTITUTE-SERVER-1}/log/@dots{}-gdb-7.10
  11094. @end example
  11095. You can freely access a huge library of build logs!
  11096. @end table
  11097. @node Debugging Build Failures
  11098. @subsection Debugging Build Failures
  11099. @cindex build failures, debugging
  11100. When defining a new package (@pxref{Defining Packages}), you will
  11101. probably find yourself spending some time debugging and tweaking the
  11102. build until it succeeds. To do that, you need to operate the build
  11103. commands yourself in an environment as close as possible to the one the
  11104. build daemon uses.
  11105. To that end, the first thing to do is to use the @option{--keep-failed}
  11106. or @option{-K} option of @command{guix build}, which will keep the
  11107. failed build tree in @file{/tmp} or whatever directory you specified as
  11108. @env{TMPDIR} (@pxref{Common Build Options, @option{--keep-failed}}).
  11109. From there on, you can @command{cd} to the failed build tree and source
  11110. the @file{environment-variables} file, which contains all the
  11111. environment variable definitions that were in place when the build
  11112. failed. So let's say you're debugging a build failure in package
  11113. @code{foo}; a typical session would look like this:
  11114. @example
  11115. $ guix build foo -K
  11116. @dots{} @i{build fails}
  11117. $ cd /tmp/guix-build-foo.drv-0
  11118. $ source ./environment-variables
  11119. $ cd foo-1.2
  11120. @end example
  11121. Now, you can invoke commands as if you were the daemon (almost) and
  11122. troubleshoot your build process.
  11123. Sometimes it happens that, for example, a package's tests pass when you
  11124. run them manually but they fail when the daemon runs them. This can
  11125. happen because the daemon runs builds in containers where, unlike in our
  11126. environment above, network access is missing, @file{/bin/sh} does not
  11127. exist, etc. (@pxref{Build Environment Setup}).
  11128. In such cases, you may need to run inspect the build process from within
  11129. a container similar to the one the build daemon creates:
  11130. @example
  11131. $ guix build -K foo
  11132. @dots{}
  11133. $ cd /tmp/guix-build-foo.drv-0
  11134. $ guix shell --no-grafts -C -D foo strace gdb
  11135. [env]# source ./environment-variables
  11136. [env]# cd foo-1.2
  11137. @end example
  11138. Here, @command{guix shell -C} creates a container and spawns a new
  11139. shell in it (@pxref{Invoking guix shell}). The @command{strace gdb}
  11140. part adds the @command{strace} and @command{gdb} commands to
  11141. the container, which you may find handy while debugging. The
  11142. @option{--no-grafts} option makes sure we get the exact same
  11143. environment, with ungrafted packages (@pxref{Security Updates}, for more
  11144. info on grafts).
  11145. To get closer to a container like that used by the build daemon, we can
  11146. remove @file{/bin/sh}:
  11147. @example
  11148. [env]# rm /bin/sh
  11149. @end example
  11150. (Don't worry, this is harmless: this is all happening in the throw-away
  11151. container created by @command{guix shell}.)
  11152. The @command{strace} command is probably not in the search path, but we
  11153. can run:
  11154. @example
  11155. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  11156. @end example
  11157. In this way, not only you will have reproduced the environment variables
  11158. the daemon uses, you will also be running the build process in a container
  11159. similar to the one the daemon uses.
  11160. @node Invoking guix edit
  11161. @section Invoking @command{guix edit}
  11162. @cindex @command{guix edit}
  11163. @cindex package definition, editing
  11164. So many packages, so many source files! The @command{guix edit} command
  11165. facilitates the life of users and packagers by pointing their editor at
  11166. the source file containing the definition of the specified packages.
  11167. For instance:
  11168. @example
  11169. guix edit gcc@@4.9 vim
  11170. @end example
  11171. @noindent
  11172. launches the program specified in the @env{VISUAL} or in the
  11173. @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  11174. and that of Vim.
  11175. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  11176. have created your own packages on @env{GUIX_PACKAGE_PATH}
  11177. (@pxref{Package Modules}), you will be able to edit the package
  11178. recipes. In other cases, you will be able to examine the read-only recipes
  11179. for packages currently in the store.
  11180. Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
  11181. @option{--load-path=@var{directory}} (or in short @option{-L
  11182. @var{directory}}) allows you to add @var{directory} to the front of the
  11183. package module search path and so make your own packages visible.
  11184. @node Invoking guix download
  11185. @section Invoking @command{guix download}
  11186. @cindex @command{guix download}
  11187. @cindex downloading package sources
  11188. When writing a package definition, developers typically need to download
  11189. a source tarball, compute its SHA256 hash, and write that
  11190. hash in the package definition (@pxref{Defining Packages}). The
  11191. @command{guix download} tool helps with this task: it downloads a file
  11192. from the given URI, adds it to the store, and prints both its file name
  11193. in the store and its SHA256 hash.
  11194. The fact that the downloaded file is added to the store saves bandwidth:
  11195. when the developer eventually tries to build the newly defined package
  11196. with @command{guix build}, the source tarball will not have to be
  11197. downloaded again because it is already in the store. It is also a
  11198. convenient way to temporarily stash files, which may be deleted
  11199. eventually (@pxref{Invoking guix gc}).
  11200. The @command{guix download} command supports the same URIs as used in
  11201. package definitions. In particular, it supports @code{mirror://} URIs.
  11202. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  11203. Guile bindings for GnuTLS are available in the user's environment; when
  11204. they are not available, an error is raised. @xref{Guile Preparations,
  11205. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  11206. GnuTLS-Guile}, for more information.
  11207. @command{guix download} verifies HTTPS server certificates by loading
  11208. the certificates of X.509 authorities from the directory pointed to by
  11209. the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
  11210. Certificates}), unless @option{--no-check-certificate} is used.
  11211. The following options are available:
  11212. @table @code
  11213. @item --hash=@var{algorithm}
  11214. @itemx -H @var{algorithm}
  11215. Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
  11216. hash}, for more information.
  11217. @item --format=@var{fmt}
  11218. @itemx -f @var{fmt}
  11219. Write the hash in the format specified by @var{fmt}. For more
  11220. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  11221. @item --no-check-certificate
  11222. Do not validate the X.509 certificates of HTTPS servers.
  11223. When using this option, you have @emph{absolutely no guarantee} that you
  11224. are communicating with the authentic server responsible for the given
  11225. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  11226. @item --output=@var{file}
  11227. @itemx -o @var{file}
  11228. Save the downloaded file to @var{file} instead of adding it to the
  11229. store.
  11230. @end table
  11231. @node Invoking guix hash
  11232. @section Invoking @command{guix hash}
  11233. @cindex @command{guix hash}
  11234. The @command{guix hash} command computes the hash of a file.
  11235. It is primarily a convenience tool for anyone contributing to the
  11236. distribution: it computes the cryptographic hash of one or more files, which can be
  11237. used in the definition of a package (@pxref{Defining Packages}).
  11238. The general syntax is:
  11239. @example
  11240. guix hash @var{option} @var{file} ...
  11241. @end example
  11242. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  11243. hash of data read from standard input. @command{guix hash} has the
  11244. following options:
  11245. @table @code
  11246. @item --hash=@var{algorithm}
  11247. @itemx -H @var{algorithm}
  11248. Compute a hash using the specified @var{algorithm}, @code{sha256} by
  11249. default.
  11250. @var{algorithm} must be the name of a cryptographic hash algorithm
  11251. supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
  11252. @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
  11253. Reference Manual}).
  11254. @item --format=@var{fmt}
  11255. @itemx -f @var{fmt}
  11256. Write the hash in the format specified by @var{fmt}.
  11257. Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
  11258. (@code{hex} and @code{hexadecimal} can be used as well).
  11259. If the @option{--format} option is not specified, @command{guix hash}
  11260. will output the hash in @code{nix-base32}. This representation is used
  11261. in the definitions of packages.
  11262. @item --recursive
  11263. @itemx -r
  11264. The @option{--recursive} option is deprecated in favor of
  11265. @option{--serializer=nar} (see below); @option{-r} remains accepted as a
  11266. convenient shorthand.
  11267. @item --serializer=@var{type}
  11268. @itemx -S @var{type}
  11269. Compute the hash on @var{file} using @var{type} serialization.
  11270. @var{type} may be one of the following:
  11271. @table @code
  11272. @item none
  11273. This is the default: it computes the hash of a file's contents.
  11274. @item nar
  11275. Compute the hash of a ``normalized archive'' (or ``nar'') containing
  11276. @var{file}, including its children if it is a directory. Some of the
  11277. metadata of @var{file} is part of the archive; for instance, when
  11278. @var{file} is a regular file, the hash is different depending on whether
  11279. @var{file} is executable or not. Metadata such as time stamps have no
  11280. impact on the hash (@pxref{Invoking guix archive}, for more info on the
  11281. nar format).
  11282. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  11283. @c it exists.
  11284. @item git
  11285. Compute the hash of the file or directory as a Git ``tree'', following
  11286. the same method as the Git version control system.
  11287. @end table
  11288. @item --exclude-vcs
  11289. @itemx -x
  11290. When combined with @option{--recursive}, exclude version control system
  11291. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
  11292. @vindex git-fetch
  11293. As an example, here is how you would compute the hash of a Git checkout,
  11294. which is useful when using the @code{git-fetch} method (@pxref{origin
  11295. Reference}):
  11296. @example
  11297. $ git clone http://example.org/foo.git
  11298. $ cd foo
  11299. $ guix hash -x --serializer=nar .
  11300. @end example
  11301. @end table
  11302. @node Invoking guix import
  11303. @section Invoking @command{guix import}
  11304. @cindex importing packages
  11305. @cindex package import
  11306. @cindex package conversion
  11307. @cindex Invoking @command{guix import}
  11308. The @command{guix import} command is useful for people who would like to
  11309. add a package to the distribution with as little work as
  11310. possible---a legitimate demand. The command knows of a few
  11311. repositories from which it can ``import'' package metadata. The result
  11312. is a package definition, or a template thereof, in the format we know
  11313. (@pxref{Defining Packages}).
  11314. The general syntax is:
  11315. @example
  11316. guix import @var{importer} @var{options}@dots{}
  11317. @end example
  11318. @var{importer} specifies the source from which to import package
  11319. metadata, and @var{options} specifies a package identifier and other
  11320. options specific to @var{importer}.
  11321. Some of the importers rely on the ability to run the @command{gpgv} command.
  11322. For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
  11323. gnupg} if needed.
  11324. Currently, the available ``importers'' are:
  11325. @table @code
  11326. @item gnu
  11327. Import metadata for the given GNU package. This provides a template
  11328. for the latest version of that GNU package, including the hash of its
  11329. source tarball, and its canonical synopsis and description.
  11330. Additional information such as the package dependencies and its
  11331. license needs to be figured out manually.
  11332. For example, the following command returns a package definition for
  11333. GNU@tie{}Hello:
  11334. @example
  11335. guix import gnu hello
  11336. @end example
  11337. Specific command-line options are:
  11338. @table @code
  11339. @item --key-download=@var{policy}
  11340. As for @command{guix refresh}, specify the policy to handle missing
  11341. OpenPGP keys when verifying the package signature. @xref{Invoking guix
  11342. refresh, @option{--key-download}}.
  11343. @end table
  11344. @item pypi
  11345. @cindex pypi
  11346. Import metadata from the @uref{https://pypi.python.org/, Python Package
  11347. Index}. Information is taken from the JSON-formatted description
  11348. available at @code{pypi.python.org} and usually includes all the relevant
  11349. information, including package dependencies. For maximum efficiency, it
  11350. is recommended to install the @command{unzip} utility, so that the
  11351. importer can unzip Python wheels and gather data from them.
  11352. The command below imports metadata for the latest version of the
  11353. @code{itsdangerous} Python package:
  11354. @example
  11355. guix import pypi itsdangerous
  11356. @end example
  11357. You can also ask for a specific version:
  11358. @example
  11359. guix import pypi itsdangerous@@1.1.0
  11360. @end example
  11361. @table @code
  11362. @item --recursive
  11363. @itemx -r
  11364. Traverse the dependency graph of the given upstream package recursively
  11365. and generate package expressions for all those packages that are not yet
  11366. in Guix.
  11367. @end table
  11368. @item gem
  11369. @cindex gem
  11370. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  11371. is taken from the JSON-formatted description available at
  11372. @code{rubygems.org} and includes most relevant information, including
  11373. runtime dependencies. There are some caveats, however. The metadata
  11374. doesn't distinguish between synopses and descriptions, so the same string
  11375. is used for both fields. Additionally, the details of non-Ruby
  11376. dependencies required to build native extensions is unavailable and left
  11377. as an exercise to the packager.
  11378. The command below imports metadata for the @code{rails} Ruby package:
  11379. @example
  11380. guix import gem rails
  11381. @end example
  11382. You can also ask for a specific version:
  11383. @example
  11384. guix import gem rails@@7.0.4
  11385. @end example
  11386. @table @code
  11387. @item --recursive
  11388. @itemx -r
  11389. Traverse the dependency graph of the given upstream package recursively
  11390. and generate package expressions for all those packages that are not yet
  11391. in Guix.
  11392. @end table
  11393. @item minetest
  11394. @cindex minetest
  11395. @cindex ContentDB
  11396. Import metadata from @uref{https://content.minetest.net, ContentDB}.
  11397. Information is taken from the JSON-formatted metadata provided through
  11398. @uref{https://content.minetest.net/help/api/, ContentDB's API} and
  11399. includes most relevant information, including dependencies. There are
  11400. some caveats, however. The license information is often incomplete.
  11401. The commit hash is sometimes missing. The descriptions are in the
  11402. Markdown format, but Guix uses Texinfo instead. Texture packs and
  11403. subgames are unsupported.
  11404. The command below imports metadata for the Mesecons mod by Jeija:
  11405. @example
  11406. guix import minetest Jeija/mesecons
  11407. @end example
  11408. The author name can also be left out:
  11409. @example
  11410. guix import minetest mesecons
  11411. @end example
  11412. @table @code
  11413. @item --recursive
  11414. @itemx -r
  11415. Traverse the dependency graph of the given upstream package recursively
  11416. and generate package expressions for all those packages that are not yet
  11417. in Guix.
  11418. @end table
  11419. @item cpan
  11420. @cindex CPAN
  11421. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  11422. Information is taken from the JSON-formatted metadata provided through
  11423. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  11424. relevant information, such as module dependencies. License information
  11425. should be checked closely. If Perl is available in the store, then the
  11426. @code{corelist} utility will be used to filter core modules out of the
  11427. list of dependencies.
  11428. The command command below imports metadata for the Acme::Boolean Perl
  11429. module:
  11430. @example
  11431. guix import cpan Acme::Boolean
  11432. @end example
  11433. @item cran
  11434. @cindex CRAN
  11435. @cindex Bioconductor
  11436. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  11437. central repository for the @uref{https://r-project.org, GNU@tie{}R
  11438. statistical and graphical environment}.
  11439. Information is extracted from the @file{DESCRIPTION} file of the package.
  11440. The command command below imports metadata for the Cairo R package:
  11441. @example
  11442. guix import cran Cairo
  11443. @end example
  11444. You can also ask for a specific version:
  11445. @example
  11446. guix import cran rasterVis@@0.50.3
  11447. @end example
  11448. When @option{--recursive} is added, the importer will traverse the
  11449. dependency graph of the given upstream package recursively and generate
  11450. package expressions for all those packages that are not yet in Guix.
  11451. When @option{--style=specification} is added, the importer will generate
  11452. package definitions whose inputs are package specifications instead of
  11453. references to package variables. This is useful when generated package
  11454. definitions are to be appended to existing user modules, as the list of
  11455. used package modules need not be changed. The default is
  11456. @option{--style=variable}.
  11457. When @option{--prefix=license:} is added, the importer will prefix
  11458. license atoms with @code{license:}, allowing a prefixed import of
  11459. @code{(guix licenses)}.
  11460. When @option{--archive=bioconductor} is added, metadata is imported from
  11461. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  11462. packages for the analysis and comprehension of high-throughput
  11463. genomic data in bioinformatics.
  11464. Information is extracted from the @file{DESCRIPTION} file contained in the
  11465. package archive.
  11466. The command below imports metadata for the GenomicRanges R package:
  11467. @example
  11468. guix import cran --archive=bioconductor GenomicRanges
  11469. @end example
  11470. Finally, you can also import R packages that have not yet been published on
  11471. CRAN or Bioconductor as long as they are in a git repository. Use
  11472. @option{--archive=git} followed by the URL of the git repository:
  11473. @example
  11474. guix import cran --archive=git https://github.com/immunogenomics/harmony
  11475. @end example
  11476. @item texlive
  11477. @cindex TeX Live
  11478. @cindex CTAN
  11479. Import TeX package information from the TeX Live package database for
  11480. TeX packages that are part of the @uref{https://www.tug.org/texlive/,
  11481. TeX Live distribution}.
  11482. Information about the package is obtained from the TeX Live package
  11483. database, a plain text file that is included in the
  11484. @code{texlive-scripts} package. The source code is downloaded from
  11485. possibly multiple locations in the SVN repository of the Tex Live
  11486. project.
  11487. The command command below imports metadata for the @code{fontspec}
  11488. TeX package:
  11489. @example
  11490. guix import texlive fontspec
  11491. @end example
  11492. Additional options include:
  11493. @table @code
  11494. @item --recursive
  11495. @itemx -r
  11496. Traverse the dependency graph of the given upstream package recursively
  11497. and generate package expressions for all those packages that are not yet
  11498. in Guix.
  11499. @end table
  11500. @item json
  11501. @cindex JSON, import
  11502. Import package metadata from a local JSON file. Consider the following
  11503. example package definition in JSON format:
  11504. @example
  11505. @{
  11506. "name": "hello",
  11507. "version": "2.10",
  11508. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  11509. "build-system": "gnu",
  11510. "home-page": "https://www.gnu.org/software/hello/",
  11511. "synopsis": "Hello, GNU world: An example GNU package",
  11512. "description": "GNU Hello prints a greeting.",
  11513. "license": "GPL-3.0+",
  11514. "native-inputs": ["gettext"]
  11515. @}
  11516. @end example
  11517. The field names are the same as for the @code{<package>} record
  11518. (@xref{Defining Packages}). References to other packages are provided
  11519. as JSON lists of quoted package specification strings such as
  11520. @code{guile} or @code{guile@@2.0}.
  11521. The importer also supports a more explicit source definition using the
  11522. common fields for @code{<origin>} records:
  11523. @example
  11524. @{
  11525. @dots{}
  11526. "source": @{
  11527. "method": "url-fetch",
  11528. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  11529. "sha256": @{
  11530. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  11531. @}
  11532. @}
  11533. @dots{}
  11534. @}
  11535. @end example
  11536. The command below reads metadata from the JSON file @code{hello.json}
  11537. and outputs a package expression:
  11538. @example
  11539. guix import json hello.json
  11540. @end example
  11541. @item hackage
  11542. @cindex hackage
  11543. Import metadata from the Haskell community's central package archive
  11544. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  11545. Cabal files and includes all the relevant information, including package
  11546. dependencies.
  11547. Specific command-line options are:
  11548. @table @code
  11549. @item --stdin
  11550. @itemx -s
  11551. Read a Cabal file from standard input.
  11552. @item --no-test-dependencies
  11553. @itemx -t
  11554. Do not include dependencies required only by the test suites.
  11555. @item --cabal-environment=@var{alist}
  11556. @itemx -e @var{alist}
  11557. @var{alist} is a Scheme alist defining the environment in which the
  11558. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  11559. @code{arch}, @code{impl} and a string representing the name of a flag.
  11560. The value associated with a flag has to be either the symbol
  11561. @code{true} or @code{false}. The value associated with other keys
  11562. has to conform to the Cabal file format definition. The default value
  11563. associated with the keys @code{os}, @code{arch} and @code{impl} is
  11564. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  11565. @item --recursive
  11566. @itemx -r
  11567. Traverse the dependency graph of the given upstream package recursively
  11568. and generate package expressions for all those packages that are not yet
  11569. in Guix.
  11570. @end table
  11571. The command below imports metadata for the latest version of the
  11572. HTTP Haskell package without including test dependencies and
  11573. specifying the value of the flag @samp{network-uri} as @code{false}:
  11574. @example
  11575. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  11576. @end example
  11577. A specific package version may optionally be specified by following the
  11578. package name by an at-sign and a version number as in the following example:
  11579. @example
  11580. guix import hackage mtl@@2.1.3.1
  11581. @end example
  11582. @item stackage
  11583. @cindex stackage
  11584. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  11585. It takes a package name, looks up the package version included in a
  11586. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  11587. release and uses the @code{hackage} importer to retrieve its metadata.
  11588. Note that it is up to you to select an LTS release compatible with the
  11589. GHC compiler used by Guix.
  11590. Specific command-line options are:
  11591. @table @code
  11592. @item --no-test-dependencies
  11593. @itemx -t
  11594. Do not include dependencies required only by the test suites.
  11595. @item --lts-version=@var{version}
  11596. @itemx -l @var{version}
  11597. @var{version} is the desired LTS release version. If omitted the latest
  11598. release is used.
  11599. @item --recursive
  11600. @itemx -r
  11601. Traverse the dependency graph of the given upstream package recursively
  11602. and generate package expressions for all those packages that are not yet
  11603. in Guix.
  11604. @end table
  11605. The command below imports metadata for the HTTP Haskell package
  11606. included in the LTS Stackage release version 7.18:
  11607. @example
  11608. guix import stackage --lts-version=7.18 HTTP
  11609. @end example
  11610. @item elpa
  11611. @cindex elpa
  11612. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  11613. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  11614. Specific command-line options are:
  11615. @table @code
  11616. @item --archive=@var{repo}
  11617. @itemx -a @var{repo}
  11618. @var{repo} identifies the archive repository from which to retrieve the
  11619. information. Currently the supported repositories and their identifiers
  11620. are:
  11621. @itemize -
  11622. @item
  11623. @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  11624. identifier. This is the default.
  11625. Packages from @code{elpa.gnu.org} are signed with one of the keys
  11626. contained in the GnuPG keyring at
  11627. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  11628. @code{emacs} package (@pxref{Package Installation, ELPA package
  11629. signatures,, emacs, The GNU Emacs Manual}).
  11630. @item
  11631. @uref{https://elpa.nongnu.org/nongnu/, NonGNU}, selected by the
  11632. @code{nongnu} identifier.
  11633. @item
  11634. @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
  11635. @code{melpa-stable} identifier.
  11636. @item
  11637. @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
  11638. identifier.
  11639. @end itemize
  11640. @item --recursive
  11641. @itemx -r
  11642. Traverse the dependency graph of the given upstream package recursively
  11643. and generate package expressions for all those packages that are not yet
  11644. in Guix.
  11645. @end table
  11646. @item crate
  11647. @cindex crate
  11648. Import metadata from the crates.io Rust package repository
  11649. @uref{https://crates.io, crates.io}, as in this example:
  11650. @example
  11651. guix import crate blake2-rfc
  11652. @end example
  11653. The crate importer also allows you to specify a version string:
  11654. @example
  11655. guix import crate constant-time-eq@@0.1.0
  11656. @end example
  11657. Additional options include:
  11658. @table @code
  11659. @item --recursive
  11660. @itemx -r
  11661. Traverse the dependency graph of the given upstream package recursively
  11662. and generate package expressions for all those packages that are not yet
  11663. in Guix.
  11664. @end table
  11665. @item elm
  11666. @cindex elm
  11667. Import metadata from the Elm package repository
  11668. @uref{https://package.elm-lang.org, package.elm-lang.org}, as in this example:
  11669. @example
  11670. guix import elm elm-explorations/webgl
  11671. @end example
  11672. The Elm importer also allows you to specify a version string:
  11673. @example
  11674. guix import elm elm-explorations/webgl@@1.1.3
  11675. @end example
  11676. Additional options include:
  11677. @table @code
  11678. @item --recursive
  11679. @itemx -r
  11680. Traverse the dependency graph of the given upstream package recursively
  11681. and generate package expressions for all those packages that are not yet
  11682. in Guix.
  11683. @end table
  11684. @item opam
  11685. @cindex OPAM
  11686. @cindex OCaml
  11687. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  11688. repository used by the OCaml community.
  11689. Additional options include:
  11690. @table @code
  11691. @item --recursive
  11692. @itemx -r
  11693. Traverse the dependency graph of the given upstream package recursively
  11694. and generate package expressions for all those packages that are not yet
  11695. in Guix.
  11696. @item --repo
  11697. By default, packages are searched in the official OPAM repository. This
  11698. option, which can be used more than once, lets you add other repositories
  11699. which will be searched for packages. It accepts as valid arguments:
  11700. @itemize
  11701. @item the name of a known repository - can be one of @code{opam},
  11702. @code{coq} (equivalent to @code{coq-released}),
  11703. @code{coq-core-dev}, @code{coq-extra-dev} or @code{grew}.
  11704. @item the URL of a repository as expected by the
  11705. @code{opam repository add} command (for instance, the URL equivalent
  11706. of the above @code{opam} name would be
  11707. @uref{https://opam.ocaml.org}).
  11708. @item the path to a local copy of a repository (a directory containing a
  11709. @file{packages/} sub-directory).
  11710. @end itemize
  11711. Repositories are assumed to be passed to this option by order of
  11712. preference. The additional repositories will not replace the default
  11713. @code{opam} repository, which is always kept as a fallback.
  11714. Also, please note that versions are not compared across repositories.
  11715. The first repository (from left to right) that has at least one version
  11716. of a given package will prevail over any others, and the version
  11717. imported will be the latest one found @emph{in this repository only}.
  11718. @end table
  11719. @item go
  11720. @cindex go
  11721. Import metadata for a Go module using
  11722. @uref{https://proxy.golang.org, proxy.golang.org}.
  11723. @example
  11724. guix import go gopkg.in/yaml.v2
  11725. @end example
  11726. It is possible to use a package specification with a @code{@@VERSION}
  11727. suffix to import a specific version.
  11728. Additional options include:
  11729. @table @code
  11730. @item --recursive
  11731. @itemx -r
  11732. Traverse the dependency graph of the given upstream package recursively
  11733. and generate package expressions for all those packages that are not yet
  11734. in Guix.
  11735. @item --pin-versions
  11736. When using this option, the importer preserves the exact versions of the
  11737. Go modules dependencies instead of using their latest available
  11738. versions. This can be useful when attempting to import packages that
  11739. recursively depend on former versions of themselves to build. When
  11740. using this mode, the symbol of the package is made by appending the
  11741. version to its name, so that multiple versions of the same package can
  11742. coexist.
  11743. @end table
  11744. @item egg
  11745. @cindex egg
  11746. Import metadata for @uref{https://wiki.call-cc.org/eggs, CHICKEN eggs}.
  11747. The information is taken from @file{PACKAGE.egg} files found in the
  11748. @uref{git://code.call-cc.org/eggs-5-all, eggs-5-all} Git
  11749. repository. However, it does not provide all the information that we
  11750. need, there is no ``description'' field, and the licenses used are not
  11751. always precise (BSD is often used instead of BSD-N).
  11752. @example
  11753. guix import egg sourcehut
  11754. @end example
  11755. You can also ask for a specific version:
  11756. @example
  11757. guix import egg arrays@@1.0
  11758. @end example
  11759. Additional options include:
  11760. @table @code
  11761. @item --recursive
  11762. @itemx -r
  11763. Traverse the dependency graph of the given upstream package recursively
  11764. and generate package expressions for all those packages that are not yet
  11765. in Guix.
  11766. @end table
  11767. @item hexpm
  11768. @cindex hexpm
  11769. Import metadata from the hex.pm Erlang and Elixir package repository
  11770. @uref{https://hex.pm, hex.pm}, as in this example:
  11771. @example
  11772. guix import hexpm stun
  11773. @end example
  11774. The importer tries to determine the build system used by the package.
  11775. The hexpm importer also allows you to specify a version string:
  11776. @example
  11777. guix import hexpm cf@@0.3.0
  11778. @end example
  11779. Additional options include:
  11780. @table @code
  11781. @item --recursive
  11782. @itemx -r
  11783. Traverse the dependency graph of the given upstream package recursively
  11784. and generate package expressions for all those packages that are not yet
  11785. in Guix.
  11786. @end table
  11787. @end table
  11788. The structure of the @command{guix import} code is modular. It would be
  11789. useful to have more importers for other package formats, and your help
  11790. is welcome here (@pxref{Contributing}).
  11791. @node Invoking guix refresh
  11792. @section Invoking @command{guix refresh}
  11793. @cindex @command {guix refresh}
  11794. The primary audience of the @command{guix refresh} command is packagers.
  11795. As a user, you may be interested in the @option{--with-latest} option,
  11796. which can bring you package update superpowers built upon @command{guix
  11797. refresh} (@pxref{Package Transformation Options,
  11798. @option{--with-latest}}). By default, @command{guix refresh} reports
  11799. any packages provided by the distribution that are outdated compared to
  11800. the latest upstream version, like this:
  11801. @example
  11802. $ guix refresh
  11803. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  11804. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  11805. @end example
  11806. Alternatively, one can specify packages to consider, in which case a
  11807. warning is emitted for packages that lack an updater:
  11808. @example
  11809. $ guix refresh coreutils guile guile-ssh
  11810. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  11811. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  11812. @end example
  11813. @command{guix refresh} browses the upstream repository of each package and determines
  11814. the highest version number of the releases therein. The command
  11815. knows how to update specific types of packages: GNU packages, ELPA
  11816. packages, etc.---see the documentation for @option{--type} below. There
  11817. are many packages, though, for which it lacks a method to determine
  11818. whether a new upstream release is available. However, the mechanism is
  11819. extensible, so feel free to get in touch with us to add a new method!
  11820. @table @code
  11821. @item --recursive
  11822. Consider the packages specified, and all the packages upon which they depend.
  11823. @example
  11824. $ guix refresh --recursive coreutils
  11825. gnu/packages/acl.scm:40:13: acl would be upgraded from 2.2.53 to 2.3.1
  11826. gnu/packages/m4.scm:30:12: 1.4.18 is already the latest version of m4
  11827. gnu/packages/xml.scm:68:2: warning: no updater for expat
  11828. gnu/packages/multiprecision.scm:40:12: 6.1.2 is already the latest version of gmp
  11829. @dots{}
  11830. @end example
  11831. @end table
  11832. If for some reason you don't want to update to the latest version, you
  11833. can update to a specific version by appending an equal sign and the
  11834. desired version number to the package specification. Note that not all
  11835. updaters support this; an error is reported when an updater cannot
  11836. refresh to the specified version.
  11837. @example
  11838. $ guix refresh trytond-party
  11839. gnu/packages/guile.scm:392:2: guile would be upgraded from 3.0.3 to 3.0.5
  11840. $ guix refresh -u guile=3.0.4
  11841. @dots{}
  11842. gnu/packages/guile.scm:392:2: guile: updating from version 3.0.3 to version 3.0.4...
  11843. @dots{}
  11844. $ guix refresh -u guile@@2.0=2.0.12
  11845. @dots{}
  11846. gnu/packages/guile.scm:147:2: guile: updating from version 2.0.10 to version 2.0.12...
  11847. @dots{}
  11848. @end example
  11849. In some specific cases, you may have many packages specified via a
  11850. manifest or a module selection which should all be updated together; for
  11851. these cases, the @option{--target-version} option can be provided to have
  11852. them all refreshed to the same version, as shown in the examples below:
  11853. @example
  11854. $ guix refresh qtbase qtdeclarative --target-version=6.5.2
  11855. gnu/packages/qt.scm:1248:13: qtdeclarative would be upgraded from 6.3.2 to 6.5.2
  11856. gnu/packages/qt.scm:584:2: qtbase would be upgraded from 6.3.2 to 6.5.2
  11857. @end example
  11858. @example
  11859. $ guix refresh --manifest=qt5-manifest.scm --target-version=5.15.10
  11860. gnu/packages/qt.scm:1173:13: qtxmlpatterns would be upgraded from 5.15.8 to 5.15.10
  11861. gnu/packages/qt.scm:1202:13: qtdeclarative would be upgraded from 5.15.8 to 5.15.10
  11862. gnu/packages/qt.scm:1762:13: qtserialbus would be upgraded from 5.15.8 to 5.15.10
  11863. gnu/packages/qt.scm:2070:13: qtquickcontrols2 would be upgraded from 5.15.8 to 5.15.10
  11864. @dots{}
  11865. @end example
  11866. Sometimes the upstream name differs from the package name used in Guix,
  11867. and @command{guix refresh} needs a little help. Most updaters honor the
  11868. @code{upstream-name} property in package definitions, which can be used
  11869. to that effect:
  11870. @lisp
  11871. (define-public network-manager
  11872. (package
  11873. (name "network-manager")
  11874. ;; @dots{}
  11875. (properties '((upstream-name . "NetworkManager")))))
  11876. @end lisp
  11877. When passed @option{--update}, it modifies distribution source files to
  11878. update the version numbers and source code hashes of those package
  11879. definitions, as well as possibly their inputs (@pxref{Defining Packages}).
  11880. This is achieved by downloading
  11881. each package's latest source tarball and its associated OpenPGP
  11882. signature, authenticating the downloaded tarball against its signature
  11883. using @command{gpgv}, and finally computing its hash---note that GnuPG must be
  11884. installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
  11885. When the public
  11886. key used to sign the tarball is missing from the user's keyring, an
  11887. attempt is made to automatically retrieve it from a public key server;
  11888. when this is successful, the key is added to the user's keyring; otherwise,
  11889. @command{guix refresh} reports an error.
  11890. The following options are supported:
  11891. @table @code
  11892. @item --expression=@var{expr}
  11893. @itemx -e @var{expr}
  11894. Consider the package @var{expr} evaluates to.
  11895. This is useful to precisely refer to a package, as in this example:
  11896. @example
  11897. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  11898. @end example
  11899. This command lists the dependents of the ``final'' libc (essentially all
  11900. the packages).
  11901. @item --update
  11902. @itemx -u
  11903. Update distribution source files (package definitions) in place. This is
  11904. usually run from a checkout of the Guix source tree (@pxref{Running
  11905. Guix Before It Is Installed}):
  11906. @example
  11907. ./pre-inst-env guix refresh -s non-core -u
  11908. @end example
  11909. @xref{Defining Packages}, for more information on package definitions.
  11910. You can also run it on packages from a third-party channel:
  11911. @example
  11912. guix refresh -L /path/to/channel -u @var{package}
  11913. @end example
  11914. @xref{Creating a Channel}, on how to create a channel.
  11915. This command updates the version and source code hash of the package.
  11916. Depending on the updater being used, it can also update the various
  11917. @samp{inputs} fields of the package. In some cases, the updater might
  11918. get inputs wrong---it might not know about an extra input that's
  11919. necessary, or it might add an input that should be avoided.
  11920. @cindex @code{updater-extra-inputs}, package property
  11921. @cindex @code{updater-ignored-inputs}, package property
  11922. To address that, packagers can add properties stating inputs that should
  11923. be added to those found by the updater or inputs that should be ignored:
  11924. the @code{updater-extra-inputs} and @code{updater-ignored-inputs}
  11925. properties pertain to ``regular'' inputs, and there are equivalent
  11926. properties for @samp{native} and @samp{propagated} inputs. In the
  11927. example below, we tell the updater that we need @samp{openmpi} as an
  11928. additional input:
  11929. @lisp
  11930. (define-public python-mpi4py
  11931. (package
  11932. (name "python-mpi4py")
  11933. ;; @dots{}
  11934. (inputs (list openmpi))
  11935. (properties
  11936. '((updater-extra-inputs . ("openmpi"))))))
  11937. @end lisp
  11938. That way, @command{guix refresh -u python-mpi4py} will leave the
  11939. @samp{openmpi} input, even if it is not among the inputs it would
  11940. normally add.
  11941. @item --select=[@var{subset}]
  11942. @itemx -s @var{subset}
  11943. Select all the packages in @var{subset}, one of @code{core}, @code{non-core}
  11944. or @code{module:@var{name}}.
  11945. The @code{core} subset refers to all the packages at the core of the
  11946. distribution---i.e., packages that are used to build ``everything
  11947. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  11948. changing one of these packages in the distribution entails a rebuild of
  11949. all the others. Thus, such updates are an inconvenience to users in
  11950. terms of build time or bandwidth used to achieve the upgrade.
  11951. The @code{non-core} subset refers to the remaining packages. It is
  11952. typically useful in cases where an update of the core packages would be
  11953. inconvenient.
  11954. The @code{module:@var{name}} subset refers to all the packages in a
  11955. specified guile module. The module can be specified as
  11956. @code{module:guile} or @code{module:(gnu packages guile)}, the former is
  11957. a shorthand for the later.
  11958. @item --manifest=@var{file}
  11959. @itemx -m @var{file}
  11960. Select all the packages from the manifest in @var{file}. This is useful to
  11961. check if any packages of the user manifest can be updated.
  11962. @item --type=@var{updater}
  11963. @itemx -t @var{updater}
  11964. Select only packages handled by @var{updater} (may be a comma-separated
  11965. list of updaters). Currently, @var{updater} may be one of:
  11966. @table @code
  11967. @item gnu
  11968. the updater for GNU packages;
  11969. @item savannah
  11970. the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
  11971. @item sourceforge
  11972. the updater for packages hosted at @uref{https://sourceforge.net, SourceForge};
  11973. @item gnome
  11974. the updater for GNOME packages;
  11975. @item kde
  11976. the updater for KDE packages;
  11977. @item xorg
  11978. the updater for X.org packages;
  11979. @item kernel.org
  11980. the updater for packages hosted on kernel.org;
  11981. @item egg
  11982. the updater for @uref{https://wiki.call-cc.org/eggs/, Egg} packages;
  11983. @item elpa
  11984. the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
  11985. @item cran
  11986. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  11987. @item bioconductor
  11988. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  11989. @item cpan
  11990. the updater for @uref{https://www.cpan.org/, CPAN} packages;
  11991. @item pypi
  11992. the updater for @uref{https://pypi.python.org, PyPI} packages.
  11993. @item gem
  11994. the updater for @uref{https://rubygems.org, RubyGems} packages.
  11995. @item github
  11996. the updater for @uref{https://github.com, GitHub} packages.
  11997. @item hackage
  11998. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  11999. @item stackage
  12000. the updater for @uref{https://www.stackage.org, Stackage} packages.
  12001. @item crate
  12002. the updater for @uref{https://crates.io, Crates} packages.
  12003. @item launchpad
  12004. the updater for @uref{https://launchpad.net, Launchpad} packages.
  12005. @item generic-html
  12006. a generic updater that crawls the HTML page where the source tarball of
  12007. the package is hosted, when applicable, or the HTML page specified by
  12008. the @code{release-monitoring-url} property of the package.
  12009. @item generic-git
  12010. a generic updater for packages hosted on Git repositories. It tries to
  12011. be smart about parsing Git tag names, but if it is not able to parse the
  12012. tag name and compare tags correctly, users can define the following
  12013. properties for a package.
  12014. @itemize
  12015. @item @code{release-tag-prefix}: a regular expression for matching a prefix of
  12016. the tag name.
  12017. @item @code{release-tag-suffix}: a regular expression for matching a suffix of
  12018. the tag name.
  12019. @item @code{release-tag-version-delimiter}: a string used as the delimiter in
  12020. the tag name for separating the numbers of the version.
  12021. @item @code{accept-pre-releases}: by default, the updater will ignore
  12022. pre-releases; to make it also look for pre-releases, set the this
  12023. property to @code{#t}.
  12024. @end itemize
  12025. @lisp
  12026. (package
  12027. (name "foo")
  12028. ;; ...
  12029. (properties
  12030. '((release-tag-prefix . "^release0-")
  12031. (release-tag-suffix . "[a-z]?$")
  12032. (release-tag-version-delimiter . ":"))))
  12033. @end lisp
  12034. @end table
  12035. For instance, the following command only checks for updates of Emacs
  12036. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  12037. @example
  12038. $ guix refresh --type=elpa,cran
  12039. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  12040. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  12041. @end example
  12042. @item --list-updaters
  12043. List available updaters and exit (see @option{--type} above).
  12044. For each updater, display the fraction of packages it covers; at the
  12045. end, display the fraction of packages covered by all these updaters.
  12046. @end table
  12047. In addition, @command{guix refresh} can be passed one or more package
  12048. names, as in this example:
  12049. @example
  12050. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  12051. @end example
  12052. @noindent
  12053. The command above specifically updates the @code{emacs} and
  12054. @code{idutils} packages. The @option{--select} option would have no
  12055. effect in this case. You might also want to update definitions that
  12056. correspond to the packages installed in your profile:
  12057. @example
  12058. $ ./pre-inst-env guix refresh -u \
  12059. $(guix package --list-installed | cut -f1)
  12060. @end example
  12061. When considering whether to upgrade a package, it is sometimes
  12062. convenient to know which packages would be affected by the upgrade and
  12063. should be checked for compatibility. For this the following option may
  12064. be used when passing @command{guix refresh} one or more package names:
  12065. @table @code
  12066. @item --list-dependent
  12067. @itemx -l
  12068. List top-level dependent packages that would need to be rebuilt as a
  12069. result of upgrading one or more packages.
  12070. @xref{Invoking guix graph, the @code{reverse-package} type of
  12071. @command{guix graph}}, for information on how to visualize the list of
  12072. dependents of a package.
  12073. @end table
  12074. Be aware that the @option{--list-dependent} option only
  12075. @emph{approximates} the rebuilds that would be required as a result of
  12076. an upgrade. More rebuilds might be required under some circumstances.
  12077. @example
  12078. $ guix refresh --list-dependent flex
  12079. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  12080. hop@@2.4.0 emacs-geiser@@0.13 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  12081. @end example
  12082. The command above lists a set of packages that could be built to check
  12083. for compatibility with an upgraded @code{flex} package.
  12084. @table @code
  12085. @item --list-transitive
  12086. @itemx -T
  12087. List all the packages which one or more packages depend upon.
  12088. @example
  12089. $ guix refresh --list-transitive flex
  12090. flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
  12091. 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{}
  12092. @end example
  12093. @end table
  12094. The command above lists a set of packages which, when changed, would cause
  12095. @code{flex} to be rebuilt.
  12096. The following options can be used to customize GnuPG operation:
  12097. @table @code
  12098. @item --gpg=@var{command}
  12099. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  12100. for in @code{$PATH}.
  12101. @item --keyring=@var{file}
  12102. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  12103. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  12104. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  12105. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  12106. information on a tool to manipulate keybox files).
  12107. When this option is omitted, @command{guix refresh} uses
  12108. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  12109. signing keys. OpenPGP signatures are checked against keys from this keyring;
  12110. missing keys are downloaded to this keyring as well (see
  12111. @option{--key-download} below).
  12112. You can export keys from your default GPG keyring into a keybox file using
  12113. commands like this one:
  12114. @example
  12115. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  12116. @end example
  12117. Likewise, you can fetch keys to a specific keybox file like this:
  12118. @example
  12119. gpg --no-default-keyring --keyring mykeyring.kbx \
  12120. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  12121. @end example
  12122. @xref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  12123. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  12124. @item --key-download=@var{policy}
  12125. Handle missing OpenPGP keys according to @var{policy}, which may be one
  12126. of:
  12127. @table @code
  12128. @item always
  12129. Always download missing OpenPGP keys from the key server, and add them
  12130. to the user's GnuPG keyring.
  12131. @item never
  12132. Never try to download missing OpenPGP keys. Instead just bail out.
  12133. @item interactive
  12134. When a package signed with an unknown OpenPGP key is encountered, ask
  12135. the user whether to download it or not. This is the default behavior.
  12136. @end table
  12137. @item --key-server=@var{host}
  12138. Use @var{host} as the OpenPGP key server when importing a public key.
  12139. @item --load-path=@var{directory}
  12140. @itemx -L @var{directory}
  12141. Add @var{directory} to the front of the package module search path
  12142. (@pxref{Package Modules}).
  12143. This allows users to define their own packages and make them visible to
  12144. the command-line tools.
  12145. @end table
  12146. The @code{github} updater uses the
  12147. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  12148. releases. When used repeatedly e.g.@: when refreshing all packages,
  12149. GitHub will eventually refuse to answer any further API requests. By
  12150. default 60 API requests per hour are allowed, and a full refresh on all
  12151. GitHub packages in Guix requires more than this. Authentication with
  12152. GitHub through the use of an API token alleviates these limits. To use
  12153. an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
  12154. token procured from @uref{https://github.com/settings/tokens} or
  12155. otherwise.
  12156. @node Invoking guix style
  12157. @section Invoking @command{guix style}
  12158. @cindex @command{guix style}
  12159. @cindex styling rules
  12160. @cindex lint, code style
  12161. @cindex format, code style
  12162. @cindex format conventions
  12163. The @command{guix style} command helps users and packagers alike style
  12164. their package definitions and configuration files according to the
  12165. latest fashionable trends. It can either reformat whole files, with the
  12166. @option{--whole-file} option, or apply specific @dfn{styling rules} to
  12167. individual package definitions. The command currently provides the
  12168. following styling rules:
  12169. @itemize
  12170. @item
  12171. formatting package definitions according to the project's conventions
  12172. (@pxref{Formatting Code});
  12173. @item
  12174. rewriting package inputs to the ``new style'', as explained below.
  12175. @end itemize
  12176. The way package inputs are written is going through a transition
  12177. (@pxref{package Reference}, for more on package inputs). Until version
  12178. 1.3.0, package inputs were written using the ``old style'', where each
  12179. input was given an explicit label, most of the time the package name:
  12180. @lisp
  12181. (package
  12182. ;; @dots{}
  12183. ;; The "old style" (deprecated).
  12184. (inputs `(("libunistring" ,libunistring)
  12185. ("libffi" ,libffi))))
  12186. @end lisp
  12187. Today, the old style is deprecated and the preferred style looks like
  12188. this:
  12189. @lisp
  12190. (package
  12191. ;; @dots{}
  12192. ;; The "new style".
  12193. (inputs (list libunistring libffi)))
  12194. @end lisp
  12195. Likewise, uses of @code{alist-delete} and friends to manipulate inputs
  12196. is now deprecated in favor of @code{modify-inputs} (@pxref{Defining
  12197. Package Variants}, for more info on @code{modify-inputs}).
  12198. In the vast majority of cases, this is a purely mechanical change on the
  12199. surface syntax that does not even incur a package rebuild. Running
  12200. @command{guix style -S inputs} can do that for you, whether you're working on
  12201. packages in Guix proper or in an external channel.
  12202. The general syntax is:
  12203. @example
  12204. guix style [@var{options}] @var{package}@dots{}
  12205. @end example
  12206. This causes @command{guix style} to analyze and rewrite the definition
  12207. of @var{package}@dots{} or, when @var{package} is omitted, of @emph{all}
  12208. the packages. The @option{--styling} or @option{-S} option allows you
  12209. to select the style rule, the default rule being @code{format}---see
  12210. below.
  12211. To reformat entire source files, the syntax is:
  12212. @example
  12213. guix style --whole-file @var{file}@dots{}
  12214. @end example
  12215. The available options are listed below.
  12216. @table @code
  12217. @item --dry-run
  12218. @itemx -n
  12219. Show source file locations that would be edited but do not modify them.
  12220. @item --whole-file
  12221. @itemx -f
  12222. Reformat the given files in their entirety. In that case, subsequent
  12223. arguments are interpreted as file names (rather than package names), and
  12224. the @option{--styling} option has no effect.
  12225. As an example, here is how you might reformat your operating system
  12226. configuration (you need write permissions for the file):
  12227. @example
  12228. guix style -f /etc/config.scm
  12229. @end example
  12230. @item --styling=@var{rule}
  12231. @itemx -S @var{rule}
  12232. Apply @var{rule}, one of the following styling rules:
  12233. @table @code
  12234. @item format
  12235. Format the given package definition(s)---this is the default styling
  12236. rule. For example, a packager running Guix on a checkout
  12237. (@pxref{Running Guix Before It Is Installed}) might want to reformat the
  12238. definition of the Coreutils package like so:
  12239. @example
  12240. ./pre-inst-env guix style coreutils
  12241. @end example
  12242. @item inputs
  12243. Rewrite package inputs to the ``new style'', as described above. This
  12244. is how you would rewrite inputs of package @code{whatnot} in your own
  12245. channel:
  12246. @example
  12247. guix style -L ~/my/channel -S inputs whatnot
  12248. @end example
  12249. Rewriting is done in a conservative way: preserving comments and bailing
  12250. out if it cannot make sense of the code that appears in an inputs field.
  12251. The @option{--input-simplification} option described below provides
  12252. fine-grain control over when inputs should be simplified.
  12253. @item arguments
  12254. Rewrite package arguments to use G-expressions (@pxref{G-Expressions}).
  12255. For example, consider this package definition:
  12256. @lisp
  12257. (define-public my-package
  12258. (package
  12259. ;; @dots{}
  12260. (arguments ;old-style quoted arguments
  12261. '(#:make-flags '("V=1")
  12262. #:phases (modify-phases %standard-phases
  12263. (delete 'build))))))
  12264. @end lisp
  12265. @noindent
  12266. Running @command{guix style -S arguments} on this package would rewrite
  12267. its @code{arguments} field like to:
  12268. @lisp
  12269. (define-public my-package
  12270. (package
  12271. ;; @dots{}
  12272. (arguments
  12273. (list #:make-flags #~'("V=1")
  12274. #:phases #~(modify-phases %standard-phases
  12275. (delete 'build))))))
  12276. @end lisp
  12277. Note that changes made by the @code{arguments} rule do not entail a
  12278. rebuild of the affected packages. Furthermore, if a package definition
  12279. happens to be using G-expressions already, @command{guix style} leaves
  12280. it unchanged.
  12281. @end table
  12282. @item --list-stylings
  12283. @itemx -l
  12284. List and describe the available styling rules and exit.
  12285. @item --load-path=@var{directory}
  12286. @itemx -L @var{directory}
  12287. Add @var{directory} to the front of the package module search path
  12288. (@pxref{Package Modules}).
  12289. @item --expression=@var{expr}
  12290. @itemx -e @var{expr}
  12291. Style the package @var{expr} evaluates to.
  12292. For example, running:
  12293. @example
  12294. guix style -e '(@@ (gnu packages gcc) gcc-5)'
  12295. @end example
  12296. styles the @code{gcc-5} package definition.
  12297. @item --input-simplification=@var{policy}
  12298. When using the @code{inputs} styling rule, with @samp{-S inputs}, this
  12299. option specifies the package input simplification policy for cases where
  12300. an input label does not match the corresponding package name.
  12301. @var{policy} may be one of the following:
  12302. @table @code
  12303. @item silent
  12304. Simplify inputs only when the change is ``silent'', meaning that the
  12305. package does not need to be rebuilt (its derivation is unchanged).
  12306. @item safe
  12307. Simplify inputs only when that is ``safe'' to do: the package might need
  12308. to be rebuilt, but the change is known to have no observable effect.
  12309. @item always
  12310. Simplify inputs even when input labels do not match package names, and
  12311. even if that might have an observable effect.
  12312. @end table
  12313. The default is @code{silent}, meaning that input simplifications do not
  12314. trigger any package rebuild.
  12315. @end table
  12316. @node Invoking guix lint
  12317. @section Invoking @command{guix lint}
  12318. @cindex @command{guix lint}
  12319. @cindex package, checking for errors
  12320. The @command{guix lint} command is meant to help package developers avoid
  12321. common errors and use a consistent style. It runs a number of checks on
  12322. a given set of packages in order to find common mistakes in their
  12323. definitions. Available @dfn{checkers} include (see
  12324. @option{--list-checkers} for a complete list):
  12325. @table @code
  12326. @item synopsis
  12327. @itemx description
  12328. Validate certain typographical and stylistic rules about package
  12329. descriptions and synopses.
  12330. @item inputs-should-be-native
  12331. Identify inputs that should most likely be native inputs.
  12332. @item source
  12333. @itemx home-page
  12334. @itemx mirror-url
  12335. @itemx github-url
  12336. @itemx source-file-name
  12337. Probe @code{home-page} and @code{source} URLs and report those that are
  12338. invalid. Suggest a @code{mirror://} URL when applicable. If the
  12339. @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
  12340. URL@. Check that the source file name is meaningful, e.g.@: is not just a
  12341. version number or ``git-checkout'', without a declared @code{file-name}
  12342. (@pxref{origin Reference}).
  12343. @item source-unstable-tarball
  12344. Parse the @code{source} URL to determine if a tarball from GitHub is
  12345. autogenerated or if it is a release tarball. Unfortunately GitHub's
  12346. autogenerated tarballs are sometimes regenerated.
  12347. @item derivation
  12348. Check that the derivation of the given packages can be successfully
  12349. computed for all the supported systems (@pxref{Derivations}).
  12350. @item profile-collisions
  12351. Check whether installing the given packages in a profile would lead to
  12352. collisions. Collisions occur when several packages with the same name
  12353. but a different version or a different store file name are propagated.
  12354. @xref{package Reference, @code{propagated-inputs}}, for more information
  12355. on propagated inputs.
  12356. @item archival
  12357. @cindex Software Heritage, source code archive
  12358. @cindex archival of source code, Software Heritage
  12359. Checks whether the package's source code is archived at
  12360. @uref{https://www.softwareheritage.org, Software Heritage}.
  12361. When the source code that is not archived comes from a version-control system
  12362. (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
  12363. ``save'' request so that it eventually archives it. This ensures that the
  12364. source will remain available in the long term, and that Guix can fall back to
  12365. Software Heritage should the source code disappear from its original host.
  12366. The status of recent ``save'' requests can be
  12367. @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
  12368. When source code is a tarball obtained with @code{url-fetch}, simply print a
  12369. message when it is not archived. As of this writing, Software Heritage does
  12370. not allow requests to save arbitrary tarballs; we are working on ways to
  12371. ensure that non-VCS source code is also archived.
  12372. Software Heritage
  12373. @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
  12374. request rate per IP address}. When the limit is reached, @command{guix lint}
  12375. prints a message and the @code{archival} checker stops doing anything until
  12376. that limit has been reset.
  12377. @item cve
  12378. @cindex security vulnerabilities
  12379. @cindex CVE, Common Vulnerabilities and Exposures
  12380. Report known vulnerabilities found in the Common Vulnerabilities and
  12381. Exposures (CVE) databases of the current and past year
  12382. @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
  12383. NIST}.
  12384. To view information about a particular vulnerability, visit pages such as:
  12385. @itemize
  12386. @item
  12387. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  12388. @item
  12389. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  12390. @end itemize
  12391. @noindent
  12392. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  12393. @code{CVE-2015-7554}.
  12394. Package developers can specify in package recipes the
  12395. @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
  12396. name and version of the package when they differ from the name or version
  12397. that Guix uses, as in this example:
  12398. @lisp
  12399. (package
  12400. (name "grub")
  12401. ;; @dots{}
  12402. ;; CPE calls this package "grub2".
  12403. (properties '((cpe-name . "grub2")
  12404. (cpe-version . "2.3"))))
  12405. @end lisp
  12406. @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
  12407. Some entries in the CVE database do not specify which version of a
  12408. package they apply to, and would thus ``stick around'' forever. Package
  12409. developers who found CVE alerts and verified they can be ignored can
  12410. declare them as in this example:
  12411. @lisp
  12412. (package
  12413. (name "t1lib")
  12414. ;; @dots{}
  12415. ;; These CVEs no longer apply and can be safely ignored.
  12416. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  12417. "CVE-2011-1553"
  12418. "CVE-2011-1554"
  12419. "CVE-2011-5244")))))
  12420. @end lisp
  12421. @item formatting
  12422. Warn about obvious source code formatting issues: trailing white space,
  12423. use of tabulations, etc.
  12424. @item input-labels
  12425. Report old-style input labels that do not match the name of the
  12426. corresponding package. This aims to help migrate from the ``old input
  12427. style''. @xref{package Reference}, for more information on package
  12428. inputs and input styles. @xref{Invoking guix style}, on how to migrate
  12429. to the new style.
  12430. @end table
  12431. The general syntax is:
  12432. @example
  12433. guix lint @var{options} @var{package}@dots{}
  12434. @end example
  12435. If no package is given on the command line, then all packages are checked.
  12436. The @var{options} may be zero or more of the following:
  12437. @table @code
  12438. @item --list-checkers
  12439. @itemx -l
  12440. List and describe all the available checkers that will be run on packages
  12441. and exit.
  12442. @item --checkers
  12443. @itemx -c
  12444. Only enable the checkers specified in a comma-separated list using the
  12445. names returned by @option{--list-checkers}.
  12446. @item --exclude
  12447. @itemx -x
  12448. Only disable the checkers specified in a comma-separated list using the
  12449. names returned by @option{--list-checkers}.
  12450. @item --expression=@var{expr}
  12451. @itemx -e @var{expr}
  12452. Consider the package @var{expr} evaluates to.
  12453. This is useful to unambiguously designate packages, as in this example:
  12454. @example
  12455. guix lint -c archival -e '(@@ (gnu packages guile) guile-3.0)'
  12456. @end example
  12457. @item --no-network
  12458. @itemx -n
  12459. Only enable the checkers that do not depend on Internet access.
  12460. @item --load-path=@var{directory}
  12461. @itemx -L @var{directory}
  12462. Add @var{directory} to the front of the package module search path
  12463. (@pxref{Package Modules}).
  12464. This allows users to define their own packages and make them visible to
  12465. the command-line tools.
  12466. @end table
  12467. @node Invoking guix size
  12468. @section Invoking @command{guix size}
  12469. @cindex size
  12470. @cindex package size
  12471. @cindex closure
  12472. @cindex @command{guix size}
  12473. The @command{guix size} command helps package developers profile the
  12474. disk usage of packages. It is easy to overlook the impact of an
  12475. additional dependency added to a package, or the impact of using a
  12476. single output for a package that could easily be split (@pxref{Packages
  12477. with Multiple Outputs}). Such are the typical issues that
  12478. @command{guix size} can highlight.
  12479. The command can be passed one or more package specifications
  12480. such as @code{gcc@@4.8}
  12481. or @code{guile:debug}, or a file name in the store. Consider this
  12482. example:
  12483. @example
  12484. $ guix size coreutils
  12485. store item total self
  12486. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  12487. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  12488. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  12489. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  12490. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  12491. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  12492. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  12493. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  12494. total: 78.9 MiB
  12495. @end example
  12496. @cindex closure
  12497. The store items listed here constitute the @dfn{transitive closure} of
  12498. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  12499. would be returned by:
  12500. @example
  12501. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  12502. @end example
  12503. Here the output shows three columns next to store items. The first column,
  12504. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  12505. the store item---that is, its own size plus the size of all its
  12506. dependencies. The next column, labeled ``self'', shows the size of the
  12507. item itself. The last column shows the ratio of the size of the item
  12508. itself to the space occupied by all the items listed here.
  12509. In this example, we see that the closure of Coreutils weighs in at
  12510. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  12511. libraries. (That libc and GCC's libraries represent a large fraction of
  12512. the closure is not a problem @i{per se} because they are always available
  12513. on the system anyway.)
  12514. Since the command also accepts store file names, assessing the size of
  12515. a build result is straightforward:
  12516. @example
  12517. guix size $(guix system build config.scm)
  12518. @end example
  12519. When the package(s) passed to @command{guix size} are available in the
  12520. store@footnote{More precisely, @command{guix size} looks for the
  12521. @emph{ungrafted} variant of the given package(s), as returned by
  12522. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  12523. for information on grafts.}, @command{guix size} queries the daemon to determine its
  12524. dependencies, and measures its size in the store, similar to @command{du
  12525. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  12526. Coreutils}).
  12527. When the given packages are @emph{not} in the store, @command{guix size}
  12528. reports information based on the available substitutes
  12529. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  12530. store items that are not even on disk, only available remotely.
  12531. You can also specify several package names:
  12532. @example
  12533. $ guix size coreutils grep sed bash
  12534. store item total self
  12535. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  12536. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  12537. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  12538. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  12539. @dots{}
  12540. total: 102.3 MiB
  12541. @end example
  12542. @noindent
  12543. In this example we see that the combination of the four packages takes
  12544. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  12545. since they have a lot of dependencies in common.
  12546. When looking at the profile returned by @command{guix size}, you may
  12547. find yourself wondering why a given package shows up in the profile at
  12548. all. To understand it, you can use @command{guix graph --path -t
  12549. references} to display the shortest path between the two packages
  12550. (@pxref{Invoking guix graph}).
  12551. The available options are:
  12552. @table @option
  12553. @item --substitute-urls=@var{urls}
  12554. Use substitute information from @var{urls}.
  12555. @xref{client-substitute-urls, the same option for @code{guix build}}.
  12556. @item --sort=@var{key}
  12557. Sort lines according to @var{key}, one of the following options:
  12558. @table @code
  12559. @item self
  12560. the size of each item (the default);
  12561. @item closure
  12562. the total size of the item's closure.
  12563. @end table
  12564. @item --map-file=@var{file}
  12565. Write a graphical map of disk usage in PNG format to @var{file}.
  12566. For the example above, the map looks like this:
  12567. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  12568. produced by @command{guix size}}
  12569. This option requires that
  12570. @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
  12571. installed and visible in Guile's module search path. When that is not
  12572. the case, @command{guix size} fails as it tries to load it.
  12573. @item --system=@var{system}
  12574. @itemx -s @var{system}
  12575. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  12576. @item --load-path=@var{directory}
  12577. @itemx -L @var{directory}
  12578. Add @var{directory} to the front of the package module search path
  12579. (@pxref{Package Modules}).
  12580. This allows users to define their own packages and make them visible to
  12581. the command-line tools.
  12582. @end table
  12583. @node Invoking guix graph
  12584. @section Invoking @command{guix graph}
  12585. @cindex DAG
  12586. @cindex @command{guix graph}
  12587. @cindex package dependencies
  12588. Packages and their dependencies form a @dfn{graph}, specifically a
  12589. directed acyclic graph (DAG). It can quickly become difficult to have a
  12590. mental model of the package DAG, so the @command{guix graph} command
  12591. provides a visual representation of the DAG@. By default,
  12592. @command{guix graph} emits a DAG representation in the input format of
  12593. @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
  12594. directly to the @command{dot} command of Graphviz. It can also emit an
  12595. HTML page with embedded JavaScript code to display a ``chord diagram''
  12596. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  12597. emit Cypher queries to construct a graph in a graph database supporting
  12598. the @uref{https://www.opencypher.org/, openCypher} query language. With
  12599. @option{--path}, it simply displays the shortest path between two
  12600. packages. The general syntax is:
  12601. @example
  12602. guix graph @var{options} @var{package}@dots{}
  12603. @end example
  12604. For example, the following command generates a PDF file representing the
  12605. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  12606. dependencies:
  12607. @example
  12608. guix graph coreutils | dot -Tpdf > dag.pdf
  12609. @end example
  12610. The output looks like this:
  12611. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  12612. Nice little graph, no?
  12613. You may find it more pleasant to navigate the graph interactively with
  12614. @command{xdot} (from the @code{xdot} package):
  12615. @example
  12616. guix graph coreutils | xdot -
  12617. @end example
  12618. But there is more than one graph! The one above is concise: it is the
  12619. graph of package objects, omitting implicit inputs such as GCC, libc,
  12620. grep, etc. It is often useful to have such a concise graph, but
  12621. sometimes one may want to see more details. @command{guix graph} supports
  12622. several types of graphs, allowing you to choose the level of detail:
  12623. @table @code
  12624. @item package
  12625. This is the default type used in the example above. It shows the DAG of
  12626. package objects, excluding implicit dependencies. It is concise, but
  12627. filters out many details.
  12628. @item reverse-package
  12629. This shows the @emph{reverse} DAG of packages. For example:
  12630. @example
  12631. guix graph --type=reverse-package ocaml
  12632. @end example
  12633. ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
  12634. you are also interested in cases where OCaml is an implicit dependency, see
  12635. @code{reverse-bag} below).
  12636. Note that for core packages this can yield huge graphs. If all you want
  12637. is to know the number of packages that depend on a given package, use
  12638. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  12639. @option{--list-dependent}}).
  12640. @item bag-emerged
  12641. This is the package DAG, @emph{including} implicit inputs.
  12642. For instance, the following command:
  12643. @example
  12644. guix graph --type=bag-emerged coreutils
  12645. @end example
  12646. ...@: yields this bigger graph:
  12647. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  12648. At the bottom of the graph, we see all the implicit inputs of
  12649. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  12650. Now, note that the dependencies of these implicit inputs---that is, the
  12651. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  12652. here, for conciseness.
  12653. @item bag
  12654. Similar to @code{bag-emerged}, but this time including all the bootstrap
  12655. dependencies.
  12656. @item bag-with-origins
  12657. Similar to @code{bag}, but also showing origins and their dependencies.
  12658. @item reverse-bag
  12659. This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
  12660. it also takes implicit dependencies into account. For example:
  12661. @example
  12662. guix graph -t reverse-bag dune
  12663. @end example
  12664. @noindent
  12665. ...@: yields the graph of all packages that depend on Dune, directly or
  12666. indirectly. Since Dune is an @emph{implicit} dependency of many packages
  12667. @i{via} @code{dune-build-system}, this shows a large number of packages,
  12668. whereas @code{reverse-package} would show very few if any.
  12669. @item derivation
  12670. This is the most detailed representation: It shows the DAG of
  12671. derivations (@pxref{Derivations}) and plain store items. Compared to
  12672. the above representation, many additional nodes are visible, including
  12673. build scripts, patches, Guile modules, etc.
  12674. For this type of graph, it is also possible to pass a @file{.drv} file
  12675. name instead of a package name, as in:
  12676. @example
  12677. guix graph -t derivation $(guix system build -d my-config.scm)
  12678. @end example
  12679. @item module
  12680. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  12681. For example, the following command shows the graph for the package
  12682. module that defines the @code{guile} package:
  12683. @example
  12684. guix graph -t module guile | xdot -
  12685. @end example
  12686. @end table
  12687. All the types above correspond to @emph{build-time dependencies}. The
  12688. following graph type represents the @emph{run-time dependencies}:
  12689. @table @code
  12690. @item references
  12691. This is the graph of @dfn{references} of a package output, as returned
  12692. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  12693. If the given package output is not available in the store, @command{guix
  12694. graph} attempts to obtain dependency information from substitutes.
  12695. Here you can also pass a store file name instead of a package name. For
  12696. example, the command below produces the reference graph of your profile
  12697. (which can be big!):
  12698. @example
  12699. guix graph -t references $(readlink -f ~/.guix-profile)
  12700. @end example
  12701. @item referrers
  12702. This is the graph of the @dfn{referrers} of a store item, as returned by
  12703. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  12704. This relies exclusively on local information from your store. For
  12705. instance, let us suppose that the current Inkscape is available in 10
  12706. profiles on your machine; @command{guix graph -t referrers inkscape}
  12707. will show a graph rooted at Inkscape and with those 10 profiles linked
  12708. to it.
  12709. It can help determine what is preventing a store item from being garbage
  12710. collected.
  12711. @end table
  12712. @cindex shortest path, between packages
  12713. Often, the graph of the package you are interested in does not fit on
  12714. your screen, and anyway all you want to know is @emph{why} that package
  12715. actually depends on some seemingly unrelated package. The
  12716. @option{--path} option instructs @command{guix graph} to display the
  12717. shortest path between two packages (or derivations, or store items,
  12718. etc.):
  12719. @example
  12720. $ guix graph --path emacs libunistring
  12721. emacs@@26.3
  12722. mailutils@@3.9
  12723. libunistring@@0.9.10
  12724. $ guix graph --path -t derivation emacs libunistring
  12725. /gnu/store/@dots{}-emacs-26.3.drv
  12726. /gnu/store/@dots{}-mailutils-3.9.drv
  12727. /gnu/store/@dots{}-libunistring-0.9.10.drv
  12728. $ guix graph --path -t references emacs libunistring
  12729. /gnu/store/@dots{}-emacs-26.3
  12730. /gnu/store/@dots{}-libidn2-2.2.0
  12731. /gnu/store/@dots{}-libunistring-0.9.10
  12732. @end example
  12733. Sometimes you still want to visualize the graph but would like to trim
  12734. it so it can actually be displayed. One way to do it is via the
  12735. @option{--max-depth} (or @option{-M}) option, which lets you specify the
  12736. maximum depth of the graph. In the example below, we visualize only
  12737. @code{libreoffice} and the nodes whose distance to @code{libreoffice} is
  12738. at most 2:
  12739. @example
  12740. guix graph -M 2 libreoffice | xdot -f fdp -
  12741. @end example
  12742. Mind you, that's still a big ball of spaghetti, but at least
  12743. @command{dot} can render it quickly and it can be browsed somewhat.
  12744. The available options are the following:
  12745. @table @option
  12746. @item --type=@var{type}
  12747. @itemx -t @var{type}
  12748. Produce a graph output of @var{type}, where @var{type} must be one of
  12749. the values listed above.
  12750. @item --list-types
  12751. List the supported graph types.
  12752. @item --backend=@var{backend}
  12753. @itemx -b @var{backend}
  12754. Produce a graph using the selected @var{backend}.
  12755. @item --list-backends
  12756. List the supported graph backends.
  12757. Currently, the available backends are Graphviz and d3.js.
  12758. @item --path
  12759. Display the shortest path between two nodes of the type specified by
  12760. @option{--type}. The example below shows the shortest path between
  12761. @code{libreoffice} and @code{llvm} according to the references of
  12762. @code{libreoffice}:
  12763. @example
  12764. $ guix graph --path -t references libreoffice llvm
  12765. /gnu/store/@dots{}-libreoffice-6.4.2.2
  12766. /gnu/store/@dots{}-libepoxy-1.5.4
  12767. /gnu/store/@dots{}-mesa-19.3.4
  12768. /gnu/store/@dots{}-llvm-9.0.1
  12769. @end example
  12770. @item --expression=@var{expr}
  12771. @itemx -e @var{expr}
  12772. Consider the package @var{expr} evaluates to.
  12773. This is useful to precisely refer to a package, as in this example:
  12774. @example
  12775. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  12776. @end example
  12777. @item --system=@var{system}
  12778. @itemx -s @var{system}
  12779. Display the graph for @var{system}---e.g., @code{i686-linux}.
  12780. The package dependency graph is largely architecture-independent, but there
  12781. are some architecture-dependent bits that this option allows you to visualize.
  12782. @item --load-path=@var{directory}
  12783. @itemx -L @var{directory}
  12784. Add @var{directory} to the front of the package module search path
  12785. (@pxref{Package Modules}).
  12786. This allows users to define their own packages and make them visible to
  12787. the command-line tools.
  12788. @end table
  12789. On top of that, @command{guix graph} supports all the usual package
  12790. transformation options (@pxref{Package Transformation Options}). This
  12791. makes it easy to view the effect of a graph-rewriting transformation
  12792. such as @option{--with-input}. For example, the command below outputs
  12793. the graph of @code{git} once @code{openssl} has been replaced by
  12794. @code{libressl} everywhere in the graph:
  12795. @example
  12796. guix graph git --with-input=openssl=libressl
  12797. @end example
  12798. So many possibilities, so much fun!
  12799. @node Invoking guix publish
  12800. @section Invoking @command{guix publish}
  12801. @cindex @command{guix publish}
  12802. The purpose of @command{guix publish} is to enable users to easily share
  12803. their store with others, who can then use it as a substitute server
  12804. (@pxref{Substitutes}).
  12805. When @command{guix publish} runs, it spawns an HTTP server which allows
  12806. anyone with network access to obtain substitutes from it. This means
  12807. that any machine running Guix can also act as if it were a build farm,
  12808. since the HTTP interface is compatible with Cuirass, the software behind
  12809. the @code{@value{SUBSTITUTE-SERVER-1}} build farm.
  12810. For security, each substitute is signed, allowing recipients to check
  12811. their authenticity and integrity (@pxref{Substitutes}). Because
  12812. @command{guix publish} uses the signing key of the system, which is only
  12813. readable by the system administrator, it must be started as root; the
  12814. @option{--user} option makes it drop root privileges early on.
  12815. The signing key pair must be generated before @command{guix publish} is
  12816. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  12817. guix archive}).
  12818. When the @option{--advertise} option is passed, the server advertises
  12819. its availability on the local network using multicast DNS (mDNS) and DNS
  12820. service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,,
  12821. guile-avahi, Using Avahi in Guile Scheme Programs}).
  12822. The general syntax is:
  12823. @example
  12824. guix publish @var{options}@dots{}
  12825. @end example
  12826. Running @command{guix publish} without any additional arguments will
  12827. spawn an HTTP server on port 8080:
  12828. @example
  12829. guix publish
  12830. @end example
  12831. @cindex socket activation, for @command{guix publish}
  12832. @command{guix publish} can also be started following the systemd
  12833. ``socket activation'' protocol (@pxref{Service De- and Constructors,
  12834. @code{make-systemd-constructor},, shepherd, The GNU Shepherd Manual}).
  12835. Once a publishing server has been authorized, the daemon may download
  12836. substitutes from it. @xref{Getting Substitutes from Other Servers}.
  12837. By default, @command{guix publish} compresses archives on the fly as it
  12838. serves them. This ``on-the-fly'' mode is convenient in that it requires
  12839. no setup and is immediately available. However, when serving lots of
  12840. clients, we recommend using the @option{--cache} option, which enables
  12841. caching of the archives before they are sent to clients---see below for
  12842. details. The @command{guix weather} command provides a handy way to
  12843. check what a server provides (@pxref{Invoking guix weather}).
  12844. As a bonus, @command{guix publish} also serves as a content-addressed
  12845. mirror for source files referenced in @code{origin} records
  12846. (@pxref{origin Reference}). For instance, assuming @command{guix
  12847. publish} is running on @code{example.org}, the following URL returns the
  12848. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  12849. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  12850. @example
  12851. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  12852. @end example
  12853. Obviously, these URLs only work for files that are in the store; in
  12854. other cases, they return 404 (``Not Found'').
  12855. @cindex build logs, publication
  12856. Build logs are available from @code{/log} URLs like:
  12857. @example
  12858. http://example.org/log/gwspk@dots{}-guile-2.2.3
  12859. @end example
  12860. @noindent
  12861. When @command{guix-daemon} is configured to save compressed build logs,
  12862. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  12863. URLs return the compressed log as-is, with an appropriate
  12864. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  12865. running @command{guix-daemon} with @option{--log-compression=gzip} since
  12866. Web browsers can automatically decompress it, which is not the case with
  12867. Bzip2 compression.
  12868. The following options are available:
  12869. @table @code
  12870. @item --port=@var{port}
  12871. @itemx -p @var{port}
  12872. Listen for HTTP requests on @var{port}.
  12873. @item --listen=@var{host}
  12874. Listen on the network interface for @var{host}. The default is to
  12875. accept connections from any interface.
  12876. @item --user=@var{user}
  12877. @itemx -u @var{user}
  12878. Change privileges to @var{user} as soon as possible---i.e., once the
  12879. server socket is open and the signing key has been read.
  12880. @item --compression[=@var{method}[:@var{level}]]
  12881. @itemx -C [@var{method}[:@var{level}]]
  12882. Compress data using the given @var{method} and @var{level}. @var{method} is
  12883. one of @code{lzip}, @code{zstd}, and @code{gzip}; when @var{method} is
  12884. omitted, @code{gzip} is used.
  12885. When @var{level} is zero, disable compression. The range 1 to 9 corresponds
  12886. to different compression levels: 1 is the fastest, and 9 is the best
  12887. (CPU-intensive). The default is 3.
  12888. Usually, @code{lzip} compresses noticeably better than @code{gzip} for a
  12889. small increase in CPU usage; see
  12890. @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip
  12891. Web page}. However, @code{lzip} achieves low decompression throughput
  12892. (on the order of 50@tie{}MiB/s on modern hardware), which can be a
  12893. bottleneck for someone who downloads over a fast network connection.
  12894. The compression ratio of @code{zstd} is between that of @code{lzip} and
  12895. that of @code{gzip}; its main advantage is a
  12896. @uref{https://facebook.github.io/zstd/,high decompression speed}.
  12897. Unless @option{--cache} is used, compression occurs on the fly and
  12898. the compressed streams are not
  12899. cached. Thus, to reduce load on the machine that runs @command{guix
  12900. publish}, it may be a good idea to choose a low compression level, to
  12901. run @command{guix publish} behind a caching proxy, or to use
  12902. @option{--cache}. Using @option{--cache} has the advantage that it
  12903. allows @command{guix publish} to add @code{Content-Length} HTTP header
  12904. to its responses.
  12905. This option can be repeated, in which case every substitute gets compressed
  12906. using all the selected methods, and all of them are advertised. This is
  12907. useful when users may not support all the compression methods: they can select
  12908. the one they support.
  12909. @item --cache=@var{directory}
  12910. @itemx -c @var{directory}
  12911. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  12912. and only serve archives that are in cache.
  12913. When this option is omitted, archives and meta-data are created
  12914. on-the-fly. This can reduce the available bandwidth, especially when
  12915. compression is enabled, since this may become CPU-bound. Another
  12916. drawback of the default mode is that the length of archives is not known
  12917. in advance, so @command{guix publish} does not add a
  12918. @code{Content-Length} HTTP header to its responses, which in turn
  12919. prevents clients from knowing the amount of data being downloaded.
  12920. Conversely, when @option{--cache} is used, the first request for a store
  12921. item (@i{via} a @code{.narinfo} URL) triggers a
  12922. background process to @dfn{bake} the archive---computing its
  12923. @code{.narinfo} and compressing the archive, if needed. Once the
  12924. archive is cached in @var{directory}, subsequent requests succeed and
  12925. are served directly from the cache, which guarantees that clients get
  12926. the best possible bandwidth.
  12927. That first @code{.narinfo} request nonetheless returns 200, provided the
  12928. requested store item is ``small enough'', below the cache bypass
  12929. threshold---see @option{--cache-bypass-threshold} below. That way,
  12930. clients do not have to wait until the archive is baked. For larger
  12931. store items, the first @code{.narinfo} request returns 404, meaning that
  12932. clients have to wait until the archive is baked.
  12933. The ``baking'' process is performed by worker threads. By default, one
  12934. thread per CPU core is created, but this can be customized. See
  12935. @option{--workers} below.
  12936. When @option{--ttl} is used, cached entries are automatically deleted
  12937. when they have expired.
  12938. @item --workers=@var{N}
  12939. When @option{--cache} is used, request the allocation of @var{N} worker
  12940. threads to ``bake'' archives.
  12941. @item --ttl=@var{ttl}
  12942. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  12943. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  12944. days, @code{1m} means 1 month, and so on.
  12945. This allows the user's Guix to keep substitute information in cache for
  12946. @var{ttl}. However, note that @code{guix publish} does not itself
  12947. guarantee that the store items it provides will indeed remain available
  12948. for as long as @var{ttl}.
  12949. Additionally, when @option{--cache} is used, cached entries that have
  12950. not been accessed for @var{ttl} and that no longer have a corresponding
  12951. item in the store, may be deleted.
  12952. @item --negative-ttl=@var{ttl}
  12953. Similarly produce @code{Cache-Control} HTTP headers to advertise the
  12954. time-to-live (TTL) of @emph{negative} lookups---missing store items, for
  12955. which the HTTP 404 code is returned. By default, no negative TTL is
  12956. advertised.
  12957. This parameter can help adjust server load and substitute latency by
  12958. instructing cooperating clients to be more or less patient when a store
  12959. item is missing.
  12960. @item --cache-bypass-threshold=@var{size}
  12961. When used in conjunction with @option{--cache}, store items smaller than
  12962. @var{size} are immediately available, even when they are not yet in
  12963. cache. @var{size} is a size in bytes, or it can be suffixed by @code{M}
  12964. for megabytes and so on. The default is @code{10M}.
  12965. ``Cache bypass'' allows you to reduce the publication delay for clients
  12966. at the expense of possibly additional I/O and CPU use on the server
  12967. side: depending on the client access patterns, those store items can end
  12968. up being baked several times until a copy is available in cache.
  12969. Increasing the threshold may be useful for sites that have few users, or
  12970. to guarantee that users get substitutes even for store items that are
  12971. not popular.
  12972. @item --nar-path=@var{path}
  12973. Use @var{path} as the prefix for the URLs of ``nar'' files
  12974. (@pxref{Invoking guix archive, normalized archives}).
  12975. By default, nars are served at a URL such as
  12976. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  12977. change the @code{/nar} part to @var{path}.
  12978. @item --public-key=@var{file}
  12979. @itemx --private-key=@var{file}
  12980. Use the specific @var{file}s as the public/private key pair used to sign
  12981. the store items being published.
  12982. The files must correspond to the same key pair (the private key is used
  12983. for signing and the public key is merely advertised in the signature
  12984. metadata). They must contain keys in the canonical s-expression format
  12985. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  12986. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  12987. @file{/etc/guix/signing-key.sec} are used.
  12988. @item --repl[=@var{port}]
  12989. @itemx -r [@var{port}]
  12990. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  12991. Reference Manual}) on @var{port} (37146 by default). This is used
  12992. primarily for debugging a running @command{guix publish} server.
  12993. @end table
  12994. Enabling @command{guix publish} on Guix System is a one-liner: just
  12995. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  12996. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  12997. @code{guix-publish-service-type}}).
  12998. If you are instead running Guix on a ``foreign distro'', follow these
  12999. instructions:
  13000. @itemize
  13001. @item
  13002. If your host distro uses the systemd init system:
  13003. @example
  13004. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  13005. /etc/systemd/system/
  13006. # systemctl start guix-publish && systemctl enable guix-publish
  13007. @end example
  13008. @item
  13009. If your host distro uses the Upstart init system:
  13010. @example
  13011. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  13012. # start guix-publish
  13013. @end example
  13014. @item
  13015. Otherwise, proceed similarly with your distro's init system.
  13016. @end itemize
  13017. @node Invoking guix challenge
  13018. @section Invoking @command{guix challenge}
  13019. @cindex reproducible builds
  13020. @cindex verifiable builds
  13021. @cindex @command{guix challenge}
  13022. @cindex challenge
  13023. Do the binaries provided by this server really correspond to the source
  13024. code it claims to build? Is a package build process deterministic?
  13025. These are the questions the @command{guix challenge} command attempts to
  13026. answer.
  13027. The former is obviously an important question: Before using a substitute
  13028. server (@pxref{Substitutes}), one had better @emph{verify} that it
  13029. provides the right binaries, and thus @emph{challenge} it. The latter
  13030. is what enables the former: If package builds are deterministic, then
  13031. independent builds of the package should yield the exact same result,
  13032. bit for bit; if a server provides a binary different from the one
  13033. obtained locally, it may be either corrupt or malicious.
  13034. We know that the hash that shows up in @file{/gnu/store} file names is
  13035. the hash of all the inputs of the process that built the file or
  13036. directory---compilers, libraries, build scripts,
  13037. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  13038. one store file name should map to exactly one build output.
  13039. @command{guix challenge} checks whether there is, indeed, a single
  13040. mapping by comparing the build outputs of several independent builds of
  13041. any given store item.
  13042. The command output looks like this:
  13043. @smallexample
  13044. $ guix challenge \
  13045. --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org" \
  13046. openssl git pius coreutils grep
  13047. updating substitutes from 'https://@value{SUBSTITUTE-SERVER-1}'... 100.0%
  13048. updating substitutes from 'https://guix.example.org'... 100.0%
  13049. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  13050. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  13051. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  13052. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  13053. differing files:
  13054. /lib/libcrypto.so.1.1
  13055. /lib/libssl.so.1.1
  13056. /gnu/store/@dots{}-git-2.5.0 contents differ:
  13057. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  13058. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  13059. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  13060. differing file:
  13061. /libexec/git-core/git-fsck
  13062. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  13063. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  13064. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  13065. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  13066. differing file:
  13067. /share/man/man1/pius.1.gz
  13068. @dots{}
  13069. 5 store items were analyzed:
  13070. - 2 (40.0%) were identical
  13071. - 3 (60.0%) differed
  13072. - 0 (0.0%) were inconclusive
  13073. @end smallexample
  13074. @noindent
  13075. In this example, @command{guix challenge} queries all the substitute
  13076. servers for each of the fives packages specified on the command line.
  13077. It then reports those store items for which the servers obtained a
  13078. result different from the local build (if it exists) and/or different
  13079. from one another; here, the @samp{local hash} lines indicate that a
  13080. local build result was available for each of these packages and shows
  13081. its hash.
  13082. @cindex non-determinism, in package builds
  13083. As an example, @code{guix.example.org} always gets a different answer.
  13084. Conversely, @code{@value{SUBSTITUTE-SERVER-1}} agrees with local builds, except in the
  13085. case of Git. This might indicate that the build process of Git is
  13086. non-deterministic, meaning that its output varies as a function of
  13087. various things that Guix does not fully control, in spite of building
  13088. packages in isolated environments (@pxref{Features}). Most common
  13089. sources of non-determinism include the addition of timestamps in build
  13090. results, the inclusion of random numbers, and directory listings sorted
  13091. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  13092. more information.
  13093. To find out what is wrong with this Git binary, the easiest approach is
  13094. to run:
  13095. @example
  13096. guix challenge git \
  13097. --diff=diffoscope \
  13098. --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
  13099. @end example
  13100. This automatically invokes @command{diffoscope}, which displays detailed
  13101. information about files that differ.
  13102. Alternatively, we can do something along these lines (@pxref{Invoking guix
  13103. archive}):
  13104. @example
  13105. $ wget -q -O - https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-git-2.5.0 \
  13106. | lzip -d | guix archive -x /tmp/git
  13107. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  13108. @end example
  13109. This command shows the difference between the files resulting from the
  13110. local build, and the files resulting from the build on
  13111. @code{@value{SUBSTITUTE-SERVER-1}} (@pxref{Overview, Comparing and Merging Files,,
  13112. diffutils, Comparing and Merging Files}). The @command{diff} command
  13113. works great for text files. When binary files differ, a better option
  13114. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  13115. visualize differences for all kinds of files.
  13116. Once you have done that work, you can tell whether the differences are due
  13117. to a non-deterministic build process or to a malicious server. We try
  13118. hard to remove sources of non-determinism in packages to make it easier
  13119. to verify substitutes, but of course, this is a process that
  13120. involves not just Guix, but a large part of the free software community.
  13121. In the meantime, @command{guix challenge} is one tool to help address
  13122. the problem.
  13123. If you are writing packages for Guix, you are encouraged to check
  13124. whether @code{@value{SUBSTITUTE-SERVER-1}} and other substitute servers obtain the
  13125. same build result as you did with:
  13126. @example
  13127. guix challenge @var{package}
  13128. @end example
  13129. The general syntax is:
  13130. @example
  13131. guix challenge @var{options} @var{argument}@dots{}
  13132. @end example
  13133. @noindent
  13134. where @var{argument} is a package specification such as
  13135. @code{guile@@2.0} or @code{glibc:debug} or, alternatively, a store file
  13136. name as returned, for example, by @command{guix build} or @command{guix
  13137. gc --list-live}.
  13138. When a difference is found between the hash of a locally-built item and
  13139. that of a server-provided substitute, or among substitutes provided by
  13140. different servers, the command displays it as in the example above and
  13141. its exit code is 2 (other non-zero exit codes denote other kinds of
  13142. errors).
  13143. The one option that matters is:
  13144. @table @code
  13145. @item --substitute-urls=@var{urls}
  13146. Consider @var{urls} the whitespace-separated list of substitute source
  13147. URLs to compare to.
  13148. @item --diff=@var{mode}
  13149. Upon mismatches, show differences according to @var{mode}, one of:
  13150. @table @asis
  13151. @item @code{simple} (the default)
  13152. Show the list of files that differ.
  13153. @item @code{diffoscope}
  13154. @itemx @var{command}
  13155. Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
  13156. two directories whose contents do not match.
  13157. When @var{command} is an absolute file name, run @var{command} instead
  13158. of Diffoscope.
  13159. @item @code{none}
  13160. Do not show further details about the differences.
  13161. @end table
  13162. Thus, unless @option{--diff=none} is passed, @command{guix challenge}
  13163. downloads the store items from the given substitute servers so that it
  13164. can compare them.
  13165. @item --verbose
  13166. @itemx -v
  13167. Show details about matches (identical contents) in addition to
  13168. information about mismatches.
  13169. @end table
  13170. @node Invoking guix copy
  13171. @section Invoking @command{guix copy}
  13172. @cindex @command{guix copy}
  13173. @cindex copy, of store items, over SSH
  13174. @cindex SSH, copy of store items
  13175. @cindex sharing store items across machines
  13176. @cindex transferring store items across machines
  13177. The @command{guix copy} command copies items from the store of one
  13178. machine to that of another machine over a secure shell (SSH)
  13179. connection@footnote{This command is available only when Guile-SSH was
  13180. found. @xref{Requirements}, for details.}. For example, the following
  13181. command copies the @code{coreutils} package, the user's profile, and all
  13182. their dependencies over to @var{host}, logged in as @var{user}:
  13183. @example
  13184. guix copy --to=@var{user}@@@var{host} \
  13185. coreutils $(readlink -f ~/.guix-profile)
  13186. @end example
  13187. If some of the items to be copied are already present on @var{host},
  13188. they are not actually sent.
  13189. The command below retrieves @code{libreoffice} and @code{gimp} from
  13190. @var{host}, assuming they are available there:
  13191. @example
  13192. guix copy --from=@var{host} libreoffice gimp
  13193. @end example
  13194. The SSH connection is established using the Guile-SSH client, which is
  13195. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  13196. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  13197. The key used to sign items that are sent must be accepted by the remote
  13198. machine. Likewise, the key used by the remote machine to sign items you
  13199. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  13200. own daemon. @xref{Invoking guix archive}, for more information about
  13201. store item authentication.
  13202. The general syntax is:
  13203. @example
  13204. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  13205. @end example
  13206. You must always specify one of the following options:
  13207. @table @code
  13208. @item --to=@var{spec}
  13209. @itemx --from=@var{spec}
  13210. Specify the host to send to or receive from. @var{spec} must be an SSH
  13211. spec such as @code{example.org}, @code{charlie@@example.org}, or
  13212. @code{charlie@@example.org:2222}.
  13213. @end table
  13214. The @var{items} can be either package names, such as @code{gimp}, or
  13215. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  13216. When specifying the name of a package to send, it is first built if
  13217. needed, unless @option{--dry-run} was specified. Common build options
  13218. are supported (@pxref{Common Build Options}).
  13219. @node Invoking guix container
  13220. @section Invoking @command{guix container}
  13221. @cindex container
  13222. @cindex @command{guix container}
  13223. @quotation Note
  13224. As of version @value{VERSION}, this tool is experimental. The interface
  13225. is subject to radical change in the future.
  13226. @end quotation
  13227. The purpose of @command{guix container} is to manipulate processes
  13228. running within an isolated environment, commonly known as a
  13229. ``container'', typically created by the @command{guix shell}
  13230. (@pxref{Invoking guix shell}) and @command{guix system container}
  13231. (@pxref{Invoking guix system}) commands.
  13232. The general syntax is:
  13233. @example
  13234. guix container @var{action} @var{options}@dots{}
  13235. @end example
  13236. @var{action} specifies the operation to perform with a container, and
  13237. @var{options} specifies the context-specific arguments for the action.
  13238. The following actions are available:
  13239. @table @code
  13240. @item exec
  13241. Execute a command within the context of a running container.
  13242. The syntax is:
  13243. @example
  13244. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  13245. @end example
  13246. @var{pid} specifies the process ID of the running container.
  13247. @var{program} specifies an executable file name within the root file
  13248. system of the container. @var{arguments} are the additional options that
  13249. will be passed to @var{program}.
  13250. The following command launches an interactive login shell inside a
  13251. Guix system container, started by @command{guix system container}, and whose
  13252. process ID is 9001:
  13253. @example
  13254. guix container exec 9001 /run/current-system/profile/bin/bash --login
  13255. @end example
  13256. Note that the @var{pid} cannot be the parent process of a container. It
  13257. must be PID 1 of the container or one of its child processes.
  13258. @end table
  13259. @node Invoking guix weather
  13260. @section Invoking @command{guix weather}
  13261. @cindex @command{guix weather}
  13262. Occasionally you're grumpy because substitutes are lacking and you end
  13263. up building packages by yourself (@pxref{Substitutes}). The
  13264. @command{guix weather} command reports on substitute availability on the
  13265. specified servers so you can have an idea of whether you'll be grumpy
  13266. today. It can sometimes be useful info as a user, but it is primarily
  13267. useful to people running @command{guix publish} (@pxref{Invoking guix
  13268. publish}).
  13269. @cindex statistics, for substitutes
  13270. @cindex availability of substitutes
  13271. @cindex substitute availability
  13272. @cindex weather, substitute availability
  13273. Here's a sample run:
  13274. @example
  13275. $ guix weather --substitute-urls=https://guix.example.org
  13276. computing 5,872 package derivations for x86_64-linux...
  13277. looking for 6,128 store items on https://guix.example.org..
  13278. updating substitutes from 'https://guix.example.org'... 100.0%
  13279. https://guix.example.org
  13280. 43.4% substitutes available (2,658 out of 6,128)
  13281. 7,032.5 MiB of nars (compressed)
  13282. 19,824.2 MiB on disk (uncompressed)
  13283. 0.030 seconds per request (182.9 seconds in total)
  13284. 33.5 requests per second
  13285. 9.8% (342 out of 3,470) of the missing items are queued
  13286. 867 queued builds
  13287. x86_64-linux: 518 (59.7%)
  13288. i686-linux: 221 (25.5%)
  13289. aarch64-linux: 128 (14.8%)
  13290. build rate: 23.41 builds per hour
  13291. x86_64-linux: 11.16 builds per hour
  13292. i686-linux: 6.03 builds per hour
  13293. aarch64-linux: 6.41 builds per hour
  13294. @end example
  13295. @cindex continuous integration, statistics
  13296. As you can see, it reports the fraction of all the packages for which
  13297. substitutes are available on the server---regardless of whether
  13298. substitutes are enabled, and regardless of whether this server's signing
  13299. key is authorized. It also reports the size of the compressed archives
  13300. (``nars'') provided by the server, the size the corresponding store
  13301. items occupy in the store (assuming deduplication is turned off), and
  13302. the server's throughput. The second part gives continuous integration
  13303. (CI) statistics, if the server supports it. In addition, using the
  13304. @option{--coverage} option, @command{guix weather} can list ``important''
  13305. package substitutes missing on the server (see below).
  13306. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  13307. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  13308. challenge}, it ignores signatures on those substitutes, which is
  13309. innocuous since the command only gathers statistics and cannot install
  13310. those substitutes.
  13311. The general syntax is:
  13312. @example
  13313. guix weather @var{options}@dots{} [@var{packages}@dots{}]
  13314. @end example
  13315. When @var{packages} is omitted, @command{guix weather} checks the availability
  13316. of substitutes for @emph{all} the packages, or for those specified with
  13317. @option{--manifest}; otherwise it only considers the specified packages. It
  13318. is also possible to query specific system types with @option{--system}.
  13319. @command{guix weather} exits with a non-zero code when the fraction of
  13320. available substitutes is below 100%.
  13321. The available options are listed below.
  13322. @table @code
  13323. @item --substitute-urls=@var{urls}
  13324. @var{urls} is the space-separated list of substitute server URLs to
  13325. query. When this option is omitted, the default set of substitute
  13326. servers is queried.
  13327. @item --system=@var{system}
  13328. @itemx -s @var{system}
  13329. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  13330. option can be repeated, in which case @command{guix weather} will query
  13331. substitutes for several system types.
  13332. @item --manifest=@var{file}
  13333. Instead of querying substitutes for all the packages, only ask for those
  13334. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  13335. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  13336. guix package}).
  13337. This option can be repeated several times, in which case the manifests
  13338. are concatenated.
  13339. @item --coverage[=@var{count}]
  13340. @itemx -c [@var{count}]
  13341. Report on substitute coverage for packages: list packages with at least
  13342. @var{count} dependents (zero by default) for which substitutes are
  13343. unavailable. Dependent packages themselves are not listed: if @var{b} depends
  13344. on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
  13345. @var{b} usually lacks substitutes as well. The result looks like this:
  13346. @example
  13347. $ guix weather --substitute-urls=@value{SUBSTITUTE-URLS} -c 10
  13348. computing 8,983 package derivations for x86_64-linux...
  13349. looking for 9,343 store items on @value{SUBSTITUTE-URLS}...
  13350. updating substitutes from '@value{SUBSTITUTE-URLS}'... 100.0%
  13351. @value{SUBSTITUTE-URLS}
  13352. 64.7% substitutes available (6,047 out of 9,343)
  13353. @dots{}
  13354. 2502 packages are missing from '@value{SUBSTITUTE-URLS}' for 'x86_64-linux', among which:
  13355. 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
  13356. 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
  13357. 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
  13358. @dots{}
  13359. @end example
  13360. What this example shows is that @code{kcoreaddons} and presumably the 58
  13361. packages that depend on it have no substitutes at
  13362. @code{@value{SUBSTITUTE-SERVER-1}}; likewise for @code{qgpgme} and the 46
  13363. packages that depend on it.
  13364. If you are a Guix developer, or if you are taking care of this build farm,
  13365. you'll probably want to have a closer look at these packages: they may simply
  13366. fail to build.
  13367. @item --display-missing
  13368. Display the list of store items for which substitutes are missing.
  13369. @end table
  13370. @node Invoking guix processes
  13371. @section Invoking @command{guix processes}
  13372. @cindex @command{guix processes}
  13373. The @command{guix processes} command can be useful to developers and system
  13374. administrators, especially on multi-user machines and on build farms: it lists
  13375. the current sessions (connections to the daemon), as well as information about
  13376. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  13377. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  13378. listed.}. Here's an example of the information it returns:
  13379. @example
  13380. $ sudo guix processes
  13381. SessionPID: 19002
  13382. ClientPID: 19090
  13383. ClientCommand: guix shell python
  13384. SessionPID: 19402
  13385. ClientPID: 19367
  13386. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  13387. SessionPID: 19444
  13388. ClientPID: 19419
  13389. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  13390. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  13391. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  13392. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  13393. ChildPID: 20495
  13394. ChildCommand: guix offload x86_64-linux 7200 1 28800
  13395. ChildPID: 27733
  13396. ChildCommand: guix offload x86_64-linux 7200 1 28800
  13397. ChildPID: 27793
  13398. ChildCommand: guix offload x86_64-linux 7200 1 28800
  13399. @end example
  13400. In this example we see that @command{guix-daemon} has three clients:
  13401. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  13402. integration tool; their process identifier (PID) is given by the
  13403. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  13404. @command{guix-daemon} sub-process of this particular session.
  13405. The @code{LockHeld} fields show which store items are currently locked
  13406. by this session, which corresponds to store items being built or
  13407. substituted (the @code{LockHeld} field is not displayed when
  13408. @command{guix processes} is not running as root). Last, by looking at
  13409. the @code{ChildPID} and @code{ChildCommand} fields, we understand that
  13410. these three builds are being offloaded (@pxref{Daemon Offload Setup}).
  13411. The output is in Recutils format so we can use the handy @command{recsel}
  13412. command to select sessions of interest (@pxref{Selection Expressions,,,
  13413. recutils, GNU recutils manual}). As an example, the command shows the command
  13414. line and PID of the client that triggered the build of a Perl package:
  13415. @example
  13416. $ sudo guix processes | \
  13417. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  13418. ClientPID: 19419
  13419. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  13420. @end example
  13421. Additional options are listed below.
  13422. @table @code
  13423. @item --format=@var{format}
  13424. @itemx -f @var{format}
  13425. Produce output in the specified @var{format}, one of:
  13426. @table @code
  13427. @item recutils
  13428. The default option. It outputs a set of Session recutils records
  13429. that include each @code{ChildProcess} as a field.
  13430. @item normalized
  13431. Normalize the output records into record sets (@pxref{Record Sets,,,
  13432. recutils, GNU recutils manual}). Normalizing into record sets allows
  13433. joins across record types. The example below lists the PID of each
  13434. @code{ChildProcess} and the associated PID for @code{Session} that
  13435. spawned the @code{ChildProcess} where the @code{Session} was started
  13436. using @command{guix build}.
  13437. @example
  13438. $ guix processes --format=normalized | \
  13439. recsel \
  13440. -j Session \
  13441. -t ChildProcess \
  13442. -p Session.PID,PID \
  13443. -e 'Session.ClientCommand ~ "guix build"'
  13444. PID: 4435
  13445. Session_PID: 4278
  13446. PID: 4554
  13447. Session_PID: 4278
  13448. PID: 4646
  13449. Session_PID: 4278
  13450. @end example
  13451. @end table
  13452. @end table
  13453. @node Foreign Architectures
  13454. @chapter Foreign Architectures
  13455. You can target computers of different CPU architectures when producing
  13456. packages (@pxref{Invoking guix package}), packs (@pxref{Invoking guix
  13457. pack}) or full systems (@pxref{Invoking guix system}).
  13458. GNU Guix supports two distinct mechanisms to target foreign
  13459. architectures:
  13460. @enumerate
  13461. @item
  13462. The traditional
  13463. @uref{https://en.wikipedia.org/wiki/Cross_compiler,cross-compilation}
  13464. mechanism.
  13465. @item
  13466. The native building mechanism which consists in building using the CPU
  13467. instruction set of the foreign system you are targeting. It often
  13468. requires emulation, using the QEMU program for instance.
  13469. @end enumerate
  13470. @menu
  13471. * Cross-Compilation:: Cross-compiling for another architecture.
  13472. * Native Builds:: Targeting another architecture through native builds.
  13473. @end menu
  13474. @node Cross-Compilation
  13475. @section Cross-Compilation
  13476. @cindex foreign architectures
  13477. The commands supporting cross-compilation are proposing the
  13478. @option{--list-targets} and @option{--target} options.
  13479. The @option{--list-targets} option lists all the supported targets that
  13480. can be passed as an argument to @option{--target}.
  13481. @example
  13482. $ guix build --list-targets
  13483. The available targets are:
  13484. - aarch64-linux-gnu
  13485. - arm-linux-gnueabihf
  13486. - i586-pc-gnu
  13487. - i686-linux-gnu
  13488. - i686-w64-mingw32
  13489. - mips64el-linux-gnu
  13490. - powerpc-linux-gnu
  13491. - powerpc64le-linux-gnu
  13492. - riscv64-linux-gnu
  13493. - x86_64-linux-gnu
  13494. - x86_64-w64-mingw32
  13495. @end example
  13496. Targets are specified as GNU triplets (@pxref{Specifying Target
  13497. Triplets, GNU configuration triplets,, autoconf, Autoconf}).
  13498. Those triplets are passed to GCC and the other underlying compilers
  13499. possibly involved when building a package, a system image or any other
  13500. GNU Guix output.
  13501. @example
  13502. $ guix build --target=aarch64-linux-gnu hello
  13503. /gnu/store/9926by9qrxa91ijkhw9ndgwp4bn24g9h-hello-2.12
  13504. $ file /gnu/store/9926by9qrxa91ijkhw9ndgwp4bn24g9h-hello-2.12/bin/hello
  13505. /gnu/store/9926by9qrxa91ijkhw9ndgwp4bn24g9h-hello-2.12/bin/hello: ELF
  13506. 64-bit LSB executable, ARM aarch64 @dots{}
  13507. @end example
  13508. The major benefit of cross-compilation is that there are no performance
  13509. penalty compared to emulation using QEMU. There are however higher
  13510. risks that some packages fail to cross-compile because fewer users are
  13511. using this mechanism extensively.
  13512. @node Native Builds
  13513. @section Native Builds
  13514. The commands that support impersonating a specific system have the
  13515. @option{--list-systems} and @option{--system} options.
  13516. The @option{--list-systems} option lists all the supported systems that
  13517. can be passed as an argument to @option{--system}.
  13518. @example
  13519. $ guix build --list-systems
  13520. The available systems are:
  13521. - x86_64-linux [current]
  13522. - aarch64-linux
  13523. - armhf-linux
  13524. - i586-gnu
  13525. - i686-linux
  13526. - mips64el-linux
  13527. - powerpc-linux
  13528. - powerpc64le-linux
  13529. - riscv64-linux
  13530. $ guix build --system=i686-linux hello
  13531. /gnu/store/cc0km35s8x2z4pmwkrqqjx46i8b1i3gm-hello-2.12
  13532. $ file /gnu/store/cc0km35s8x2z4pmwkrqqjx46i8b1i3gm-hello-2.12/bin/hello
  13533. /gnu/store/cc0km35s8x2z4pmwkrqqjx46i8b1i3gm-hello-2.12/bin/hello: ELF
  13534. 32-bit LSB executable, Intel 80386 @dots{}
  13535. @end example
  13536. In the above example, the current system is @var{x86_64-linux}. The
  13537. @var{hello} package is however built for the @var{i686-linux} system.
  13538. This is possible because the @var{i686} CPU instruction set is a subset
  13539. of the @var{x86_64}, hence @var{i686} targeting binaries can be run on
  13540. @var{x86_64}.
  13541. Still in the context of the previous example, if picking the
  13542. @var{aarch64-linux} system and the @command{guix build
  13543. --system=aarch64-linux hello} has to build some derivations, an extra
  13544. step might be needed.
  13545. The @var{aarch64-linux} targeting binaries cannot directly be run on a
  13546. @var{x86_64-linux} system. An emulation layer is requested. The GNU
  13547. Guix daemon can take advantage of the Linux kernel
  13548. @uref{https://en.wikipedia.org/wiki/Binfmt_misc,binfmt_misc} mechanism
  13549. for that. In short, the Linux kernel can defer the execution of a
  13550. binary targeting a foreign platform, here @var{aarch64-linux}, to a
  13551. userspace program, usually an emulator.
  13552. There is a service that registers QEMU as a backend for the
  13553. @code{binfmt_misc} mechanism (@pxref{Virtualization Services,
  13554. @code{qemu-binfmt-service-type}}). On Debian based foreign
  13555. distributions, the alternative would be the @code{qemu-user-static}
  13556. package.
  13557. If the @code{binfmt_misc} mechanism is not setup correctly, the building
  13558. will fail this way:
  13559. @example
  13560. $ guix build --system=armhf-linux hello --check
  13561. @dots{}
  13562. @ unsupported-platform /gnu/store/jjn969pijv7hff62025yxpfmc8zy0aq0-hello-2.12.drv aarch64-linux
  13563. while setting up the build environment: a `aarch64-linux' is required to
  13564. build `/gnu/store/jjn969pijv7hff62025yxpfmc8zy0aq0-hello-2.12.drv', but
  13565. I am a `x86_64-linux'@dots{}
  13566. @end example
  13567. whereas, with the @code{binfmt_misc} mechanism correctly linked with
  13568. QEMU, one can expect to see:
  13569. @example
  13570. $ guix build --system=armhf-linux hello --check
  13571. /gnu/store/13xz4nghg39wpymivlwghy08yzj97hlj-hello-2.12
  13572. @end example
  13573. The main advantage of native building compared to cross-compiling, is
  13574. that more packages are likely to build correctly. However it comes at a
  13575. price: compilation backed by QEMU is @emph{way slower} than
  13576. cross-compilation, because every instruction needs to be emulated.
  13577. The availability of substitutes for the architecture targeted by the
  13578. @code{--system} option can mitigate this problem. An other way to work
  13579. around it is to install GNU Guix on a machine whose CPU supports
  13580. the targeted instruction set, and set it up as an offload machine
  13581. (@pxref{Daemon Offload Setup}).
  13582. @node System Configuration
  13583. @chapter System Configuration
  13584. @cindex system configuration
  13585. Guix System supports a consistent whole-system configuration
  13586. mechanism. By that we mean that all aspects of the global system
  13587. configuration---such as the available system services, timezone and
  13588. locale settings, user accounts---are declared in a single place. Such
  13589. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  13590. One of the advantages of putting all the system configuration under the
  13591. control of Guix is that it supports transactional system upgrades, and
  13592. makes it possible to roll back to a previous system instantiation,
  13593. should something go wrong with the new one (@pxref{Features}). Another
  13594. advantage is that it makes it easy to replicate the exact same configuration
  13595. across different machines, or at different points in time, without
  13596. having to resort to additional administration tools layered on top of
  13597. the own tools of the system.
  13598. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  13599. This section describes this mechanism. First we focus on the system
  13600. administrator's viewpoint---explaining how the system is configured and
  13601. instantiated. Then we show how this mechanism can be extended, for
  13602. instance to support new system services.
  13603. @menu
  13604. * Using the Configuration System:: Customizing your GNU system.
  13605. * operating-system Reference:: Detail of operating-system declarations.
  13606. * File Systems:: Configuring file system mounts.
  13607. * Mapped Devices:: Block device extra processing.
  13608. * Swap Space:: Backing RAM with disk space.
  13609. * User Accounts:: Specifying user accounts.
  13610. * Keyboard Layout:: How the system interprets key strokes.
  13611. * Locales:: Language and cultural convention settings.
  13612. * Services:: Specifying system services.
  13613. * Setuid Programs:: Programs running with elevated privileges.
  13614. * X.509 Certificates:: Authenticating HTTPS servers.
  13615. * Name Service Switch:: Configuring libc's name service switch.
  13616. * Initial RAM Disk:: Linux-Libre bootstrapping.
  13617. * Bootloader Configuration:: Configuring the boot loader.
  13618. * Invoking guix system:: Instantiating a system configuration.
  13619. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  13620. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  13621. * Defining Services:: Adding new service definitions.
  13622. @end menu
  13623. @node Using the Configuration System
  13624. @section Using the Configuration System
  13625. The operating system is configured by providing an
  13626. @code{operating-system} declaration in a file that can then be passed to
  13627. the @command{guix system} command (@pxref{Invoking guix system}). A
  13628. simple setup, with the default Linux-Libre
  13629. kernel, initial RAM disk, and a couple of system services added to those
  13630. provided by default looks like this:
  13631. @findex operating-system
  13632. @lisp
  13633. @include os-config-bare-bones.texi
  13634. @end lisp
  13635. The configuration is declarative and hopefully mostly self-describing.
  13636. It is actually code in the Scheme programming language; the whole
  13637. @code{(operating-system @dots{})} expression produces a @dfn{record}
  13638. with a number of @dfn{fields}.
  13639. Some of the fields defined
  13640. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  13641. Others, such as @code{packages} and @code{services}, can be omitted, in
  13642. which case they get a default value. @xref{operating-system Reference},
  13643. for details about all the available fields.
  13644. Below we discuss the effect of some of the most important fields,
  13645. and how to @dfn{instantiate} the operating system using
  13646. @command{guix system}.
  13647. @quotation Do not panic
  13648. @cindex Scheme programming language, getting started
  13649. Intimidated by the Scheme language or curious about it? The Cookbook
  13650. has a short section to get started that explains the fundamentals, which
  13651. you will find helpful when hacking your configuration. @xref{A Scheme
  13652. Crash Course,,, guix-cookbook, GNU Guix Cookbook}.
  13653. @end quotation
  13654. @unnumberedsubsec Bootloader
  13655. @cindex legacy boot, on Intel machines
  13656. @cindex BIOS boot, on Intel machines
  13657. @cindex UEFI boot
  13658. @cindex EFI boot
  13659. The @code{bootloader} field describes the method that will be used to boot
  13660. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  13661. mode, as in the example above. However, more recent machines rely instead on
  13662. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  13663. the @code{bootloader} field should contain something along these lines:
  13664. @lisp
  13665. (bootloader-configuration
  13666. (bootloader grub-efi-bootloader)
  13667. (targets '("/boot/efi")))
  13668. @end lisp
  13669. @xref{Bootloader Configuration}, for more information on the available
  13670. configuration options.
  13671. @unnumberedsubsec Globally-Visible Packages
  13672. @vindex %base-packages
  13673. The @code{packages} field lists packages that will be globally visible
  13674. on the system, for all user accounts---i.e., in every user's @env{PATH}
  13675. environment variable---in addition to the per-user profiles
  13676. (@pxref{Invoking guix package}). The @code{%base-packages} variable
  13677. provides all the tools one would expect for basic user and administrator
  13678. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  13679. the @command{mg} lightweight text editor, @command{find}, @command{grep},
  13680. etc. The example above adds GNU@tie{}Screen to those,
  13681. taken from the @code{(gnu packages screen)}
  13682. module (@pxref{Package Modules}). The
  13683. @code{(list package output)} syntax can be used to add a specific output
  13684. of a package:
  13685. @lisp
  13686. (use-modules (gnu packages))
  13687. (use-modules (gnu packages dns))
  13688. (operating-system
  13689. ;; ...
  13690. (packages (cons (list isc-bind "utils")
  13691. %base-packages)))
  13692. @end lisp
  13693. @findex specification->package
  13694. Referring to packages by variable name, like @code{isc-bind} above, has
  13695. the advantage of being unambiguous; it also allows typos and such to be
  13696. diagnosed right away as ``unbound variables''. The downside is that one
  13697. needs to know which module defines which package, and to augment the
  13698. @code{use-package-modules} line accordingly. To avoid that, one can use
  13699. the @code{specification->package} procedure of the @code{(gnu packages)}
  13700. module, which returns the best package for a given name or name and
  13701. version:
  13702. @lisp
  13703. (use-modules (gnu packages))
  13704. (operating-system
  13705. ;; ...
  13706. (packages (append (map specification->package
  13707. '("tcpdump" "htop" "gnupg@@2.0"))
  13708. %base-packages)))
  13709. @end lisp
  13710. @unnumberedsubsec System Services
  13711. @cindex services
  13712. @vindex %base-services
  13713. The @code{services} field lists @dfn{system services} to be made
  13714. available when the system starts (@pxref{Services}).
  13715. The @code{operating-system} declaration above specifies that, in
  13716. addition to the basic services, we want the OpenSSH secure shell
  13717. daemon listening on port 2222 (@pxref{Networking Services,
  13718. @code{openssh-service-type}}). Under the hood,
  13719. @code{openssh-service-type} arranges so that @command{sshd} is started with the
  13720. right command-line options, possibly with supporting configuration files
  13721. generated as needed (@pxref{Defining Services}).
  13722. @cindex customization, of services
  13723. @findex modify-services
  13724. Occasionally, instead of using the base services as is, you will want to
  13725. customize them. To do this, use @code{modify-services} (@pxref{Service
  13726. Reference, @code{modify-services}}) to modify the list.
  13727. @anchor{auto-login to TTY} For example, suppose you want to modify
  13728. @code{guix-daemon} and Mingetty (the console log-in) in the
  13729. @code{%base-services} list (@pxref{Base Services,
  13730. @code{%base-services}}). To do that, you can write the following in
  13731. your operating system declaration:
  13732. @lisp
  13733. (define %my-services
  13734. ;; My very own list of services.
  13735. (modify-services %base-services
  13736. (guix-service-type config =>
  13737. (guix-configuration
  13738. (inherit config)
  13739. ;; Fetch substitutes from example.org.
  13740. (substitute-urls
  13741. (list "https://example.org/guix"
  13742. "https://ci.guix.gnu.org"))))
  13743. (mingetty-service-type config =>
  13744. (mingetty-configuration
  13745. (inherit config)
  13746. ;; Automatically log in as "guest".
  13747. (auto-login "guest")))))
  13748. (operating-system
  13749. ;; @dots{}
  13750. (services %my-services))
  13751. @end lisp
  13752. This changes the configuration---i.e., the service parameters---of the
  13753. @code{guix-service-type} instance, and that of all the
  13754. @code{mingetty-service-type} instances in the @code{%base-services} list
  13755. (@pxref{Auto-Login to a Specific TTY, see the cookbook for how to
  13756. auto-login one user to a specific TTY,, guix-cookbook, GNU Guix Cookbook})).
  13757. Observe how this is accomplished: first, we arrange for the original
  13758. configuration to be bound to the identifier @code{config} in the
  13759. @var{body}, and then we write the @var{body} so that it evaluates to the
  13760. desired configuration. In particular, notice how we use @code{inherit}
  13761. to create a new configuration which has the same values as the old
  13762. configuration, but with a few modifications.
  13763. @cindex encrypted disk
  13764. The configuration for a typical ``desktop'' usage, with an encrypted
  13765. root partition, a swap file on the root partition, the X11 display
  13766. server, GNOME and Xfce (users can choose which of these desktop
  13767. environments to use at the log-in screen by pressing @kbd{F1}), network
  13768. management, power management, and more, would look like this:
  13769. @lisp
  13770. @include os-config-desktop.texi
  13771. @end lisp
  13772. A graphical system with a choice of lightweight window managers
  13773. instead of full-blown desktop environments would look like this:
  13774. @lisp
  13775. @include os-config-lightweight-desktop.texi
  13776. @end lisp
  13777. This example refers to the @file{/boot/efi} file system by its UUID,
  13778. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  13779. as returned by the @command{blkid} command.
  13780. @xref{Desktop Services}, for the exact list of services provided by
  13781. @code{%desktop-services}. @xref{X.509 Certificates}, for background
  13782. information about the @code{nss-certs} package that is used here.
  13783. Again, @code{%desktop-services} is just a list of service objects. If
  13784. you want to remove services from there, you can do so using the
  13785. procedures for list filtering (@pxref{SRFI-1 Filtering and
  13786. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  13787. following expression returns a list that contains all the services in
  13788. @code{%desktop-services} minus the Avahi service:
  13789. @lisp
  13790. (remove (lambda (service)
  13791. (eq? (service-kind service) avahi-service-type))
  13792. %desktop-services)
  13793. @end lisp
  13794. Alternatively, the @code{modify-services} macro can be used:
  13795. @lisp
  13796. (modify-services %desktop-services
  13797. (delete avahi-service-type))
  13798. @end lisp
  13799. @unnumberedsubsec Instantiating the System
  13800. Assuming the @code{operating-system} declaration
  13801. is stored in the @file{my-system-config.scm}
  13802. file, the @command{guix system reconfigure my-system-config.scm} command
  13803. instantiates that configuration, and makes it the default GRUB boot
  13804. entry (@pxref{Invoking guix system}).
  13805. @quotation Note
  13806. We recommend that you keep this @file{my-system-config.scm} file safe
  13807. and under version control to easily track changes to your configuration.
  13808. @end quotation
  13809. The normal way to change the system configuration is by updating this
  13810. file and re-running @command{guix system reconfigure}. One should never
  13811. have to touch files in @file{/etc} or to run commands that modify the
  13812. system state such as @command{useradd} or @command{grub-install}. In
  13813. fact, you must avoid that since that would not only void your warranty
  13814. but also prevent you from rolling back to previous versions of your
  13815. system, should you ever need to.
  13816. @cindex roll-back, of the operating system
  13817. Speaking of roll-back, each time you run @command{guix system
  13818. reconfigure}, a new @dfn{generation} of the system is created---without
  13819. modifying or deleting previous generations. Old system generations get
  13820. an entry in the bootloader boot menu, allowing you to boot them in case
  13821. something went wrong with the latest generation. Reassuring, no? The
  13822. @command{guix system list-generations} command lists the system
  13823. generations available on disk. It is also possible to roll back the
  13824. system via the commands @command{guix system roll-back} and
  13825. @command{guix system switch-generation}.
  13826. Although the @command{guix system reconfigure} command will not modify
  13827. previous generations, you must take care when the current generation is not
  13828. the latest (e.g., after invoking @command{guix system roll-back}), since
  13829. the operation might overwrite a later generation (@pxref{Invoking guix
  13830. system}).
  13831. @unnumberedsubsec The Programming Interface
  13832. At the Scheme level, the bulk of an @code{operating-system} declaration
  13833. is instantiated with the following monadic procedure (@pxref{The Store
  13834. Monad}):
  13835. @deffn {Monadic Procedure} operating-system-derivation os
  13836. Return a derivation that builds @var{os}, an @code{operating-system}
  13837. object (@pxref{Derivations}).
  13838. The output of the derivation is a single directory that refers to all
  13839. the packages, configuration files, and other supporting files needed to
  13840. instantiate @var{os}.
  13841. @end deffn
  13842. This procedure is provided by the @code{(gnu system)} module. Along
  13843. with @code{(gnu services)} (@pxref{Services}), this module contains the
  13844. guts of Guix System. Make sure to visit it!
  13845. @node operating-system Reference
  13846. @section @code{operating-system} Reference
  13847. This section summarizes all the options available in
  13848. @code{operating-system} declarations (@pxref{Using the Configuration
  13849. System}).
  13850. @deftp {Data Type} operating-system
  13851. This is the data type representing an operating system configuration.
  13852. By that, we mean all the global system configuration, not per-user
  13853. configuration (@pxref{Using the Configuration System}).
  13854. @table @asis
  13855. @item @code{kernel} (default: @code{linux-libre})
  13856. The package object of the operating system kernel to
  13857. use@footnote{Currently only the Linux-libre kernel is fully supported.
  13858. Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
  13859. available when building a virtual machine disk image.}.
  13860. @cindex hurd
  13861. @item @code{hurd} (default: @code{#f})
  13862. The package object of the Hurd to be started by the kernel. When this
  13863. field is set, produce a GNU/Hurd operating system. In that case,
  13864. @code{kernel} must also be set to the @code{gnumach} package---the
  13865. microkernel the Hurd runs on.
  13866. @quotation Warning
  13867. This feature is experimental and only supported for disk images.
  13868. @end quotation
  13869. @item @code{kernel-loadable-modules} (default: '())
  13870. A list of objects (usually packages) to collect loadable kernel modules
  13871. from--e.g. @code{(list ddcci-driver-linux)}.
  13872. @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
  13873. List of strings or gexps representing additional arguments to pass on
  13874. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  13875. @item @code{bootloader}
  13876. The system bootloader configuration object. @xref{Bootloader Configuration}.
  13877. @item @code{label}
  13878. This is the label (a string) as it appears in the bootloader's menu entry.
  13879. The default label includes the kernel name and version.
  13880. @item @code{keyboard-layout} (default: @code{#f})
  13881. This field specifies the keyboard layout to use in the console. It can be
  13882. either @code{#f}, in which case the default keyboard layout is used (usually
  13883. US English), or a @code{<keyboard-layout>} record. @xref{Keyboard Layout},
  13884. for more information.
  13885. This keyboard layout is in effect as soon as the kernel has booted. For
  13886. instance, it is the keyboard layout in effect when you type a passphrase if
  13887. your root file system is on a @code{luks-device-mapping} mapped device
  13888. (@pxref{Mapped Devices}).
  13889. @quotation Note
  13890. This does @emph{not} specify the keyboard layout used by the bootloader, nor
  13891. that used by the graphical display server. @xref{Bootloader Configuration},
  13892. for information on how to specify the bootloader's keyboard layout. @xref{X
  13893. Window}, for information on how to specify the keyboard layout used by the X
  13894. Window System.
  13895. @end quotation
  13896. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  13897. @cindex initrd
  13898. @cindex initial RAM disk
  13899. The list of Linux kernel modules that need to be available in the
  13900. initial RAM disk. @xref{Initial RAM Disk}.
  13901. @item @code{initrd} (default: @code{base-initrd})
  13902. A procedure that returns an initial RAM disk for the Linux
  13903. kernel. This field is provided to support low-level customization and
  13904. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  13905. @item @code{firmware} (default: @code{%base-firmware})
  13906. @cindex firmware
  13907. List of firmware packages loadable by the operating system kernel.
  13908. The default includes firmware needed for Atheros- and Broadcom-based
  13909. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  13910. respectively). @xref{Hardware Considerations}, for more info on
  13911. supported hardware.
  13912. @item @code{host-name}
  13913. The host name.
  13914. @item @code{mapped-devices} (default: @code{'()})
  13915. A list of mapped devices. @xref{Mapped Devices}.
  13916. @item @code{file-systems}
  13917. A list of file systems. @xref{File Systems}.
  13918. @item @code{swap-devices} (default: @code{'()})
  13919. @cindex swap devices
  13920. A list of swap spaces. @xref{Swap Space}.
  13921. @item @code{users} (default: @code{%base-user-accounts})
  13922. @itemx @code{groups} (default: @code{%base-groups})
  13923. List of user accounts and groups. @xref{User Accounts}.
  13924. If the @code{users} list lacks a user account with UID@tie{}0, a
  13925. ``root'' account with UID@tie{}0 is automatically added.
  13926. @item @code{skeletons} (default: @code{(default-skeletons)})
  13927. A list of target file name/file-like object tuples (@pxref{G-Expressions,
  13928. file-like objects}). These are the skeleton files that will be added to
  13929. the home directory of newly-created user accounts.
  13930. For instance, a valid value may look like this:
  13931. @lisp
  13932. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  13933. (".guile" ,(plain-file "guile"
  13934. "(use-modules (ice-9 readline))
  13935. (activate-readline)")))
  13936. @end lisp
  13937. @item @code{issue} (default: @code{%default-issue})
  13938. A string denoting the contents of the @file{/etc/issue} file, which is
  13939. displayed when users log in on a text console.
  13940. @item @code{packages} (default: @code{%base-packages})
  13941. A list of packages to be installed in the global profile, which is accessible
  13942. at @file{/run/current-system/profile}. Each element is either a package
  13943. variable or a package/output tuple. Here's a simple example of both:
  13944. @lisp
  13945. (cons* git ; the default "out" output
  13946. (list git "send-email") ; another output of git
  13947. %base-packages) ; the default set
  13948. @end lisp
  13949. The default set includes core utilities and it is good practice to
  13950. install non-core utilities in user profiles (@pxref{Invoking guix
  13951. package}).
  13952. @item @code{timezone} (default: @code{"Etc/UTC"})
  13953. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  13954. You can run the @command{tzselect} command to find out which timezone
  13955. string corresponds to your region. Choosing an invalid timezone name
  13956. causes @command{guix system} to fail.
  13957. @item @code{locale} (default: @code{"en_US.utf8"})
  13958. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  13959. Library Reference Manual}). @xref{Locales}, for more information.
  13960. @item @code{locale-definitions} (default: @code{%default-locale-definitions})
  13961. The list of locale definitions to be compiled and that may be used at
  13962. run time. @xref{Locales}.
  13963. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  13964. The list of GNU@tie{}libc packages whose locale data and tools are used
  13965. to build the locale definitions. @xref{Locales}, for compatibility
  13966. considerations that justify this option.
  13967. @item @code{name-service-switch} (default: @code{%default-nss})
  13968. Configuration of the libc name service switch (NSS)---a
  13969. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  13970. details.
  13971. @item @code{services} (default: @code{%base-services})
  13972. A list of service objects denoting system services. @xref{Services}.
  13973. @anchor{operating-system-essential-services}
  13974. @cindex essential services
  13975. @item @code{essential-services} (default: ...)
  13976. The list of ``essential services''---i.e., things like instances of
  13977. @code{system-service-type} (@pxref{Service Reference}) and
  13978. @code{host-name-service-type}, which are derived from the operating
  13979. system definition itself. As a user you should @emph{never} need to
  13980. touch this field.
  13981. @item @code{pam-services} (default: @code{(base-pam-services)})
  13982. @cindex PAM
  13983. @cindex pluggable authentication modules
  13984. Linux @dfn{pluggable authentication module} (PAM) services.
  13985. @c FIXME: Add xref to PAM services section.
  13986. @item @code{setuid-programs} (default: @code{%setuid-programs})
  13987. List of @code{<setuid-program>}. @xref{Setuid Programs}, for more
  13988. information.
  13989. @item @code{sudoers-file} (default: @code{%sudoers-specification})
  13990. @cindex sudoers file
  13991. The contents of the @file{/etc/sudoers} file as a file-like object
  13992. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  13993. This file specifies which users can use the @command{sudo} command, what
  13994. they are allowed to do, and what privileges they may gain. The default
  13995. is that only @code{root} and members of the @code{wheel} group may use
  13996. @code{sudo}.
  13997. @end table
  13998. @defmac this-operating-system
  13999. When used in the @emph{lexical scope} of an operating system field definition,
  14000. this identifier resolves to the operating system being defined.
  14001. The example below shows how to refer to the operating system being defined in
  14002. the definition of the @code{label} field:
  14003. @lisp
  14004. (use-modules (gnu) (guix))
  14005. (operating-system
  14006. ;; ...
  14007. (label (package-full-name
  14008. (operating-system-kernel this-operating-system))))
  14009. @end lisp
  14010. It is an error to refer to @code{this-operating-system} outside an operating
  14011. system definition.
  14012. @end defmac
  14013. @end deftp
  14014. @node File Systems
  14015. @section File Systems
  14016. The list of file systems to be mounted is specified in the
  14017. @code{file-systems} field of the operating system declaration
  14018. (@pxref{Using the Configuration System}). Each file system is declared
  14019. using the @code{file-system} form, like this:
  14020. @lisp
  14021. (file-system
  14022. (mount-point "/home")
  14023. (device "/dev/sda3")
  14024. (type "ext4"))
  14025. @end lisp
  14026. As usual, some of the fields are mandatory---those shown in the example
  14027. above---while others can be omitted. These are described below.
  14028. @deftp {Data Type} file-system
  14029. Objects of this type represent file systems to be mounted. They
  14030. contain the following members:
  14031. @table @asis
  14032. @item @code{type}
  14033. This is a string specifying the type of the file system---e.g.,
  14034. @code{"ext4"}.
  14035. @item @code{mount-point}
  14036. This designates the place where the file system is to be mounted.
  14037. @item @code{device}
  14038. This names the ``source'' of the file system. It can be one of three
  14039. things: a file system label, a file system UUID, or the name of a
  14040. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  14041. systems without having to hard-code their actual device
  14042. name@footnote{Note that, while it is tempting to use
  14043. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  14044. result, this is not recommended: These special device nodes are created
  14045. by the udev daemon and may be unavailable at the time the device is
  14046. mounted.}.
  14047. @findex file-system-label
  14048. File system labels are created using the @code{file-system-label}
  14049. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  14050. plain strings. Here's an example of a file system referred to by its
  14051. label, as shown by the @command{e2label} command:
  14052. @lisp
  14053. (file-system
  14054. (mount-point "/home")
  14055. (type "ext4")
  14056. (device (file-system-label "my-home")))
  14057. @end lisp
  14058. @findex uuid
  14059. UUIDs are converted from their string representation (as shown by the
  14060. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  14061. @code{uuid} form expects 16-byte UUIDs as defined in
  14062. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  14063. form of UUID used by the ext2 family of file systems and others, but it
  14064. is different from ``UUIDs'' found in FAT file systems, for instance.},
  14065. like this:
  14066. @lisp
  14067. (file-system
  14068. (mount-point "/home")
  14069. (type "ext4")
  14070. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  14071. @end lisp
  14072. When the source of a file system is a mapped device (@pxref{Mapped
  14073. Devices}), its @code{device} field @emph{must} refer to the mapped
  14074. device name---e.g., @file{"/dev/mapper/root-partition"}.
  14075. This is required so that
  14076. the system knows that mounting the file system depends on having the
  14077. corresponding device mapping established.
  14078. @item @code{flags} (default: @code{'()})
  14079. This is a list of symbols denoting mount flags. Recognized flags
  14080. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  14081. access to special files), @code{no-suid} (ignore setuid and setgid
  14082. bits), @code{no-atime} (do not update file access times),
  14083. @code{no-diratime} (likewise for directories only),
  14084. @code{strict-atime} (update file access time), @code{lazy-time} (only
  14085. update time on the in-memory version of the file inode),
  14086. @code{no-exec} (disallow program execution), and @code{shared} (make the
  14087. mount shared).
  14088. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
  14089. Manual}, for more information on these flags.
  14090. @item @code{options} (default: @code{#f})
  14091. This is either @code{#f}, or a string denoting mount options passed to
  14092. the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
  14093. Library Reference Manual}, for details.
  14094. Run @command{man 8 mount} for options for various file systems, but
  14095. beware that what it lists as file-system-independent ``mount options'' are
  14096. in fact flags, and belong in the @code{flags} field described above.
  14097. The @code{file-system-options->alist} and @code{alist->file-system-options}
  14098. procedures from @code{(gnu system file-systems)} can be used to convert
  14099. file system options given as an association list to the string
  14100. representation, and vice-versa.
  14101. @item @code{mount?} (default: @code{#t})
  14102. This value indicates whether to automatically mount the file system when
  14103. the system is brought up. When set to @code{#f}, the file system gets
  14104. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  14105. is not automatically mounted.
  14106. @item @code{needed-for-boot?} (default: @code{#f})
  14107. This Boolean value indicates whether the file system is needed when
  14108. booting. If that is true, then the file system is mounted when the
  14109. initial RAM disk (initrd) is loaded. This is always the case, for
  14110. instance, for the root file system.
  14111. @item @code{check?} (default: @code{#t})
  14112. This Boolean indicates whether the file system should be checked for
  14113. errors before being mounted. How and when this happens can be further
  14114. adjusted with the following options.
  14115. @item @code{skip-check-if-clean?} (default: @code{#t})
  14116. When true, this Boolean indicates that a file system check triggered
  14117. by @code{check?} may exit early if the file system is marked as
  14118. ``clean'', meaning that it was previously correctly unmounted and
  14119. should not contain errors.
  14120. Setting this to false will always force a full consistency check when
  14121. @code{check?} is true. This may take a very long time and is not
  14122. recommended on healthy systems---in fact, it may reduce reliability!
  14123. Conversely, some primitive file systems like @code{fat} do not keep
  14124. track of clean shutdowns and will perform a full scan regardless of the
  14125. value of this option.
  14126. @item @code{repair} (default: @code{'preen})
  14127. When @code{check?} finds errors, it can (try to) repair them and
  14128. continue booting. This option controls when and how to do so.
  14129. If false, try not to modify the file system at all. Checking certain
  14130. file systems like @code{jfs} may still write to the device to replay
  14131. the journal. No repairs will be attempted.
  14132. If @code{#t}, try to repair any errors found and assume ``yes'' to
  14133. all questions. This will fix the most errors, but may be risky.
  14134. If @code{'preen}, repair only errors that are safe to fix without
  14135. human interaction. What that means is left up to the developers of
  14136. each file system and may be equivalent to ``none'' or ``all''.
  14137. @item @code{create-mount-point?} (default: @code{#f})
  14138. When true, the mount point is created if it does not exist yet.
  14139. @item @code{mount-may-fail?} (default: @code{#f})
  14140. When true, this indicates that mounting this file system can fail but
  14141. that should not be considered an error. This is useful in unusual
  14142. cases; an example of this is @code{efivarfs}, a file system that can
  14143. only be mounted on EFI/UEFI systems.
  14144. @item @code{dependencies} (default: @code{'()})
  14145. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  14146. representing file systems that must be mounted or mapped devices that
  14147. must be opened before (and unmounted or closed after) this one.
  14148. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  14149. a dependency of @file{/sys/fs/cgroup/cpu} and
  14150. @file{/sys/fs/cgroup/memory}.
  14151. Another example is a file system that depends on a mapped device, for
  14152. example for an encrypted partition (@pxref{Mapped Devices}).
  14153. @end table
  14154. @end deftp
  14155. @deffn {Procedure} file-system-label str
  14156. This procedure returns an opaque file system label from @var{str}, a
  14157. string:
  14158. @lisp
  14159. (file-system-label "home")
  14160. @result{} #<file-system-label "home">
  14161. @end lisp
  14162. File system labels are used to refer to file systems by label rather
  14163. than by device name. See above for examples.
  14164. @end deffn
  14165. The @code{(gnu system file-systems)} exports the following useful
  14166. variables.
  14167. @defvar %base-file-systems
  14168. These are essential file systems that are required on normal systems,
  14169. such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
  14170. below). Operating system declarations should always contain at least
  14171. these.
  14172. @end defvar
  14173. @defvar %pseudo-terminal-file-system
  14174. This is the file system to be mounted as @file{/dev/pts}. It supports
  14175. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  14176. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  14177. Manual}). Pseudo-terminals are used by terminal emulators such as
  14178. @command{xterm}.
  14179. @end defvar
  14180. @defvar %shared-memory-file-system
  14181. This file system is mounted as @file{/dev/shm} and is used to support
  14182. memory sharing across processes (@pxref{Memory-mapped I/O,
  14183. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  14184. @end defvar
  14185. @defvar %immutable-store
  14186. This file system performs a read-only ``bind mount'' of
  14187. @file{/gnu/store}, making it read-only for all the users including
  14188. @code{root}. This prevents against accidental modification by software
  14189. running as @code{root} or by system administrators.
  14190. The daemon itself is still able to write to the store: it remounts it
  14191. read-write in its own ``name space.''
  14192. @end defvar
  14193. @defvar %binary-format-file-system
  14194. The @code{binfmt_misc} file system, which allows handling of arbitrary
  14195. executable file types to be delegated to user space. This requires the
  14196. @code{binfmt.ko} kernel module to be loaded.
  14197. @end defvar
  14198. @defvar %fuse-control-file-system
  14199. The @code{fusectl} file system, which allows unprivileged users to mount
  14200. and unmount user-space FUSE file systems. This requires the
  14201. @code{fuse.ko} kernel module to be loaded.
  14202. @end defvar
  14203. The @code{(gnu system uuid)} module provides tools to deal with file
  14204. system ``unique identifiers'' (UUIDs).
  14205. @deffn {Procedure} uuid str [type]
  14206. Return an opaque UUID (unique identifier) object of the given @var{type}
  14207. (a symbol) by parsing @var{str} (a string):
  14208. @lisp
  14209. (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
  14210. @result{} #<<uuid> type: dce bv: @dots{}>
  14211. (uuid "1234-ABCD" 'fat)
  14212. @result{} #<<uuid> type: fat bv: @dots{}>
  14213. @end lisp
  14214. @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
  14215. @code{ntfs}, or one of the commonly found synonyms for these.
  14216. UUIDs are another way to unambiguously refer to file systems in
  14217. operating system configuration. See the examples above.
  14218. @end deffn
  14219. @menu
  14220. * Btrfs file system::
  14221. @end menu
  14222. @node Btrfs file system
  14223. @subsection Btrfs file system
  14224. The Btrfs has special features, such as subvolumes, that merit being
  14225. explained in more details. The following section attempts to cover
  14226. basic as well as complex uses of a Btrfs file system with the Guix
  14227. System.
  14228. In its simplest usage, a Btrfs file system can be described, for
  14229. example, by:
  14230. @lisp
  14231. (file-system
  14232. (mount-point "/home")
  14233. (type "btrfs")
  14234. (device (file-system-label "my-home")))
  14235. @end lisp
  14236. The example below is more complex, as it makes use of a Btrfs
  14237. subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
  14238. @code{my-btrfs-pool}, and is located on an encrypted device (hence the
  14239. dependency on @code{mapped-devices}):
  14240. @lisp
  14241. (file-system
  14242. (device (file-system-label "my-btrfs-pool"))
  14243. (mount-point "/")
  14244. (type "btrfs")
  14245. (options "subvol=rootfs")
  14246. (dependencies mapped-devices))
  14247. @end lisp
  14248. Some bootloaders, for example GRUB, only mount a Btrfs partition at its
  14249. top level during the early boot, and rely on their configuration to
  14250. refer to the correct subvolume path within that top level. The
  14251. bootloaders operating in this way typically produce their configuration
  14252. on a running system where the Btrfs partitions are already mounted and
  14253. where the subvolume information is readily available. As an example,
  14254. @command{grub-mkconfig}, the configuration generator command shipped
  14255. with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
  14256. path of a subvolume.
  14257. The Guix System produces a bootloader configuration using the operating
  14258. system configuration as its sole input; it is therefore necessary to
  14259. extract the subvolume name on which @file{/gnu/store} lives (if any)
  14260. from that operating system configuration. To better illustrate,
  14261. consider a subvolume named 'rootfs' which contains the root file system
  14262. data. In such situation, the GRUB bootloader would only see the top
  14263. level of the root Btrfs partition, e.g.:
  14264. @example
  14265. / (top level)
  14266. ├── rootfs (subvolume directory)
  14267. ├── gnu (normal directory)
  14268. ├── store (normal directory)
  14269. [...]
  14270. @end example
  14271. Thus, the subvolume name must be prepended to the @file{/gnu/store} path
  14272. of the kernel, initrd binaries and any other files referred to in the
  14273. GRUB configuration that must be found during the early boot.
  14274. The next example shows a nested hierarchy of subvolumes and
  14275. directories:
  14276. @example
  14277. / (top level)
  14278. ├── rootfs (subvolume)
  14279. ├── gnu (normal directory)
  14280. ├── store (subvolume)
  14281. [...]
  14282. @end example
  14283. This scenario would work without mounting the 'store' subvolume.
  14284. Mounting 'rootfs' is sufficient, since the subvolume name matches its
  14285. intended mount point in the file system hierarchy. Alternatively, the
  14286. 'store' subvolume could be referred to by setting the @code{subvol}
  14287. option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
  14288. Finally, a more contrived example of nested subvolumes:
  14289. @example
  14290. / (top level)
  14291. ├── root-snapshots (subvolume)
  14292. ├── root-current (subvolume)
  14293. ├── guix-store (subvolume)
  14294. [...]
  14295. @end example
  14296. Here, the 'guix-store' subvolume doesn't match its intended mount point,
  14297. so it is necessary to mount it. The subvolume must be fully specified,
  14298. by passing its file name to the @code{subvol} option. To illustrate,
  14299. the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
  14300. a file system declaration such as:
  14301. @lisp
  14302. (file-system
  14303. (device (file-system-label "btrfs-pool-1"))
  14304. (mount-point "/gnu/store")
  14305. (type "btrfs")
  14306. (options "subvol=root-snapshots/root-current/guix-store,\
  14307. compress-force=zstd,space_cache=v2"))
  14308. @end lisp
  14309. @node Mapped Devices
  14310. @section Mapped Devices
  14311. @cindex device mapping
  14312. @cindex mapped devices
  14313. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  14314. such as a hard disk partition, can be @dfn{mapped} into another device,
  14315. usually in @code{/dev/mapper/},
  14316. with additional processing over the data that flows through
  14317. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  14318. concept of a ``mapped device'' and that of a file system: both boil down
  14319. to @emph{translating} input/output operations made on a file to
  14320. operations on its backing store. Thus, the Hurd implements mapped
  14321. devices, like file systems, using the generic @dfn{translator} mechanism
  14322. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  14323. typical example is encryption device mapping: all writes to the mapped
  14324. device are encrypted, and all reads are deciphered, transparently.
  14325. Guix extends this notion by considering any device or set of devices that
  14326. are @dfn{transformed} in some way to create a new device; for instance,
  14327. RAID devices are obtained by @dfn{assembling} several other devices, such
  14328. as hard disks or partitions, into a new one that behaves as one partition.
  14329. Mapped devices are declared using the @code{mapped-device} form,
  14330. defined as follows; for examples, see below.
  14331. @deftp {Data Type} mapped-device
  14332. Objects of this type represent device mappings that will be made when
  14333. the system boots up.
  14334. @table @code
  14335. @item source
  14336. This is either a string specifying the name of the block device to be mapped,
  14337. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  14338. need to be assembled for creating a new one. In case of LVM this is a
  14339. string specifying name of the volume group to be mapped.
  14340. @item target
  14341. This string specifies the name of the resulting mapped device. For
  14342. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  14343. specifying @code{"my-partition"} leads to the creation of
  14344. the @code{"/dev/mapper/my-partition"} device.
  14345. For RAID devices of type @code{raid-device-mapping}, the full device name
  14346. such as @code{"/dev/md0"} needs to be given.
  14347. LVM logical volumes of type @code{lvm-device-mapping} need to
  14348. be specified as @code{"VGNAME-LVNAME"}.
  14349. @item targets
  14350. This list of strings specifies names of the resulting mapped devices in case
  14351. there are several. The format is identical to @var{target}.
  14352. @item type
  14353. This must be a @code{mapped-device-kind} object, which specifies how
  14354. @var{source} is mapped to @var{target}.
  14355. @end table
  14356. @end deftp
  14357. @defvar luks-device-mapping
  14358. This defines LUKS block device encryption using the @command{cryptsetup}
  14359. command from the package with the same name. It relies on the
  14360. @code{dm-crypt} Linux kernel module.
  14361. @end defvar
  14362. @defvar raid-device-mapping
  14363. This defines a RAID device, which is assembled using the @code{mdadm}
  14364. command from the package with the same name. It requires a Linux kernel
  14365. module for the appropriate RAID level to be loaded, such as @code{raid456}
  14366. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  14367. @end defvar
  14368. @cindex LVM, logical volume manager
  14369. @defvar lvm-device-mapping
  14370. This defines one or more logical volumes for the Linux
  14371. @uref{https://www.sourceware.org/lvm2/, Logical Volume Manager (LVM)}.
  14372. The volume group is activated by the @command{vgchange} command from the
  14373. @code{lvm2} package.
  14374. @end defvar
  14375. @cindex disk encryption
  14376. @cindex LUKS
  14377. The following example specifies a mapping from @file{/dev/sda3} to
  14378. @file{/dev/mapper/home} using LUKS---the
  14379. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  14380. standard mechanism for disk encryption.
  14381. The @file{/dev/mapper/home}
  14382. device can then be used as the @code{device} of a @code{file-system}
  14383. declaration (@pxref{File Systems}).
  14384. @lisp
  14385. (mapped-device
  14386. (source "/dev/sda3")
  14387. (target "home")
  14388. (type luks-device-mapping))
  14389. @end lisp
  14390. Alternatively, to become independent of device numbering, one may obtain
  14391. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  14392. command like:
  14393. @example
  14394. cryptsetup luksUUID /dev/sda3
  14395. @end example
  14396. and use it as follows:
  14397. @lisp
  14398. (mapped-device
  14399. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  14400. (target "home")
  14401. (type luks-device-mapping))
  14402. @end lisp
  14403. @cindex swap encryption
  14404. It is also desirable to encrypt swap space, since swap space may contain
  14405. sensitive data. One way to accomplish that is to use a swap file in a
  14406. file system on a device mapped via LUKS encryption. In this way, the
  14407. swap file is encrypted because the entire device is encrypted.
  14408. @xref{Swap Space}, or @xref{Preparing for Installation,,Disk
  14409. Partitioning}, for an example.
  14410. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  14411. may be declared as follows:
  14412. @lisp
  14413. (mapped-device
  14414. (source (list "/dev/sda1" "/dev/sdb1"))
  14415. (target "/dev/md0")
  14416. (type raid-device-mapping))
  14417. @end lisp
  14418. The @file{/dev/md0} device can then be used as the @code{device} of a
  14419. @code{file-system} declaration (@pxref{File Systems}).
  14420. Note that the RAID level need not be given; it is chosen during the
  14421. initial creation and formatting of the RAID device and is determined
  14422. automatically later.
  14423. LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
  14424. be declared as follows:
  14425. @lisp
  14426. (mapped-device
  14427. (source "vg0")
  14428. (targets (list "vg0-alpha" "vg0-beta"))
  14429. (type lvm-device-mapping))
  14430. @end lisp
  14431. Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
  14432. then be used as the @code{device} of a @code{file-system} declaration
  14433. (@pxref{File Systems}).
  14434. @node Swap Space
  14435. @section Swap Space
  14436. @cindex swap space
  14437. Swap space, as it is commonly called, is a disk area specifically
  14438. designated for paging: the process in charge of memory management
  14439. (the Linux kernel or Hurd's default pager) can decide that some memory
  14440. pages stored in RAM which belong to a running program but are unused
  14441. should be stored on disk instead. It unloads those from the RAM,
  14442. freeing up precious fast memory, and writes them to the swap space. If
  14443. the program tries to access that very page, the memory management
  14444. process loads it back into memory for the program to use.
  14445. A common misconception about swap is that it is only useful when small
  14446. amounts of RAM are available to the system. However, it should be noted
  14447. that kernels often use all available RAM for disk access caching to make
  14448. I/O faster, and thus paging out unused portions of program memory will
  14449. expand the RAM available for such caching.
  14450. For a more detailed description of how memory is managed from the
  14451. viewpoint of a monolithic kernel, @pxref{Memory
  14452. Concepts,,, libc, The GNU C Library Reference Manual}.
  14453. The Linux kernel has support for swap partitions and swap files: the
  14454. former uses a whole disk partition for paging, whereas the second uses a
  14455. file on a file system for that (the file system driver needs to support
  14456. it). On a comparable setup, both have the same performance, so one
  14457. should consider ease of use when deciding between them. Partitions are
  14458. ``simpler'' and do not need file system support, but need to be
  14459. allocated at disk formatting time (logical volumes notwithstanding),
  14460. whereas files can be allocated and deallocated at any time.
  14461. @cindex hibernation
  14462. @cindex suspend to disk
  14463. Swap space is also required to put the system into @dfn{hibernation}
  14464. (also called @dfn{suspend to disk}), whereby memory is dumped to swap
  14465. before shutdown so it can be restored when the machine is eventually
  14466. restarted. Hibernation uses at most half the size of the RAM in the
  14467. configured swap space. The Linux kernel needs to know about the swap
  14468. space to be used to resume from hibernation on boot (@i{via} a kernel
  14469. argument). When using a swap file, its offset in the device holding it
  14470. also needs to be given to the kernel; that value has to be updated if
  14471. the file is initialized again as swap---e.g., because its size was
  14472. changed.
  14473. Note that swap space is not zeroed on shutdown, so sensitive data (such
  14474. as passwords) may linger on it if it was paged out. As such, you should
  14475. consider having your swap reside on an encrypted device (@pxref{Mapped
  14476. Devices}).
  14477. @deftp {Data Type} swap-space
  14478. Objects of this type represent swap spaces. They contain the following
  14479. members:
  14480. @table @asis
  14481. @item @code{target}
  14482. The device or file to use, either a UUID, a @code{file-system-label} or
  14483. a string, as in the definition of a @code{file-system} (@pxref{File
  14484. Systems}).
  14485. @item @code{dependencies} (default: @code{'()})
  14486. A list of @code{file-system} or @code{mapped-device} objects, upon which
  14487. the availability of the space depends. Note that just like for
  14488. @code{file-system} objects, dependencies which are needed for boot and
  14489. mounted in early userspace are not managed by the Shepherd, and so
  14490. automatically filtered out for you.
  14491. @item @code{priority} (default: @code{#f})
  14492. Only supported by the Linux kernel. Either @code{#f} to disable swap
  14493. priority, or an integer between 0 and 32767. The kernel will first use
  14494. swap spaces of higher priority when paging, and use same priority spaces
  14495. on a round-robin basis. The kernel will use swap spaces without a set
  14496. priority after prioritized spaces, and in the order that they appeared in
  14497. (not round-robin).
  14498. @item @code{discard?} (default: @code{#f})
  14499. Only supported by the Linux kernel. When true, the kernel will notify
  14500. the disk controller of discarded pages, for example with the TRIM
  14501. operation on Solid State Drives.
  14502. @end table
  14503. @end deftp
  14504. Here are some examples:
  14505. @lisp
  14506. (swap-space (target (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  14507. @end lisp
  14508. Use the swap partition with the given UUID@. You can learn the UUID of a
  14509. Linux swap partition by running @command{swaplabel @var{device}}, where
  14510. @var{device} is the @file{/dev} file name of that partition.
  14511. @lisp
  14512. (swap-space
  14513. (target (file-system-label "swap"))
  14514. (dependencies mapped-devices))
  14515. @end lisp
  14516. Use the partition with label @code{swap}, which can be found after all
  14517. the @var{mapped-devices} mapped devices have been opened. Again, the
  14518. @command{swaplabel} command allows you to view and change the label of a
  14519. Linux swap partition.
  14520. Here's a more involved example with the corresponding @code{file-systems} part
  14521. of an @code{operating-system} declaration.
  14522. @lisp
  14523. (file-systems
  14524. (list (file-system
  14525. (device (file-system-label "root"))
  14526. (mount-point "/")
  14527. (type "ext4"))
  14528. (file-system
  14529. (device (file-system-label "btrfs"))
  14530. (mount-point "/btrfs")
  14531. (type "btrfs"))))
  14532. (swap-devices
  14533. (list
  14534. (swap-space
  14535. (target "/btrfs/swapfile")
  14536. (dependencies (filter (file-system-mount-point-predicate "/btrfs")
  14537. file-systems)))))
  14538. @end lisp
  14539. Use the file @file{/btrfs/swapfile} as swap space, which depends on the
  14540. file system mounted at @file{/btrfs}. Note how we use Guile's filter to
  14541. select the file system in an elegant fashion!
  14542. @lisp
  14543. (swap-devices
  14544. (list
  14545. (swap-space
  14546. (target "/dev/mapper/my-swap")
  14547. (dependencies mapped-devices))))
  14548. (kernel-arguments
  14549. (cons* "resume=/dev/mapper/my-swap"
  14550. %default-kernel-arguments))
  14551. @end lisp
  14552. The above snippet of an @code{operating-system} declaration enables
  14553. the mapped device @file{/dev/mapper/my-swap} (which may be part of an
  14554. encrypted device) as swap space, and tells the kernel to use it for
  14555. hibernation via the @code{resume} kernel argument
  14556. (@pxref{operating-system Reference}, @code{kernel-arguments}).
  14557. @lisp
  14558. (swap-devices
  14559. (list
  14560. (swap-space
  14561. (target "/swapfile")
  14562. (dependencies (filter (file-system-mount-point-predicate "/")
  14563. file-systems)))))
  14564. (kernel-arguments
  14565. (cons* "resume=/dev/sda3" ;device that holds /swapfile
  14566. "resume_offset=92514304" ;offset of /swapfile on device
  14567. %default-kernel-arguments))
  14568. @end lisp
  14569. This other snippet of @code{operating-system} enables the swap file
  14570. @file{/swapfile} for hibernation by telling the kernel about the
  14571. partition containing it
  14572. (@code{resume} argument) and its offset on that partition (@code{resume_offset}
  14573. argument). The latter value can be found in the output of the command
  14574. @command{filefrag -e} as the first number right under the
  14575. @code{physical_offset} column header (the second command extracts its
  14576. value directly):
  14577. @smallexample
  14578. $ sudo filefrag -e /swapfile
  14579. Filesystem type is: ef53
  14580. File size of /swapfile is 2463842304 (601524 blocks of 4096 bytes)
  14581. ext: logical_offset: physical_offset: length: expected: flags:
  14582. 0: 0.. 2047: 92514304.. 92516351: 2048:
  14583. @dots{}
  14584. $ sudo filefrag -e /swapfile | grep '^ *0:' | cut -d: -f3 | cut -d. -f1
  14585. 92514304
  14586. @end smallexample
  14587. @node User Accounts
  14588. @section User Accounts
  14589. @cindex users
  14590. @cindex accounts
  14591. @cindex user accounts
  14592. User accounts and groups are entirely managed through the
  14593. @code{operating-system} declaration. They are specified with the
  14594. @code{user-account} and @code{user-group} forms:
  14595. @lisp
  14596. (user-account
  14597. (name "alice")
  14598. (group "users")
  14599. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  14600. "audio" ;sound card
  14601. "video" ;video devices such as webcams
  14602. "cdrom")) ;the good ol' CD-ROM
  14603. (comment "Bob's sister"))
  14604. @end lisp
  14605. Here's a user account that uses a different shell and a custom home
  14606. directory (the default would be @file{"/home/bob"}):
  14607. @lisp
  14608. (user-account
  14609. (name "bob")
  14610. (group "users")
  14611. (comment "Alice's bro")
  14612. (shell (file-append zsh "/bin/zsh"))
  14613. (home-directory "/home/robert"))
  14614. @end lisp
  14615. When booting or upon completion of @command{guix system reconfigure},
  14616. the system ensures that only the user accounts and groups specified in
  14617. the @code{operating-system} declaration exist, and with the specified
  14618. properties. Thus, account or group creations or modifications made by
  14619. directly invoking commands such as @command{useradd} are lost upon
  14620. reconfiguration or reboot. This ensures that the system remains exactly
  14621. as declared.
  14622. @deftp {Data Type} user-account
  14623. Objects of this type represent user accounts. The following members may
  14624. be specified:
  14625. @table @asis
  14626. @item @code{name}
  14627. The name of the user account.
  14628. @item @code{group}
  14629. @cindex groups
  14630. This is the name (a string) or identifier (a number) of the user group
  14631. this account belongs to.
  14632. @item @code{supplementary-groups} (default: @code{'()})
  14633. Optionally, this can be defined as a list of group names that this
  14634. account belongs to.
  14635. @item @code{uid} (default: @code{#f})
  14636. This is the user ID for this account (a number), or @code{#f}. In the
  14637. latter case, a number is automatically chosen by the system when the
  14638. account is created.
  14639. @item @code{comment} (default: @code{""})
  14640. A comment about the account, such as the account owner's full name.
  14641. Note that, for non-system accounts, users are free to change their real
  14642. name as it appears in @file{/etc/passwd} using the @command{chfn}
  14643. command. When they do, their choice prevails over the system
  14644. administrator's choice; reconfiguring does @emph{not} change their name.
  14645. @item @code{home-directory}
  14646. This is the name of the home directory for the account.
  14647. @item @code{create-home-directory?} (default: @code{#t})
  14648. Indicates whether the home directory of this account should be created
  14649. if it does not exist yet.
  14650. @item @code{shell} (default: Bash)
  14651. This is a G-expression denoting the file name of a program to be used as
  14652. the shell (@pxref{G-Expressions}). For example, you would refer to the
  14653. Bash executable like this:
  14654. @lisp
  14655. (file-append bash "/bin/bash")
  14656. @end lisp
  14657. @noindent
  14658. ... and to the Zsh executable like that:
  14659. @lisp
  14660. (file-append zsh "/bin/zsh")
  14661. @end lisp
  14662. @item @code{system?} (default: @code{#f})
  14663. This Boolean value indicates whether the account is a ``system''
  14664. account. System accounts are sometimes treated specially; for instance,
  14665. graphical login managers do not list them.
  14666. @anchor{user-account-password}
  14667. @cindex password, for user accounts
  14668. @item @code{password} (default: @code{#f})
  14669. You would normally leave this field to @code{#f}, initialize user
  14670. passwords as @code{root} with the @command{passwd} command, and then let
  14671. users change it with @command{passwd}. Passwords set with
  14672. @command{passwd} are of course preserved across reboot and
  14673. reconfiguration.
  14674. If you @emph{do} want to set an initial password for an account, then
  14675. this field must contain the encrypted password, as a string. You can use the
  14676. @code{crypt} procedure for this purpose:
  14677. @lisp
  14678. (user-account
  14679. (name "charlie")
  14680. (group "users")
  14681. ;; Specify a SHA-512-hashed initial password.
  14682. (password (crypt "InitialPassword!" "$6$abc")))
  14683. @end lisp
  14684. @quotation Note
  14685. The hash of this initial password will be available in a file in
  14686. @file{/gnu/store}, readable by all the users, so this method must be used with
  14687. care.
  14688. @end quotation
  14689. @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
  14690. more information on password encryption, and @ref{Encryption,,, guile, GNU
  14691. Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
  14692. @end table
  14693. @end deftp
  14694. @cindex groups
  14695. User group declarations are even simpler:
  14696. @lisp
  14697. (user-group (name "students"))
  14698. @end lisp
  14699. @deftp {Data Type} user-group
  14700. This type is for, well, user groups. There are just a few fields:
  14701. @table @asis
  14702. @item @code{name}
  14703. The name of the group.
  14704. @item @code{id} (default: @code{#f})
  14705. The group identifier (a number). If @code{#f}, a new number is
  14706. automatically allocated when the group is created.
  14707. @item @code{system?} (default: @code{#f})
  14708. This Boolean value indicates whether the group is a ``system'' group.
  14709. System groups have low numerical IDs.
  14710. @item @code{password} (default: @code{#f})
  14711. What, user groups can have a password? Well, apparently yes. Unless
  14712. @code{#f}, this field specifies the password of the group.
  14713. @end table
  14714. @end deftp
  14715. For convenience, a variable lists all the basic user groups one may
  14716. expect:
  14717. @defvar %base-groups
  14718. This is the list of basic user groups that users and/or packages expect
  14719. to be present on the system. This includes groups such as ``root'',
  14720. ``wheel'', and ``users'', as well as groups used to control access to
  14721. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  14722. @end defvar
  14723. @defvar %base-user-accounts
  14724. This is the list of basic system accounts that programs may expect to
  14725. find on a GNU/Linux system, such as the ``nobody'' account.
  14726. Note that the ``root'' account is not included here. It is a
  14727. special-case and is automatically added whether or not it is specified.
  14728. @end defvar
  14729. @node Keyboard Layout
  14730. @section Keyboard Layout
  14731. @cindex keyboard layout
  14732. @cindex keymap
  14733. To specify what each key of your keyboard does, you need to tell the operating
  14734. system what @dfn{keyboard layout} you want to use. The default, when nothing
  14735. is specified, is the US English QWERTY layout for 105-key PC keyboards.
  14736. However, German speakers will usually prefer the German QWERTZ layout, French
  14737. speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
  14738. or bépo, and they might even want to further customize the effect of some of
  14739. the keys. This section explains how to get that done.
  14740. @cindex keyboard layout, definition
  14741. There are three components that will want to know about your keyboard layout:
  14742. @itemize
  14743. @item
  14744. The @emph{bootloader} may want to know what keyboard layout you want to use
  14745. (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
  14746. you want, for instance, to make sure that you can type the passphrase of your
  14747. encrypted root partition using the right layout.
  14748. @item
  14749. The @emph{operating system kernel}, Linux, will need that so that the console
  14750. is properly configured (@pxref{operating-system Reference,
  14751. @code{keyboard-layout}}).
  14752. @item
  14753. The @emph{graphical display server}, usually Xorg, also has its own idea of
  14754. the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
  14755. @end itemize
  14756. Guix allows you to configure all three separately but, fortunately, it allows
  14757. you to share the same keyboard layout for all three components.
  14758. @cindex XKB, keyboard layouts
  14759. Keyboard layouts are represented by records created by the
  14760. @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
  14761. the X Keyboard extension (XKB), each layout has four attributes: a name (often
  14762. a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
  14763. optional variant name, an optional keyboard model name, and a possibly empty
  14764. list of additional options. In most cases the layout name is all you care
  14765. about.
  14766. @deffn {Procedure} keyboard-layout name [variant] [#:model] [#:options '()]
  14767. Return a new keyboard layout with the given @var{name} and @var{variant}.
  14768. @var{name} must be a string such as @code{"fr"}; @var{variant} must be a
  14769. string such as @code{"bepo"} or @code{"nodeadkeys"}. See the
  14770. @code{xkeyboard-config} package for valid options.
  14771. @end deffn
  14772. Here are a few examples:
  14773. @lisp
  14774. ;; The German QWERTZ layout. Here we assume a standard
  14775. ;; "pc105" keyboard model.
  14776. (keyboard-layout "de")
  14777. ;; The bépo variant of the French layout.
  14778. (keyboard-layout "fr" "bepo")
  14779. ;; The Catalan layout.
  14780. (keyboard-layout "es" "cat")
  14781. ;; Arabic layout with "Alt-Shift" to switch to US layout.
  14782. (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
  14783. ;; The Latin American Spanish layout. In addition, the
  14784. ;; "Caps Lock" key is used as an additional "Ctrl" key,
  14785. ;; and the "Menu" key is used as a "Compose" key to enter
  14786. ;; accented letters.
  14787. (keyboard-layout "latam"
  14788. #:options '("ctrl:nocaps" "compose:menu"))
  14789. ;; The Russian layout for a ThinkPad keyboard.
  14790. (keyboard-layout "ru" #:model "thinkpad")
  14791. ;; The "US international" layout, which is the US layout plus
  14792. ;; dead keys to enter accented characters. This is for an
  14793. ;; Apple MacBook keyboard.
  14794. (keyboard-layout "us" "intl" #:model "macbook78")
  14795. @end lisp
  14796. See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
  14797. for a complete list of supported layouts, variants, and models.
  14798. @cindex keyboard layout, configuration
  14799. Let's say you want your system to use the Turkish keyboard layout throughout
  14800. your system---bootloader, console, and Xorg. Here's what your system
  14801. configuration would look like:
  14802. @findex set-xorg-configuration
  14803. @lisp
  14804. ;; Using the Turkish layout for the bootloader, the console,
  14805. ;; and for Xorg.
  14806. (operating-system
  14807. ;; ...
  14808. (keyboard-layout (keyboard-layout "tr")) ;for the console
  14809. (bootloader (bootloader-configuration
  14810. (bootloader grub-efi-bootloader)
  14811. (targets '("/boot/efi"))
  14812. (keyboard-layout keyboard-layout))) ;for GRUB
  14813. (services (cons (set-xorg-configuration
  14814. (xorg-configuration ;for Xorg
  14815. (keyboard-layout keyboard-layout)))
  14816. %desktop-services)))
  14817. @end lisp
  14818. In the example above, for GRUB and for Xorg, we just refer to the
  14819. @code{keyboard-layout} field defined above, but we could just as well refer to
  14820. a different layout. The @code{set-xorg-configuration} procedure communicates
  14821. the desired Xorg configuration to the graphical log-in manager, by default
  14822. GDM.
  14823. We've discussed how to specify the @emph{default} keyboard layout of your
  14824. system when it starts, but you can also adjust it at run time:
  14825. @itemize
  14826. @item
  14827. If you're using GNOME, its settings panel has a ``Region & Language'' entry
  14828. where you can select one or more keyboard layouts.
  14829. @item
  14830. Under Xorg, the @command{setxkbmap} command (from the same-named package)
  14831. allows you to change the current layout. For example, this is how you would
  14832. change the layout to US Dvorak:
  14833. @example
  14834. setxkbmap us dvorak
  14835. @end example
  14836. @item
  14837. The @code{loadkeys} command changes the keyboard layout in effect in the Linux
  14838. console. However, note that @code{loadkeys} does @emph{not} use the XKB
  14839. keyboard layout categorization described above. The command below loads the
  14840. French bépo layout:
  14841. @example
  14842. loadkeys fr-bepo
  14843. @end example
  14844. @end itemize
  14845. @node Locales
  14846. @section Locales
  14847. @cindex locale
  14848. A @dfn{locale} defines cultural conventions for a particular language
  14849. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  14850. Reference Manual}). Each locale has a name that typically has the form
  14851. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  14852. @code{fr_LU.utf8} designates the locale for the French language, with
  14853. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  14854. @cindex locale definition
  14855. Usually, you will want to specify the default locale for the machine
  14856. using the @code{locale} field of the @code{operating-system} declaration
  14857. (@pxref{operating-system Reference, @code{locale}}).
  14858. The selected locale is automatically added to the @dfn{locale
  14859. definitions} known to the system if needed, with its codeset inferred
  14860. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  14861. @code{UTF-8} codeset. Additional locale definitions can be specified in
  14862. the @code{locale-definitions} slot of @code{operating-system}---this is
  14863. useful, for instance, if the codeset could not be inferred from the
  14864. locale name. The default set of locale definitions includes some widely
  14865. used locales, but not all the available locales, in order to save space.
  14866. For instance, to add the North Frisian locale for Germany, the value of
  14867. that field may be:
  14868. @lisp
  14869. (cons (locale-definition
  14870. (name "fy_DE.utf8") (source "fy_DE"))
  14871. %default-locale-definitions)
  14872. @end lisp
  14873. Likewise, to save space, one might want @code{locale-definitions} to
  14874. list only the locales that are actually used, as in:
  14875. @lisp
  14876. (list (locale-definition
  14877. (name "ja_JP.eucjp") (source "ja_JP")
  14878. (charset "EUC-JP")))
  14879. @end lisp
  14880. @vindex LOCPATH
  14881. The compiled locale definitions are available at
  14882. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  14883. version, which is the default location where the GNU@tie{}libc provided
  14884. by Guix looks for locale data. This can be overridden using the
  14885. @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
  14886. @env{LOCPATH} and locale packages}).
  14887. The @code{locale-definition} form is provided by the @code{(gnu system
  14888. locale)} module. Details are given below.
  14889. @deftp {Data Type} locale-definition
  14890. This is the data type of a locale definition.
  14891. @table @asis
  14892. @item @code{name}
  14893. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  14894. Reference Manual}, for more information on locale names.
  14895. @item @code{source}
  14896. The name of the source for that locale. This is typically the
  14897. @code{@var{language}_@var{territory}} part of the locale name.
  14898. @item @code{charset} (default: @code{"UTF-8"})
  14899. The ``character set'' or ``code set'' for that locale,
  14900. @uref{https://www.iana.org/assignments/character-sets, as defined by
  14901. IANA}.
  14902. @end table
  14903. @end deftp
  14904. @defvar %default-locale-definitions
  14905. A list of commonly used UTF-8 locales, used as the default
  14906. value of the @code{locale-definitions} field of @code{operating-system}
  14907. declarations.
  14908. @cindex locale name
  14909. @cindex normalized codeset in locale names
  14910. These locale definitions use the @dfn{normalized codeset} for the part
  14911. that follows the dot in the name (@pxref{Using gettextized software,
  14912. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  14913. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  14914. @code{uk_UA.UTF-8}.
  14915. @end defvar
  14916. @subsection Locale Data Compatibility Considerations
  14917. @cindex incompatibility, of locale data
  14918. @code{operating-system} declarations provide a @code{locale-libcs} field
  14919. to specify the GNU@tie{}libc packages that are used to compile locale
  14920. declarations (@pxref{operating-system Reference}). ``Why would I
  14921. care?'', you may ask. Well, it turns out that the binary format of
  14922. locale data is occasionally incompatible from one libc version to
  14923. another.
  14924. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  14925. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  14926. For instance, a program linked against libc version 2.21 is unable to
  14927. read locale data produced with libc 2.22; worse, that program
  14928. @emph{aborts} instead of simply ignoring the incompatible locale
  14929. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  14930. the incompatible locale data, which is already an improvement.}.
  14931. Similarly, a program linked against libc 2.22 can read most, but not
  14932. all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
  14933. data is incompatible); thus calls to @code{setlocale} may fail, but
  14934. programs will not abort.
  14935. The ``problem'' with Guix is that users have a lot of freedom: They can
  14936. choose whether and when to upgrade software in their profiles, and might
  14937. be using a libc version different from the one the system administrator
  14938. used to build the system-wide locale data.
  14939. Fortunately, unprivileged users can also install their own locale data
  14940. and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  14941. @env{GUIX_LOCPATH} and locale packages}).
  14942. Still, it is best if the system-wide locale data at
  14943. @file{/run/current-system/locale} is built for all the libc versions
  14944. actually in use on the system, so that all the programs can access
  14945. it---this is especially crucial on a multi-user system. To do that, the
  14946. administrator can specify several libc packages in the
  14947. @code{locale-libcs} field of @code{operating-system}:
  14948. @lisp
  14949. (use-package-modules base)
  14950. (operating-system
  14951. ;; @dots{}
  14952. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  14953. @end lisp
  14954. This example would lead to a system containing locale definitions for
  14955. both libc 2.21 and the current version of libc in
  14956. @file{/run/current-system/locale}.
  14957. @node Services
  14958. @section Services
  14959. @cindex system services
  14960. An important part of preparing an @code{operating-system} declaration is
  14961. listing @dfn{system services} and their configuration (@pxref{Using the
  14962. Configuration System}). System services are typically daemons launched
  14963. when the system boots, or other actions needed at that time---e.g.,
  14964. configuring network access.
  14965. Guix has a broad definition of ``service'' (@pxref{Service
  14966. Composition}), but many services are managed by the GNU@tie{}Shepherd
  14967. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  14968. command allows you to list the available services, show their status,
  14969. start and stop them, or do other specific operations (@pxref{Jump
  14970. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  14971. @example
  14972. # herd status
  14973. @end example
  14974. The above command, run as @code{root}, lists the currently defined
  14975. services. The @command{herd doc} command shows a synopsis of the given
  14976. service and its associated actions:
  14977. @example
  14978. # herd doc nscd
  14979. Run libc's name service cache daemon (nscd).
  14980. # herd doc nscd action invalidate
  14981. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  14982. @end example
  14983. The @command{start}, @command{stop}, and @command{restart} sub-commands
  14984. have the effect you would expect. For instance, the commands below stop
  14985. the nscd service and restart the Xorg display server:
  14986. @example
  14987. # herd stop nscd
  14988. Service nscd has been stopped.
  14989. # herd restart xorg-server
  14990. Service xorg-server has been stopped.
  14991. Service xorg-server has been started.
  14992. @end example
  14993. @cindex configuration, action for shepherd services
  14994. @cindex configuration file, of a shepherd service
  14995. For some services, @command{herd configuration} returns the name of the
  14996. service's configuration file, which can be handy to inspect its
  14997. configuration:
  14998. @example
  14999. # herd configuration sshd
  15000. /gnu/store/@dots{}-sshd_config
  15001. @end example
  15002. The following sections document the available services, starting with
  15003. the core services, that may be used in an @code{operating-system}
  15004. declaration.
  15005. @menu
  15006. * Base Services:: Essential system services.
  15007. * Scheduled Job Execution:: The mcron service.
  15008. * Log Rotation:: The rottlog service.
  15009. * Networking Setup:: Setting up network interfaces.
  15010. * Networking Services:: Firewall, SSH daemon, etc.
  15011. * Unattended Upgrades:: Automated system upgrades.
  15012. * X Window:: Graphical display.
  15013. * Printing Services:: Local and remote printer support.
  15014. * Desktop Services:: D-Bus and desktop services.
  15015. * Sound Services:: ALSA and Pulseaudio services.
  15016. * File Search Services:: Tools to search for files.
  15017. * Database Services:: SQL databases, key-value stores, etc.
  15018. * Mail Services:: IMAP, POP3, SMTP, and all that.
  15019. * Messaging Services:: Messaging services.
  15020. * Telephony Services:: Telephony services.
  15021. * File-Sharing Services:: File-sharing services.
  15022. * Monitoring Services:: Monitoring services.
  15023. * Kerberos Services:: Kerberos services.
  15024. * LDAP Services:: LDAP services.
  15025. * Web Services:: Web servers.
  15026. * Certificate Services:: TLS certificates via Let's Encrypt.
  15027. * DNS Services:: DNS daemons.
  15028. * VNC Services:: VNC daemons.
  15029. * VPN Services:: VPN daemons.
  15030. * Network File System:: NFS related services.
  15031. * Samba Services:: Samba services.
  15032. * Continuous Integration:: Cuirass and Laminar services.
  15033. * Power Management Services:: Extending battery life.
  15034. * Audio Services:: The MPD.
  15035. * Virtualization Services:: Virtualization services.
  15036. * Version Control Services:: Providing remote access to Git repositories.
  15037. * Game Services:: Game servers.
  15038. * PAM Mount Service:: Service to mount volumes when logging in.
  15039. * Guix Services:: Services relating specifically to Guix.
  15040. * Linux Services:: Services tied to the Linux kernel.
  15041. * Hurd Services:: Services specific for a Hurd System.
  15042. * Miscellaneous Services:: Other services.
  15043. @end menu
  15044. @node Base Services
  15045. @subsection Base Services
  15046. The @code{(gnu services base)} module provides definitions for the basic
  15047. services that one expects from the system. The services exported by
  15048. this module are listed below.
  15049. @defvar %base-services
  15050. This variable contains a list of basic services (@pxref{Service Types
  15051. and Services}, for more information on service objects) one would
  15052. expect from the system: a login service (mingetty) on each tty, syslogd,
  15053. the libc name service cache daemon (nscd), the udev device manager, and
  15054. more.
  15055. This is the default value of the @code{services} field of
  15056. @code{operating-system} declarations. Usually, when customizing a
  15057. system, you will want to append services to @code{%base-services}, like
  15058. this:
  15059. @lisp
  15060. (append (list (service avahi-service-type)
  15061. (service openssh-service-type))
  15062. %base-services)
  15063. @end lisp
  15064. @end defvar
  15065. @defvar special-files-service-type
  15066. This is the service that sets up ``special files'' such as
  15067. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  15068. The value associated with @code{special-files-service-type} services
  15069. must be a list of two-element lists where the first element is the ``special file''
  15070. and the second element is its target. By default it is:
  15071. @cindex @file{/bin/sh}
  15072. @cindex @file{sh}, in @file{/bin}
  15073. @lisp
  15074. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  15075. ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
  15076. @end lisp
  15077. @cindex @file{/usr/bin/env}
  15078. @cindex @file{env}, in @file{/usr/bin}
  15079. If you want to add, say, @code{/bin/bash} to your system, you can
  15080. change it to:
  15081. @lisp
  15082. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  15083. ("/usr/bin/env" ,(file-append coreutils "/bin/env"))
  15084. ("/bin/bash" ,(file-append bash "/bin/bash")))
  15085. @end lisp
  15086. Since this is part of @code{%base-services}, you can use
  15087. @code{modify-services} to customize the set of special files
  15088. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  15089. to add a special file is @i{via} the @code{extra-special-file} procedure
  15090. (see below).
  15091. @end defvar
  15092. @deffn {Procedure} extra-special-file file target
  15093. Use @var{target} as the ``special file'' @var{file}.
  15094. For example, adding the following lines to the @code{services} field of
  15095. your operating system declaration leads to a @file{/usr/bin/env}
  15096. symlink:
  15097. @lisp
  15098. (extra-special-file "/usr/bin/env"
  15099. (file-append coreutils "/bin/env"))
  15100. @end lisp
  15101. @end deffn
  15102. @defvar host-name-service-type
  15103. Type of the service that sets the system host name, whose value
  15104. is a string. This service is included in @code{operating-system} by
  15105. default (@pxref{operating-system-essential-services,@code{essential-services}}).
  15106. @end defvar
  15107. @defvar console-font-service-type
  15108. Install the given fonts on the specified ttys (fonts are per
  15109. virtual console on the kernel Linux). The value of this service is a list of
  15110. tty/font pairs. The font can be the name of a font provided by the @code{kbd}
  15111. package or any valid argument to @command{setfont}, as in this example:
  15112. @lisp
  15113. `(("tty1" . "LatGrkCyr-8x16")
  15114. ("tty2" . ,(file-append
  15115. font-tamzen
  15116. "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  15117. ("tty3" . ,(file-append
  15118. font-terminus
  15119. "/share/consolefonts/ter-132n"))) ; for HDPI
  15120. @end lisp
  15121. @end defvar
  15122. @defvar hosts-service-type
  15123. Type of the service that populates the entries for (@file{/etc/hosts}).
  15124. This service type can be @emph{extended} by passing it a list of
  15125. @code{host} records.
  15126. The example below shows how to add two entries to @file{/etc/hosts}:
  15127. @c TRANSLATORS: The domain names below SHOULD NOT be translated.
  15128. @c They're domains reserved for use in documentation. (RFC6761 Section 6.5)
  15129. @c The addresses used are explained in RFC3849 and RFC5737.
  15130. @lisp
  15131. (simple-service 'add-extra-hosts
  15132. hosts-service-type
  15133. (list (host "192.0.2.1" "example.com"
  15134. '("example.net" "example.org"))
  15135. (host "2001:db8::1" "example.com"
  15136. '("example.net" "example.org"))))
  15137. @end lisp
  15138. @quotation Note
  15139. @cindex @file{/etc/hosts} default entries
  15140. By default @file{/etc/hosts} comes with the following entries:
  15141. @example
  15142. 127.0.0.1 localhost @var{host-name}
  15143. ::1 localhost @var{host-name}
  15144. @end example
  15145. For most setups this is what you want though if you find yourself in
  15146. the situation where you want to change the default entries, you can
  15147. do so in @code{operating-system} via @code{modify-services}
  15148. (@pxref{Service Reference,@code{modify-services}}).
  15149. The following example shows how to unset @var{host-name} from being an
  15150. alias of @code{localhost}.
  15151. @lisp
  15152. (operating-system
  15153. ;; @dots{}
  15154. (essential-services
  15155. (modify-services
  15156. (operating-system-default-essential-services this-operating-system)
  15157. (hosts-service-type config => (list
  15158. (host "127.0.0.1" "localhost")
  15159. (host "::1" "localhost"))))))
  15160. @end lisp
  15161. @end quotation
  15162. @end defvar
  15163. @deffn {Procedure} host @var{address} @var{canonical-name} [@var{aliases}]
  15164. Return a new record for the host at @var{address} with the given
  15165. @var{canonical-name} and possibly @var{aliases}.
  15166. @var{address} must be a string denoting a valid IPv4 or IPv6 address, and
  15167. @var{canonical-name} and the strings listed in @var{aliases} must be valid
  15168. host names.
  15169. @end deffn
  15170. @defvar login-service-type
  15171. Type of the service that provides a console login service, whose value
  15172. is a @code{<login-configuration>} object.
  15173. @end defvar
  15174. @deftp {Data Type} login-configuration
  15175. Data type representing the configuration of login, which specifies the
  15176. @acronym{MOTD, message of the day}, among other things.
  15177. @table @asis
  15178. @item @code{motd}
  15179. @cindex message of the day
  15180. A file-like object containing the ``message of the day''.
  15181. @item @code{allow-empty-passwords?} (default: @code{#t})
  15182. Allow empty passwords by default so that first-time users can log in when
  15183. the 'root' account has just been created.
  15184. @end table
  15185. @end deftp
  15186. @defvar mingetty-service-type
  15187. Type of the service that runs Mingetty, an implementation of the
  15188. virtual console log-in. The value for this service is a
  15189. @code{<mingetty-configuration>} object.
  15190. @end defvar
  15191. @deftp {Data Type} mingetty-configuration
  15192. Data type representing the configuration of Mingetty, which specifies
  15193. the tty to run, among other things.
  15194. @table @asis
  15195. @item @code{tty}
  15196. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  15197. @item @code{auto-login} (default: @code{#f})
  15198. When true, this field must be a string denoting the user name under
  15199. which the system automatically logs in. When it is @code{#f}, a
  15200. user name and password must be entered to log in.
  15201. @item @code{login-program} (default: @code{#f})
  15202. This must be either @code{#f}, in which case the default log-in program
  15203. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  15204. the name of the log-in program.
  15205. @item @code{login-pause?} (default: @code{#f})
  15206. When set to @code{#t} in conjunction with @var{auto-login}, the user
  15207. will have to press a key before the log-in shell is launched.
  15208. @item @code{clear-on-logout?} (default: @code{#t})
  15209. When set to @code{#t}, the screen will be cleared after logout.
  15210. @item @code{mingetty} (default: @var{mingetty})
  15211. The Mingetty package to use.
  15212. @end table
  15213. @end deftp
  15214. @defvar agetty-service-type
  15215. Type of the service that runs agetty, which implements virtual and
  15216. serial console log-in. The value for this service is a
  15217. @code{<agetty-configuration>} object.
  15218. @end defvar
  15219. @deftp {Data Type} agetty-configuration
  15220. Data type representing the configuration of agetty, which specifies the
  15221. tty to run, among other things@footnote{See the @code{agetty(8)}
  15222. man page for more information.}.
  15223. @table @asis
  15224. @item @code{tty}
  15225. The name of the console this agetty runs on, as a string---e.g.,
  15226. @code{"ttyS0"}. This argument is optional, it will default to
  15227. a reasonable default serial port used by the kernel Linux.
  15228. For this, if there is a value for an option @code{agetty.tty} in the kernel
  15229. command line, agetty will extract the device name of the serial port
  15230. from it and use that.
  15231. If not and if there is a value for an option @code{console} with a tty in
  15232. the Linux command line, agetty will extract the device name of the
  15233. serial port from it and use that.
  15234. In both cases, agetty will leave the other serial device settings
  15235. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  15236. correct values.
  15237. @item @code{baud-rate} (default: @code{#f})
  15238. A string containing a comma-separated list of one or more baud rates, in
  15239. descending order.
  15240. @item @code{term} (default: @code{#f})
  15241. A string containing the value used for the @env{TERM} environment
  15242. variable.
  15243. @item @code{eight-bits?} (default: @code{#f})
  15244. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  15245. disabled.
  15246. @item @code{auto-login} (default: @code{#f})
  15247. When passed a login name, as a string, the specified user will be logged
  15248. in automatically without prompting for their login name or password.
  15249. @item @code{no-reset?} (default: @code{#f})
  15250. When @code{#t}, don't reset terminal cflags (control modes).
  15251. @item @code{host} (default: @code{#f})
  15252. This accepts a string containing the ``login_host'', which will be written
  15253. into the @file{/var/run/utmpx} file.
  15254. @item @code{remote?} (default: @code{#f})
  15255. When set to @code{#t} in conjunction with @var{host}, this will add an
  15256. @code{-r} fakehost option to the command line of the login program
  15257. specified in @var{login-program}.
  15258. @item @code{flow-control?} (default: @code{#f})
  15259. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  15260. @item @code{no-issue?} (default: @code{#f})
  15261. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  15262. not be displayed before presenting the login prompt.
  15263. @item @code{init-string} (default: @code{#f})
  15264. This accepts a string that will be sent to the tty or modem before
  15265. sending anything else. It can be used to initialize a modem.
  15266. @item @code{no-clear?} (default: @code{#f})
  15267. When set to @code{#t}, agetty will not clear the screen before showing
  15268. the login prompt.
  15269. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  15270. This must be either a gexp denoting the name of a log-in program, or
  15271. unset, in which case the default value is the @command{login} from the
  15272. Shadow tool suite.
  15273. @item @code{local-line} (default: @code{#f})
  15274. Control the CLOCAL line flag. This accepts one of three symbols as
  15275. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  15276. the default value chosen by agetty is @code{'auto}.
  15277. @item @code{extract-baud?} (default: @code{#f})
  15278. When set to @code{#t}, instruct agetty to try to extract the baud rate
  15279. from the status messages produced by certain types of modems.
  15280. @item @code{skip-login?} (default: @code{#f})
  15281. When set to @code{#t}, do not prompt the user for a login name. This
  15282. can be used with @var{login-program} field to use non-standard login
  15283. systems.
  15284. @item @code{no-newline?} (default: @code{#f})
  15285. When set to @code{#t}, do not print a newline before printing the
  15286. @file{/etc/issue} file.
  15287. @c Is this dangerous only when used with login-program, or always?
  15288. @item @code{login-options} (default: @code{#f})
  15289. This option accepts a string containing options that are passed to the
  15290. login program. When used with the @var{login-program}, be aware that a
  15291. malicious user could try to enter a login name containing embedded
  15292. options that could be parsed by the login program.
  15293. @item @code{login-pause} (default: @code{#f})
  15294. When set to @code{#t}, wait for any key before showing the login prompt.
  15295. This can be used in conjunction with @var{auto-login} to save memory by
  15296. lazily spawning shells.
  15297. @item @code{chroot} (default: @code{#f})
  15298. Change root to the specified directory. This option accepts a directory
  15299. path as a string.
  15300. @item @code{hangup?} (default: @code{#f})
  15301. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  15302. specified terminal.
  15303. @item @code{keep-baud?} (default: @code{#f})
  15304. When set to @code{#t}, try to keep the existing baud rate. The baud
  15305. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  15306. character.
  15307. @item @code{timeout} (default: @code{#f})
  15308. When set to an integer value, terminate if no user name could be read
  15309. within @var{timeout} seconds.
  15310. @item @code{detect-case?} (default: @code{#f})
  15311. When set to @code{#t}, turn on support for detecting an uppercase-only
  15312. terminal. This setting will detect a login name containing only
  15313. uppercase letters as indicating an uppercase-only terminal and turn on
  15314. some upper-to-lower case conversions. Note that this will not support
  15315. Unicode characters.
  15316. @item @code{wait-cr?} (default: @code{#f})
  15317. When set to @code{#t}, wait for the user or modem to send a
  15318. carriage-return or linefeed character before displaying
  15319. @file{/etc/issue} or login prompt. This is typically used with the
  15320. @var{init-string} option.
  15321. @item @code{no-hints?} (default: @code{#f})
  15322. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  15323. locks.
  15324. @item @code{no-hostname?} (default: @code{#f})
  15325. By default, the hostname is printed. When this option is set to
  15326. @code{#t}, no hostname will be shown at all.
  15327. @item @code{long-hostname?} (default: @code{#f})
  15328. By default, the hostname is only printed until the first dot. When this
  15329. option is set to @code{#t}, the fully qualified hostname by
  15330. @code{gethostname} or @code{getaddrinfo} is shown.
  15331. @item @code{erase-characters} (default: @code{#f})
  15332. This option accepts a string of additional characters that should be
  15333. interpreted as backspace when the user types their login name.
  15334. @item @code{kill-characters} (default: @code{#f})
  15335. This option accepts a string that should be interpreted to mean ``ignore
  15336. all previous characters'' (also called a ``kill'' character) when the user
  15337. types their login name.
  15338. @item @code{chdir} (default: @code{#f})
  15339. This option accepts, as a string, a directory path that will be changed
  15340. to before login.
  15341. @item @code{delay} (default: @code{#f})
  15342. This options accepts, as an integer, the number of seconds to sleep
  15343. before opening the tty and displaying the login prompt.
  15344. @item @code{nice} (default: @code{#f})
  15345. This option accepts, as an integer, the nice value with which to run the
  15346. @command{login} program.
  15347. @item @code{extra-options} (default: @code{'()})
  15348. This option provides an ``escape hatch'' for the user to provide arbitrary
  15349. command-line arguments to @command{agetty} as a list of strings.
  15350. @item @code{shepherd-requirement} (default: @code{'()})
  15351. The option can be used to provides extra shepherd requirements (for example
  15352. @code{'syslogd}) to the respective @code{'term-}* shepherd service.
  15353. @end table
  15354. @end deftp
  15355. @defvar kmscon-service-type
  15356. Type of the service that runs @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon},
  15357. which implements virtual console log-in. The value for this service is a
  15358. @code{<kmscon-configuration>} object.
  15359. @end defvar
  15360. @deftp {Data Type} kmscon-configuration
  15361. Data type representing the configuration of Kmscon, which specifies the
  15362. tty to run, among other things.
  15363. @table @asis
  15364. @item @code{virtual-terminal}
  15365. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  15366. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  15367. A gexp denoting the name of the log-in program. The default log-in program is
  15368. @command{login} from the Shadow tool suite.
  15369. @item @code{login-arguments} (default: @code{'("-p")})
  15370. A list of arguments to pass to @command{login}.
  15371. @item @code{auto-login} (default: @code{#f})
  15372. When passed a login name, as a string, the specified user will be logged
  15373. in automatically without prompting for their login name or password.
  15374. @item @code{hardware-acceleration?} (default: #f)
  15375. Whether to use hardware acceleration.
  15376. @item @code{font-engine} (default: @code{"pango"})
  15377. Font engine used in Kmscon.
  15378. @item @code{font-size} (default: @code{12})
  15379. Font size used in Kmscon.
  15380. @item @code{keyboard-layout} (default: @code{#f})
  15381. If this is @code{#f}, Kmscon uses the default keyboard layout---usually US
  15382. English (``qwerty'') for a 105-key PC keyboard.
  15383. Otherwise this must be a @code{keyboard-layout} object specifying the
  15384. keyboard layout. @xref{Keyboard Layout}, for more information on how to
  15385. specify the keyboard layout.
  15386. @item @code{kmscon} (default: @var{kmscon})
  15387. The Kmscon package to use.
  15388. @end table
  15389. @end deftp
  15390. @cindex @abbr{nscd, name service cache daemon}
  15391. @defvar nscd-service-type
  15392. Type of the service that runs the libc @abbr{nscd, name service cache
  15393. daemon}, whose value is an @code{<nscd-configuration>} object.
  15394. For convenience, the Shepherd service for nscd provides the following actions:
  15395. @table @code
  15396. @item invalidate
  15397. @cindex nscd, cache invalidation
  15398. @cindex cache invalidation, nscd
  15399. This invalidate the given cache. For instance, running:
  15400. @example
  15401. herd invalidate nscd hosts
  15402. @end example
  15403. @noindent
  15404. invalidates the host name lookup cache of nscd.
  15405. @item statistics
  15406. Running @command{herd statistics nscd} displays information about nscd usage
  15407. and caches.
  15408. @end table
  15409. @end defvar
  15410. @deftp {Data Type} nscd-configuration
  15411. Data type representing the @abbr{nscd, name service cache daemon}
  15412. configuration.
  15413. @table @asis
  15414. @item @code{name-services} (default: @code{'()})
  15415. List of packages denoting @dfn{name services} that must be visible to
  15416. the nscd---e.g., @code{(list @var{nss-mdns})}.
  15417. @item @code{glibc} (default: @var{glibc})
  15418. Package object denoting the GNU C Library providing the @command{nscd}
  15419. command.
  15420. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  15421. Name of the nscd log file. This is where debugging output goes when
  15422. @code{debug-level} is strictly positive.
  15423. @item @code{debug-level} (default: @code{0})
  15424. Integer denoting the debugging levels. Higher numbers mean that more
  15425. debugging output is logged.
  15426. @item @code{caches} (default: @code{%nscd-default-caches})
  15427. List of @code{<nscd-cache>} objects denoting things to be cached; see
  15428. below.
  15429. @end table
  15430. @end deftp
  15431. @deftp {Data Type} nscd-cache
  15432. Data type representing a cache database of nscd and its parameters.
  15433. @table @asis
  15434. @item @code{database}
  15435. This is a symbol representing the name of the database to be cached.
  15436. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  15437. @code{services}, which designate the corresponding NSS database
  15438. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  15439. @item @code{positive-time-to-live}
  15440. @itemx @code{negative-time-to-live} (default: @code{20})
  15441. A number representing the number of seconds during which a positive or
  15442. negative lookup result remains in cache.
  15443. @item @code{check-files?} (default: @code{#t})
  15444. Whether to check for updates of the files corresponding to
  15445. @var{database}.
  15446. For instance, when @var{database} is @code{hosts}, setting this flag
  15447. instructs nscd to check for updates in @file{/etc/hosts} and to take
  15448. them into account.
  15449. @item @code{persistent?} (default: @code{#t})
  15450. Whether the cache should be stored persistently on disk.
  15451. @item @code{shared?} (default: @code{#t})
  15452. Whether the cache should be shared among users.
  15453. @item @code{max-database-size} (default: 32@tie{}MiB)
  15454. Maximum size in bytes of the database cache.
  15455. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  15456. @c settings, so leave them out.
  15457. @end table
  15458. @end deftp
  15459. @defvar %nscd-default-caches
  15460. List of @code{<nscd-cache>} objects used by default by
  15461. @code{nscd-configuration} (see above).
  15462. It enables persistent and aggressive caching of service and host name
  15463. lookups. The latter provides better host name lookup performance,
  15464. resilience in the face of unreliable name servers, and also better
  15465. privacy---often the result of host name lookups is in local cache, so
  15466. external name servers do not even need to be queried.
  15467. @end defvar
  15468. @cindex syslog
  15469. @cindex logging
  15470. @defvar syslog-service-type
  15471. Type of the service that runs the syslog daemon, whose value is a
  15472. @code{<syslog-configuration>} object.
  15473. @end defvar
  15474. To have a modified @code{syslog-configuration} come into effect after
  15475. reconfiguring your system, the @samp{reload} action should be preferred
  15476. to restarting the service, as many services such as the login manager
  15477. depend on it and would be restarted as well:
  15478. @example
  15479. # herd reload syslog
  15480. @end example
  15481. which will cause the running @command{syslogd} process to reload its
  15482. configuration.
  15483. @deftp {Data Type} syslog-configuration
  15484. Data type representing the configuration of the syslog daemon.
  15485. @table @asis
  15486. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  15487. The syslog daemon to use.
  15488. @item @code{config-file} (default: @code{%default-syslog.conf})
  15489. The syslog configuration file to use.
  15490. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  15491. information on the configuration file syntax.
  15492. @end table
  15493. @end deftp
  15494. @defvar guix-service-type
  15495. This is the type of the service that runs the build daemon,
  15496. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  15497. @code{guix-configuration} record as described below.
  15498. @end defvar
  15499. @anchor{guix-configuration-type}
  15500. @deftp {Data Type} guix-configuration
  15501. This data type represents the configuration of the Guix build daemon.
  15502. @xref{Invoking guix-daemon}, for more information.
  15503. @table @asis
  15504. @item @code{guix} (default: @var{guix})
  15505. The Guix package to use.
  15506. @item @code{build-group} (default: @code{"guixbuild"})
  15507. Name of the group for build user accounts.
  15508. @item @code{build-accounts} (default: @code{10})
  15509. Number of build user accounts to create.
  15510. @item @code{authorize-key?} (default: @code{#t})
  15511. @cindex substitutes, authorization thereof
  15512. Whether to authorize the substitute keys listed in
  15513. @code{authorized-keys}---by default that of
  15514. @code{@value{SUBSTITUTE-SERVER-1}} and
  15515. @code{@value{SUBSTITUTE-SERVER-2}}
  15516. (@pxref{Substitutes}).
  15517. When @code{authorize-key?} is true, @file{/etc/guix/acl} cannot be
  15518. changed by invoking @command{guix archive --authorize}. You must
  15519. instead adjust @code{guix-configuration} as you wish and reconfigure the
  15520. system. This ensures that your operating system configuration file is
  15521. self-contained.
  15522. @quotation Note
  15523. When booting or reconfiguring to a system where @code{authorize-key?}
  15524. is true, the existing @file{/etc/guix/acl} file is backed up as
  15525. @file{/etc/guix/acl.bak} if it was determined to be a manually modified
  15526. file. This is to facilitate migration from earlier versions, which
  15527. allowed for in-place modifications to @file{/etc/guix/acl}.
  15528. @end quotation
  15529. @vindex %default-authorized-guix-keys
  15530. @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
  15531. The list of authorized key files for archive imports, as a list of
  15532. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  15533. contains that of @code{@value{SUBSTITUTE-SERVER-1}} and
  15534. @code{@value{SUBSTITUTE-SERVER-2}} (@pxref{Substitutes}). See
  15535. @code{substitute-urls} below for an example on how to change it.
  15536. @item @code{use-substitutes?} (default: @code{#t})
  15537. Whether to use substitutes.
  15538. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  15539. The list of URLs where to look for substitutes by default.
  15540. Suppose you would like to fetch substitutes from @code{guix.example.org}
  15541. in addition to @code{@value{SUBSTITUTE-SERVER-1}}. You will need to do
  15542. two things: (1) add @code{guix.example.org} to @code{substitute-urls},
  15543. and (2) authorize its signing key, having done appropriate checks
  15544. (@pxref{Substitute Server Authorization}). The configuration below does
  15545. exactly that:
  15546. @lisp
  15547. (guix-configuration
  15548. (substitute-urls
  15549. (append (list "https://guix.example.org")
  15550. %default-substitute-urls))
  15551. (authorized-keys
  15552. (append (list (local-file "./guix.example.org-key.pub"))
  15553. %default-authorized-guix-keys)))
  15554. @end lisp
  15555. This example assumes that the file @file{./guix.example.org-key.pub}
  15556. contains the public key that @code{guix.example.org} uses to sign
  15557. substitutes.
  15558. @item @code{generate-substitute-key?} (default: @code{#t})
  15559. Whether to generate a @dfn{substitute key pair} under
  15560. @file{/etc/guix/signing-key.pub} and @file{/etc/guix/signing-key.sec} if
  15561. there is not already one.
  15562. This key pair is used when exporting store items, for instance with
  15563. @command{guix publish} (@pxref{Invoking guix publish}) or @command{guix
  15564. archive} (@pxref{Invoking guix archive}). Generating a key pair takes a
  15565. few seconds when enough entropy is available and is only done once; you
  15566. might want to turn it off for instance in a virtual machine that does
  15567. not need it and where the extra boot time is a problem.
  15568. @item @code{max-silent-time} (default: @code{0})
  15569. @itemx @code{timeout} (default: @code{0})
  15570. The number of seconds of silence and the number of seconds of activity,
  15571. respectively, after which a build process times out. A value of zero
  15572. disables the timeout.
  15573. @item @code{log-compression} (default: @code{'gzip})
  15574. The type of compression used for build logs---one of @code{gzip},
  15575. @code{bzip2}, or @code{none}.
  15576. @item @code{discover?} (default: @code{#f})
  15577. Whether to discover substitute servers on the local network using mDNS
  15578. and DNS-SD.
  15579. @item @code{extra-options} (default: @code{'()})
  15580. List of extra command-line options for @command{guix-daemon}.
  15581. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  15582. File where @command{guix-daemon}'s standard output and standard error
  15583. are written.
  15584. @cindex HTTP proxy, for @code{guix-daemon}
  15585. @cindex proxy, for @code{guix-daemon} HTTP access
  15586. @item @code{http-proxy} (default: @code{#f})
  15587. The URL of the HTTP and HTTPS proxy used for downloading fixed-output
  15588. derivations and substitutes.
  15589. It is also possible to change the daemon's proxy at run time through the
  15590. @code{set-http-proxy} action, which restarts it:
  15591. @example
  15592. herd set-http-proxy guix-daemon http://localhost:8118
  15593. @end example
  15594. To clear the proxy settings, run:
  15595. @example
  15596. herd set-http-proxy guix-daemon
  15597. @end example
  15598. @item @code{tmpdir} (default: @code{#f})
  15599. A directory path where the @command{guix-daemon} will perform builds.
  15600. @item @code{environment} (default: @code{'()})
  15601. Environment variables to be set before starting the daemon, as a list of
  15602. @code{key=value} strings.
  15603. @end table
  15604. @end deftp
  15605. @deftp {Data Type} guix-extension
  15606. This data type represents the parameters of the Guix build daemon that
  15607. are extendable. This is the type of the object that must be used within
  15608. a guix service extension.
  15609. @xref{Service Composition}, for more information.
  15610. @table @asis
  15611. @item @code{authorized-keys} (default: @code{'()})
  15612. A list of file-like objects where each element contains a public key.
  15613. @item @code{substitute-urls} (default: @code{'()})
  15614. A list of strings where each element is a substitute URL.
  15615. @item @code{chroot-directories} (default: @code{'()})
  15616. A list of file-like objects or strings pointing to additional directories the build daemon can use.
  15617. @end table
  15618. @end deftp
  15619. @defvar udev-service-type
  15620. Type of the service that runs udev, a service which populates the
  15621. @file{/dev} directory dynamically, whose value is a
  15622. @code{<udev-configuration>} object.
  15623. This service type can be @emph{extended} using procedures
  15624. @code{udev-rules-service} along with @code{file->udev-rule} or
  15625. @code{udev-rule} which simplify the process of writing udev rules.
  15626. @end defvar
  15627. @deftp {Data Type} udev-configuration
  15628. Data type representing the configuration of udev.
  15629. @table @asis
  15630. @item @code{udev} (default: @code{eudev}) (type: file-like)
  15631. Package object of the udev service.
  15632. @item @code{rules} (default: @var{'()}) (type: list-of-file-like)
  15633. List of file-like objects denoting udev-rule files.
  15634. @end table
  15635. @end deftp
  15636. @deffn {Procedure} udev-rule @var{file-name} @var{contents}
  15637. Return a udev-rule file named @var{file-name} containing the rules
  15638. defined by the @var{contents} literal.
  15639. In the following example, a rule for a USB device is defined to be
  15640. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  15641. upon detecting a USB device with a given product identifier.
  15642. @lisp
  15643. (define %example-udev-rule
  15644. (udev-rule
  15645. "90-usb-thing.rules"
  15646. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  15647. "ATTR@{product@}==\"Example\", "
  15648. "RUN+=\"/path/to/script\"")))
  15649. @end lisp
  15650. @end deffn
  15651. @deffn {Procedure} udev-rules-service @var{name} @var{rules} [#:groups '()]
  15652. Return a service that extends @code{udev-service-type} with @var{rules}
  15653. and @code{account-service-type} with @var{groups} as system groups.
  15654. This works by creating a singleton service type
  15655. @code{@var{name}-udev-rules}, of which the returned service is an
  15656. instance.
  15657. Here we show how it can be used to extend @code{udev-service-type}
  15658. with the previously defined rule @code{%example-udev-rule}.
  15659. @lisp
  15660. (operating-system
  15661. ;; @dots{}
  15662. (services
  15663. (cons (udev-rules-service 'usb-thing %example-udev-rule)
  15664. %desktop-services)))
  15665. @end lisp
  15666. @end deffn
  15667. @deffn {Procedure} file->udev-rule @var{file-name} @var{file}
  15668. Return a udev-rule file named @var{file-name} containing the rules
  15669. defined within @var{file}, a file-like object.
  15670. The following example showcases how we can use an existing rule file.
  15671. @lisp
  15672. (use-modules (guix download) ;for url-fetch
  15673. (guix packages) ;for origin
  15674. @dots{})
  15675. (define %android-udev-rules
  15676. (file->udev-rule
  15677. "51-android-udev.rules"
  15678. (let ((version "20170910"))
  15679. (origin
  15680. (method url-fetch)
  15681. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  15682. "android-udev-rules/" version "/51-android.rules"))
  15683. (sha256
  15684. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  15685. @end lisp
  15686. @end deffn
  15687. Additionally, Guix package definitions can be included in @var{rules} in
  15688. order to extend the udev rules with the definitions found under their
  15689. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  15690. @var{file->udev-rule} example, we could have used the
  15691. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  15692. packages android)} module.
  15693. The following example shows how to use the @var{android-udev-rules}
  15694. package so that the Android tool @command{adb} can detect devices
  15695. without root privileges. It also details how to create the
  15696. @code{adbusers} group, which is required for the proper functioning of
  15697. the rules defined within the @code{android-udev-rules} package. To
  15698. create such a group, we must define it both as part of the
  15699. @code{supplementary-groups} of our @code{user-account} declaration, as
  15700. well as in the @var{groups} of the @code{udev-rules-service} procedure.
  15701. @lisp
  15702. (use-modules (gnu packages android) ;for android-udev-rules
  15703. (gnu system shadow) ;for user-group
  15704. @dots{})
  15705. (operating-system
  15706. ;; @dots{}
  15707. (users (cons (user-account
  15708. ;; @dots{}
  15709. (supplementary-groups
  15710. '("adbusers" ;for adb
  15711. "wheel" "netdev" "audio" "video")))))
  15712. ;; @dots{}
  15713. (services
  15714. (cons (udev-rules-service 'android android-udev-rules
  15715. #:groups '("adbusers"))
  15716. %desktop-services)))
  15717. @end lisp
  15718. @defvar urandom-seed-service-type
  15719. Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
  15720. when rebooting. It also tries to seed @file{/dev/urandom} from
  15721. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  15722. readable.
  15723. @end defvar
  15724. @defvar %random-seed-file
  15725. This is the name of the file where some random bytes are saved by
  15726. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  15727. It defaults to @file{/var/lib/random-seed}.
  15728. @end defvar
  15729. @cindex mouse
  15730. @cindex gpm
  15731. @defvar gpm-service-type
  15732. This is the type of the service that runs GPM, the @dfn{general-purpose
  15733. mouse daemon}, which provides mouse support to the Linux console. GPM
  15734. allows users to use the mouse in the console, notably to select, copy,
  15735. and paste text.
  15736. The value for services of this type must be a @code{gpm-configuration}
  15737. (see below). This service is not part of @code{%base-services}.
  15738. @end defvar
  15739. @deftp {Data Type} gpm-configuration
  15740. Data type representing the configuration of GPM.
  15741. @table @asis
  15742. @item @code{options} (default: @code{%default-gpm-options})
  15743. Command-line options passed to @command{gpm}. The default set of
  15744. options instruct @command{gpm} to listen to mouse events on
  15745. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  15746. more information.
  15747. @item @code{gpm} (default: @code{gpm})
  15748. The GPM package to use.
  15749. @end table
  15750. @end deftp
  15751. @anchor{guix-publish-service-type}
  15752. @defvar guix-publish-service-type
  15753. This is the service type for @command{guix publish} (@pxref{Invoking
  15754. guix publish}). Its value must be a @code{guix-publish-configuration}
  15755. object, as described below.
  15756. This assumes that @file{/etc/guix} already contains a signing key pair as
  15757. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  15758. archive}). If that is not the case, the service will fail to start.
  15759. @end defvar
  15760. @deftp {Data Type} guix-publish-configuration
  15761. Data type representing the configuration of the @code{guix publish}
  15762. service.
  15763. @table @asis
  15764. @item @code{guix} (default: @code{guix})
  15765. The Guix package to use.
  15766. @item @code{port} (default: @code{80})
  15767. The TCP port to listen for connections.
  15768. @item @code{host} (default: @code{"localhost"})
  15769. The host (and thus, network interface) to listen to. Use
  15770. @code{"0.0.0.0"} to listen on all the network interfaces.
  15771. @item @code{advertise?} (default: @code{#f})
  15772. When true, advertise the service on the local network @i{via} the DNS-SD
  15773. protocol, using Avahi.
  15774. This allows neighboring Guix devices with discovery on (see
  15775. @code{guix-configuration} above) to discover this @command{guix publish}
  15776. instance and to automatically download substitutes from it.
  15777. @item @code{compression} (default: @code{'(("gzip" 3) ("zstd" 3))})
  15778. This is a list of compression method/level tuple used when compressing
  15779. substitutes. For example, to compress all substitutes with @emph{both} lzip
  15780. at level 7 and gzip at level 9, write:
  15781. @lisp
  15782. '(("lzip" 7) ("gzip" 9))
  15783. @end lisp
  15784. Level 9 achieves the best compression ratio at the expense of increased CPU
  15785. usage, whereas level 1 achieves fast compression. @xref{Invoking guix
  15786. publish}, for more information on the available compression methods and
  15787. the tradeoffs involved.
  15788. An empty list disables compression altogether.
  15789. @item @code{nar-path} (default: @code{"nar"})
  15790. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  15791. publish, @option{--nar-path}}, for details.
  15792. @item @code{cache} (default: @code{#f})
  15793. When it is @code{#f}, disable caching and instead generate archives on
  15794. demand. Otherwise, this should be the name of a directory---e.g.,
  15795. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  15796. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  15797. @option{--cache}}, for more information on the tradeoffs involved.
  15798. @item @code{workers} (default: @code{#f})
  15799. When it is an integer, this is the number of worker threads used for
  15800. caching; when @code{#f}, the number of processors is used.
  15801. @xref{Invoking guix publish, @option{--workers}}, for more information.
  15802. @item @code{cache-bypass-threshold} (default: 10 MiB)
  15803. When @code{cache} is true, this is the maximum size in bytes of a store
  15804. item for which @command{guix publish} may bypass its cache in case of a
  15805. cache miss. @xref{Invoking guix publish,
  15806. @option{--cache-bypass-threshold}}, for more information.
  15807. @item @code{ttl} (default: @code{#f})
  15808. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  15809. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  15810. for more information.
  15811. @item @code{negative-ttl} (default: @code{#f})
  15812. When it is an integer, this denotes the @dfn{time-to-live} in
  15813. seconds for the negative lookups. @xref{Invoking guix publish,
  15814. @option{--negative-ttl}}, for more information.
  15815. @end table
  15816. @end deftp
  15817. @defvar rngd-service-type
  15818. Type of the service that runs rng-tools rngd, whose value is an
  15819. @code{<rngd-configuration>} object.
  15820. @end defvar
  15821. @deftp {Data Type} rngd-configuration
  15822. Data type representing the configuration of rngd.
  15823. @table @asis
  15824. @item @code{rng-tools} (default: @code{rng-tools}) (type: file-like)
  15825. Package object of the rng-tools rngd.
  15826. @item @code{device} (default: @var{"/dev/hwrng"}) (type: string)
  15827. Path of the device to add to the kernel's entropy pool. The service
  15828. will fail if @var{device} does not exist.
  15829. @end table
  15830. @end deftp
  15831. @cindex session limits
  15832. @cindex ulimit
  15833. @cindex priority
  15834. @cindex realtime
  15835. @cindex jackd
  15836. @cindex nofile
  15837. @cindex open file descriptors
  15838. @anchor{pam-limits-service-type}
  15839. @defvar pam-limits-service-type
  15840. Type of the service that installs a configuration file for the
  15841. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  15842. @code{pam_limits} module}. The value for this service type is
  15843. a list of @code{pam-limits-entry} values, which can be used to specify
  15844. @code{ulimit} limits and @code{nice} priority limits to user sessions.
  15845. By default, the value is the empty list.
  15846. The following limits definition sets two hard and soft limits for all
  15847. login sessions of users in the @code{realtime} group:
  15848. @lisp
  15849. (service pam-limits-service-type
  15850. (list
  15851. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  15852. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  15853. @end lisp
  15854. The first entry increases the maximum realtime priority for
  15855. non-privileged processes; the second entry lifts any restriction of the
  15856. maximum address space that can be locked in memory. These settings are
  15857. commonly used for real-time audio systems.
  15858. Another useful example is raising the maximum number of open file
  15859. descriptors that can be used:
  15860. @lisp
  15861. (service pam-limits-service-type
  15862. (list
  15863. (pam-limits-entry "*" 'both 'nofile 100000)))
  15864. @end lisp
  15865. In the above example, the asterisk means the limit should apply to any
  15866. user. It is important to ensure the chosen value doesn't exceed the
  15867. maximum system value visible in the @file{/proc/sys/fs/file-max} file,
  15868. else the users would be prevented from login in. For more information
  15869. about the Pluggable Authentication Module (PAM) limits, refer to the
  15870. @samp{pam_limits} man page from the @code{linux-pam} package.
  15871. @end defvar
  15872. @defvar greetd-service-type
  15873. @uref{https://git.sr.ht/~kennylevinsen/greetd, @code{greetd}} is a minimal and
  15874. flexible login manager daemon, that makes no assumptions about what you
  15875. want to launch.
  15876. If you can run it from your shell in a TTY, greetd can start it. If it
  15877. can be taught to speak a simple JSON-based IPC protocol, then it can be
  15878. a geeter.
  15879. @code{greetd-service-type} provides necessary infrastructure for logging
  15880. in users, including:
  15881. @itemize @bullet
  15882. @item
  15883. @code{greetd} PAM service
  15884. @item
  15885. Special variation of @code{pam-mount} to mount @code{XDG_RUNTIME_DIR}
  15886. @end itemize
  15887. Here is example of switching from @code{mingetty-service-type} to
  15888. @code{greetd-service-type}, and how different terminals could be:
  15889. @lisp
  15890. (append
  15891. (modify-services %base-services
  15892. ;; greetd-service-type provides "greetd" PAM service
  15893. (delete login-service-type)
  15894. ;; and can be used in place of mingetty-service-type
  15895. (delete mingetty-service-type))
  15896. (list
  15897. (service greetd-service-type
  15898. (greetd-configuration
  15899. (terminals
  15900. (list
  15901. ;; we can make any terminal active by default
  15902. (greetd-terminal-configuration (terminal-vt "1") (terminal-switch #t))
  15903. ;; we can make environment without XDG_RUNTIME_DIR set
  15904. ;; even provide our own environment variables
  15905. (greetd-terminal-configuration
  15906. (terminal-vt "2")
  15907. (default-session-command
  15908. (greetd-agreety-session
  15909. (extra-env '(("MY_VAR" . "1")))
  15910. (xdg-env? #f))))
  15911. ;; we can use different shell instead of default bash
  15912. (greetd-terminal-configuration
  15913. (terminal-vt "3")
  15914. (default-session-command
  15915. (greetd-agreety-session (command (file-append zsh "/bin/zsh")))))
  15916. ;; we can use any other executable command as greeter
  15917. (greetd-terminal-configuration
  15918. (terminal-vt "4")
  15919. (default-session-command (program-file "my-noop-greeter" #~(exit))))
  15920. (greetd-terminal-configuration (terminal-vt "5"))
  15921. (greetd-terminal-configuration (terminal-vt "6"))))))
  15922. ;; mingetty-service-type can be used in parallel
  15923. ;; if needed to do so, do not (delete login-service-type)
  15924. ;; as illustrated above
  15925. #| (service mingetty-service-type (mingetty-configuration (tty "tty8"))) |#))
  15926. @end lisp
  15927. @end defvar
  15928. @deftp {Data Type} greetd-configuration
  15929. Configuration record for the @code{greetd-service-type}.
  15930. @table @asis
  15931. @item @code{motd}
  15932. A file-like object containing the ``message of the day''.
  15933. @item @code{allow-empty-passwords?} (default: @code{#t})
  15934. Allow empty passwords by default so that first-time users can log in when
  15935. the 'root' account has just been created.
  15936. @item @code{terminals} (default: @code{'()})
  15937. List of @code{greetd-terminal-configuration} per terminal for which
  15938. @code{greetd} should be started.
  15939. @item @code{greeter-supplementary-groups} (default: @code{'()})
  15940. List of groups which should be added to @code{greeter} user. For instance:
  15941. @lisp
  15942. (greeter-supplementary-groups '("seat" "video"))
  15943. @end lisp
  15944. Note that this example will fail if @code{seat} group does not exist.
  15945. @end table
  15946. @end deftp
  15947. @deftp {Data Type} greetd-terminal-configuration
  15948. Configuration record for per terminal greetd daemon service.
  15949. @table @asis
  15950. @item @code{greetd} (default: @code{greetd})
  15951. The greetd package to use.
  15952. @item @code{config-file-name}
  15953. Configuration file name to use for greetd daemon. Generally, autogenerated
  15954. derivation based on @code{terminal-vt} value.
  15955. @item @code{log-file-name}
  15956. Log file name to use for greetd daemon. Generally, autogenerated
  15957. name based on @code{terminal-vt} value.
  15958. @item @code{terminal-vt} (default: @samp{"7"})
  15959. The VT to run on. Use of a specific VT with appropriate conflict avoidance
  15960. is recommended.
  15961. @item @code{terminal-switch} (default: @code{#f})
  15962. Make this terminal active on start of @code{greetd}.
  15963. @item @code{source-profile?} (default: @code{#t})
  15964. Whether to source @file{/etc/profile} and @file{~/.profile}, when they
  15965. exist.
  15966. @item @code{default-session-user} (default: @samp{"greeter"})
  15967. The user to use for running the greeter.
  15968. @item @code{default-session-command} (default: @code{(greetd-agreety-session)})
  15969. Can be either instance of @code{greetd-agreety-session} configuration or
  15970. @code{gexp->script} like object to use as greeter.
  15971. @end table
  15972. @end deftp
  15973. @deftp {Data Type} greetd-agreety-session
  15974. Configuration record for the agreety greetd greeter.
  15975. @table @asis
  15976. @item @code{agreety} (default: @code{greetd})
  15977. The package with @command{/bin/agreety} command.
  15978. @item @code{command} (default: @code{(file-append bash "/bin/bash")})
  15979. Command to be started by @command{/bin/agreety} on successful login.
  15980. @item @code{command-args} (default: @code{'("-l")})
  15981. Command arguments to pass to command.
  15982. @item @code{extra-env} (default: @code{'()})
  15983. Extra environment variables to set on login.
  15984. @item @code{xdg-env?} (default: @code{#t})
  15985. If true @code{XDG_RUNTIME_DIR} and @code{XDG_SESSION_TYPE} will be set
  15986. before starting command. One should note that, @code{extra-env} variables
  15987. are set right after mentioned variables, so that they can be overridden.
  15988. @end table
  15989. @end deftp
  15990. @deftp {Data Type} greetd-wlgreet-session
  15991. Generic configuration record for the wlgreet greetd greeter.
  15992. @table @asis
  15993. @item @code{wlgreet} (default: @code{wlgreet})
  15994. The package with the @command{/bin/wlgreet} command.
  15995. @item @code{command} (default: @code{(file-append sway "/bin/sway")})
  15996. Command to be started by @command{/bin/wlgreet} on successful login.
  15997. @item @code{command-args} (default: @code{'()})
  15998. Command arguments to pass to command.
  15999. @item @code{output-mode} (default: @code{"all"})
  16000. Option to use for @code{outputMode} in the TOML configuration file.
  16001. @item @code{scale} (default: @code{1})
  16002. Option to use for @code{scale} in the TOML configuration file.
  16003. @item @code{background} (default: @code{'(0 0 0 0.9)})
  16004. RGBA list to use as the background colour of the login prompt.
  16005. @item @code{headline} (default: @code{'(1 1 1 1)})
  16006. RGBA list to use as the headline colour of the UI popup.
  16007. @item @code{prompt} (default: @code{'(1 1 1 1)})
  16008. RGBA list to use as the prompt colour of the UI popup.
  16009. @item @code{prompt-error} (default: @code{'(1 1 1 1)})
  16010. RGBA list to use as the error colour of the UI popup.
  16011. @item @code{border} (default: @code{'(1 1 1 1)})
  16012. RGBA list to use as the border colour of the UI popup.
  16013. @item @code{extra-env} (default: @code{'()})
  16014. Extra environment variables to set on login.
  16015. @end table
  16016. @end deftp
  16017. @deftp {Data Type} greetd-wlgreet-sway-session
  16018. Sway-specific configuration record for the wlgreet greetd greeter.
  16019. @table @asis
  16020. @item @code{wlgreet-session} (default: @code{(greetd-wlgreet-session)})
  16021. A @code{greetd-wlgreet-session} record for generic wlgreet configuration,
  16022. on top of the Sway-specific @code{greetd-wlgreet-sway-session}.
  16023. @item @code{sway} (default: @code{sway})
  16024. The package providing the @command{/bin/sway} command.
  16025. @item @code{sway-configuration} (default: #f)
  16026. File-like object providing an additional Sway configuration file to be
  16027. prepended to the mandatory part of the configuration.
  16028. @end table
  16029. Here is an example of a greetd configuration that uses wlgreet and Sway:
  16030. @lisp
  16031. (greetd-configuration
  16032. ;; We need to give the greeter user these permissions, otherwise
  16033. ;; Sway will crash on launch.
  16034. (greeter-supplementary-groups (list "video" "input" "seat"))
  16035. (terminals
  16036. (list (greetd-terminal-configuration
  16037. (terminal-vt "1")
  16038. (terminal-switch #t)
  16039. (default-session-command
  16040. (greetd-wlgreet-sway-session
  16041. (sway-configuration
  16042. (local-file "sway-greetd.conf"))))))))
  16043. @end lisp
  16044. @end deftp
  16045. @node Scheduled Job Execution
  16046. @subsection Scheduled Job Execution
  16047. @cindex cron
  16048. @cindex mcron
  16049. @cindex scheduling jobs
  16050. The @code{(gnu services mcron)} module provides an interface to
  16051. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  16052. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  16053. Unix @command{cron} daemon; the main difference is that it is
  16054. implemented in Guile Scheme, which provides a lot of flexibility when
  16055. specifying the scheduling of jobs and their actions.
  16056. The example below defines an operating system that runs the
  16057. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  16058. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  16059. well as the @command{mkid} command on behalf of an unprivileged user
  16060. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  16061. gexps to introduce job definitions that are passed to mcron
  16062. (@pxref{G-Expressions}).
  16063. @lisp
  16064. (use-modules (guix) (gnu) (gnu services mcron))
  16065. (use-package-modules base idutils)
  16066. (define updatedb-job
  16067. ;; Run 'updatedb' at 3AM every day. Here we write the
  16068. ;; job's action as a Scheme procedure.
  16069. #~(job '(next-hour '(3))
  16070. (lambda ()
  16071. (system* (string-append #$findutils "/bin/updatedb")
  16072. "--prunepaths=/tmp /var/tmp /gnu/store"))
  16073. "updatedb"))
  16074. (define garbage-collector-job
  16075. ;; Collect garbage 5 minutes after midnight every day.
  16076. ;; The job's action is a shell command.
  16077. #~(job "5 0 * * *" ;Vixie cron syntax
  16078. "guix gc -F 1G"))
  16079. (define idutils-job
  16080. ;; Update the index database as user "charlie" at 12:15PM
  16081. ;; and 19:15PM. This runs from the user's home directory.
  16082. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  16083. (string-append #$idutils "/bin/mkid src")
  16084. #:user "charlie"))
  16085. (operating-system
  16086. ;; @dots{}
  16087. ;; %BASE-SERVICES already includes an instance of
  16088. ;; 'mcron-service-type', which we extend with additional
  16089. ;; jobs using 'simple-service'.
  16090. (services (cons (simple-service 'my-cron-jobs
  16091. mcron-service-type
  16092. (list garbage-collector-job
  16093. updatedb-job
  16094. idutils-job))
  16095. %base-services)))
  16096. @end lisp
  16097. @quotation Tip
  16098. When providing the action of a job specification as a procedure, you
  16099. should provide an explicit name for the job via the optional 3rd
  16100. argument as done in the @code{updatedb-job} example above. Otherwise,
  16101. the job would appear as ``Lambda function'' in the output of
  16102. @command{herd schedule mcron}, which is not nearly descriptive enough!
  16103. @end quotation
  16104. @quotation Tip
  16105. Avoid calling the Guile procedures @code{execl}, @code{execle} or
  16106. @code{execlp} inside a job specification, else mcron won't be able to
  16107. output the completion status of the job.
  16108. @end quotation
  16109. For more complex jobs defined in Scheme where you need control over the top
  16110. level, for instance to introduce a @code{use-modules} form, you can move your
  16111. code to a separate program using the @code{program-file} procedure of the
  16112. @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
  16113. illustrates that.
  16114. @lisp
  16115. (define %battery-alert-job
  16116. ;; Beep when the battery percentage falls below %MIN-LEVEL.
  16117. #~(job
  16118. '(next-minute (range 0 60 1))
  16119. #$(program-file
  16120. "battery-alert.scm"
  16121. (with-imported-modules (source-module-closure
  16122. '((guix build utils)))
  16123. #~(begin
  16124. (use-modules (guix build utils)
  16125. (ice-9 popen)
  16126. (ice-9 regex)
  16127. (ice-9 textual-ports)
  16128. (srfi srfi-2))
  16129. (define %min-level 20)
  16130. (setenv "LC_ALL" "C") ;ensure English output
  16131. (and-let* ((input-pipe (open-pipe*
  16132. OPEN_READ
  16133. #$(file-append acpi "/bin/acpi")))
  16134. (output (get-string-all input-pipe))
  16135. (m (string-match "Discharging, ([0-9]+)%" output))
  16136. (level (string->number (match:substring m 1)))
  16137. ((< level %min-level)))
  16138. (format #t "warning: Battery level is low (~a%)~%" level)
  16139. (invoke #$(file-append beep "/bin/beep") "-r5")))))))
  16140. @end lisp
  16141. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  16142. for more information on mcron job specifications. Below is the
  16143. reference of the mcron service.
  16144. On a running system, you can use the @code{schedule} action of the service to
  16145. visualize the mcron jobs that will be executed next:
  16146. @example
  16147. # herd schedule mcron
  16148. @end example
  16149. @noindent
  16150. The example above lists the next five tasks that will be executed, but you can
  16151. also specify the number of tasks to display:
  16152. @example
  16153. # herd schedule mcron 10
  16154. @end example
  16155. @defvar mcron-service-type
  16156. This is the type of the @code{mcron} service, whose value is an
  16157. @code{mcron-configuration} object.
  16158. This service type can be the target of a service extension that provides
  16159. additional job specifications (@pxref{Service Composition}). In other
  16160. words, it is possible to define services that provide additional mcron
  16161. jobs to run.
  16162. @end defvar
  16163. @c Generated via (generate-documentation) at the bottom of (gnu services
  16164. @c mcron).
  16165. @c %start of fragment
  16166. @deftp {Data Type} mcron-configuration
  16167. Available @code{mcron-configuration} fields are:
  16168. @table @asis
  16169. @item @code{mcron} (default: @code{mcron}) (type: file-like)
  16170. The mcron package to use.
  16171. @item @code{jobs} (default: @code{'()}) (type: list-of-gexps)
  16172. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  16173. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  16174. specifications,, mcron,GNU@tie{}mcron}).
  16175. @item @code{log?} (default: @code{#t}) (type: boolean)
  16176. Log messages to standard output.
  16177. @item @code{log-file} (default: @code{"/var/log/mcron.log"}) (type: string)
  16178. Log file location.
  16179. @item @code{log-format} (default: @code{"~1@@*~a ~a: ~a~%"}) (type: string)
  16180. @code{(ice-9 format)} format string for log messages. The default value
  16181. produces messages like @samp{@var{pid} @var{name}: @var{message}}
  16182. (@pxref{Invoking mcron, Invoking,, mcron,GNU@tie{}mcron}). Each message
  16183. is also prefixed by a timestamp by GNU Shepherd.
  16184. @item @code{date-format} (type: maybe-string)
  16185. @code{(srfi srfi-19)} format string for date.
  16186. @end table
  16187. @end deftp
  16188. @c %end of fragment
  16189. @node Log Rotation
  16190. @subsection Log Rotation
  16191. @cindex rottlog
  16192. @cindex log rotation
  16193. @cindex logging
  16194. Log files such as those found in @file{/var/log} tend to grow endlessly,
  16195. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  16196. their contents in separate files, possibly compressed. The @code{(gnu
  16197. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  16198. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  16199. This service is part of @code{%base-services}, and thus enabled by
  16200. default, with the default settings, for commonly encountered log files.
  16201. The example below shows how to extend it with an additional
  16202. @dfn{rotation}, should you need to do that (usually, services that
  16203. produce log files already take care of that):
  16204. @lisp
  16205. (use-modules (guix) (gnu))
  16206. (use-service-modules admin)
  16207. (define my-log-files
  16208. ;; Log files that I want to rotate.
  16209. '("/var/log/something.log" "/var/log/another.log"))
  16210. (operating-system
  16211. ;; @dots{}
  16212. (services (cons (simple-service 'rotate-my-stuff
  16213. rottlog-service-type
  16214. (list (log-rotation
  16215. (frequency 'daily)
  16216. (files my-log-files))))
  16217. %base-services)))
  16218. @end lisp
  16219. @defvar rottlog-service-type
  16220. This is the type of the Rottlog service, whose value is a
  16221. @code{rottlog-configuration} object.
  16222. Other services can extend this one with new @code{log-rotation} objects
  16223. (see below), thereby augmenting the set of files to be rotated.
  16224. This service type can define mcron jobs (@pxref{Scheduled Job
  16225. Execution}) to run the rottlog service.
  16226. @end defvar
  16227. @deftp {Data Type} rottlog-configuration
  16228. Data type representing the configuration of rottlog.
  16229. @table @asis
  16230. @item @code{rottlog} (default: @code{rottlog})
  16231. The Rottlog package to use.
  16232. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  16233. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  16234. rottlog, GNU Rot[t]log Manual}).
  16235. @item @code{rotations} (default: @code{%default-rotations})
  16236. A list of @code{log-rotation} objects as defined below.
  16237. @item @code{jobs}
  16238. This is a list of gexps where each gexp corresponds to an mcron job
  16239. specification (@pxref{Scheduled Job Execution}).
  16240. @end table
  16241. @end deftp
  16242. @deftp {Data Type} log-rotation
  16243. Data type representing the rotation of a group of log files.
  16244. Taking an example from the Rottlog manual (@pxref{Period Related File
  16245. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  16246. defined like this:
  16247. @lisp
  16248. (log-rotation
  16249. (frequency 'daily)
  16250. (files '("/var/log/apache/*"))
  16251. (options '("storedir apache-archives"
  16252. "rotate 6"
  16253. "notifempty"
  16254. "nocompress")))
  16255. @end lisp
  16256. The list of fields is as follows:
  16257. @table @asis
  16258. @item @code{frequency} (default: @code{'weekly})
  16259. The log rotation frequency, a symbol.
  16260. @item @code{files}
  16261. The list of files or file glob patterns to rotate.
  16262. @vindex %default-log-rotation-options
  16263. @item @code{options} (default: @code{%default-log-rotation-options})
  16264. The list of rottlog options for this rotation (@pxref{Configuration
  16265. parameters,,, rottlog, GNU Rot[t]log Manual}).
  16266. @item @code{post-rotate} (default: @code{#f})
  16267. Either @code{#f} or a gexp to execute once the rotation has completed.
  16268. @end table
  16269. @end deftp
  16270. @defvar %default-rotations
  16271. Specifies weekly rotation of @code{%rotated-files} and of
  16272. @file{/var/log/guix-daemon.log}.
  16273. @end defvar
  16274. @defvar %rotated-files
  16275. The list of syslog-controlled files to be rotated. By default it is:
  16276. @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
  16277. "/var/log/maillog")}.
  16278. @end defvar
  16279. Some log files just need to be deleted periodically once they are old,
  16280. without any other criterion and without any archival step. This is the
  16281. case of build logs stored by @command{guix-daemon} under
  16282. @file{/var/log/guix/drvs} (@pxref{Invoking guix-daemon}). The
  16283. @code{log-cleanup} service addresses this use case. For example,
  16284. @code{%base-services} (@pxref{Base Services}) includes the following:
  16285. @lisp
  16286. ;; Periodically delete old build logs.
  16287. (service log-cleanup-service-type
  16288. (log-cleanup-configuration
  16289. (directory "/var/log/guix/drvs")))
  16290. @end lisp
  16291. That ensures build logs do not accumulate endlessly.
  16292. @defvar log-cleanup-service-type
  16293. This is the type of the service to delete old logs. Its value must be a
  16294. @code{log-cleanup-configuration} record as described below.
  16295. @end defvar
  16296. @deftp {Data Type} log-cleanup-configuration
  16297. Data type representing the log cleanup configuration
  16298. @table @asis
  16299. @item @code{directory}
  16300. Name of the directory containing log files.
  16301. @item @code{expiry} (default: @code{(* 6 30 24 3600)})
  16302. Age in seconds after which a file is subject to deletion (six months by
  16303. default).
  16304. @item @code{schedule} (default: @code{"30 12 01,08,15,22 * *"})
  16305. String or gexp denoting the corresponding mcron job schedule
  16306. (@pxref{Scheduled Job Execution}).
  16307. @end table
  16308. @end deftp
  16309. @cindex logging, anonymization
  16310. @subheading Anonip Service
  16311. Anonip is a privacy filter that removes IP address from web server logs.
  16312. This service creates a FIFO and filters any written lines with anonip
  16313. before writing the filtered log to a target file.
  16314. The following example sets up the FIFO
  16315. @file{/var/run/anonip/https.access.log} and writes the filtered log file
  16316. @file{/var/log/anonip/https.access.log}.
  16317. @lisp
  16318. (service anonip-service-type
  16319. (anonip-configuration
  16320. (input "/var/run/anonip/https.access.log")
  16321. (output "/var/log/anonip/https.access.log")))
  16322. @end lisp
  16323. Configure your web server to write its logs to the FIFO at
  16324. @file{/var/run/anonip/https.access.log} and collect the anonymized log
  16325. file at @file{/var/web-logs/https.access.log}.
  16326. @deftp {Data Type} anonip-configuration
  16327. This data type represents the configuration of anonip.
  16328. It has the following parameters:
  16329. @table @asis
  16330. @item @code{anonip} (default: @code{anonip})
  16331. The anonip package to use.
  16332. @item @code{input}
  16333. The file name of the input log file to process. The service creates a
  16334. FIFO of this name. The web server should write its logs to this FIFO.
  16335. @item @code{output}
  16336. The file name of the processed log file.
  16337. @end table
  16338. The following optional settings may be provided:
  16339. @table @asis
  16340. @item @code{skip-private?}
  16341. When @code{#true} do not mask addresses in private ranges.
  16342. @item @code{column}
  16343. A 1-based indexed column number. Assume IP address is in the specified
  16344. column (default is 1).
  16345. @item @code{replacement}
  16346. Replacement string in case address parsing fails, e.g. @code{"0.0.0.0"}.
  16347. @item @code{ipv4mask}
  16348. Number of bits to mask in IPv4 addresses.
  16349. @item @code{ipv6mask}
  16350. Number of bits to mask in IPv6 addresses.
  16351. @item @code{increment}
  16352. Increment the IP address by the given number. By default this is zero.
  16353. @item @code{delimiter}
  16354. Log delimiter string.
  16355. @item @code{regex}
  16356. Regular expression for detecting IP addresses. Use this instead of @code{column}.
  16357. @end table
  16358. @end deftp
  16359. @node Networking Setup
  16360. @subsection Networking Setup
  16361. The @code{(gnu services networking)} module provides services to
  16362. configure network interfaces and set up networking on your machine.
  16363. Those services provide different ways for you to set up your machine: by
  16364. declaring a static network configuration, by running a Dynamic Host
  16365. Configuration Protocol (DHCP) client, or by running daemons such as
  16366. NetworkManager and Connman that automate the whole process,
  16367. automatically adapt to connectivity changes, and provide a high-level
  16368. user interface.
  16369. On a laptop, NetworkManager and Connman are by far the most convenient
  16370. options, which is why the default desktop services include
  16371. NetworkManager (@pxref{Desktop Services, @code{%desktop-services}}).
  16372. For a server, or for a virtual machine or a container, static network
  16373. configuration or a simple DHCP client are often more appropriate.
  16374. This section describes the various network setup services available,
  16375. starting with static network configuration.
  16376. @defvar static-networking-service-type
  16377. This is the type for statically-configured network interfaces. Its
  16378. value must be a list of @code{static-networking} records. Each of them
  16379. declares a set of @dfn{addresses}, @dfn{routes}, and @dfn{links}, as
  16380. shown below.
  16381. @cindex network interface controller (NIC)
  16382. @cindex NIC, networking interface controller
  16383. Here is the simplest configuration, with only one network interface
  16384. controller (NIC) and only IPv4 connectivity:
  16385. @lisp
  16386. ;; Static networking for one NIC, IPv4-only.
  16387. (service static-networking-service-type
  16388. (list (static-networking
  16389. (addresses
  16390. (list (network-address
  16391. (device "eno1")
  16392. (value "10.0.2.15/24"))))
  16393. (routes
  16394. (list (network-route
  16395. (destination "default")
  16396. (gateway "10.0.2.2"))))
  16397. (name-servers '("10.0.2.3")))))
  16398. @end lisp
  16399. The snippet above can be added to the @code{services} field of your
  16400. operating system configuration (@pxref{Using the Configuration System}).
  16401. It will configure your machine to have 10.0.2.15 as its IP address, with
  16402. a 24-bit netmask for the local network---meaning that any 10.0.2.@var{x}
  16403. address is on the local area network (LAN). Traffic to addresses
  16404. outside the local network is routed @i{via} 10.0.2.2. Host names are
  16405. resolved by sending domain name system (DNS) queries to 10.0.2.3.
  16406. @end defvar
  16407. @deftp {Data Type} static-networking
  16408. This is the data type representing a static network configuration.
  16409. As an example, here is how you would declare the configuration of a
  16410. machine with a single network interface controller (NIC) available as
  16411. @code{eno1}, and with one IPv4 and one IPv6 address:
  16412. @lisp
  16413. ;; Network configuration for one NIC, IPv4 + IPv6.
  16414. (static-networking
  16415. (addresses (list (network-address
  16416. (device "eno1")
  16417. (value "10.0.2.15/24"))
  16418. (network-address
  16419. (device "eno1")
  16420. (value "2001:123:4567:101::1/64"))))
  16421. (routes (list (network-route
  16422. (destination "default")
  16423. (gateway "10.0.2.2"))
  16424. (network-route
  16425. (destination "default")
  16426. (gateway "2020:321:4567:42::1"))))
  16427. (name-servers '("10.0.2.3")))
  16428. @end lisp
  16429. If you are familiar with the @command{ip} command of the
  16430. @uref{https://wiki.linuxfoundation.org/networking/iproute2,
  16431. @code{iproute2} package} found on Linux-based systems, the declaration
  16432. above is equivalent to typing:
  16433. @example
  16434. ip address add 10.0.2.15/24 dev eno1
  16435. ip address add 2001:123:4567:101::1/64 dev eno1
  16436. ip route add default via inet 10.0.2.2
  16437. ip route add default via inet6 2020:321:4567:42::1
  16438. @end example
  16439. Run @command{man 8 ip} for more info. Venerable GNU/Linux users will
  16440. certainly know how to do it with @command{ifconfig} and @command{route},
  16441. but we'll spare you that.
  16442. The available fields of this data type are as follows:
  16443. @table @asis
  16444. @item @code{addresses}
  16445. @itemx @code{links} (default: @code{'()})
  16446. @itemx @code{routes} (default: @code{'()})
  16447. The list of @code{network-address}, @code{network-link}, and
  16448. @code{network-route} records for this network (see below).
  16449. @item @code{name-servers} (default: @code{'()})
  16450. The list of IP addresses (strings) of domain name servers. These IP
  16451. addresses go to @file{/etc/resolv.conf}.
  16452. @item @code{provision} (default: @code{'(networking)})
  16453. If true, this should be a list of symbols for the Shepherd service
  16454. corresponding to this network configuration.
  16455. @item @code{requirement} (default @code{'()})
  16456. The list of Shepherd services depended on.
  16457. @end table
  16458. @end deftp
  16459. @deftp {Data Type} network-address
  16460. This is the data type representing the IP address of a network
  16461. interface.
  16462. @table @code
  16463. @item device
  16464. The name of the network interface for this address---e.g.,
  16465. @code{"eno1"}.
  16466. @item value
  16467. The actual IP address and network mask, in
  16468. @uref{https://en.wikipedia.org/wiki/CIDR#CIDR_notation, @acronym{CIDR,
  16469. Classless Inter-Domain Routing} notation}, as a string.
  16470. For example, @code{"10.0.2.15/24"} denotes IPv4 address 10.0.2.15 on a
  16471. 24-bit sub-network---all 10.0.2.@var{x} addresses are on the same local
  16472. network.
  16473. @item ipv6?
  16474. Whether @code{value} denotes an IPv6 address. By default this is
  16475. automatically determined.
  16476. @end table
  16477. @end deftp
  16478. @deftp {Data Type} network-route
  16479. This is the data type representing a network route.
  16480. @table @asis
  16481. @item @code{destination}
  16482. The route destination (a string), either an IP address and network mask
  16483. or @code{"default"} to denote the default route.
  16484. @item @code{source} (default: @code{#f})
  16485. The route source.
  16486. @item @code{device} (default: @code{#f})
  16487. The device used for this route---e.g., @code{"eno2"}.
  16488. @item @code{ipv6?} (default: auto)
  16489. Whether this is an IPv6 route. By default this is automatically
  16490. determined based on @code{destination} or @code{gateway}.
  16491. @item @code{gateway} (default: @code{#f})
  16492. IP address (a string) through which traffic is routed.
  16493. @end table
  16494. @end deftp
  16495. @deftp {Data Type} network-link
  16496. Data type for a network link (@pxref{Link,,, guile-netlink,
  16497. Guile-Netlink Manual}).
  16498. @table @code
  16499. @item name
  16500. The name of the link---e.g., @code{"v0p0"}.
  16501. @item type
  16502. A symbol denoting the type of the link---e.g., @code{'veth}.
  16503. @item arguments
  16504. List of arguments for this type of link.
  16505. @end table
  16506. @end deftp
  16507. @cindex loopback device
  16508. @defvar %loopback-static-networking
  16509. This is the @code{static-networking} record representing the ``loopback
  16510. device'', @code{lo}, for IP addresses 127.0.0.1 and ::1, and providing
  16511. the @code{loopback} Shepherd service.
  16512. @end defvar
  16513. @cindex networking, with QEMU
  16514. @cindex QEMU, networking
  16515. @defvar %qemu-static-networking
  16516. This is the @code{static-networking} record representing network setup
  16517. when using QEMU's user-mode network stack on @code{eth0} (@pxref{Using
  16518. the user mode network stack,,, QEMU, QEMU Documentation}).
  16519. @end defvar
  16520. @cindex DHCP, networking service
  16521. @defvar dhcp-client-service-type
  16522. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  16523. Protocol (DHCP) client.
  16524. @end defvar
  16525. @deftp {Data Type} dhcp-client-configuration
  16526. Data type representing the configuration of the DHCP client service.
  16527. @table @asis
  16528. @item @code{package} (default: @code{isc-dhcp})
  16529. DHCP client package to use.
  16530. @item @code{interfaces} (default: @code{'all})
  16531. Either @code{'all} or the list of interface names that the DHCP client
  16532. should listen on---e.g., @code{'("eno1")}.
  16533. When set to @code{'all}, the DHCP client listens on all the available
  16534. non-loopback interfaces that can be activated. Otherwise the DHCP
  16535. client listens only on the specified interfaces.
  16536. @item @code{shepherd-requirement} (default: @code{'()})
  16537. @itemx @code{shepherd-provision} (default: @code{'(networking)})
  16538. This option can be used to provide a list of symbols naming Shepherd services
  16539. that this service will depend on, such as @code{'wpa-supplicant} or
  16540. @code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet
  16541. networks.
  16542. Likewise, @code{shepherd-provision} is a list of Shepherd service names
  16543. (symbols) provided by this service. You might want to change the
  16544. default value if you intend to run several DHCP clients, only one of
  16545. which provides the @code{networking} Shepherd service.
  16546. @end table
  16547. @end deftp
  16548. @cindex NetworkManager
  16549. @defvar network-manager-service-type
  16550. This is the service type for the
  16551. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  16552. service. The value for this service type is a
  16553. @code{network-manager-configuration} record.
  16554. This service is part of @code{%desktop-services} (@pxref{Desktop
  16555. Services}).
  16556. @end defvar
  16557. @deftp {Data Type} network-manager-configuration
  16558. Data type representing the configuration of NetworkManager.
  16559. @table @asis
  16560. @item @code{network-manager} (default: @code{network-manager})
  16561. The NetworkManager package to use.
  16562. @item @code{shepherd-requirement} (default: @code{'(wpa-supplicant)})
  16563. This option can be used to provide a list of symbols naming Shepherd services
  16564. that this service will depend on, such as @code{'wpa-supplicant} or
  16565. @code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet
  16566. networks.
  16567. @item @code{dns} (default: @code{"default"})
  16568. Processing mode for DNS, which affects how NetworkManager uses the
  16569. @code{resolv.conf} configuration file.
  16570. @table @samp
  16571. @item default
  16572. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  16573. provided by currently active connections.
  16574. @item dnsmasq
  16575. NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
  16576. @dfn{conditional forwarding} configuration if you are connected to a VPN, and
  16577. then update @code{resolv.conf} to point to the local nameserver.
  16578. With this setting, you can share your network connection. For example when
  16579. you want to share your network connection to another laptop @i{via} an
  16580. Ethernet cable, you can open @command{nm-connection-editor} and configure the
  16581. Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
  16582. and reestablish the connection (or reboot).
  16583. You can also set up a @dfn{host-to-guest connection} to QEMU VMs
  16584. (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
  16585. e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
  16586. browser on your host system, or connect to the VM @i{via} SSH
  16587. (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
  16588. host-to-guest connection, run this command once:
  16589. @example
  16590. nmcli connection add type tun \
  16591. connection.interface-name tap0 \
  16592. tun.mode tap tun.owner $(id -u) \
  16593. ipv4.method shared \
  16594. ipv4.addresses 172.28.112.1/24
  16595. @end example
  16596. Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
  16597. @option{-nic tap,ifname=tap0,script=no,downscript=no} to
  16598. @command{qemu-system-...}.
  16599. @item none
  16600. NetworkManager will not modify @code{resolv.conf}.
  16601. @end table
  16602. @item @code{vpn-plugins} (default: @code{'()})
  16603. This is the list of available plugins for virtual private networks
  16604. (VPNs). An example of this is the @code{network-manager-openvpn}
  16605. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  16606. @end table
  16607. @end deftp
  16608. @cindex Connman
  16609. @defvar connman-service-type
  16610. This is the service type to run @url{https://01.org/connman,Connman},
  16611. a network connection manager.
  16612. Its value must be an
  16613. @code{connman-configuration} record as in this example:
  16614. @lisp
  16615. (service connman-service-type
  16616. (connman-configuration
  16617. (disable-vpn? #t)))
  16618. @end lisp
  16619. See below for details about @code{connman-configuration}.
  16620. @end defvar
  16621. @deftp {Data Type} connman-configuration
  16622. Data Type representing the configuration of connman.
  16623. @table @asis
  16624. @item @code{connman} (default: @var{connman})
  16625. The connman package to use.
  16626. @item @code{shepherd-requirement} (default: @code{'()})
  16627. This option can be used to provide a list of symbols naming Shepherd services
  16628. that this service will depend on, such as @code{'wpa-supplicant} or
  16629. @code{'iwd} if you require authenticated access for encrypted WiFi or Ethernet
  16630. networks.
  16631. @item @code{disable-vpn?} (default: @code{#f})
  16632. When true, disable connman's vpn plugin.
  16633. @end table
  16634. @end deftp
  16635. @cindex WPA Supplicant
  16636. @defvar wpa-supplicant-service-type
  16637. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  16638. supplicant}, an authentication daemon required to authenticate against
  16639. encrypted WiFi or ethernet networks.
  16640. @end defvar
  16641. @deftp {Data Type} wpa-supplicant-configuration
  16642. Data type representing the configuration of WPA Supplicant.
  16643. It takes the following parameters:
  16644. @table @asis
  16645. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  16646. The WPA Supplicant package to use.
  16647. @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
  16648. List of services that should be started before WPA Supplicant starts.
  16649. @item @code{dbus?} (default: @code{#t})
  16650. Whether to listen for requests on D-Bus.
  16651. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  16652. Where to store the PID file.
  16653. @item @code{interface} (default: @code{#f})
  16654. If this is set, it must specify the name of a network interface that
  16655. WPA supplicant will control.
  16656. @item @code{config-file} (default: @code{#f})
  16657. Optional configuration file to use.
  16658. @item @code{extra-options} (default: @code{'()})
  16659. List of additional command-line arguments to pass to the daemon.
  16660. @end table
  16661. @end deftp
  16662. @cindex ModemManager
  16663. Some networking devices such as modems require special care, and this is
  16664. what the services below focus on.
  16665. @defvar modem-manager-service-type
  16666. This is the service type for the
  16667. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  16668. service. The value for this service type is a
  16669. @code{modem-manager-configuration} record.
  16670. This service is part of @code{%desktop-services} (@pxref{Desktop
  16671. Services}).
  16672. @end defvar
  16673. @deftp {Data Type} modem-manager-configuration
  16674. Data type representing the configuration of ModemManager.
  16675. @table @asis
  16676. @item @code{modem-manager} (default: @code{modem-manager})
  16677. The ModemManager package to use.
  16678. @end table
  16679. @end deftp
  16680. @cindex USB_ModeSwitch
  16681. @cindex Modeswitching
  16682. @defvar usb-modeswitch-service-type
  16683. This is the service type for the
  16684. @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch}
  16685. service. The value for this service type is
  16686. a @code{usb-modeswitch-configuration} record.
  16687. When plugged in, some USB modems (and other USB devices) initially present
  16688. themselves as a read-only storage medium and not as a modem. They need to be
  16689. @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
  16690. installs udev rules to automatically modeswitch these devices when they are
  16691. plugged in.
  16692. This service is part of @code{%desktop-services} (@pxref{Desktop
  16693. Services}).
  16694. @end defvar
  16695. @deftp {Data Type} usb-modeswitch-configuration
  16696. Data type representing the configuration of USB_ModeSwitch.
  16697. @table @asis
  16698. @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
  16699. The USB_ModeSwitch package providing the binaries for modeswitching.
  16700. @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
  16701. The package providing the device data and udev rules file used by
  16702. USB_ModeSwitch.
  16703. @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
  16704. Which config file to use for the USB_ModeSwitch dispatcher. By default the
  16705. config file shipped with USB_ModeSwitch is used which disables logging to
  16706. @file{/var/log} among other default settings. If set to @code{#f}, no config
  16707. file is used.
  16708. @end table
  16709. @end deftp
  16710. @node Networking Services
  16711. @subsection Networking Services
  16712. The @code{(gnu services networking)} module discussed in the previous
  16713. section provides services for more advanced setups: providing a DHCP
  16714. service for others to use, filtering packets with iptables or nftables,
  16715. running a WiFi access point with @command{hostapd}, running the
  16716. @command{inetd} ``superdaemon'', and more. This section describes
  16717. those.
  16718. @defvar dhcpd-service-type
  16719. This type defines a service that runs a DHCP daemon. To create a
  16720. service of this type, you must supply a @code{<dhcpd-configuration>}.
  16721. For example:
  16722. @lisp
  16723. (service dhcpd-service-type
  16724. (dhcpd-configuration
  16725. (config-file (local-file "my-dhcpd.conf"))
  16726. (interfaces '("enp0s25"))))
  16727. @end lisp
  16728. @end defvar
  16729. @deftp {Data Type} dhcpd-configuration
  16730. @table @asis
  16731. @item @code{package} (default: @code{isc-dhcp})
  16732. The package that provides the DHCP daemon. This package is expected to
  16733. provide the daemon at @file{sbin/dhcpd} relative to its output
  16734. directory. The default package is the
  16735. @uref{https://www.isc.org/dhcp/, ISC's DHCP server}.
  16736. @item @code{config-file} (default: @code{#f})
  16737. The configuration file to use. This is required. It will be passed to
  16738. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  16739. object (@pxref{G-Expressions, file-like objects}). See @code{man
  16740. dhcpd.conf} for details on the configuration file syntax.
  16741. @item @code{version} (default: @code{"4"})
  16742. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  16743. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  16744. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  16745. details.
  16746. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  16747. The run directory to use. At service activation time, this directory
  16748. will be created if it does not exist.
  16749. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  16750. The PID file to use. This corresponds to the @code{-pf} option of
  16751. @code{dhcpd}. See @code{man dhcpd} for details.
  16752. @item @code{interfaces} (default: @code{'()})
  16753. The names of the network interfaces on which dhcpd should listen for
  16754. broadcasts. If this list is not empty, then its elements (which must be
  16755. strings) will be appended to the @code{dhcpd} invocation when starting
  16756. the daemon. It may not be necessary to explicitly specify any
  16757. interfaces here; see @code{man dhcpd} for details.
  16758. @end table
  16759. @end deftp
  16760. @cindex hostapd service, for Wi-Fi access points
  16761. @cindex Wi-Fi access points, hostapd service
  16762. @defvar hostapd-service-type
  16763. This is the service type to run the @uref{https://w1.fi/hostapd/,
  16764. hostapd} daemon to set up WiFi (IEEE 802.11) access points and
  16765. authentication servers. Its associated value must be a
  16766. @code{hostapd-configuration} as shown below:
  16767. @lisp
  16768. ;; Use wlan1 to run the access point for "My Network".
  16769. (service hostapd-service-type
  16770. (hostapd-configuration
  16771. (interface "wlan1")
  16772. (ssid "My Network")
  16773. (channel 12)))
  16774. @end lisp
  16775. @end defvar
  16776. @deftp {Data Type} hostapd-configuration
  16777. This data type represents the configuration of the hostapd service, with
  16778. the following fields:
  16779. @table @asis
  16780. @item @code{package} (default: @code{hostapd})
  16781. The hostapd package to use.
  16782. @item @code{interface} (default: @code{"wlan0"})
  16783. The network interface to run the WiFi access point.
  16784. @item @code{ssid}
  16785. The SSID (@dfn{service set identifier}), a string that identifies this
  16786. network.
  16787. @item @code{broadcast-ssid?} (default: @code{#t})
  16788. Whether to broadcast this SSID.
  16789. @item @code{channel} (default: @code{1})
  16790. The WiFi channel to use.
  16791. @item @code{driver} (default: @code{"nl80211"})
  16792. The driver interface type. @code{"nl80211"} is used with all Linux
  16793. mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
  16794. RADIUS server that does # not control any wireless/wired driver.
  16795. @item @code{extra-settings} (default: @code{""})
  16796. Extra settings to append as-is to the hostapd configuration file. See
  16797. @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
  16798. configuration file reference.
  16799. @end table
  16800. @end deftp
  16801. @defvar simulated-wifi-service-type
  16802. This is the type of a service to simulate WiFi networking, which can be
  16803. useful in virtual machines for testing purposes. The service loads the
  16804. Linux kernel
  16805. @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
  16806. @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
  16807. network that can be seen on @code{wlan0}, by default.
  16808. The service's value is a @code{hostapd-configuration} record.
  16809. @end defvar
  16810. @cindex iptables
  16811. @defvar iptables-service-type
  16812. This is the service type to set up an iptables configuration. iptables is a
  16813. packet filtering framework supported by the Linux kernel. This service
  16814. supports configuring iptables for both IPv4 and IPv6. A simple example
  16815. configuration rejecting all incoming connections except those to the ssh port
  16816. 22 is shown below.
  16817. @lisp
  16818. (service iptables-service-type
  16819. (iptables-configuration
  16820. (ipv4-rules (plain-file "iptables.rules" "*filter
  16821. :INPUT ACCEPT
  16822. :FORWARD ACCEPT
  16823. :OUTPUT ACCEPT
  16824. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  16825. -A INPUT -p tcp --dport 22 -j ACCEPT
  16826. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  16827. COMMIT
  16828. "))
  16829. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  16830. :INPUT ACCEPT
  16831. :FORWARD ACCEPT
  16832. :OUTPUT ACCEPT
  16833. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  16834. -A INPUT -p tcp --dport 22 -j ACCEPT
  16835. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  16836. COMMIT
  16837. "))))
  16838. @end lisp
  16839. @end defvar
  16840. @deftp {Data Type} iptables-configuration
  16841. The data type representing the configuration of iptables.
  16842. @table @asis
  16843. @item @code{iptables} (default: @code{iptables})
  16844. The iptables package that provides @code{iptables-restore} and
  16845. @code{ip6tables-restore}.
  16846. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  16847. The iptables rules to use. It will be passed to @code{iptables-restore}.
  16848. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  16849. objects}).
  16850. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  16851. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  16852. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  16853. objects}).
  16854. @end table
  16855. @end deftp
  16856. @cindex nftables
  16857. @defvar nftables-service-type
  16858. This is the service type to set up a nftables configuration. nftables is a
  16859. netfilter project that aims to replace the existing iptables, ip6tables,
  16860. arptables and ebtables framework. It provides a new packet filtering
  16861. framework, a new user-space utility @command{nft}, and a compatibility layer
  16862. for iptables. This service comes with a default ruleset
  16863. @code{%default-nftables-ruleset} that rejecting all incoming connections
  16864. except those to the ssh port 22. To use it, simply write:
  16865. @lisp
  16866. (service nftables-service-type)
  16867. @end lisp
  16868. @end defvar
  16869. @deftp {Data Type} nftables-configuration
  16870. The data type representing the configuration of nftables.
  16871. @table @asis
  16872. @item @code{package} (default: @code{nftables})
  16873. The nftables package that provides @command{nft}.
  16874. @item @code{ruleset} (default: @code{%default-nftables-ruleset})
  16875. The nftables ruleset to use. This may be any ``file-like'' object
  16876. (@pxref{G-Expressions, file-like objects}).
  16877. @end table
  16878. @end deftp
  16879. @cindex NTP (Network Time Protocol), service
  16880. @cindex ntpd, service for the Network Time Protocol daemon
  16881. @cindex real time clock
  16882. @defvar ntp-service-type
  16883. This is the type of the service running the @uref{https://www.ntp.org,
  16884. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  16885. system clock synchronized with that of the specified NTP servers.
  16886. The value of this service is an @code{ntpd-configuration} object, as described
  16887. below.
  16888. @end defvar
  16889. @deftp {Data Type} ntp-configuration
  16890. This is the data type for the NTP service configuration.
  16891. @table @asis
  16892. @item @code{servers} (default: @code{%ntp-servers})
  16893. This is the list of servers (@code{<ntp-server>} records) with which
  16894. @command{ntpd} will be synchronized. See the @code{ntp-server} data type
  16895. definition below.
  16896. @item @code{allow-large-adjustment?} (default: @code{#t})
  16897. This determines whether @command{ntpd} is allowed to make an initial
  16898. adjustment of more than 1,000 seconds.
  16899. @item @code{ntp} (default: @code{ntp})
  16900. The NTP package to use.
  16901. @end table
  16902. @end deftp
  16903. @defvar %ntp-servers
  16904. List of host names used as the default NTP servers. These are servers of the
  16905. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  16906. @end defvar
  16907. @deftp {Data Type} ntp-server
  16908. The data type representing the configuration of a NTP server.
  16909. @table @asis
  16910. @item @code{type} (default: @code{'server})
  16911. The type of the NTP server, given as a symbol. One of @code{'pool},
  16912. @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
  16913. @item @code{address}
  16914. The address of the server, as a string.
  16915. @item @code{options}
  16916. NTPD options to use with that specific server, given as a list of option names
  16917. and/or of option names and values tuples. The following example define a server
  16918. to use with the options @option{iburst} and @option{prefer}, as well as
  16919. @option{version} 3 and a @option{maxpoll} time of 16 seconds.
  16920. @example
  16921. (ntp-server
  16922. (type 'server)
  16923. (address "some.ntp.server.org")
  16924. (options `(iburst (version 3) (maxpoll 16) prefer))))
  16925. @end example
  16926. @end table
  16927. @end deftp
  16928. @cindex OpenNTPD
  16929. @defvar openntpd-service-type
  16930. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  16931. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  16932. clock synchronized with that of the given servers.
  16933. @lisp
  16934. (service
  16935. openntpd-service-type
  16936. (openntpd-configuration
  16937. (listen-on '("127.0.0.1" "::1"))
  16938. (sensor '("udcf0 correction 70000"))
  16939. (constraint-from '("www.gnu.org"))
  16940. (constraints-from '("https://www.google.com/"))))
  16941. @end lisp
  16942. @end defvar
  16943. @defvar %openntpd-servers
  16944. This variable is a list of the server addresses defined in
  16945. @code{%ntp-servers}.
  16946. @end defvar
  16947. @deftp {Data Type} openntpd-configuration
  16948. @table @asis
  16949. @item @code{openntpd} (default: @code{openntpd})
  16950. The openntpd package to use.
  16951. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  16952. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  16953. @item @code{query-from} (default: @code{'()})
  16954. A list of local IP address the ntpd daemon should use for outgoing queries.
  16955. @item @code{sensor} (default: @code{'()})
  16956. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  16957. will listen to each sensor that actually exists and ignore non-existent ones.
  16958. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  16959. information.
  16960. @item @code{server} (default: @code{'()})
  16961. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  16962. @item @code{servers} (default: @code{%openntp-servers})
  16963. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  16964. @item @code{constraint-from} (default: @code{'()})
  16965. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  16966. This time information is not used for precision but acts as an authenticated
  16967. constraint, thereby reducing the impact of unauthenticated NTP
  16968. man-in-the-middle attacks.
  16969. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  16970. a constraint.
  16971. @item @code{constraints-from} (default: @code{'()})
  16972. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  16973. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  16974. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  16975. @end table
  16976. @end deftp
  16977. @cindex inetd
  16978. @defvar inetd-service-type
  16979. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  16980. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  16981. connections on internet sockets, and lazily starts the specified server
  16982. program when a connection is made on one of these sockets.
  16983. The value of this service is an @code{inetd-configuration} object. The
  16984. following example configures the @command{inetd} daemon to provide the
  16985. built-in @command{echo} service, as well as an smtp service which
  16986. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  16987. gateway @code{hostname}:
  16988. @lisp
  16989. (service
  16990. inetd-service-type
  16991. (inetd-configuration
  16992. (entries (list
  16993. (inetd-entry
  16994. (name "echo")
  16995. (socket-type 'stream)
  16996. (protocol "tcp")
  16997. (wait? #f)
  16998. (user "root"))
  16999. (inetd-entry
  17000. (node "127.0.0.1")
  17001. (name "smtp")
  17002. (socket-type 'stream)
  17003. (protocol "tcp")
  17004. (wait? #f)
  17005. (user "root")
  17006. (program (file-append openssh "/bin/ssh"))
  17007. (arguments
  17008. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  17009. "-W" "smtp-server:25" "user@@hostname")))))))
  17010. @end lisp
  17011. See below for more details about @code{inetd-configuration}.
  17012. @end defvar
  17013. @deftp {Data Type} inetd-configuration
  17014. Data type representing the configuration of @command{inetd}.
  17015. @table @asis
  17016. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  17017. The @command{inetd} executable to use.
  17018. @item @code{entries} (default: @code{'()})
  17019. A list of @command{inetd} service entries. Each entry should be created
  17020. by the @code{inetd-entry} constructor.
  17021. @end table
  17022. @end deftp
  17023. @deftp {Data Type} inetd-entry
  17024. Data type representing an entry in the @command{inetd} configuration.
  17025. Each entry corresponds to a socket where @command{inetd} will listen for
  17026. requests.
  17027. @table @asis
  17028. @item @code{node} (default: @code{#f})
  17029. Optional string, a comma-separated list of local addresses
  17030. @command{inetd} should use when listening for this service.
  17031. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  17032. description of all options.
  17033. @item @code{name}
  17034. A string, the name must correspond to an entry in @code{/etc/services}.
  17035. @item @code{socket-type}
  17036. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  17037. @code{'seqpacket}.
  17038. @item @code{protocol}
  17039. A string, must correspond to an entry in @code{/etc/protocols}.
  17040. @item @code{wait?} (default: @code{#t})
  17041. Whether @command{inetd} should wait for the server to exit before
  17042. listening to new service requests.
  17043. @item @code{user}
  17044. A string containing the user (and, optionally, group) name of the user
  17045. as whom the server should run. The group name can be specified in a
  17046. suffix, separated by a colon or period, i.e.@: @code{"user"},
  17047. @code{"user:group"} or @code{"user.group"}.
  17048. @item @code{program} (default: @code{"internal"})
  17049. The server program which will serve the requests, or @code{"internal"}
  17050. if @command{inetd} should use a built-in service.
  17051. @item @code{arguments} (default: @code{'()})
  17052. A list strings or file-like objects, which are the server program's
  17053. arguments, starting with the zeroth argument, i.e.@: the name of the
  17054. program itself. For @command{inetd}'s internal services, this entry
  17055. must be @code{'()} or @code{'("internal")}.
  17056. @end table
  17057. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  17058. detailed discussion of each configuration field.
  17059. @end deftp
  17060. @cindex opendht, distributed hash table network service
  17061. @cindex dhtproxy, for use with jami
  17062. @defvar opendht-service-type
  17063. This is the type of the service running a @uref{https://opendht.net,
  17064. OpenDHT} node, @command{dhtnode}. The daemon can be used to host your
  17065. own proxy service to the distributed hash table (DHT), for example to
  17066. connect to with Jami, among other applications.
  17067. @quotation Important
  17068. When using the OpenDHT proxy server, the IP addresses it ``sees'' from
  17069. the clients should be addresses reachable from other peers. In practice
  17070. this means that a publicly reachable address is best suited for a proxy
  17071. server, outside of your private network. For example, hosting the proxy
  17072. server on a IPv4 private local network and exposing it via port
  17073. forwarding could work for external peers, but peers local to the proxy
  17074. would have their private addresses shared with the external peers,
  17075. leading to connectivity problems.
  17076. @end quotation
  17077. The value of this service is a @code{opendht-configuration} object, as
  17078. described below.
  17079. @end defvar
  17080. @c The fields documentation has been auto-generated using the
  17081. @c configuration->documentation procedure from
  17082. @c (gnu services configuration).
  17083. @deftp {Data Type} opendht-configuration
  17084. Available @code{opendht-configuration} fields are:
  17085. @table @asis
  17086. @item @code{opendht} (default: @code{opendht}) (type: file-like)
  17087. The @code{opendht} package to use.
  17088. @item @code{peer-discovery?} (default: @code{#f}) (type: boolean)
  17089. Whether to enable the multicast local peer discovery mechanism.
  17090. @item @code{enable-logging?} (default: @code{#f}) (type: boolean)
  17091. Whether to enable logging messages to syslog. It is disabled by default
  17092. as it is rather verbose.
  17093. @item @code{debug?} (default: @code{#f}) (type: boolean)
  17094. Whether to enable debug-level logging messages. This has no effect if
  17095. logging is disabled.
  17096. @item @code{bootstrap-host} (default: @code{"bootstrap.jami.net:4222"}) (type: maybe-string)
  17097. The node host name that is used to make the first connection to the
  17098. network. A specific port value can be provided by appending the
  17099. @code{:PORT} suffix. By default, it uses the Jami bootstrap nodes, but
  17100. any host can be specified here. It's also possible to disable
  17101. bootstrapping by explicitly setting this field to the
  17102. @code{%unset-value} value.
  17103. @item @code{port} (default: @code{4222}) (type: maybe-number)
  17104. The UDP port to bind to. When left unspecified, an available port is
  17105. automatically selected.
  17106. @item @code{proxy-server-port} (type: maybe-number)
  17107. Spawn a proxy server listening on the specified port.
  17108. @item @code{proxy-server-port-tls} (type: maybe-number)
  17109. Spawn a proxy server listening to TLS connections on the specified port.
  17110. @end table
  17111. @end deftp
  17112. @cindex Tor
  17113. @defvar tor-service-type
  17114. Type for a service that runs the @uref{https://torproject.org, Tor}
  17115. anonymous networking daemon. The service is configured using a
  17116. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  17117. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  17118. @cindex onion services, for Tor
  17119. Services of this type can be extended by other services to specify
  17120. @dfn{onion services} (in addition to those already specified in
  17121. @code{tor-configuration}) as in this example:
  17122. @lisp
  17123. (simple-service 'my-extra-onion-service tor-service-type
  17124. (list (tor-onion-service-configuration
  17125. (name "extra-onion-service")
  17126. (mapping '((80 . "127.0.0.1:8080"))))))
  17127. @end lisp
  17128. @end defvar
  17129. @deftp {Data Type} tor-configuration
  17130. @table @asis
  17131. @item @code{tor} (default: @code{tor})
  17132. The package that provides the Tor daemon. This package is expected to provide
  17133. the daemon at @file{bin/tor} relative to its output directory. The default
  17134. package is the @uref{https://www.torproject.org, Tor Project's}
  17135. implementation.
  17136. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  17137. The configuration file to use. It will be appended to a default configuration
  17138. file, and the final configuration file will be passed to @code{tor} via its
  17139. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  17140. file-like objects}). See @code{man tor} for details on the configuration file
  17141. syntax.
  17142. @item @code{hidden-services} (default: @code{'()})
  17143. The list of @code{<tor-onion-service-configuration>} records to use.
  17144. For any onion service you include in this list, appropriate
  17145. configuration to enable the onion service will be automatically added to
  17146. the default configuration file.
  17147. @item @code{socks-socket-type} (default: @code{'tcp})
  17148. The default socket type that Tor should use for its SOCKS socket. This must
  17149. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  17150. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  17151. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  17152. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  17153. @code{tor} group.
  17154. If you want to customize the SOCKS socket in more detail, leave
  17155. @code{socks-socket-type} at its default value of @code{'tcp} and use
  17156. @code{config-file} to override the default by providing your own
  17157. @code{SocksPort} option.
  17158. @item @code{control-socket?} (default: @code{#f})
  17159. Whether or not to provide a ``control socket'' by which Tor can be
  17160. controlled to, for instance, dynamically instantiate tor onion services.
  17161. If @code{#t}, Tor will listen for control commands on the UNIX domain socket
  17162. @file{/var/run/tor/control-sock}, which will be made writable by members of the
  17163. @code{tor} group.
  17164. @end table
  17165. @end deftp
  17166. @cindex onion service, tor
  17167. @deftp {Data Type} tor-onion-service-configuration
  17168. Data Type representing a Tor @dfn{Onion Service} configuration.
  17169. See @url{https://community.torproject.org/onion-services/, the Tor
  17170. project's documentation} for more information.
  17171. Available @code{tor-onion-service-configuration} fields are:
  17172. @table @asis
  17173. @item @code{name} (type: string)
  17174. Name for this Onion Service. This creates a
  17175. @file{/var/lib/tor/hidden-services/@var{name}} directory, where the
  17176. @file{hostname} file contains the @indicateurl{.onion} host name for this Onion
  17177. Service.
  17178. @item @code{mapping} (type: alist)
  17179. Association list of port to address mappings. The following example:
  17180. @lisp
  17181. '((22 . "127.0.0.1:22")
  17182. (80 . "127.0.0.1:8080"))
  17183. @end lisp
  17184. maps ports 22 and 80 of the Onion Service to the local ports 22 and 8080.
  17185. @end table
  17186. @end deftp
  17187. The @code{(gnu services rsync)} module provides the following services:
  17188. You might want an rsync daemon if you have files that you want available
  17189. so anyone (or just yourself) can download existing files or upload new
  17190. files.
  17191. @defvar rsync-service-type
  17192. This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
  17193. The value for this service type is a
  17194. @command{rsync-configuration} record as in this example:
  17195. @lisp
  17196. ;; Export two directories over rsync. By default rsync listens on
  17197. ;; all the network interfaces.
  17198. (service rsync-service-type
  17199. (rsync-configuration
  17200. (modules (list (rsync-module
  17201. (name "music")
  17202. (file-name "/srv/zik")
  17203. (read-only? #f))
  17204. (rsync-module
  17205. (name "movies")
  17206. (file-name "/home/charlie/movies"))))))
  17207. @end lisp
  17208. See below for details about @code{rsync-configuration}.
  17209. @end defvar
  17210. @deftp {Data Type} rsync-configuration
  17211. Data type representing the configuration for @code{rsync-service}.
  17212. @table @asis
  17213. @item @code{package} (default: @var{rsync})
  17214. @code{rsync} package to use.
  17215. @item @code{address} (default: @code{#f})
  17216. IP address on which @command{rsync} listens for incoming connections.
  17217. If unspecified, it defaults to listening on all available addresses.
  17218. @item @code{port-number} (default: @code{873})
  17219. TCP port on which @command{rsync} listens for incoming connections. If port
  17220. is less than @code{1024} @command{rsync} needs to be started as the
  17221. @code{root} user and group.
  17222. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  17223. Name of the file where @command{rsync} writes its PID.
  17224. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  17225. Name of the file where @command{rsync} writes its lock file.
  17226. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  17227. Name of the file where @command{rsync} writes its log file.
  17228. @item @code{user} (default: @code{"root"})
  17229. Owner of the @code{rsync} process.
  17230. @item @code{group} (default: @code{"root"})
  17231. Group of the @code{rsync} process.
  17232. @item @code{uid} (default: @code{"rsyncd"})
  17233. User name or user ID that file transfers to and from that module should take
  17234. place as when the daemon was run as @code{root}.
  17235. @item @code{gid} (default: @code{"rsyncd"})
  17236. Group name or group ID that will be used when accessing the module.
  17237. @item @code{modules} (default: @code{%default-modules})
  17238. List of ``modules''---i.e., directories exported over rsync. Each
  17239. element must be a @code{rsync-module} record, as described below.
  17240. @end table
  17241. @end deftp
  17242. @deftp {Data Type} rsync-module
  17243. This is the data type for rsync ``modules''. A module is a directory
  17244. exported over the rsync protocol. The available fields are as follows:
  17245. @table @asis
  17246. @item @code{name}
  17247. The module name. This is the name that shows up in URLs. For example,
  17248. if the module is called @code{music}, the corresponding URL will be
  17249. @code{rsync://host.example.org/music}.
  17250. @item @code{file-name}
  17251. Name of the directory being exported.
  17252. @item @code{comment} (default: @code{""})
  17253. Comment associated with the module. Client user interfaces may display
  17254. it when they obtain the list of available modules.
  17255. @item @code{read-only?} (default: @code{#t})
  17256. Whether or not client will be able to upload files. If this is false,
  17257. the uploads will be authorized if permissions on the daemon side permit
  17258. it.
  17259. @item @code{chroot?} (default: @code{#t})
  17260. When this is true, the rsync daemon changes root to the module's
  17261. directory before starting file transfers with the client. This improves
  17262. security, but requires rsync to run as root.
  17263. @item @code{timeout} (default: @code{300})
  17264. Idle time in seconds after which the daemon closes a connection with the
  17265. client.
  17266. @end table
  17267. @end deftp
  17268. @cindex Syncthing, file synchronization service
  17269. @cindex backup service, Syncthing
  17270. The @code{(gnu services syncthing)} module provides the following services:
  17271. @cindex syncthing
  17272. You might want a syncthing daemon if you have files between two or more
  17273. computers and want to sync them in real time, safely protected from
  17274. prying eyes.
  17275. @defvar syncthing-service-type
  17276. This is the service type for the @uref{https://syncthing.net/,
  17277. syncthing} daemon, The value for this service type is a
  17278. @command{syncthing-configuration} record as in this example:
  17279. @lisp
  17280. (service syncthing-service-type
  17281. (syncthing-configuration (user "alice")))
  17282. @end lisp
  17283. @quotation Note
  17284. This service is also available for Guix Home, where it runs directly
  17285. with your user privileges (@pxref{Networking Home Services,
  17286. @code{home-syncthing-service-type}}).
  17287. @end quotation
  17288. See below for details about @code{syncthing-configuration}.
  17289. @end defvar
  17290. @deftp {Data Type} syncthing-configuration
  17291. Data type representing the configuration for @code{syncthing-service-type}.
  17292. @table @asis
  17293. @item @code{syncthing} (default: @var{syncthing})
  17294. @code{syncthing} package to use.
  17295. @item @code{arguments} (default: @var{'()})
  17296. List of command-line arguments passing to @code{syncthing} binary.
  17297. @item @code{logflags} (default: @var{0})
  17298. Sum of logging flags, see
  17299. @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}.
  17300. @item @code{user} (default: @var{#f})
  17301. The user as which the Syncthing service is to be run.
  17302. This assumes that the specified user exists.
  17303. @item @code{group} (default: @var{"users"})
  17304. The group as which the Syncthing service is to be run.
  17305. This assumes that the specified group exists.
  17306. @item @code{home} (default: @var{#f})
  17307. Common configuration and data directory. The default configuration
  17308. directory is @file{$HOME} of the specified Syncthing @code{user}.
  17309. @end table
  17310. @end deftp
  17311. Furthermore, @code{(gnu services ssh)} provides the following services.
  17312. @cindex SSH
  17313. @cindex SSH server
  17314. @defvar lsh-service-type
  17315. Type of the service that runs the GNU@tie{}lsh secure shell (SSH)
  17316. daemon, @command{lshd}. The value for this service is a
  17317. @code{<lsh-configuration>} object.
  17318. @end defvar
  17319. @deftp {Data Type} lsh-configuration
  17320. Data type representing the configuration of @command{lshd}.
  17321. @table @asis
  17322. @item @code{lsh} (default: @code{lsh}) (type: file-like)
  17323. The package object of the GNU@tie{}lsh secure shell (SSH) daemon.
  17324. @item @code{daemonic?} (default: @code{#t}) (type: boolean)
  17325. Whether to detach from the controlling terminal.
  17326. @item @code{host-key} (default: @code{"/etc/lsh/host-key"}) (type: string)
  17327. File containing the @dfn{host key}. This file must be readable by
  17328. root only.
  17329. @item @code{interfaces} (default: @code{'()}) (type: list)
  17330. List of host names or addresses that @command{lshd} will listen on.
  17331. If empty, @command{lshd} listens for connections on all the network
  17332. interfaces.
  17333. @item @code{port-number} (default: @code{22}) (type: integer)
  17334. Port to listen on.
  17335. @item @code{allow-empty-passwords?} (default: @code{#f}) (type: boolean)
  17336. Whether to accept log-ins with empty passwords.
  17337. @item @code{root-login?} (default: @code{#f}) (type: boolean)
  17338. Whether to accept log-ins as root.
  17339. @item @code{syslog-output?} (default: @code{#t}) (type: boolean)
  17340. Whether to log @command{lshd} standard output to syslogd.
  17341. This will make the service depend on the existence of a syslogd service.
  17342. @item @code{pid-file?} (default: @code{#f}) (type: boolean)
  17343. When @code{#t}, @command{lshd} writes its PID to the file specified in
  17344. @var{pid-file}.
  17345. @item @code{pid-file} (default: @code{"/var/run/lshd.pid"}) (type: string)
  17346. File that @command{lshd} will write its PID to.
  17347. @item @code{x11-forwarding?} (default: @code{#t}) (type: boolean)
  17348. Whether to enable X11 forwarding.
  17349. @item @code{tcp/ip-forwarding?} (default: @code{#t}) (type: boolean)
  17350. Whether to enable TCP/IP forwarding.
  17351. @item @code{password-authentication?} (default: @code{#t}) (type: boolean)
  17352. Whether to accept log-ins using password authentication.
  17353. @item @code{public-key-authentication?} (default: @code{#t}) (type: boolean)
  17354. Whether to accept log-ins using public key authentication.
  17355. @item @code{initialize?} (default: @code{#t}) (type: boolean)
  17356. When @code{#f}, it is up to the user to initialize the randomness
  17357. generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  17358. a key pair with the private key stored in file @var{host-key}
  17359. (@pxref{lshd basics,,, lsh, LSH Manual}).
  17360. @end table
  17361. @end deftp
  17362. @cindex SSH
  17363. @cindex SSH server
  17364. @defvar openssh-service-type
  17365. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  17366. shell daemon, @command{sshd}. Its value must be an
  17367. @code{openssh-configuration} record as in this example:
  17368. @lisp
  17369. (service openssh-service-type
  17370. (openssh-configuration
  17371. (x11-forwarding? #t)
  17372. (permit-root-login 'prohibit-password)
  17373. (authorized-keys
  17374. `(("alice" ,(local-file "alice.pub"))
  17375. ("bob" ,(local-file "bob.pub"))))))
  17376. @end lisp
  17377. See below for details about @code{openssh-configuration}.
  17378. This service can be extended with extra authorized keys, as in this
  17379. example:
  17380. @lisp
  17381. (service-extension openssh-service-type
  17382. (const `(("charlie"
  17383. ,(local-file "charlie.pub")))))
  17384. @end lisp
  17385. @end defvar
  17386. @deftp {Data Type} openssh-configuration
  17387. This is the configuration record for OpenSSH's @command{sshd}.
  17388. @table @asis
  17389. @item @code{openssh} (default @var{openssh})
  17390. The OpenSSH package to use.
  17391. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  17392. Name of the file where @command{sshd} writes its PID.
  17393. @item @code{port-number} (default: @code{22})
  17394. TCP port on which @command{sshd} listens for incoming connections.
  17395. @item @code{max-connections} (default: @code{200})
  17396. Hard limit on the maximum number of simultaneous client connections,
  17397. enforced by the inetd-style Shepherd service (@pxref{Service De- and
  17398. Constructors, @code{make-inetd-constructor},, shepherd, The GNU Shepherd
  17399. Manual}).
  17400. @item @code{permit-root-login} (default: @code{#f})
  17401. This field determines whether and when to allow logins as root. If
  17402. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  17403. If it's the symbol @code{'prohibit-password}, then root logins are
  17404. permitted but not with password-based authentication.
  17405. @item @code{allow-empty-passwords?} (default: @code{#f})
  17406. When true, users with empty passwords may log in. When false, they may
  17407. not.
  17408. @item @code{password-authentication?} (default: @code{#t})
  17409. When true, users may log in with their password. When false, they have
  17410. other authentication methods.
  17411. @item @code{public-key-authentication?} (default: @code{#t})
  17412. When true, users may log in using public key authentication. When
  17413. false, users have to use other authentication method.
  17414. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  17415. This is used only by protocol version 2.
  17416. @item @code{x11-forwarding?} (default: @code{#f})
  17417. When true, forwarding of X11 graphical client connections is
  17418. enabled---in other words, @command{ssh} options @option{-X} and
  17419. @option{-Y} will work.
  17420. @item @code{allow-agent-forwarding?} (default: @code{#t})
  17421. Whether to allow agent forwarding.
  17422. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  17423. Whether to allow TCP forwarding.
  17424. @item @code{gateway-ports?} (default: @code{#f})
  17425. Whether to allow gateway ports.
  17426. @item @code{challenge-response-authentication?} (default: @code{#f})
  17427. Specifies whether challenge response authentication is allowed (e.g.@: via
  17428. PAM).
  17429. @item @code{use-pam?} (default: @code{#t})
  17430. Enables the Pluggable Authentication Module interface. If set to
  17431. @code{#t}, this will enable PAM authentication using
  17432. @code{challenge-response-authentication?} and
  17433. @code{password-authentication?}, in addition to PAM account and session
  17434. module processing for all authentication types.
  17435. Because PAM challenge response authentication usually serves an
  17436. equivalent role to password authentication, you should disable either
  17437. @code{challenge-response-authentication?} or
  17438. @code{password-authentication?}.
  17439. @item @code{print-last-log?} (default: @code{#t})
  17440. Specifies whether @command{sshd} should print the date and time of the
  17441. last user login when a user logs in interactively.
  17442. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  17443. Configures external subsystems (e.g.@: file transfer daemon).
  17444. This is a list of two-element lists, each of which containing the
  17445. subsystem name and a command (with optional arguments) to execute upon
  17446. subsystem request.
  17447. The command @command{internal-sftp} implements an in-process SFTP
  17448. server. Alternatively, one can specify the @command{sftp-server} command:
  17449. @lisp
  17450. (service openssh-service-type
  17451. (openssh-configuration
  17452. (subsystems
  17453. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  17454. @end lisp
  17455. @item @code{accepted-environment} (default: @code{'()})
  17456. List of strings describing which environment variables may be exported.
  17457. Each string gets on its own line. See the @code{AcceptEnv} option in
  17458. @code{man sshd_config}.
  17459. This example allows ssh-clients to export the @env{COLORTERM} variable.
  17460. It is set by terminal emulators, which support colors. You can use it in
  17461. your shell's resource file to enable colors for the prompt and commands
  17462. if this variable is set.
  17463. @lisp
  17464. (service openssh-service-type
  17465. (openssh-configuration
  17466. (accepted-environment '("COLORTERM"))))
  17467. @end lisp
  17468. @item @code{authorized-keys} (default: @code{'()})
  17469. @cindex authorized keys, SSH
  17470. @cindex SSH authorized keys
  17471. This is the list of authorized keys. Each element of the list is a user
  17472. name followed by one or more file-like objects that represent SSH public
  17473. keys. For example:
  17474. @lisp
  17475. (openssh-configuration
  17476. (authorized-keys
  17477. `(("rekado" ,(local-file "rekado.pub"))
  17478. ("chris" ,(local-file "chris.pub"))
  17479. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  17480. @end lisp
  17481. @noindent
  17482. registers the specified public keys for user accounts @code{rekado},
  17483. @code{chris}, and @code{root}.
  17484. Additional authorized keys can be specified @i{via}
  17485. @code{service-extension}.
  17486. Note that this does @emph{not} interfere with the use of
  17487. @file{~/.ssh/authorized_keys}.
  17488. @item @code{generate-host-keys?} (default: @code{#t})
  17489. Whether to generate host key pairs with @command{ssh-keygen -A} under
  17490. @file{/etc/ssh} if there are none.
  17491. Generating key pairs takes a few seconds when enough entropy is
  17492. available and is only done once. You might want to turn it off for
  17493. instance in a virtual machine that does not need it because host keys
  17494. are provided in some other way, and where the extra boot time is a
  17495. problem.
  17496. @item @code{log-level} (default: @code{'info})
  17497. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  17498. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  17499. page for @file{sshd_config} for the full list of level names.
  17500. @item @code{extra-content} (default: @code{""})
  17501. This field can be used to append arbitrary text to the configuration file. It
  17502. is especially useful for elaborate configurations that cannot be expressed
  17503. otherwise. This configuration, for example, would generally disable root
  17504. logins, but permit them from one specific IP address:
  17505. @lisp
  17506. (openssh-configuration
  17507. (extra-content "\
  17508. Match Address 192.168.0.1
  17509. PermitRootLogin yes"))
  17510. @end lisp
  17511. @end table
  17512. @end deftp
  17513. @defvar dropbear-service-type
  17514. Type of the service that runs the
  17515. @url{https://matt.ucc.asn.au/dropbear/dropbear.html, Dropbear SSH daemon},
  17516. whose value is a @code{<dropbear-configuration>} object.
  17517. For example, to specify a Dropbear service listening on port 1234:
  17518. @lisp
  17519. (service dropbear-service-type (dropbear-configuration
  17520. (port-number 1234)))
  17521. @end lisp
  17522. @end defvar
  17523. @deftp {Data Type} dropbear-configuration
  17524. This data type represents the configuration of a Dropbear SSH daemon.
  17525. @table @asis
  17526. @item @code{dropbear} (default: @var{dropbear})
  17527. The Dropbear package to use.
  17528. @item @code{port-number} (default: 22)
  17529. The TCP port where the daemon waits for incoming connections.
  17530. @item @code{syslog-output?} (default: @code{#t})
  17531. Whether to enable syslog output.
  17532. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  17533. File name of the daemon's PID file.
  17534. @item @code{root-login?} (default: @code{#f})
  17535. Whether to allow @code{root} logins.
  17536. @item @code{allow-empty-passwords?} (default: @code{#f})
  17537. Whether to allow empty passwords.
  17538. @item @code{password-authentication?} (default: @code{#t})
  17539. Whether to enable password-based authentication.
  17540. @end table
  17541. @end deftp
  17542. @cindex AutoSSH
  17543. @defvar autossh-service-type
  17544. This is the type for the @uref{https://www.harding.motd.ca/autossh,
  17545. AutoSSH} program that runs a copy of @command{ssh} and monitors it,
  17546. restarting it as necessary should it die or stop passing traffic.
  17547. AutoSSH can be run manually from the command-line by passing arguments
  17548. to the binary @command{autossh} from the package @code{autossh}, but it
  17549. can also be run as a Guix service. This latter use case is documented
  17550. here.
  17551. AutoSSH can be used to forward local traffic to a remote machine using
  17552. an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
  17553. is run as.
  17554. For example, to specify a service running autossh as the user
  17555. @code{pino} and forwarding all local connections to port @code{8081} to
  17556. @code{remote:8081} using an SSH tunnel, add this call to the operating
  17557. system's @code{services} field:
  17558. @lisp
  17559. (service autossh-service-type
  17560. (autossh-configuration
  17561. (user "pino")
  17562. (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
  17563. @end lisp
  17564. @end defvar
  17565. @deftp {Data Type} autossh-configuration
  17566. This data type represents the configuration of an AutoSSH service.
  17567. @table @asis
  17568. @item @code{user} (default @code{"autossh"})
  17569. The user as which the AutoSSH service is to be run.
  17570. This assumes that the specified user exists.
  17571. @item @code{poll} (default @code{600})
  17572. Specifies the connection poll time in seconds.
  17573. @item @code{first-poll} (default @code{#f})
  17574. Specifies how many seconds AutoSSH waits before the first connection
  17575. test. After this first test, polling is resumed at the pace defined in
  17576. @code{poll}. When set to @code{#f}, the first poll is not treated
  17577. specially and will also use the connection poll specified in
  17578. @code{poll}.
  17579. @item @code{gate-time} (default @code{30})
  17580. Specifies how many seconds an SSH connection must be active before it is
  17581. considered successful.
  17582. @item @code{log-level} (default @code{1})
  17583. The log level, corresponding to the levels used by syslog---so @code{0}
  17584. is the most silent while @code{7} is the chattiest.
  17585. @item @code{max-start} (default @code{#f})
  17586. The maximum number of times SSH may be (re)started before AutoSSH exits.
  17587. When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
  17588. @item @code{message} (default @code{""})
  17589. The message to append to the echo message sent when testing connections.
  17590. @item @code{port} (default @code{"0"})
  17591. The ports used for monitoring the connection. When set to @code{"0"},
  17592. monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
  17593. a positive integer, ports @var{n} and @var{n}+1 are used for
  17594. monitoring the connection, such that port @var{n} is the base
  17595. monitoring port and @code{n+1} is the echo port. When set to
  17596. @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
  17597. integers, the ports @var{n} and @var{m} are used for monitoring the
  17598. connection, such that port @var{n} is the base monitoring port and
  17599. @var{m} is the echo port.
  17600. @item @code{ssh-options} (default @code{'()})
  17601. The list of command-line arguments to pass to @command{ssh} when it is
  17602. run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
  17603. may cause undefined behaviour.
  17604. @end table
  17605. @end deftp
  17606. @cindex WebSSH
  17607. @defvar webssh-service-type
  17608. This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
  17609. program that runs a web SSH client. WebSSH can be run manually from the
  17610. command-line by passing arguments to the binary @command{wssh} from the
  17611. package @code{webssh}, but it can also be run as a Guix service. This
  17612. latter use case is documented here.
  17613. For example, to specify a service running WebSSH on loopback interface
  17614. on port @code{8888} with reject policy with a list of allowed to
  17615. connection hosts, and NGINX as a reverse-proxy to this service listening
  17616. for HTTPS connection, add this call to the operating system's
  17617. @code{services} field:
  17618. @lisp
  17619. (service webssh-service-type
  17620. (webssh-configuration (address "127.0.0.1")
  17621. (port 8888)
  17622. (policy 'reject)
  17623. (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
  17624. "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
  17625. (service nginx-service-type
  17626. (nginx-configuration
  17627. (server-blocks
  17628. (list
  17629. (nginx-server-configuration
  17630. (inherit %webssh-configuration-nginx)
  17631. (server-name '("webssh.example.com"))
  17632. (listen '("443 ssl"))
  17633. (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
  17634. (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
  17635. (locations
  17636. (cons (nginx-location-configuration
  17637. (uri "/.well-known")
  17638. (body '("root /var/www;")))
  17639. (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
  17640. @end lisp
  17641. @end defvar
  17642. @deftp {Data Type} webssh-configuration
  17643. Data type representing the configuration for @code{webssh-service}.
  17644. @table @asis
  17645. @item @code{package} (default: @var{webssh})
  17646. @code{webssh} package to use.
  17647. @item @code{user-name} (default: @var{"webssh"})
  17648. User name or user ID that file transfers to and from that module should take
  17649. place.
  17650. @item @code{group-name} (default: @var{"webssh"})
  17651. Group name or group ID that will be used when accessing the module.
  17652. @item @code{address} (default: @var{#f})
  17653. IP address on which @command{webssh} listens for incoming connections.
  17654. @item @code{port} (default: @var{8888})
  17655. TCP port on which @command{webssh} listens for incoming connections.
  17656. @item @code{policy} (default: @var{#f})
  17657. Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
  17658. @item @code{known-hosts} (default: @var{'()})
  17659. List of hosts which allowed for SSH connection from @command{webssh}.
  17660. @item @code{log-file} (default: @file{"/var/log/webssh.log"})
  17661. Name of the file where @command{webssh} writes its log file.
  17662. @item @code{log-level} (default: @var{#f})
  17663. Logging level.
  17664. @end table
  17665. @end deftp
  17666. @defvar block-facebook-hosts-service-type
  17667. This service type adds a list of known Facebook hosts to the
  17668. @file{/etc/hosts} file.
  17669. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual})
  17670. Each line contains a entry that maps a known server name of the Facebook
  17671. on-line service---e.g., @code{www.facebook.com}---to the local
  17672. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  17673. This mechanism can prevent programs running locally, such as Web
  17674. browsers, from accessing Facebook.
  17675. @end defvar
  17676. The @code{(gnu services avahi)} provides the following definition.
  17677. @defvar avahi-service-type
  17678. This is the service that runs @command{avahi-daemon}, a system-wide
  17679. mDNS/DNS-SD responder that allows for service discovery and
  17680. ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
  17681. Its value must be an @code{avahi-configuration} record---see below.
  17682. This service extends the name service cache daemon (nscd) so that it can
  17683. resolve @code{.local} host names using
  17684. @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
  17685. Service Switch}, for information on host name resolution.
  17686. Additionally, add the @var{avahi} package to the system profile so that
  17687. commands such as @command{avahi-browse} are directly usable.
  17688. @end defvar
  17689. @deftp {Data Type} avahi-configuration
  17690. Data type representation the configuration for Avahi.
  17691. @table @asis
  17692. @item @code{host-name} (default: @code{#f})
  17693. If different from @code{#f}, use that as the host name to
  17694. publish for this machine; otherwise, use the machine's actual host name.
  17695. @item @code{publish?} (default: @code{#t})
  17696. When true, allow host names and services to be published (broadcast) over the
  17697. network.
  17698. @item @code{publish-workstation?} (default: @code{#t})
  17699. When true, @command{avahi-daemon} publishes the machine's host name and IP
  17700. address via mDNS on the local network. To view the host names published on
  17701. your local network, you can run:
  17702. @example
  17703. avahi-browse _workstation._tcp
  17704. @end example
  17705. @item @code{wide-area?} (default: @code{#f})
  17706. When true, DNS-SD over unicast DNS is enabled.
  17707. @item @code{ipv4?} (default: @code{#t})
  17708. @itemx @code{ipv6?} (default: @code{#t})
  17709. These fields determine whether to use IPv4/IPv6 sockets.
  17710. @item @code{domains-to-browse} (default: @code{'()})
  17711. This is a list of domains to browse.
  17712. @end table
  17713. @end deftp
  17714. @defvar openvswitch-service-type
  17715. This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
  17716. service, whose value should be an @code{openvswitch-configuration}
  17717. object.
  17718. @end defvar
  17719. @deftp {Data Type} openvswitch-configuration
  17720. Data type representing the configuration of Open vSwitch, a multilayer
  17721. virtual switch which is designed to enable massive network automation
  17722. through programmatic extension.
  17723. @table @asis
  17724. @item @code{package} (default: @var{openvswitch})
  17725. Package object of the Open vSwitch.
  17726. @end table
  17727. @end deftp
  17728. @defvar pagekite-service-type
  17729. This is the service type for the @uref{https://pagekite.net, PageKite} service,
  17730. a tunneling solution for making localhost servers publicly visible, even from
  17731. behind restrictive firewalls or NAT without forwarded ports. The value for
  17732. this service type is a @code{pagekite-configuration} record.
  17733. Here's an example exposing the local HTTP and SSH daemons:
  17734. @lisp
  17735. (service pagekite-service-type
  17736. (pagekite-configuration
  17737. (kites '("http:@@kitename:localhost:80:@@kitesecret"
  17738. "raw/22:@@kitename:localhost:22:@@kitesecret"))
  17739. (extra-file "/etc/pagekite.rc")))
  17740. @end lisp
  17741. @end defvar
  17742. @deftp {Data Type} pagekite-configuration
  17743. Data type representing the configuration of PageKite.
  17744. @table @asis
  17745. @item @code{package} (default: @var{pagekite})
  17746. Package object of PageKite.
  17747. @item @code{kitename} (default: @code{#f})
  17748. PageKite name for authenticating to the frontend server.
  17749. @item @code{kitesecret} (default: @code{#f})
  17750. Shared secret for authenticating to the frontend server. You should probably
  17751. put this inside @code{extra-file} instead.
  17752. @item @code{frontend} (default: @code{#f})
  17753. Connect to the named PageKite frontend server instead of the
  17754. @uref{https://pagekite.net,,pagekite.net} service.
  17755. @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
  17756. List of service kites to use. Exposes HTTP on port 80 by default. The format
  17757. is @code{proto:kitename:host:port:secret}.
  17758. @item @code{extra-file} (default: @code{#f})
  17759. Extra configuration file to read, which you are expected to create manually.
  17760. Use this to add additional options and manage shared secrets out-of-band.
  17761. @end table
  17762. @end deftp
  17763. @defvar yggdrasil-service-type
  17764. The service type for connecting to the @uref{https://yggdrasil-network.github.io/,
  17765. Yggdrasil network}, an early-stage implementation of a fully end-to-end
  17766. encrypted IPv6 network.
  17767. @quotation
  17768. Yggdrasil provides name-independent routing with cryptographically generated
  17769. addresses. Static addressing means you can keep the same address as long as
  17770. you want, even if you move to a new location, or generate a new address (by
  17771. generating new keys) whenever you want.
  17772. @uref{https://yggdrasil-network.github.io/2018/07/28/addressing.html}
  17773. @end quotation
  17774. Pass it a value of @code{yggdrasil-configuration} to connect it to public
  17775. peers and/or local peers.
  17776. Here is an example using public peers and a static address. The static
  17777. signing and encryption keys are defined in @file{/etc/yggdrasil-private.conf}
  17778. (the default value for @code{config-file}).
  17779. @lisp
  17780. ;; part of the operating-system declaration
  17781. (service yggdrasil-service-type
  17782. (yggdrasil-configuration
  17783. (autoconf? #f) ;; use only the public peers
  17784. (json-config
  17785. ;; choose one from
  17786. ;; https://github.com/yggdrasil-network/public-peers
  17787. '((peers . #("tcp://1.2.3.4:1337"))))
  17788. ;; /etc/yggdrasil-private.conf is the default value for config-file
  17789. ))
  17790. @end lisp
  17791. @example
  17792. # sample content for /etc/yggdrasil-private.conf
  17793. @{
  17794. # Your public key. Your peers may ask you for this to put
  17795. # into their AllowedPublicKeys configuration.
  17796. PublicKey: 64277...
  17797. # Your private key. DO NOT share this with anyone!
  17798. PrivateKey: 5c750...
  17799. @}
  17800. @end example
  17801. @end defvar
  17802. @deftp {Data Type} yggdrasil-configuration
  17803. Data type representing the configuration of Yggdrasil.
  17804. @table @asis
  17805. @item @code{package} (default: @code{yggdrasil})
  17806. Package object of Yggdrasil.
  17807. @item @code{json-config} (default: @code{'()})
  17808. Contents of @file{/etc/yggdrasil.conf}. Will be merged with
  17809. @file{/etc/yggdrasil-private.conf}. Note that these settings are stored in
  17810. the Guix store, which is readable to all users. @strong{Do not store your
  17811. private keys in it}. See the output of @code{yggdrasil -genconf} for a
  17812. quick overview of valid keys and their default values.
  17813. @item @code{autoconf?} (default: @code{#f})
  17814. Whether to use automatic mode. Enabling it makes Yggdrasil use adynamic IP
  17815. and peer with IPv6 neighbors.
  17816. @item @code{log-level} (default: @code{'info})
  17817. How much detail to include in logs. Use @code{'debug} for more detail.
  17818. @item @code{log-to} (default: @code{'stdout})
  17819. Where to send logs. By default, the service logs standard output to
  17820. @file{/var/log/yggdrasil.log}. The alternative is @code{'syslog}, which
  17821. sends output to the running syslog service.
  17822. @item @code{config-file} (default: @code{"/etc/yggdrasil-private.conf"})
  17823. What HJSON file to load sensitive data from. This is where private keys
  17824. should be stored, which are necessary to specify if you don't want a
  17825. randomized address after each restart. Use @code{#f} to disable. Options
  17826. defined in this file take precedence over @code{json-config}. Use the output
  17827. of @code{yggdrasil -genconf} as a starting point. To configure a static
  17828. address, delete everything except these options:
  17829. @itemize
  17830. @item @code{EncryptionPublicKey}
  17831. @item @code{EncryptionPrivateKey}
  17832. @item @code{SigningPublicKey}
  17833. @item @code{SigningPrivateKey}
  17834. @end itemize
  17835. @end table
  17836. @end deftp
  17837. @cindex IPFS
  17838. @defvar ipfs-service-type
  17839. The service type for connecting to the @uref{https://ipfs.io,IPFS network},
  17840. a global, versioned, peer-to-peer file system. Pass it a
  17841. @code{ipfs-configuration} to change the ports used for the gateway and API.
  17842. Here's an example configuration, using some non-standard ports:
  17843. @lisp
  17844. (service ipfs-service-type
  17845. (ipfs-configuration
  17846. (gateway "/ip4/127.0.0.1/tcp/8880")
  17847. (api "/ip4/127.0.0.1/tcp/8881")))
  17848. @end lisp
  17849. @end defvar
  17850. @deftp {Data Type} ipfs-configuration
  17851. Data type representing the configuration of IPFS.
  17852. @table @asis
  17853. @item @code{package} (default: @code{go-ipfs})
  17854. Package object of IPFS.
  17855. @item @code{gateway} (default: @code{"/ip4/127.0.0.1/tcp/8082"})
  17856. Address of the gateway, in ‘multiaddress’ format.
  17857. @item @code{api} (default: @code{"/ip4/127.0.0.1/tcp/5001"})
  17858. Address of the API endpoint, in ‘multiaddress’ format.
  17859. @end table
  17860. @end deftp
  17861. @cindex keepalived
  17862. @defvar keepalived-service-type
  17863. This is the type for the @uref{https://www.keepalived.org/, Keepalived}
  17864. routing software, @command{keepalived}. Its value must be an
  17865. @code{keepalived-configuration} record as in this example for master
  17866. machine:
  17867. @lisp
  17868. (service keepalived-service-type
  17869. (keepalived-configuration
  17870. (config-file (local-file "keepalived-master.conf"))))
  17871. @end lisp
  17872. where @file{keepalived-master.conf}:
  17873. @example
  17874. vrrp_instance my-group @{
  17875. state MASTER
  17876. interface enp9s0
  17877. virtual_router_id 100
  17878. priority 100
  17879. unicast_peer @{ 10.0.0.2 @}
  17880. virtual_ipaddress @{
  17881. 10.0.0.4/24
  17882. @}
  17883. @}
  17884. @end example
  17885. and for backup machine:
  17886. @lisp
  17887. (service keepalived-service-type
  17888. (keepalived-configuration
  17889. (config-file (local-file "keepalived-backup.conf"))))
  17890. @end lisp
  17891. where @file{keepalived-backup.conf}:
  17892. @example
  17893. vrrp_instance my-group @{
  17894. state BACKUP
  17895. interface enp9s0
  17896. virtual_router_id 100
  17897. priority 99
  17898. unicast_peer @{ 10.0.0.3 @}
  17899. virtual_ipaddress @{
  17900. 10.0.0.4/24
  17901. @}
  17902. @}
  17903. @end example
  17904. @end defvar
  17905. @node Unattended Upgrades
  17906. @subsection Unattended Upgrades
  17907. @cindex unattended upgrades
  17908. @cindex upgrades, unattended
  17909. Guix provides a service to perform @emph{unattended upgrades}:
  17910. periodically, the system automatically reconfigures itself from the
  17911. latest Guix. Guix System has several properties that make unattended
  17912. upgrades safe:
  17913. @itemize
  17914. @item
  17915. upgrades are transactional (either the upgrade succeeds or it fails, but
  17916. you cannot end up with an ``in-between'' system state);
  17917. @item
  17918. the upgrade log is kept---you can view it with @command{guix system
  17919. list-generations}---and you can roll back to any previous generation,
  17920. should the upgraded system fail to behave as intended;
  17921. @item
  17922. channel code is authenticated so you know you can only run genuine code
  17923. (@pxref{Channels});
  17924. @item
  17925. @command{guix system reconfigure} prevents downgrades, which makes it
  17926. immune to @dfn{downgrade attacks}.
  17927. @end itemize
  17928. To set up unattended upgrades, add an instance of
  17929. @code{unattended-upgrade-service-type} like the one below to the list of
  17930. your operating system services:
  17931. @lisp
  17932. (service unattended-upgrade-service-type)
  17933. @end lisp
  17934. The defaults above set up weekly upgrades: every Sunday at midnight.
  17935. You do not need to provide the operating system configuration file: it
  17936. uses @file{/run/current-system/configuration.scm}, which ensures it
  17937. always uses your latest configuration---@pxref{provenance-service-type},
  17938. for more information about this file.
  17939. There are several things that can be configured, in particular the
  17940. periodicity and services (daemons) to be restarted upon completion.
  17941. When the upgrade is successful, the service takes care of deleting
  17942. system generations older that some threshold, as per @command{guix
  17943. system delete-generations}. See the reference below for details.
  17944. To ensure that upgrades are actually happening, you can run
  17945. @command{guix system describe}. To investigate upgrade failures, visit
  17946. the unattended upgrade log file (see below).
  17947. @defvar unattended-upgrade-service-type
  17948. This is the service type for unattended upgrades. It sets up an mcron
  17949. job (@pxref{Scheduled Job Execution}) that runs @command{guix system
  17950. reconfigure} from the latest version of the specified channels.
  17951. Its value must be a @code{unattended-upgrade-configuration} record (see
  17952. below).
  17953. @end defvar
  17954. @deftp {Data Type} unattended-upgrade-configuration
  17955. This data type represents the configuration of the unattended upgrade
  17956. service. The following fields are available:
  17957. @table @asis
  17958. @item @code{schedule} (default: @code{"30 01 * * 0"})
  17959. This is the schedule of upgrades, expressed as a gexp containing an
  17960. mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
  17961. mcron, GNU@tie{}mcron}).
  17962. @item @code{channels} (default: @code{#~%default-channels})
  17963. This gexp specifies the channels to use for the upgrade
  17964. (@pxref{Channels}). By default, the tip of the official @code{guix}
  17965. channel is used.
  17966. @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
  17967. This field specifies the operating system configuration file to use.
  17968. The default is to reuse the config file of the current configuration.
  17969. There are cases, though, where referring to
  17970. @file{/run/current-system/configuration.scm} is not enough, for instance
  17971. because that file refers to extra files (SSH public keys, extra
  17972. configuration files, etc.) @i{via} @code{local-file} and similar
  17973. constructs. For those cases, we recommend something along these lines:
  17974. @lisp
  17975. (unattended-upgrade-configuration
  17976. (operating-system-file
  17977. (file-append (local-file "." "config-dir" #:recursive? #t)
  17978. "/config.scm")))
  17979. @end lisp
  17980. The effect here is to import all of the current directory into the
  17981. store, and to refer to @file{config.scm} within that directory.
  17982. Therefore, uses of @code{local-file} within @file{config.scm} will work
  17983. as expected. @xref{G-Expressions}, for information about
  17984. @code{local-file} and @code{file-append}.
  17985. @item @code{operating-system-expression} (default: @code{#f})
  17986. This field specifies an expression that evaluates to the operating
  17987. system to use for the upgrade. If no value is provided the
  17988. @code{operating-system-file} field value is used.
  17989. @lisp
  17990. (unattended-upgrade-configuration
  17991. (operating-system-expression
  17992. #~(@@ (guix system install) installation-os)))
  17993. @end lisp
  17994. @item @code{services-to-restart} (default: @code{'(mcron)})
  17995. This field specifies the Shepherd services to restart when the upgrade
  17996. completes.
  17997. Those services are restarted right away upon completion, as with
  17998. @command{herd restart}, which ensures that the latest version is
  17999. running---remember that by default @command{guix system reconfigure}
  18000. only restarts services that are not currently running, which is
  18001. conservative: it minimizes disruption but leaves outdated services
  18002. running.
  18003. Use @command{herd status} to find out candidates for restarting.
  18004. @xref{Services}, for general information about services. Common
  18005. services to restart would include @code{ntpd} and @code{ssh-daemon}.
  18006. By default, the @code{mcron} service is restarted. This ensures that
  18007. the latest version of the unattended upgrade job will be used next time.
  18008. @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
  18009. This is the expiration time in seconds for system generations. System
  18010. generations older that this amount of time are deleted with
  18011. @command{guix system delete-generations} when an upgrade completes.
  18012. @quotation Note
  18013. The unattended upgrade service does not run the garbage collector. You
  18014. will probably want to set up your own mcron job to run @command{guix gc}
  18015. periodically.
  18016. @end quotation
  18017. @item @code{maximum-duration} (default: @code{3600})
  18018. Maximum duration in seconds for the upgrade; past that time, the upgrade
  18019. aborts.
  18020. This is primarily useful to ensure the upgrade does not end up
  18021. rebuilding or re-downloading ``the world''.
  18022. @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
  18023. File where unattended upgrades are logged.
  18024. @end table
  18025. @end deftp
  18026. @node X Window
  18027. @subsection X Window
  18028. @cindex X11
  18029. @cindex X Window System
  18030. @cindex login manager
  18031. Support for the X Window graphical display system---specifically
  18032. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  18033. there is no @code{xorg-service} procedure. Instead, the X server is
  18034. started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
  18035. @cindex GDM
  18036. @cindex GNOME, login manager
  18037. @anchor{gdm}
  18038. GDM of course allows users to log in into window managers and desktop
  18039. environments other than GNOME; for those using GNOME, GDM is required for
  18040. features such as automatic screen locking.
  18041. @cindex window manager
  18042. To use X11, you must install at least one @dfn{window manager}---for
  18043. example the @code{windowmaker} or @code{openbox} packages---preferably
  18044. by adding it to the @code{packages} field of your operating system
  18045. definition (@pxref{operating-system Reference, system-wide packages}).
  18046. @anchor{wayland-gdm}
  18047. GDM also supports Wayland: it can itself use Wayland instead of X11 for
  18048. its user interface, and it can also start Wayland sessions. The former is
  18049. required for the latter, to enable, set @code{wayland?} to @code{#t} in
  18050. @code{gdm-configuration}.
  18051. @defvar gdm-service-type
  18052. This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
  18053. Desktop Manager} (GDM), a program that manages graphical display servers and
  18054. handles graphical user logins. Its value must be a @code{gdm-configuration}
  18055. (see below).
  18056. @cindex session types
  18057. GDM looks for @dfn{session types} described by the @file{.desktop} files in
  18058. @file{/run/current-system/profile/share/xsessions} (for X11 sessions) and
  18059. @file{/run/current-system/profile/share/wayland-sessions} (for Wayland
  18060. sessions) and allows users to choose a session from the log-in screen.
  18061. Packages such as @code{gnome}, @code{xfce}, @code{i3} and @code{sway} provide
  18062. @file{.desktop} files; adding them to the system-wide set of packages
  18063. automatically makes them available at the log-in screen.
  18064. In addition, @file{~/.xsession} files are honored. When available,
  18065. @file{~/.xsession} must be an executable that starts a window manager
  18066. and/or other X clients.
  18067. @end defvar
  18068. @deftp {Data Type} gdm-configuration
  18069. @table @asis
  18070. @item @code{auto-login?} (default: @code{#f})
  18071. @itemx @code{default-user} (default: @code{#f})
  18072. When @code{auto-login?} is false, GDM presents a log-in screen.
  18073. When @code{auto-login?} is true, GDM logs in directly as
  18074. @code{default-user}.
  18075. @item @code{auto-suspend?} (default @code{#t})
  18076. When true, GDM will automatically suspend to RAM when nobody is
  18077. physically connected. When a machine is used via remote desktop or SSH,
  18078. this should be set to false to avoid GDM interrupting remote sessions or
  18079. rendering the machine unavailable.
  18080. @item @code{debug?} (default: @code{#f})
  18081. When true, GDM writes debug messages to its log.
  18082. @item @code{gnome-shell-assets} (default: ...)
  18083. List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
  18084. @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
  18085. Configuration of the Xorg graphical server.
  18086. @item @code{x-session} (default: @code{(xinitrc)})
  18087. Script to run before starting a X session.
  18088. @item @code{xdmcp?} (default: @code{#f})
  18089. When true, enable the X Display Manager Control Protocol (XDMCP). This
  18090. should only be enabled in trusted environments, as the protocol is not
  18091. secure. When enabled, GDM listens for XDMCP queries on the UDP port
  18092. 177.
  18093. @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
  18094. File name of the @code{dbus-daemon} executable.
  18095. @item @code{gdm} (default: @code{gdm})
  18096. The GDM package to use.
  18097. @item @code{wayland?} (default: @code{#f})
  18098. When true, enables Wayland in GDM, necessary to use Wayland sessions.
  18099. @item @code{wayland-session} (default: @code{gdm-wayland-session-wrapper})
  18100. The Wayland session wrapper to use, needed to setup the
  18101. environment.
  18102. @end table
  18103. @end deftp
  18104. @defvar slim-service-type
  18105. This is the type for the SLiM graphical login manager for X11.
  18106. Like GDM, SLiM looks for session types described by @file{.desktop} files and
  18107. allows users to choose a session from the log-in screen using @kbd{F1}. It
  18108. also honors @file{~/.xsession} files.
  18109. Unlike GDM, SLiM does not spawn the user session on a different VT after
  18110. logging in, which means that you can only start one graphical session. If you
  18111. want to be able to run multiple graphical sessions at the same time you have
  18112. to add multiple SLiM services to your system services. The following example
  18113. shows how to replace the default GDM service with two SLiM services on tty7
  18114. and tty8.
  18115. @lisp
  18116. (use-modules (gnu services)
  18117. (gnu services desktop)
  18118. (gnu services xorg))
  18119. (operating-system
  18120. ;; ...
  18121. (services (cons* (service slim-service-type (slim-configuration
  18122. (display ":0")
  18123. (vt "vt7")))
  18124. (service slim-service-type (slim-configuration
  18125. (display ":1")
  18126. (vt "vt8")))
  18127. (modify-services %desktop-services
  18128. (delete gdm-service-type)))))
  18129. @end lisp
  18130. @end defvar
  18131. @deftp {Data Type} slim-configuration
  18132. Data type representing the configuration of @code{slim-service-type}.
  18133. @table @asis
  18134. @item @code{allow-empty-passwords?} (default: @code{#t})
  18135. Whether to allow logins with empty passwords.
  18136. @item @code{gnupg?} (default: @code{#f})
  18137. If enabled, @code{pam-gnupg} will attempt to automatically unlock the
  18138. user's GPG keys with the login password via @code{gpg-agent}. The
  18139. keygrips of all keys to be unlocked should be written to
  18140. @file{~/.pam-gnupg}, and can be queried with @code{gpg -K
  18141. --with-keygrip}. Presetting passphrases must be enabled by adding
  18142. @code{allow-preset-passphrase} in @file{~/.gnupg/gpg-agent.conf}.
  18143. @item @code{auto-login?} (default: @code{#f})
  18144. @itemx @code{default-user} (default: @code{""})
  18145. When @code{auto-login?} is false, SLiM presents a log-in screen.
  18146. When @code{auto-login?} is true, SLiM logs in directly as
  18147. @code{default-user}.
  18148. @item @code{theme} (default: @code{%default-slim-theme})
  18149. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  18150. The graphical theme to use and its name.
  18151. @item @code{auto-login-session} (default: @code{#f})
  18152. If true, this must be the name of the executable to start as the default
  18153. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  18154. If false, a session described by one of the available @file{.desktop}
  18155. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  18156. will be used.
  18157. @quotation Note
  18158. You must install at least one window manager in the system profile or in
  18159. your user profile. Failing to do that, if @code{auto-login-session} is
  18160. false, you will be unable to log in.
  18161. @end quotation
  18162. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  18163. Configuration of the Xorg graphical server.
  18164. @item @code{display} (default @code{":0"})
  18165. The display on which to start the Xorg graphical server.
  18166. @item @code{vt} (default @code{"vt7"})
  18167. The VT on which to start the Xorg graphical server.
  18168. @item @code{xauth} (default: @code{xauth})
  18169. The XAuth package to use.
  18170. @item @code{shepherd} (default: @code{shepherd})
  18171. The Shepherd package used when invoking @command{halt} and
  18172. @command{reboot}.
  18173. @item @code{sessreg} (default: @code{sessreg})
  18174. The sessreg package used in order to register the session.
  18175. @item @code{slim} (default: @code{slim})
  18176. The SLiM package to use.
  18177. @end table
  18178. @end deftp
  18179. @defvar %default-theme
  18180. @defvarx %default-theme-name
  18181. The default SLiM theme and its name.
  18182. @end defvar
  18183. @cindex login manager
  18184. @cindex X11 login
  18185. @defvar sddm-service-type
  18186. This is the type of the service to run the
  18187. @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
  18188. must be a @code{sddm-configuration} record (see below).
  18189. Here's an example use:
  18190. @lisp
  18191. (service sddm-service-type
  18192. (sddm-configuration
  18193. (auto-login-user "alice")
  18194. (auto-login-session "xfce.desktop")))
  18195. @end lisp
  18196. @end defvar
  18197. @deftp {Data Type} sddm-configuration
  18198. This data type represents the configuration of the SDDM login manager.
  18199. The available fields are:
  18200. @table @asis
  18201. @item @code{sddm} (default: @code{sddm})
  18202. The SDDM package to use.
  18203. @item @code{display-server} (default: "x11")
  18204. Select display server to use for the greeter. Valid values are
  18205. @samp{"x11"} or @samp{"wayland"}.
  18206. @item @code{numlock} (default: "on")
  18207. Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
  18208. @item @code{halt-command} (default @code{#~(string-append #$shepherd "/sbin/halt")})
  18209. Command to run when halting.
  18210. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  18211. Command to run when rebooting.
  18212. @item @code{theme} (default "maldives")
  18213. Theme to use. Default themes provided by SDDM are @samp{"elarun"},
  18214. @samp{"maldives"} or @samp{"maya"}.
  18215. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  18216. Directory to look for themes.
  18217. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  18218. Directory to look for faces.
  18219. @item @code{default-path} (default "/run/current-system/profile/bin")
  18220. Default PATH to use.
  18221. @item @code{minimum-uid} (default: 1000)
  18222. Minimum UID displayed in SDDM and allowed for log-in.
  18223. @item @code{maximum-uid} (default: 2000)
  18224. Maximum UID to display in SDDM.
  18225. @item @code{remember-last-user?} (default #t)
  18226. Remember last user.
  18227. @item @code{remember-last-session?} (default #t)
  18228. Remember last session.
  18229. @item @code{hide-users} (default "")
  18230. Usernames to hide from SDDM greeter.
  18231. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  18232. Users with shells listed will be hidden from the SDDM greeter.
  18233. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  18234. Script to run before starting a wayland session.
  18235. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  18236. Directory to look for desktop files starting wayland sessions.
  18237. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  18238. Configuration of the Xorg graphical server.
  18239. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  18240. Path to xauth.
  18241. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  18242. Path to Xephyr.
  18243. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  18244. Script to run after starting xorg-server.
  18245. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  18246. Script to run before stopping xorg-server.
  18247. @item @code{xsession-command} (default: @code{xinitrc})
  18248. Script to run before starting a X session.
  18249. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  18250. Directory to look for desktop files starting X sessions.
  18251. @item @code{minimum-vt} (default: 7)
  18252. Minimum VT to use.
  18253. @item @code{auto-login-user} (default "")
  18254. User account that will be automatically logged in.
  18255. Setting this to the empty string disables auto-login.
  18256. @item @code{auto-login-session} (default "")
  18257. The @file{.desktop} file name to use as the auto-login session, or the empty string.
  18258. @item @code{relogin?} (default #f)
  18259. Relogin after logout.
  18260. @end table
  18261. @end deftp
  18262. @cindex lightdm, graphical login manager
  18263. @cindex display manager, lightdm
  18264. @anchor{lightdm}
  18265. @defvar lightdm-service-type
  18266. This is the type of the service to run the
  18267. @url{https://github.com/canonical/lightdm,LightDM display manager}. Its
  18268. value must be a @code{lightdm-configuration} record, which is documented
  18269. below. Among its distinguishing features are TigerVNC integration for
  18270. easily remoting your desktop as well as support for the XDMCP protocol,
  18271. which can be used by remote clients to start a session from the login
  18272. manager.
  18273. In its most basic form, it can be used simply as:
  18274. @lisp
  18275. (service lightdm-service-type)
  18276. @end lisp
  18277. A more elaborate example making use of the VNC capabilities and enabling
  18278. more features and verbose logs could look like:
  18279. @lisp
  18280. (service lightdm-service-type
  18281. (lightdm-configuration
  18282. (allow-empty-passwords? #t)
  18283. (xdmcp? #t)
  18284. (vnc-server? #t)
  18285. (vnc-server-command
  18286. (file-append tigervnc-server "/bin/Xvnc"
  18287. " -SecurityTypes None"))
  18288. (seats
  18289. (list (lightdm-seat-configuration
  18290. (name "*")
  18291. (user-session "ratpoison"))))))
  18292. @end lisp
  18293. @end defvar
  18294. @c The LightDM service documentation can be auto-generated via the
  18295. @c 'generate-doc' procedure at the bottom of the (gnu services lightdm)
  18296. @c module.
  18297. @c %start of fragment
  18298. @deftp {Data Type} lightdm-configuration
  18299. Available @code{lightdm-configuration} fields are:
  18300. @table @asis
  18301. @item @code{lightdm} (default: @code{lightdm}) (type: file-like)
  18302. The lightdm package to use.
  18303. @item @code{allow-empty-passwords?} (default: @code{#f}) (type: boolean)
  18304. Whether users not having a password set can login.
  18305. @item @code{debug?} (default: @code{#f}) (type: boolean)
  18306. Enable verbose output.
  18307. @item @code{xorg-configuration} (type: xorg-configuration)
  18308. The default Xorg server configuration to use to generate the Xorg server
  18309. start script. It can be refined per seat via the @code{xserver-command}
  18310. of the @code{<lightdm-seat-configuration>} record, if desired.
  18311. @item @code{greeters} (type: list-of-greeter-configurations)
  18312. The LightDM greeter configurations specifying the greeters to use.
  18313. @item @code{seats} (type: list-of-seat-configurations)
  18314. The seat configurations to use. A LightDM seat is akin to a user.
  18315. @item @code{xdmcp?} (default: @code{#f}) (type: boolean)
  18316. Whether a XDMCP server should listen on port UDP 177.
  18317. @item @code{xdmcp-listen-address} (type: maybe-string)
  18318. The host or IP address the XDMCP server listens for incoming
  18319. connections. When unspecified, listen on for any hosts/IP addresses.
  18320. @item @code{vnc-server?} (default: @code{#f}) (type: boolean)
  18321. Whether a VNC server is started.
  18322. @item @code{vnc-server-command} (type: file-like)
  18323. The Xvnc command to use for the VNC server, it's possible to provide
  18324. extra options not otherwise exposed along the command, for example to
  18325. disable security:
  18326. @lisp
  18327. (vnc-server-command (file-append tigervnc-server "/bin/Xvnc"
  18328. " -SecurityTypes None" ))
  18329. @end lisp
  18330. Or to set a PasswordFile for the classic (unsecure) VncAuth
  18331. mechanism:
  18332. @lisp
  18333. (vnc-server-command (file-append tigervnc-server "/bin/Xvnc"
  18334. " -PasswordFile /var/lib/lightdm/.vnc/passwd"))
  18335. @end lisp
  18336. The password file should be manually created using the
  18337. @command{vncpasswd} command. Note that LightDM will create new sessions
  18338. for VNC users, which means they need to authenticate in the same way as
  18339. local users would.
  18340. @item @code{vnc-server-listen-address} (type: maybe-string)
  18341. The host or IP address the VNC server listens for incoming connections.
  18342. When unspecified, listen for any hosts/IP addresses.
  18343. @item @code{vnc-server-port} (default: @code{5900}) (type: number)
  18344. The TCP port the VNC server should listen to.
  18345. @item @code{extra-config} (default: @code{'()}) (type: list-of-strings)
  18346. Extra configuration values to append to the LightDM configuration file.
  18347. @end table
  18348. @end deftp
  18349. @c %end of fragment
  18350. @c %start of fragment
  18351. @deftp {Data Type} lightdm-gtk-greeter-configuration
  18352. Available @code{lightdm-gtk-greeter-configuration} fields are:
  18353. @table @asis
  18354. @item @code{lightdm-gtk-greeter} (default: @code{lightdm-gtk-greeter}) (type: file-like)
  18355. The lightdm-gtk-greeter package to use.
  18356. @item @code{assets} (default: @code{(adwaita-icon-theme gnome-themes-extra hicolor-icon-theme)}) (type: list-of-file-likes)
  18357. The list of packages complementing the greeter, such as package
  18358. providing icon themes.
  18359. @item @code{theme-name} (default: @code{"Adwaita"}) (type: string)
  18360. The name of the theme to use.
  18361. @item @code{icon-theme-name} (default: @code{"Adwaita"}) (type: string)
  18362. The name of the icon theme to use.
  18363. @item @code{cursor-theme-name} (default: @code{"Adwaita"}) (type: string)
  18364. The name of the cursor theme to use.
  18365. @item @code{cursor-theme-size} (default: @code{16}) (type: number)
  18366. The size to use for the cursor theme.
  18367. @item @code{allow-debugging?} (type: maybe-boolean)
  18368. Set to #t to enable debug log level.
  18369. @item @code{background} (type: file-like)
  18370. The background image to use.
  18371. @item @code{at-spi-enabled?} (default: @code{#f}) (type: boolean)
  18372. Enable accessibility support through the Assistive Technology Service
  18373. Provider Interface (AT-SPI).
  18374. @item @code{a11y-states} (default: @code{(contrast font keyboard reader)}) (type: list-of-a11y-states)
  18375. The accessibility features to enable, given as list of symbols.
  18376. @item @code{reader} (type: maybe-file-like)
  18377. The command to use to launch a screen reader.
  18378. @item @code{extra-config} (default: @code{'()}) (type: list-of-strings)
  18379. Extra configuration values to append to the LightDM GTK Greeter
  18380. configuration file.
  18381. @end table
  18382. @end deftp
  18383. @c %end of fragment
  18384. @c %start of fragment
  18385. @deftp {Data Type} lightdm-seat-configuration
  18386. Available @code{lightdm-seat-configuration} fields are:
  18387. @table @asis
  18388. @item @code{name} (type: seat-name)
  18389. The name of the seat. An asterisk (*) can be used in the name to apply
  18390. the seat configuration to all the seat names it matches.
  18391. @item @code{user-session} (type: maybe-string)
  18392. The session to use by default. The session name must be provided as a
  18393. lowercase string, such as @code{"gnome"}, @code{"ratpoison"}, etc.
  18394. @item @code{type} (default: @code{local}) (type: seat-type)
  18395. The type of the seat, either the @code{local} or @code{xremote} symbol.
  18396. @item @code{autologin-user} (type: maybe-string)
  18397. The username to automatically log in with by default.
  18398. @item @code{greeter-session} (default: @code{lightdm-gtk-greeter}) (type: greeter-session)
  18399. The greeter session to use, specified as a symbol. Currently, only
  18400. @code{lightdm-gtk-greeter} is supported.
  18401. @item @code{xserver-command} (type: maybe-file-like)
  18402. The Xorg server command to run.
  18403. @item @code{session-wrapper} (type: file-like)
  18404. The xinitrc session wrapper to use.
  18405. @item @code{extra-config} (default: @code{'()}) (type: list-of-strings)
  18406. Extra configuration values to append to the seat configuration section.
  18407. @end table
  18408. @end deftp
  18409. @c %end of fragment
  18410. @cindex Xorg, configuration
  18411. @deftp {Data Type} xorg-configuration
  18412. This data type represents the configuration of the Xorg graphical
  18413. display server. Note that there is no Xorg service; instead, the X
  18414. server is started by a ``display manager'' such as GDM, SDDM, LightDM or
  18415. SLiM@. Thus, the configuration of these display managers aggregates an
  18416. @code{xorg-configuration} record.
  18417. @table @asis
  18418. @item @code{modules} (default: @code{%default-xorg-modules})
  18419. This is a list of @dfn{module packages} loaded by the Xorg
  18420. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  18421. @item @code{fonts} (default: @code{%default-xorg-fonts})
  18422. This is a list of font directories to add to the server's @dfn{font path}.
  18423. @item @code{drivers} (default: @code{'()})
  18424. This must be either the empty list, in which case Xorg chooses a graphics
  18425. driver automatically, or a list of driver names that will be tried in this
  18426. order---e.g., @code{'("modesetting" "vesa")}.
  18427. @item @code{resolutions} (default: @code{'()})
  18428. When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
  18429. resolution. Otherwise, it must be a list of resolutions---e.g., @code{'((1024
  18430. 768) (640 480))}.
  18431. @cindex keyboard layout, for Xorg
  18432. @cindex keymap, for Xorg
  18433. @item @code{keyboard-layout} (default: @code{#f})
  18434. If this is @code{#f}, Xorg uses the default keyboard layout---usually US
  18435. English (``qwerty'') for a 105-key PC keyboard.
  18436. Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
  18437. layout in use when Xorg is running. @xref{Keyboard Layout}, for more
  18438. information on how to specify the keyboard layout.
  18439. @item @code{extra-config} (default: @code{'()})
  18440. This is a list of strings or objects appended to the configuration file. It
  18441. is used to pass extra text to be added verbatim to the configuration file.
  18442. @item @code{server} (default: @code{xorg-server})
  18443. This is the package providing the Xorg server.
  18444. @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
  18445. This is the list of command-line arguments to pass to the X server. The
  18446. default is @code{-nolisten tcp}.
  18447. @end table
  18448. @end deftp
  18449. @deffn {Procedure} set-xorg-configuration config [login-manager-service-type]
  18450. Tell the log-in manager (of type @var{login-manager-service-type}) to use
  18451. @var{config}, an @code{<xorg-configuration>} record.
  18452. Since the Xorg configuration is embedded in the log-in manager's
  18453. configuration---e.g., @code{gdm-configuration}---this procedure provides a
  18454. shorthand to set the Xorg configuration.
  18455. @end deffn
  18456. @deffn {Procedure} xorg-start-command [config]
  18457. Return a @code{startx} script in which the modules, fonts, etc. specified
  18458. in @var{config}, are available. The result should be used in place of
  18459. @code{startx}.
  18460. Usually the X server is started by a login manager.
  18461. @end deffn
  18462. @defvar screen-locker-service-type
  18463. Type for a service that adds a package for a screen locker or screen
  18464. saver to the set of setuid programs and/or add a PAM entry for it. The
  18465. value for this service is a @code{<screen-locker-configuration>} object.
  18466. While the default behavior is to setup both a setuid program and PAM
  18467. entry, these two methods are redundant. Screen locker programs may not
  18468. execute when PAM is configured and @code{setuid} is set on their
  18469. executable. In this case, @code{using-setuid?} can be set to @code{#f}.
  18470. For example, to make XlockMore usable:
  18471. @lisp
  18472. (service screen-locker-service-type
  18473. (screen-locker-configuration
  18474. (name "xlock")
  18475. (program (file-append xlockmore "/bin/xlock"))))
  18476. @end lisp
  18477. makes the good ol' XlockMore usable.
  18478. For example, swaylock fails to execute when compiled with PAM support
  18479. and setuid enabled. One can thus disable setuid:
  18480. @lisp
  18481. (service screen-locker-service-type
  18482. (screen-locker-configuration
  18483. (name "swaylock")
  18484. (program (file-append swaylock "/bin/swaylock"))
  18485. (using-pam? #t)
  18486. (using-setuid? #f)))
  18487. @end lisp
  18488. @end defvar
  18489. @deftp {Data Type} screen-locker-configuration
  18490. Available @code{screen-locker-configuration} fields are:
  18491. @table @asis
  18492. @item @code{name} (type: string)
  18493. Name of the screen locker.
  18494. @item @code{program} (type: file-like)
  18495. Path to the executable for the screen locker as a G-Expression.
  18496. @item @code{allow-empty-password?} (default: @code{#f}) (type: boolean)
  18497. Whether to allow empty passwords.
  18498. @item @code{using-pam?} (default: @code{#t}) (type: boolean)
  18499. Whether to setup PAM entry.
  18500. @item @code{using-setuid?} (default: @code{#t}) (type: boolean)
  18501. Whether to setup program as setuid binary.
  18502. @end table
  18503. @end deftp
  18504. @node Printing Services
  18505. @subsection Printing Services
  18506. @cindex printer support with CUPS
  18507. The @code{(gnu services cups)} module provides a Guix service definition
  18508. for the CUPS printing service. To add printer support to a Guix
  18509. system, add a @code{cups-service} to the operating system definition:
  18510. @defvar cups-service-type
  18511. The service type for the CUPS print server. Its value should be a valid
  18512. CUPS configuration (see below). To use the default settings, simply
  18513. write:
  18514. @lisp
  18515. (service cups-service-type)
  18516. @end lisp
  18517. @end defvar
  18518. The CUPS configuration controls the basic things about your CUPS
  18519. installation: what interfaces it listens on, what to do if a print job
  18520. fails, how much logging to do, and so on. To actually add a printer,
  18521. you have to visit the @url{http://localhost:631} URL, or use a tool such
  18522. as GNOME's printer configuration services. By default, configuring a
  18523. CUPS service will generate a self-signed certificate if needed, for
  18524. secure connections to the print server.
  18525. Suppose you want to enable the Web interface of CUPS and also add
  18526. support for Epson printers @i{via} the @code{epson-inkjet-printer-escpr}
  18527. package and for HP printers @i{via} the @code{hplip-minimal} package.
  18528. You can do that directly, like this (you need to use the
  18529. @code{(gnu packages cups)} module):
  18530. @lisp
  18531. (service cups-service-type
  18532. (cups-configuration
  18533. (web-interface? #t)
  18534. (extensions
  18535. (list cups-filters epson-inkjet-printer-escpr hplip-minimal))))
  18536. @end lisp
  18537. @quotation Note
  18538. If you wish to use the Qt5 based GUI which comes with the hplip
  18539. package then it is suggested that you install the @code{hplip} package,
  18540. either in your OS configuration file or as your user.
  18541. @end quotation
  18542. The available configuration parameters follow. Each parameter
  18543. definition is preceded by its type; for example, @samp{string-list foo}
  18544. indicates that the @code{foo} parameter should be specified as a list of
  18545. strings. There is also a way to specify the configuration as a string,
  18546. if you have an old @code{cupsd.conf} file that you want to port over
  18547. from some other system; see the end for more details.
  18548. @c The following documentation was initially generated by
  18549. @c (generate-documentation) in (gnu services cups). Manually maintained
  18550. @c documentation is better, so we shouldn't hesitate to edit below as
  18551. @c needed. However if the change you want to make to this documentation
  18552. @c can be done in an automated way, it's probably easier to change
  18553. @c (generate-documentation) than to make it below and have to deal with
  18554. @c the churn as CUPS updates.
  18555. Available @code{cups-configuration} fields are:
  18556. @deftypevr {@code{cups-configuration} parameter} package cups
  18557. The CUPS package.
  18558. @end deftypevr
  18559. @deftypevr {@code{cups-configuration} parameter} package-list extensions (default: @code{(list brlaser cups-filters epson-inkjet-printer-escpr foomatic-filters hplip-minimal splix)})
  18560. Drivers and other extensions to the CUPS package.
  18561. @end deftypevr
  18562. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  18563. Configuration of where to write logs, what directories to use for print
  18564. spools, and related privileged configuration parameters.
  18565. Available @code{files-configuration} fields are:
  18566. @deftypevr {@code{files-configuration} parameter} log-location access-log
  18567. Defines the access log filename. Specifying a blank filename disables
  18568. access log generation. The value @code{stderr} causes log entries to be
  18569. sent to the standard error file when the scheduler is running in the
  18570. foreground, or to the system log daemon when run in the background. The
  18571. value @code{syslog} causes log entries to be sent to the system log
  18572. daemon. The server name may be included in filenames using the string
  18573. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  18574. Defaults to @samp{"/var/log/cups/access_log"}.
  18575. @end deftypevr
  18576. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  18577. Where CUPS should cache data.
  18578. Defaults to @samp{"/var/cache/cups"}.
  18579. @end deftypevr
  18580. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  18581. Specifies the permissions for all configuration files that the scheduler
  18582. writes.
  18583. Note that the permissions for the printers.conf file are currently
  18584. masked to only allow access from the scheduler user (typically root).
  18585. This is done because printer device URIs sometimes contain sensitive
  18586. authentication information that should not be generally known on the
  18587. system. There is no way to disable this security feature.
  18588. Defaults to @samp{"0640"}.
  18589. @end deftypevr
  18590. @deftypevr {@code{files-configuration} parameter} log-location error-log
  18591. Defines the error log filename. Specifying a blank filename disables
  18592. error log generation. The value @code{stderr} causes log entries to be
  18593. sent to the standard error file when the scheduler is running in the
  18594. foreground, or to the system log daemon when run in the background. The
  18595. value @code{syslog} causes log entries to be sent to the system log
  18596. daemon. The server name may be included in filenames using the string
  18597. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  18598. Defaults to @samp{"/var/log/cups/error_log"}.
  18599. @end deftypevr
  18600. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  18601. Specifies which errors are fatal, causing the scheduler to exit. The
  18602. kind strings are:
  18603. @table @code
  18604. @item none
  18605. No errors are fatal.
  18606. @item all
  18607. All of the errors below are fatal.
  18608. @item browse
  18609. Browsing initialization errors are fatal, for example failed connections
  18610. to the DNS-SD daemon.
  18611. @item config
  18612. Configuration file syntax errors are fatal.
  18613. @item listen
  18614. Listen or Port errors are fatal, except for IPv6 failures on the
  18615. loopback or @code{any} addresses.
  18616. @item log
  18617. Log file creation or write errors are fatal.
  18618. @item permissions
  18619. Bad startup file permissions are fatal, for example shared TLS
  18620. certificate and key files with world-read permissions.
  18621. @end table
  18622. Defaults to @samp{"all -browse"}.
  18623. @end deftypevr
  18624. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  18625. Specifies whether the file pseudo-device can be used for new printer
  18626. queues. The URI @uref{file:///dev/null} is always allowed.
  18627. Defaults to @samp{#f}.
  18628. @end deftypevr
  18629. @deftypevr {@code{files-configuration} parameter} string group
  18630. Specifies the group name or ID that will be used when executing external
  18631. programs.
  18632. Defaults to @samp{"lp"}.
  18633. @end deftypevr
  18634. @deftypevr {@code{files-configuration} parameter} string log-file-group
  18635. Specifies the group name or ID that will be used for log files.
  18636. Defaults to @samp{"lpadmin"}.
  18637. @end deftypevr
  18638. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  18639. Specifies the permissions for all log files that the scheduler writes.
  18640. Defaults to @samp{"0644"}.
  18641. @end deftypevr
  18642. @deftypevr {@code{files-configuration} parameter} log-location page-log
  18643. Defines the page log filename. Specifying a blank filename disables
  18644. page log generation. The value @code{stderr} causes log entries to be
  18645. sent to the standard error file when the scheduler is running in the
  18646. foreground, or to the system log daemon when run in the background. The
  18647. value @code{syslog} causes log entries to be sent to the system log
  18648. daemon. The server name may be included in filenames using the string
  18649. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  18650. Defaults to @samp{"/var/log/cups/page_log"}.
  18651. @end deftypevr
  18652. @deftypevr {@code{files-configuration} parameter} string remote-root
  18653. Specifies the username that is associated with unauthenticated accesses
  18654. by clients claiming to be the root user. The default is @code{remroot}.
  18655. Defaults to @samp{"remroot"}.
  18656. @end deftypevr
  18657. @deftypevr {@code{files-configuration} parameter} file-name request-root
  18658. Specifies the directory that contains print jobs and other HTTP request
  18659. data.
  18660. Defaults to @samp{"/var/spool/cups"}.
  18661. @end deftypevr
  18662. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  18663. Specifies the level of security sandboxing that is applied to print
  18664. filters, backends, and other child processes of the scheduler; either
  18665. @code{relaxed} or @code{strict}. This directive is currently only
  18666. used/supported on macOS.
  18667. Defaults to @samp{strict}.
  18668. @end deftypevr
  18669. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  18670. Specifies the location of TLS certificates and private keys. CUPS will
  18671. look for public and private keys in this directory: @file{.crt} files
  18672. for PEM-encoded certificates and corresponding @file{.key} files for
  18673. PEM-encoded private keys.
  18674. Defaults to @samp{"/etc/cups/ssl"}.
  18675. @end deftypevr
  18676. @deftypevr {@code{files-configuration} parameter} file-name server-root
  18677. Specifies the directory containing the server configuration files.
  18678. Defaults to @samp{"/etc/cups"}.
  18679. @end deftypevr
  18680. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  18681. Specifies whether the scheduler calls fsync(2) after writing
  18682. configuration or state files.
  18683. Defaults to @samp{#f}.
  18684. @end deftypevr
  18685. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  18686. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  18687. @end deftypevr
  18688. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  18689. Specifies the directory where temporary files are stored.
  18690. Defaults to @samp{"/var/spool/cups/tmp"}.
  18691. @end deftypevr
  18692. @deftypevr {@code{files-configuration} parameter} string user
  18693. Specifies the user name or ID that is used when running external
  18694. programs.
  18695. Defaults to @samp{"lp"}.
  18696. @end deftypevr
  18697. @deftypevr {@code{files-configuration} parameter} string set-env
  18698. Set the specified environment variable to be passed to child processes.
  18699. Defaults to @samp{"variable value"}.
  18700. @end deftypevr
  18701. @end deftypevr
  18702. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  18703. Specifies the logging level for the AccessLog file. The @code{config}
  18704. level logs when printers and classes are added, deleted, or modified and
  18705. when configuration files are accessed or updated. The @code{actions}
  18706. level logs when print jobs are submitted, held, released, modified, or
  18707. canceled, and any of the conditions for @code{config}. The @code{all}
  18708. level logs all requests.
  18709. Defaults to @samp{actions}.
  18710. @end deftypevr
  18711. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  18712. Specifies whether to purge job history data automatically when it is no
  18713. longer required for quotas.
  18714. Defaults to @samp{#f}.
  18715. @end deftypevr
  18716. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
  18717. Specifies a list of DNS-SD sub-types to advertise for each shared printer.
  18718. The default @samp{(list "_cups" "_print" "_universal")} tells clients
  18719. that CUPS sharing, IPP Everywhere, AirPrint, and Mopria are supported.
  18720. @end deftypevr
  18721. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  18722. Specifies which protocols to use for local printer sharing.
  18723. Defaults to @samp{dnssd}.
  18724. @end deftypevr
  18725. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  18726. Specifies whether the CUPS web interface is advertised.
  18727. Defaults to @samp{#f}.
  18728. @end deftypevr
  18729. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  18730. Specifies whether shared printers are advertised.
  18731. Defaults to @samp{#f}.
  18732. @end deftypevr
  18733. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  18734. Specifies the default type of authentication to use.
  18735. Defaults to @samp{Basic}.
  18736. @end deftypevr
  18737. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  18738. Specifies whether encryption will be used for authenticated requests.
  18739. Defaults to @samp{Required}.
  18740. @end deftypevr
  18741. @deftypevr {@code{cups-configuration} parameter} string default-language
  18742. Specifies the default language to use for text and web content.
  18743. Defaults to @samp{"en"}.
  18744. @end deftypevr
  18745. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  18746. Specifies the default paper size for new print queues. @samp{"Auto"}
  18747. uses a locale-specific default, while @samp{"None"} specifies there is
  18748. no default paper size. Specific size names are typically
  18749. @samp{"Letter"} or @samp{"A4"}.
  18750. Defaults to @samp{"Auto"}.
  18751. @end deftypevr
  18752. @deftypevr {@code{cups-configuration} parameter} string default-policy
  18753. Specifies the default access policy to use.
  18754. Defaults to @samp{"default"}.
  18755. @end deftypevr
  18756. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  18757. Specifies whether local printers are shared by default.
  18758. Defaults to @samp{#t}.
  18759. @end deftypevr
  18760. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  18761. Specifies the delay for updating of configuration and state files, in
  18762. seconds. A value of 0 causes the update to happen as soon as possible,
  18763. typically within a few milliseconds.
  18764. Defaults to @samp{30}.
  18765. @end deftypevr
  18766. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  18767. Specifies what to do when an error occurs. Possible values are
  18768. @code{abort-job}, which will discard the failed print job;
  18769. @code{retry-job}, which will retry the job at a later time;
  18770. @code{retry-current-job}, which retries the failed job immediately; and
  18771. @code{stop-printer}, which stops the printer.
  18772. Defaults to @samp{stop-printer}.
  18773. @end deftypevr
  18774. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  18775. Specifies the maximum cost of filters that are run concurrently, which
  18776. can be used to minimize disk, memory, and CPU resource problems. A
  18777. limit of 0 disables filter limiting. An average print to a
  18778. non-PostScript printer needs a filter limit of about 200. A PostScript
  18779. printer needs about half that (100). Setting the limit below these
  18780. thresholds will effectively limit the scheduler to printing a single job
  18781. at any time.
  18782. Defaults to @samp{0}.
  18783. @end deftypevr
  18784. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  18785. Specifies the scheduling priority of filters that are run to print a
  18786. job. The nice value ranges from 0, the highest priority, to 19, the
  18787. lowest priority.
  18788. Defaults to @samp{0}.
  18789. @end deftypevr
  18790. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  18791. Specifies whether to do reverse lookups on connecting clients. The
  18792. @code{double} setting causes @code{cupsd} to verify that the hostname
  18793. resolved from the address matches one of the addresses returned for that
  18794. hostname. Double lookups also prevent clients with unregistered
  18795. addresses from connecting to your server. Only set this option to
  18796. @code{#t} or @code{double} if absolutely required.
  18797. Defaults to @samp{#f}.
  18798. @end deftypevr
  18799. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  18800. Specifies the number of seconds to wait before killing the filters and
  18801. backend associated with a canceled or held job.
  18802. Defaults to @samp{30}.
  18803. @end deftypevr
  18804. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  18805. Specifies the interval between retries of jobs in seconds. This is
  18806. typically used for fax queues but can also be used with normal print
  18807. queues whose error policy is @code{retry-job} or
  18808. @code{retry-current-job}.
  18809. Defaults to @samp{30}.
  18810. @end deftypevr
  18811. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  18812. Specifies the number of retries that are done for jobs. This is
  18813. typically used for fax queues but can also be used with normal print
  18814. queues whose error policy is @code{retry-job} or
  18815. @code{retry-current-job}.
  18816. Defaults to @samp{5}.
  18817. @end deftypevr
  18818. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  18819. Specifies whether to support HTTP keep-alive connections.
  18820. Defaults to @samp{#t}.
  18821. @end deftypevr
  18822. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  18823. Specifies the maximum size of print files, IPP requests, and HTML form
  18824. data. A limit of 0 disables the limit check.
  18825. Defaults to @samp{0}.
  18826. @end deftypevr
  18827. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  18828. Listens on the specified interfaces for connections. Valid values are
  18829. of the form @var{address}:@var{port}, where @var{address} is either an
  18830. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  18831. indicate all addresses. Values can also be file names of local UNIX
  18832. domain sockets. The Listen directive is similar to the Port directive
  18833. but allows you to restrict access to specific interfaces or networks.
  18834. @end deftypevr
  18835. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  18836. Specifies a set of additional access controls.
  18837. Available @code{location-access-controls} fields are:
  18838. @deftypevr {@code{location-access-controls} parameter} file-name path
  18839. Specifies the URI path to which the access control applies.
  18840. @end deftypevr
  18841. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  18842. Access controls for all access to this path, in the same format as the
  18843. @code{access-controls} of @code{operation-access-control}.
  18844. Defaults to @samp{'()}.
  18845. @end deftypevr
  18846. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  18847. Access controls for method-specific access to this path.
  18848. Defaults to @samp{'()}.
  18849. Available @code{method-access-controls} fields are:
  18850. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  18851. If @code{#t}, apply access controls to all methods except the listed
  18852. methods. Otherwise apply to only the listed methods.
  18853. Defaults to @samp{#f}.
  18854. @end deftypevr
  18855. @deftypevr {@code{method-access-controls} parameter} method-list methods
  18856. Methods to which this access control applies.
  18857. Defaults to @samp{'()}.
  18858. @end deftypevr
  18859. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  18860. Access control directives, as a list of strings. Each string should be
  18861. one directive, such as @samp{"Order allow,deny"}.
  18862. Defaults to @samp{'()}.
  18863. @end deftypevr
  18864. @end deftypevr
  18865. @end deftypevr
  18866. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  18867. Specifies the number of debugging messages that are retained for logging
  18868. if an error occurs in a print job. Debug messages are logged regardless
  18869. of the LogLevel setting.
  18870. Defaults to @samp{100}.
  18871. @end deftypevr
  18872. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  18873. Specifies the level of logging for the ErrorLog file. The value
  18874. @code{none} stops all logging while @code{debug2} logs everything.
  18875. Defaults to @samp{info}.
  18876. @end deftypevr
  18877. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  18878. Specifies the format of the date and time in the log files. The value
  18879. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  18880. Defaults to @samp{standard}.
  18881. @end deftypevr
  18882. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  18883. Specifies the maximum number of simultaneous clients that are allowed by
  18884. the scheduler.
  18885. Defaults to @samp{100}.
  18886. @end deftypevr
  18887. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  18888. Specifies the maximum number of simultaneous clients that are allowed
  18889. from a single address.
  18890. Defaults to @samp{100}.
  18891. @end deftypevr
  18892. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  18893. Specifies the maximum number of copies that a user can print of each
  18894. job.
  18895. Defaults to @samp{9999}.
  18896. @end deftypevr
  18897. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  18898. Specifies the maximum time a job may remain in the @code{indefinite}
  18899. hold state before it is canceled. A value of 0 disables cancellation of
  18900. held jobs.
  18901. Defaults to @samp{0}.
  18902. @end deftypevr
  18903. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  18904. Specifies the maximum number of simultaneous jobs that are allowed. Set
  18905. to 0 to allow an unlimited number of jobs.
  18906. Defaults to @samp{500}.
  18907. @end deftypevr
  18908. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  18909. Specifies the maximum number of simultaneous jobs that are allowed per
  18910. printer. A value of 0 allows up to @code{max-jobs} per printer.
  18911. Defaults to @samp{0}.
  18912. @end deftypevr
  18913. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  18914. Specifies the maximum number of simultaneous jobs that are allowed per
  18915. user. A value of 0 allows up to @code{max-jobs} per user.
  18916. Defaults to @samp{0}.
  18917. @end deftypevr
  18918. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  18919. Specifies the maximum time a job may take to print before it is
  18920. canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
  18921. Defaults to @samp{10800}.
  18922. @end deftypevr
  18923. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  18924. Specifies the maximum size of the log files before they are rotated, in
  18925. bytes. The value 0 disables log rotation.
  18926. Defaults to @samp{1048576}.
  18927. @end deftypevr
  18928. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-subscriptions
  18929. Specifies the maximum number of simultaneous event subscriptions that are
  18930. allowed. Set to @samp{0} to allow an unlimited number of subscriptions.
  18931. Defaults to @samp{0}.
  18932. @end deftypevr
  18933. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-subscriptions-per-job
  18934. Specifies the maximum number of simultaneous event subscriptions that are
  18935. allowed per job. A value of @samp{0} allows up to @code{max-subscriptions}
  18936. per job.
  18937. Defaults to @samp{0}.
  18938. @end deftypevr
  18939. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-subscriptions-per-printer
  18940. Specifies the maximum number of simultaneous event subscriptions that are
  18941. allowed per printer. A value of @samp{0} allows up to @code{max-subscriptions}
  18942. per printer.
  18943. Defaults to @samp{0}.
  18944. @end deftypevr
  18945. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-subscriptions-per-user
  18946. Specifies the maximum number of simultaneous event subscriptions that are
  18947. allowed per user. A value of @samp{0} allows up to @code{max-subscriptions}
  18948. per user.
  18949. Defaults to @samp{0}.
  18950. @end deftypevr
  18951. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  18952. Specifies the maximum amount of time to allow between files in a
  18953. multiple file print job, in seconds.
  18954. Defaults to @samp{900}.
  18955. @end deftypevr
  18956. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  18957. Passes the specified environment variable(s) to child processes; a list
  18958. of strings.
  18959. Defaults to @samp{'()}.
  18960. @end deftypevr
  18961. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  18962. Specifies named access control policies.
  18963. Available @code{policy-configuration} fields are:
  18964. @deftypevr {@code{policy-configuration} parameter} string name
  18965. Name of the policy.
  18966. @end deftypevr
  18967. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  18968. Specifies an access list for a job's private values. @code{@@ACL} maps
  18969. to the printer's requesting-user-name-allowed or
  18970. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  18971. owner. @code{@@SYSTEM} maps to the groups listed for the
  18972. @code{system-group} field of the @code{files-configuration},
  18973. which is reified into the @code{cups-files.conf(5)} file. Other
  18974. possible elements of the access list include specific user names, and
  18975. @code{@@@var{group}} to indicate members of a specific group. The
  18976. access list may also be simply @code{all} or @code{default}.
  18977. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  18978. @end deftypevr
  18979. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  18980. Specifies the list of job values to make private, or @code{all},
  18981. @code{default}, or @code{none}.
  18982. Defaults to @samp{"job-name job-originating-host-name
  18983. job-originating-user-name phone"}.
  18984. @end deftypevr
  18985. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  18986. Specifies an access list for a subscription's private values.
  18987. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  18988. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  18989. owner. @code{@@SYSTEM} maps to the groups listed for the
  18990. @code{system-group} field of the @code{files-configuration},
  18991. which is reified into the @code{cups-files.conf(5)} file. Other
  18992. possible elements of the access list include specific user names, and
  18993. @code{@@@var{group}} to indicate members of a specific group. The
  18994. access list may also be simply @code{all} or @code{default}.
  18995. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  18996. @end deftypevr
  18997. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  18998. Specifies the list of job values to make private, or @code{all},
  18999. @code{default}, or @code{none}.
  19000. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  19001. notify-subscriber-user-name notify-user-data"}.
  19002. @end deftypevr
  19003. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  19004. Access control by IPP operation.
  19005. Defaults to @samp{'()}.
  19006. @end deftypevr
  19007. @end deftypevr
  19008. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  19009. Specifies whether job files (documents) are preserved after a job is
  19010. printed. If a numeric value is specified, job files are preserved for
  19011. the indicated number of seconds after printing. Otherwise a boolean
  19012. value applies indefinitely.
  19013. Defaults to @samp{86400}.
  19014. @end deftypevr
  19015. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  19016. Specifies whether the job history is preserved after a job is printed.
  19017. If a numeric value is specified, the job history is preserved for the
  19018. indicated number of seconds after printing. If @code{#t}, the job
  19019. history is preserved until the MaxJobs limit is reached.
  19020. Defaults to @samp{#t}.
  19021. @end deftypevr
  19022. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list-or-#f ready-paper-sizes
  19023. Specifies a list of potential paper sizes that are reported as ready,
  19024. that is: loaded. The actual list will contain only the sizes that each
  19025. printer supports.
  19026. The default value of @code{#f} is a special case: CUPS will use
  19027. @samp{(list \"Letter\" \"Legal\" \"Tabloid\" \"4x6\" \"Env10\")}
  19028. if the default paper size is \"Letter\", and
  19029. @samp{(list \"A3\" \"A4\" \"A5\" \"A6\" \"EnvDL\")} otherwise.
  19030. @end deftypevr
  19031. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  19032. Specifies the amount of time to wait for job completion before
  19033. restarting the scheduler.
  19034. Defaults to @samp{30}.
  19035. @end deftypevr
  19036. @deftypevr {@code{cups-configuration} parameter} string server-admin
  19037. Specifies the email address of the server administrator.
  19038. Defaults to @samp{"root@@localhost.localdomain"}.
  19039. @end deftypevr
  19040. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  19041. The ServerAlias directive is used for HTTP Host header validation when
  19042. clients connect to the scheduler from external interfaces. Using the
  19043. special name @code{*} can expose your system to known browser-based DNS
  19044. rebinding attacks, even when accessing sites through a firewall. If the
  19045. auto-discovery of alternate names does not work, we recommend listing
  19046. each alternate name with a ServerAlias directive instead of using
  19047. @code{*}.
  19048. Defaults to @samp{*}.
  19049. @end deftypevr
  19050. @deftypevr {@code{cups-configuration} parameter} string server-name
  19051. Specifies the fully-qualified host name of the server.
  19052. Defaults to @samp{"localhost"}.
  19053. @end deftypevr
  19054. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  19055. Specifies what information is included in the Server header of HTTP
  19056. responses. @code{None} disables the Server header. @code{ProductOnly}
  19057. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  19058. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  19059. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  19060. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  19061. 2.0.0 (@var{uname}) IPP/2.0}.
  19062. Defaults to @samp{Minimal}.
  19063. @end deftypevr
  19064. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  19065. Listens on the specified interfaces for encrypted connections. Valid
  19066. values are of the form @var{address}:@var{port}, where @var{address} is
  19067. either an IPv6 address enclosed in brackets, an IPv4 address, or
  19068. @code{*} to indicate all addresses.
  19069. Defaults to @samp{'()}.
  19070. @end deftypevr
  19071. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  19072. Sets encryption options. By default, CUPS only supports encryption
  19073. using TLS v1.0 or higher using known secure cipher suites. Security is
  19074. reduced when @code{Allow} options are used, and enhanced when @code{Deny}
  19075. options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
  19076. suites, which are required for some older clients. The @code{AllowSSL3} option
  19077. enables SSL v3.0, which is required for some older clients that do not support
  19078. TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
  19079. @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
  19080. protocol version to TLS v1.1.
  19081. Defaults to @samp{'()}.
  19082. @end deftypevr
  19083. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  19084. Specifies whether the scheduler requires clients to strictly adhere to
  19085. the IPP specifications.
  19086. Defaults to @samp{#f}.
  19087. @end deftypevr
  19088. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  19089. Specifies the HTTP request timeout, in seconds.
  19090. Defaults to @samp{900}.
  19091. @end deftypevr
  19092. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  19093. Specifies whether the web interface is enabled.
  19094. Defaults to @samp{#f}.
  19095. @end deftypevr
  19096. At this point you're probably thinking ``oh dear, Guix manual, I like
  19097. you but you can stop already with the configuration options''. Indeed.
  19098. However, one more point: it could be that you have an existing
  19099. @code{cupsd.conf} that you want to use. In that case, you can pass an
  19100. @code{opaque-cups-configuration} as the configuration of a
  19101. @code{cups-service-type}.
  19102. Available @code{opaque-cups-configuration} fields are:
  19103. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  19104. The CUPS package.
  19105. @end deftypevr
  19106. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  19107. The contents of the @code{cupsd.conf}, as a string.
  19108. @end deftypevr
  19109. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  19110. The contents of the @code{cups-files.conf} file, as a string.
  19111. @end deftypevr
  19112. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  19113. strings of the same name, you could instantiate a CUPS service like
  19114. this:
  19115. @lisp
  19116. (service cups-service-type
  19117. (opaque-cups-configuration
  19118. (cupsd.conf cupsd.conf)
  19119. (cups-files.conf cups-files.conf)))
  19120. @end lisp
  19121. @node Desktop Services
  19122. @subsection Desktop Services
  19123. The @code{(gnu services desktop)} module provides services that are
  19124. usually useful in the context of a ``desktop'' setup---that is, on a
  19125. machine running a graphical display server, possibly with graphical user
  19126. interfaces, etc. It also defines services that provide specific desktop
  19127. environments like GNOME, Xfce or MATE.
  19128. To simplify things, the module defines a variable containing the set of
  19129. services that users typically expect on a machine with a graphical
  19130. environment and networking:
  19131. @defvar %desktop-services
  19132. This is a list of services that builds upon @code{%base-services} and
  19133. adds or adjusts services for a typical ``desktop'' setup.
  19134. In particular, it adds a graphical login manager (@pxref{X Window,
  19135. @code{gdm-service-type}}), screen lockers, a network management tool
  19136. (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
  19137. support (@pxref{Networking Services, @code{modem-manager-service-type}}),
  19138. energy and color management services, the @code{elogind} login and seat
  19139. manager, the Polkit privilege service, the GeoClue location service, the
  19140. AccountsService daemon that allows authorized users change system passwords,
  19141. a NTP client (@pxref{Networking Services}) and the Avahi daemon.
  19142. @end defvar
  19143. The @code{%desktop-services} variable can be used as the @code{services}
  19144. field of an @code{operating-system} declaration (@pxref{operating-system
  19145. Reference, @code{services}}).
  19146. Additionally, the @code{gnome-desktop-service-type},
  19147. @code{xfce-desktop-service}, @code{mate-desktop-service-type},
  19148. @code{lxqt-desktop-service-type} and @code{enlightenment-desktop-service-type}
  19149. procedures can add GNOME, Xfce, MATE and/or Enlightenment to a system. To
  19150. ``add GNOME'' means that system-level services like the backlight adjustment
  19151. helpers and the power management utilities are added to the system, extending
  19152. @code{polkit} and @code{dbus} appropriately, allowing GNOME to operate with
  19153. elevated privileges on a limited number of special-purpose system interfaces.
  19154. Additionally, adding a service made by @code{gnome-desktop-service-type} adds
  19155. the GNOME metapackage to the system profile. Likewise, adding the Xfce
  19156. service not only adds the @code{xfce} metapackage to the system profile, but
  19157. it also gives the Thunar file manager the ability to open a ``root-mode'' file
  19158. management window, if the user authenticates using the administrator's
  19159. password via the standard polkit graphical interface. To ``add MATE'' means
  19160. that @code{polkit} and @code{dbus} are extended appropriately, allowing MATE
  19161. to operate with elevated privileges on a limited number of special-purpose
  19162. system interfaces. Additionally, adding a service of type
  19163. @code{mate-desktop-service-type} adds the MATE metapackage to the system
  19164. profile. ``Adding Enlightenment'' means that @code{dbus} is extended
  19165. appropriately, and several of Enlightenment's binaries are set as setuid,
  19166. allowing Enlightenment's screen locker and other functionality to work as
  19167. expected.
  19168. The desktop environments in Guix use the Xorg display server by
  19169. default. If you'd like to use the newer display server protocol
  19170. called Wayland, you need to enable Wayland support in GDM
  19171. (@pxref{wayland-gdm}). Another solution is to use the
  19172. @code{sddm-service} instead of GDM as the graphical login manager.
  19173. You should then select the ``GNOME (Wayland)'' session in SDDM@.
  19174. Alternatively you can also try starting GNOME on Wayland manually from a
  19175. TTY with the command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  19176. gnome-session``. Currently only GNOME has support for Wayland.
  19177. @defvar gnome-desktop-service-type
  19178. This is the type of the service that adds the @uref{https://www.gnome.org,
  19179. GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
  19180. object (see below).
  19181. This service adds the @code{gnome} package to the system profile, and extends
  19182. polkit with the actions from @code{gnome-settings-daemon}.
  19183. @end defvar
  19184. @deftp {Data Type} gnome-desktop-configuration
  19185. Configuration record for the GNOME desktop environment.
  19186. @table @asis
  19187. @item @code{gnome} (default: @code{gnome})
  19188. The GNOME package to use.
  19189. @end table
  19190. @end deftp
  19191. @defvar plasma-desktop-service-type
  19192. This is the type of the service that adds the @uref{https://kde.org/plasma-desktop/,
  19193. Plasma} desktop environment. Its value is a @code{plasma-desktop-configuration}
  19194. object (see below).
  19195. This service adds the @code{plasma} package to the system profile.
  19196. @end defvar
  19197. @deftp {Data Type} plasma-desktop-configuration
  19198. Configuration record for the Plasma desktop environment.
  19199. @table @asis
  19200. @item @code{plasma} (default: @code{plasma})
  19201. The Plasma package to use.
  19202. @end table
  19203. @end deftp
  19204. @defvar xfce-desktop-service-type
  19205. This is the type of a service to run the @uref{Xfce, https://xfce.org/}
  19206. desktop environment. Its value is an @code{xfce-desktop-configuration} object
  19207. (see below).
  19208. This service adds the @code{xfce} package to the system profile, and
  19209. extends polkit with the ability for @code{thunar} to manipulate the file
  19210. system as root from within a user session, after the user has authenticated
  19211. with the administrator's password.
  19212. Note that @code{xfce4-panel} and its plugin packages should be installed in
  19213. the same profile to ensure compatibility. When using this service, you should
  19214. add extra plugins (@code{xfce4-whiskermenu-plugin},
  19215. @code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your
  19216. @code{operating-system}.
  19217. @end defvar
  19218. @deftp {Data Type} xfce-desktop-configuration
  19219. Configuration record for the Xfce desktop environment.
  19220. @table @asis
  19221. @item @code{xfce} (default: @code{xfce})
  19222. The Xfce package to use.
  19223. @end table
  19224. @end deftp
  19225. @defvar mate-desktop-service-type
  19226. This is the type of the service that runs the @uref{https://mate-desktop.org/,
  19227. MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
  19228. object (see below).
  19229. This service adds the @code{mate} package to the system
  19230. profile, and extends polkit with the actions from
  19231. @code{mate-settings-daemon}.
  19232. @end defvar
  19233. @deftp {Data Type} mate-desktop-configuration
  19234. Configuration record for the MATE desktop environment.
  19235. @table @asis
  19236. @item @code{mate} (default: @code{mate})
  19237. The MATE package to use.
  19238. @end table
  19239. @end deftp
  19240. @defvar lxqt-desktop-service-type
  19241. This is the type of the service that runs the @uref{https://lxqt-project.org,
  19242. LXQt desktop environment}. Its value is a @code{lxqt-desktop-configuration}
  19243. object (see below).
  19244. This service adds the @code{lxqt} package to the system
  19245. profile.
  19246. @end defvar
  19247. @deftp {Data Type} lxqt-desktop-configuration
  19248. Configuration record for the LXQt desktop environment.
  19249. @table @asis
  19250. @item @code{lxqt} (default: @code{lxqt})
  19251. The LXQT package to use.
  19252. @end table
  19253. @end deftp
  19254. @defvar sugar-desktop-service-type
  19255. This is the type of the service that runs the
  19256. @uref{https://www.sugarlabs.org, Sugar desktop environment}. Its value
  19257. is a @code{sugar-desktop-configuration} object (see below).
  19258. This service adds the @code{sugar} package to the system profile, as
  19259. well as any selected Sugar activities. By default it only includes a
  19260. minimal set of activities.
  19261. @end defvar
  19262. @deftp {Data Type} sugar-desktop-configuration
  19263. Configuration record for the Sugar desktop environment.
  19264. @table @asis
  19265. @item @code{sugar} (default: @code{sugar})
  19266. The Sugar package to use.
  19267. @item @code{gobject-introspection} (default: @code{gobject-introspection})
  19268. The @code{gobject-introspection} package to use. This package is used
  19269. to access libraries installed as dependencies of Sugar activities.
  19270. @item @code{activities} (default: @code{(list sugar-help-activity)})
  19271. A list of Sugar activities to install.
  19272. @end table
  19273. @end deftp
  19274. The following example configures the Sugar desktop environment with a
  19275. number of useful activities:
  19276. @lisp
  19277. (use-modules (gnu))
  19278. (use-package-modules sugar)
  19279. (use-service-modules desktop)
  19280. (operating-system
  19281. ...
  19282. (services (cons* (service sugar-desktop-service-type
  19283. (sugar-desktop-configuration
  19284. (activities (list sugar-browse-activity
  19285. sugar-help-activity
  19286. sugar-jukebox-activity
  19287. sugar-typing-turtle-activity))))
  19288. %desktop-services))
  19289. ...)
  19290. @end lisp
  19291. @defvar enlightenment-desktop-service-type
  19292. Return a service that adds the @code{enlightenment} package to the system
  19293. profile, and extends dbus with actions from @code{efl}.
  19294. @end defvar
  19295. @deftp {Data Type} enlightenment-desktop-service-configuration
  19296. @table @asis
  19297. @item @code{enlightenment} (default: @code{enlightenment})
  19298. The enlightenment package to use.
  19299. @end table
  19300. @end deftp
  19301. Because the GNOME, Xfce and MATE desktop services pull in so many packages,
  19302. the default @code{%desktop-services} variable doesn't include any of
  19303. them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
  19304. @code{%desktop-services} in the @code{services} field of your
  19305. @code{operating-system}:
  19306. @lisp
  19307. (use-modules (gnu))
  19308. (use-service-modules desktop)
  19309. (operating-system
  19310. ...
  19311. ;; cons* adds items to the list given as its last argument.
  19312. (services (cons* (service gnome-desktop-service-type)
  19313. (service xfce-desktop-service)
  19314. %desktop-services))
  19315. ...)
  19316. @end lisp
  19317. These desktop environments will then be available as options in the
  19318. graphical login window.
  19319. The actual service definitions included in @code{%desktop-services} and
  19320. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  19321. are described below.
  19322. @defvar dbus-root-service-type
  19323. Type for a service that runs the D-Bus ``system bus''.
  19324. @footnote{@uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process
  19325. communication facility. Its system bus is used to allow system services
  19326. to communicate and to be notified of system-wide events.}
  19327. The value for this service type is a @code{<dbus-configuration>} record.
  19328. @end defvar
  19329. @deftp {Data Type} dbus-configuration
  19330. Data type representing the configuration for @code{dbus-root-service-type}.
  19331. @table @asis
  19332. @item @code{dbus} (default: @code{dbus}) (type: file-like)
  19333. Package object for dbus.
  19334. @item @code{services} (default: @code{'()}) (type: list)
  19335. List of packages that provide an @file{etc/dbus-1/system.d} directory
  19336. containing additional D-Bus configuration and policy files.
  19337. For example, to allow avahi-daemon to use the system bus, @var{services}
  19338. must be equal to @code{(list avahi)}.
  19339. @item @code{verbose?} (default: @code{#f}) (type: boolean)
  19340. When @code{#t}, D-Bus is launched with environment variable
  19341. @samp{DBUS_VERBOSE} set to @samp{1}. A verbose-enabled D-Bus package
  19342. such as @code{dbus-verbose} should be provided to @var{dbus} in this
  19343. scenario. The verbose output is logged to
  19344. @file{/var/log/dbus-daemon.log}.
  19345. @end table
  19346. @end deftp
  19347. @subsubheading Elogind
  19348. @uref{https://github.com/elogind/elogind, Elogind} is a login and seat
  19349. management daemon that also handles most system-level power events for a
  19350. computer, for example suspending the system when a lid is closed, or
  19351. shutting it down when the power button is pressed.
  19352. It also provides a D-Bus interface that can be used to know which users
  19353. are logged in, know what kind of sessions they have open, suspend the
  19354. system, inhibit system suspend, reboot the system, and other tasks.
  19355. @defvar elogind-service-type
  19356. Type of the service that runs @command{elogind}, a login and
  19357. seat management daemon. The value for this service is a
  19358. @code{<elogind-configuration>} object.
  19359. @end defvar
  19360. @c TODO: field descriptions. This is best done by refactoring
  19361. @c elogind-configuration to use define-configuration which embeds the
  19362. @c descriptions in the code and then use configuration->documentation.
  19363. @deftp {Data Type} elogind-configuration
  19364. Data type representing the configuration of @command{elogind}.
  19365. @table @asis
  19366. @item @code{elogind} (default: @code{elogind}) (type: file-like)
  19367. ...
  19368. @item @code{kill-user-processes?} (default: @code{#f}) (type: boolean)
  19369. ...
  19370. @item @code{kill-only-users} (default: @code{'()}) (type: list)
  19371. ...
  19372. @item @code{kill-exclude-users} (default: @code{'("root")}) (type: list-of-string)
  19373. ...
  19374. @item @code{inhibit-delay-max-seconds} (default: @code{5}) (type: integer)
  19375. ...
  19376. @item @code{handle-power-key} (default: @code{'poweroff}) (type: symbol)
  19377. ...
  19378. @item @code{handle-suspend-key} (default: @code{'suspend}) (type: symbol)
  19379. ...
  19380. @item @code{handle-hibernate-key} (default: @code{'hibernate}) (type: symbol)
  19381. ...
  19382. @item @code{handle-lid-switch} (default: @code{'suspend}) (type: symbol)
  19383. ...
  19384. @item @code{handle-lid-switch-docked} (default: @code{'ignore}) (type: symbol)
  19385. ...
  19386. @item @code{handle-lid-switch-external-power} (default: @code{*unspecified*}) (type: symbol)
  19387. ...
  19388. @item @code{power-key-ignore-inhibited?} (default: @code{#f}) (type: boolean)
  19389. ...
  19390. @item @code{suspend-key-ignore-inhibited?} (default: @code{#f}) (type: boolean)
  19391. ...
  19392. @item @code{hibernate-key-ignore-inhibited?} (default: @code{#f}) (type: boolean)
  19393. ...
  19394. @item @code{lid-switch-ignore-inhibited?} (default: @code{#t}) (type: boolean)
  19395. ...
  19396. @item @code{holdoff-timeout-seconds} (default: @code{30}) (type: integer)
  19397. ...
  19398. @item @code{idle-action} (default: @code{'ignore}) (type: symbol)
  19399. ...
  19400. @item @code{idle-action-seconds} (default: @code{(* 30 60)}) (type: integer)
  19401. ...
  19402. @item @code{runtime-directory-size-percent} (default: @code{10}) (type: integer)
  19403. ...
  19404. @item @code{runtime-directory-size} (default: @code{#f}) (type: integer)
  19405. ...
  19406. @item @code{remove-ipc?} (default: @code{#t}) (type: boolean)
  19407. ...
  19408. @item @code{suspend-state} (default: @code{'("mem" "standby" "freeze")}) (type: list)
  19409. ...
  19410. @item @code{suspend-mode} (default: @code{'()}) (type: list)
  19411. ...
  19412. @item @code{hibernate-state} (default: @code{'("disk")}) (type: list)
  19413. ...
  19414. @item @code{hibernate-mode} (default: @code{'("platform" "shutdown")}) (type: list)
  19415. ...
  19416. @item @code{hybrid-sleep-state} (default: @code{'("disk")}) (type: list)
  19417. ...
  19418. @item @code{hybrid-sleep-mode} (default: @code{'("suspend" "platform" "shutdown")}) (type: list)
  19419. ...
  19420. @end table
  19421. @end deftp
  19422. @defvar accountsservice-service-type
  19423. Type for the service that runs AccountsService, a system service that can
  19424. list available accounts, change their passwords, and so on.
  19425. AccountsService integrates with PolicyKit to enable unprivileged users
  19426. to acquire the capability to modify their system configuration.
  19427. See @url{https://www.freedesktop.org/wiki/Software/AccountsService/,
  19428. AccountsService} for more information.
  19429. The value for this service is a file-like object, by default it is
  19430. set to @code{accountsservice} (the package object for AccountsService).
  19431. @end defvar
  19432. @defvar polkit-service-type
  19433. Type for the service that runs the
  19434. @url{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  19435. management service}, which allows system administrators to grant access to
  19436. privileged operations in a structured way. By querying the Polkit service, a
  19437. privileged system component can know when it should grant additional
  19438. capabilities to ordinary users. For example, an ordinary user can be granted
  19439. the capability to suspend the system if the user is logged in locally.
  19440. The value for this service is a @code{<polkit-configuration>} object.
  19441. @end defvar
  19442. @c TODO: Document <polkit-configuration>, preferably by refactoring this to use
  19443. @c define-configuration and generating documentation from it.
  19444. @defvar polkit-wheel-service
  19445. Service that adds the @code{wheel} group as admins to the Polkit
  19446. service. This makes it so that users in the @code{wheel} group are queried
  19447. for their own passwords when performing administrative actions instead of
  19448. @code{root}'s, similar to the behaviour used by @code{sudo}.
  19449. @end defvar
  19450. @defvar upower-service-type
  19451. Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
  19452. system-wide monitor for power consumption and battery levels, with the given
  19453. configuration settings.
  19454. It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
  19455. notably used by GNOME.
  19456. @end defvar
  19457. @deftp {Data Type} upower-configuration
  19458. Data type representation the configuration for UPower.
  19459. @table @asis
  19460. @item @code{upower} (default: @var{upower})
  19461. Package to use for @code{upower}.
  19462. @item @code{watts-up-pro?} (default: @code{#f})
  19463. Enable the Watts Up Pro device.
  19464. @item @code{poll-batteries?} (default: @code{#t})
  19465. Enable polling the kernel for battery level changes.
  19466. @item @code{ignore-lid?} (default: @code{#f})
  19467. Ignore the lid state, this can be useful if it's incorrect on a device.
  19468. @item @code{use-percentage-for-policy?} (default: @code{#t})
  19469. Whether to use a policy based on battery percentage rather than on
  19470. estimated time left. A policy based on battery percentage is usually
  19471. more reliable.
  19472. @item @code{percentage-low} (default: @code{20})
  19473. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  19474. at which the battery is considered low.
  19475. @item @code{percentage-critical} (default: @code{5})
  19476. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  19477. at which the battery is considered critical.
  19478. @item @code{percentage-action} (default: @code{2})
  19479. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  19480. at which action will be taken.
  19481. @item @code{time-low} (default: @code{1200})
  19482. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  19483. seconds at which the battery is considered low.
  19484. @item @code{time-critical} (default: @code{300})
  19485. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  19486. seconds at which the battery is considered critical.
  19487. @item @code{time-action} (default: @code{120})
  19488. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  19489. seconds at which action will be taken.
  19490. @item @code{critical-power-action} (default: @code{'hybrid-sleep})
  19491. The action taken when @code{percentage-action} or @code{time-action} is
  19492. reached (depending on the configuration of @code{use-percentage-for-policy?}).
  19493. Possible values are:
  19494. @itemize @bullet
  19495. @item
  19496. @code{'power-off}
  19497. @item
  19498. @code{'hibernate}
  19499. @item
  19500. @code{'hybrid-sleep}.
  19501. @end itemize
  19502. @end table
  19503. @end deftp
  19504. @defvar udisks-service-type
  19505. Type for the service that runs
  19506. @uref{https://udisks.freedesktop.org/docs/latest/, UDisks},
  19507. a @dfn{disk management} daemon that provides user interfaces
  19508. with notifications and ways to mount/unmount disks. Programs that talk
  19509. to UDisks include the @command{udisksctl} command, part of UDisks, and
  19510. GNOME Disks. Note that Udisks relies on the @command{mount} command, so
  19511. it will only be able to use the file-system utilities installed in the
  19512. system profile. For example if you want to be able to mount NTFS
  19513. file-systems in read and write fashion, you'll need to have
  19514. @code{ntfs-3g} installed system-wide.
  19515. The value for this service is a @code{<udisks-configuration>} object.
  19516. @end defvar
  19517. @deftp {Data Type} udisks-configuration
  19518. Data type representing the configuration for @code{udisks-service-type}.
  19519. @table @asis
  19520. @item @code{udisks} (default: @code{udisks}) (type: file-like)
  19521. Package object for UDisks.
  19522. @end table
  19523. @end deftp
  19524. @defvar colord-service-type
  19525. This is the type of the service that runs @command{colord}, a system
  19526. service with a D-Bus
  19527. interface to manage the color profiles of input and output devices such as
  19528. screens and scanners. It is notably used by the GNOME Color Manager graphical
  19529. tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
  19530. site} for more information.
  19531. @end defvar
  19532. @cindex scanner access
  19533. @defvar sane-service-type
  19534. This service provides access to scanners @i{via}
  19535. @uref{http://www.sane-project.org, SANE} by installing the necessary
  19536. udev rules. It is included in @code{%desktop-services} (@pxref{Desktop
  19537. Services}) and relies by default on @code{sane-backends-minimal} package
  19538. (see below) for hardware support.
  19539. @end defvar
  19540. @defvar sane-backends-minimal
  19541. The default package which the @code{sane-service-type} installs. It
  19542. supports many recent scanners.
  19543. @end defvar
  19544. @defvar sane-backends
  19545. This package includes support for all scanners that
  19546. @code{sane-backends-minimal} supports, plus older Hewlett-Packard
  19547. scanners supported by @code{hplip} package. In order to use this on
  19548. a system which relies on @code{%desktop-services}, you may use
  19549. @code{modify-services} (@pxref{Service Reference,
  19550. @code{modify-services}}) as illustrated below:
  19551. @lisp
  19552. (use-modules (gnu))
  19553. (use-service-modules
  19554. @dots{}
  19555. desktop)
  19556. (use-package-modules
  19557. @dots{}
  19558. scanner)
  19559. (define %my-desktop-services
  19560. ;; List of desktop services that supports a broader range of scanners.
  19561. (modify-services %desktop-services
  19562. (sane-service-type _ => sane-backends)))
  19563. (operating-system
  19564. @dots{}
  19565. (services %my-desktop-services))
  19566. @end lisp
  19567. @end defvar
  19568. @deffn {Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  19569. Return a configuration allowing an application to access GeoClue
  19570. location data. @var{name} is the Desktop ID of the application, without
  19571. the @code{.desktop} part. If @var{allowed?} is true, the application
  19572. will have access to location information by default. The boolean
  19573. @var{system?} value indicates whether an application is a system component
  19574. or not. Finally @var{users} is a list of UIDs of all users for which
  19575. this application is allowed location info access. An empty users list
  19576. means that all users are allowed.
  19577. @end deffn
  19578. @defvar %standard-geoclue-applications
  19579. The standard list of well-known GeoClue application configurations,
  19580. granting authority to the GNOME date-and-time utility to ask for the
  19581. current location in order to set the time zone, and allowing the
  19582. IceCat and Epiphany web browsers to request location information.
  19583. IceCat and Epiphany both query the user before allowing a web page to
  19584. know the user's location.
  19585. @end defvar
  19586. @defvar geoclue-service-type
  19587. Type for the service that runs the
  19588. @url{https://wiki.freedesktop.org/www/Software/GeoClue/, GeoClue}
  19589. location service. This service provides a D-Bus interface to allow
  19590. applications to request access to a user's physical location, and
  19591. optionally to add information to online location databases.
  19592. The value for this service is a @code{<geoclue-configuration>} object.
  19593. @end defvar
  19594. @c TODO: Document <geoclue-configuration>, preferably by refactoring this to use
  19595. @c define-configuration and generating documentation from it.
  19596. @defvar bluetooth-service-type
  19597. This is the type for the @uref{https://bluez.org/, Linux Bluetooth Protocol
  19598. Stack} (BlueZ) system, which generates the @file{/etc/bluetooth/main.conf}
  19599. configuration file. The value for this type is a @command{bluetooth-configuration}
  19600. record as in this example:
  19601. @lisp
  19602. (service bluetooth-service-type)
  19603. @end lisp
  19604. See below for details about @code{bluetooth-configuration}.
  19605. @end defvar
  19606. @deftp {Data Type} bluetooth-configuration
  19607. Data type representing the configuration for @code{bluetooth-service}.
  19608. @table @asis
  19609. @item @code{bluez} (default: @code{bluez})
  19610. @code{bluez} package to use.
  19611. @item @code{name} (default: @code{"BlueZ"})
  19612. Default adapter name.
  19613. @item @code{class} (default: @code{#x000000})
  19614. Default device class. Only the major and minor device class bits are considered.
  19615. @item @code{discoverable-timeout} (default: @code{180})
  19616. How long to stay in discoverable mode before going back to non-discoverable. The
  19617. value is in seconds.
  19618. @item @code{always-pairable?} (default: @code{#f})
  19619. Always allow pairing even if there are no agents registered.
  19620. @item @code{pairable-timeout} (default: @code{0})
  19621. How long to stay in pairable mode before going back to non-discoverable. The
  19622. value is in seconds.
  19623. @item @code{device-id} (default: @code{#f})
  19624. Use vendor id source (assigner), vendor, product and version information for
  19625. DID profile support. The values are separated by ":" and @var{assigner}, @var{VID},
  19626. @var{PID} and @var{version}.
  19627. Possible values are:
  19628. @itemize @bullet
  19629. @item
  19630. @code{#f} to disable it,
  19631. @item
  19632. @code{"assigner:1234:5678:abcd"}, where @var{assigner} is either @code{usb} (default)
  19633. or @code{bluetooth}.
  19634. @end itemize
  19635. @item @code{reverse-service-discovery?} (default: @code{#t})
  19636. Do reverse service discovery for previously unknown devices that connect to
  19637. us. For BR/EDR this option is really only needed for qualification since the
  19638. BITE tester doesn't like us doing reverse SDP for some test cases, for LE
  19639. this disables the GATT client functionally so it can be used in system which
  19640. can only operate as peripheral.
  19641. @item @code{name-resolving?} (default: @code{#t})
  19642. Enable name resolving after inquiry. Set it to @code{#f} if you don't need
  19643. remote devices name and want shorter discovery cycle.
  19644. @item @code{debug-keys?} (default: @code{#f})
  19645. Enable runtime persistency of debug link keys. Default is false which makes
  19646. debug link keys valid only for the duration of the connection that they were
  19647. created for.
  19648. @item @code{controller-mode} (default: @code{'dual})
  19649. Restricts all controllers to the specified transport. @code{'dual} means both
  19650. BR/EDR and LE are enabled (if supported by the hardware).
  19651. Possible values are:
  19652. @itemize @bullet
  19653. @item
  19654. @code{'dual}
  19655. @item
  19656. @code{'bredr}
  19657. @item
  19658. @code{'le}
  19659. @end itemize
  19660. @item @code{multi-profile} (default: @code{'off})
  19661. Enables Multi Profile Specification support. This allows to specify if system
  19662. supports only Multiple Profiles Single Device (MPSD) configuration or both
  19663. Multiple Profiles Single Device (MPSD) and Multiple Profiles Multiple Devices
  19664. (MPMD) configurations.
  19665. Possible values are:
  19666. @itemize @bullet
  19667. @item
  19668. @code{'off}
  19669. @item
  19670. @code{'single}
  19671. @item
  19672. @code{'multiple}
  19673. @end itemize
  19674. @item @code{fast-connectable?} (default: @code{#f})
  19675. Permanently enables the Fast Connectable setting for adapters that support
  19676. it. When enabled other devices can connect faster to us, however the
  19677. tradeoff is increased power consumptions. This feature will fully work only
  19678. on kernel version 4.1 and newer.
  19679. @item @code{privacy} (default: @code{'off})
  19680. Default privacy settings.
  19681. @itemize @bullet
  19682. @item
  19683. @code{'off}: Disable local privacy
  19684. @item
  19685. @code{'network/on}: A device will only accept advertising packets from peer
  19686. devices that contain private addresses. It may not be compatible with some
  19687. legacy devices since it requires the use of RPA(s) all the time
  19688. @item
  19689. @code{'device}: A device in device privacy mode is only concerned about the
  19690. privacy of the device and will accept advertising packets from peer devices
  19691. that contain their Identity Address as well as ones that contain a private
  19692. address, even if the peer device has distributed its IRK in the past
  19693. @end itemize
  19694. and additionally, if @var{controller-mode} is set to @code{'dual}:
  19695. @itemize @bullet
  19696. @item
  19697. @code{'limited-network}: Apply Limited Discoverable Mode to advertising, which
  19698. follows the same policy as to BR/EDR that publishes the identity address when
  19699. discoverable, and Network Privacy Mode for scanning
  19700. @item
  19701. @code{'limited-device}: Apply Limited Discoverable Mode to advertising, which
  19702. follows the same policy as to BR/EDR that publishes the identity address when
  19703. discoverable, and Device Privacy Mode for scanning.
  19704. @end itemize
  19705. @item @code{just-works-repairing} (default: @code{'never})
  19706. Specify the policy to the JUST-WORKS repairing initiated by peer.
  19707. Possible values:
  19708. @itemize @bullet
  19709. @item
  19710. @code{'never}
  19711. @item
  19712. @code{'confirm}
  19713. @item
  19714. @code{'always}
  19715. @end itemize
  19716. @item @code{temporary-timeout} (default: @code{30})
  19717. How long to keep temporary devices around. The value is in seconds. @code{0}
  19718. disables the timer completely.
  19719. @item @code{refresh-discovery?} (default: @code{#t})
  19720. Enables the device to issue an SDP request to update known services when
  19721. profile is connected.
  19722. @item @code{experimental} (default: @code{#f})
  19723. Enables experimental features and interfaces, alternatively a list of UUIDs
  19724. can be given.
  19725. Possible values:
  19726. @itemize @bullet
  19727. @item
  19728. @code{#t}
  19729. @item
  19730. @code{#f}
  19731. @item
  19732. @code{(list (uuid <uuid-1>) (uuid <uuid-2>) ...)}.
  19733. @end itemize
  19734. List of possible UUIDs:
  19735. @itemize @bullet
  19736. @item
  19737. @code{d4992530-b9ec-469f-ab01-6c481c47da1c}: BlueZ Experimental Debug,
  19738. @item
  19739. @code{671b10b5-42c0-4696-9227-eb28d1b049d6}: BlueZ Experimental Simultaneous Central and Peripheral,
  19740. @item
  19741. @code{"15c0a148-c273-11ea-b3de-0242ac130004}: BlueZ Experimental LL privacy,
  19742. @item
  19743. @code{330859bc-7506-492d-9370-9a6f0614037f}: BlueZ Experimental Bluetooth Quality Report,
  19744. @item
  19745. @code{a6695ace-ee7f-4fb9-881a-5fac66c629af}: BlueZ Experimental Offload Codecs.
  19746. @end itemize
  19747. @item @code{remote-name-request-retry-delay} (default: @code{300})
  19748. The duration to avoid retrying to resolve a peer's name, if the previous
  19749. try failed.
  19750. @item @code{page-scan-type} (default: @code{#f})
  19751. BR/EDR Page scan activity type.
  19752. @item @code{page-scan-interval} (default: @code{#f})
  19753. BR/EDR Page scan activity interval.
  19754. @item @code{page-scan-window} (default: @code{#f})
  19755. BR/EDR Page scan activity window.
  19756. @item @code{inquiry-scan-type} (default: @code{#f})
  19757. BR/EDR Inquiry scan activity type.
  19758. @item @code{inquiry-scan-interval} (default: @code{#f})
  19759. BR/EDR Inquiry scan activity interval.
  19760. @item @code{inquiry-scan-window} (default: @code{#f})
  19761. BR/EDR Inquiry scan activity window.
  19762. @item @code{link-supervision-timeout} (default: @code{#f})
  19763. BR/EDR Link supervision timeout.
  19764. @item @code{page-timeout} (default: @code{#f})
  19765. BR/EDR Page timeout.
  19766. @item @code{min-sniff-interval} (default: @code{#f})
  19767. BR/EDR minimum sniff interval.
  19768. @item @code{max-sniff-interval} (default: @code{#f})
  19769. BR/EDR maximum sniff interval.
  19770. @item @code{min-advertisement-interval} (default: @code{#f})
  19771. LE minimum advertisement interval (used for legacy advertisement only).
  19772. @item @code{max-advertisement-interval} (default: @code{#f})
  19773. LE maximum advertisement interval (used for legacy advertisement only).
  19774. @item @code{multi-advertisement-rotation-interval} (default: @code{#f})
  19775. LE multiple advertisement rotation interval.
  19776. @item @code{scan-interval-auto-connect} (default: @code{#f})
  19777. LE scanning interval used for passive scanning supporting auto connect.
  19778. @item @code{scan-window-auto-connect} (default: @code{#f})
  19779. LE scanning window used for passive scanning supporting auto connect.
  19780. @item @code{scan-interval-suspend} (default: @code{#f})
  19781. LE scanning interval used for active scanning supporting wake from suspend.
  19782. @item @code{scan-window-suspend} (default: @code{#f})
  19783. LE scanning window used for active scanning supporting wake from suspend.
  19784. @item @code{scan-interval-discovery} (default: @code{#f})
  19785. LE scanning interval used for active scanning supporting discovery.
  19786. @item @code{scan-window-discovery} (default: @code{#f})
  19787. LE scanning window used for active scanning supporting discovery.
  19788. @item @code{scan-interval-adv-monitor} (default: @code{#f})
  19789. LE scanning interval used for passive scanning supporting the advertisement monitor APIs.
  19790. @item @code{scan-window-adv-monitor} (default: @code{#f})
  19791. LE scanning window used for passive scanning supporting the advertisement monitor APIs.
  19792. @item @code{scan-interval-connect} (default: @code{#f})
  19793. LE scanning interval used for connection establishment.
  19794. @item @code{scan-window-connect} (default: @code{#f})
  19795. LE scanning window used for connection establishment.
  19796. @item @code{min-connection-interval} (default: @code{#f})
  19797. LE default minimum connection interval. This value is superseded by any specific
  19798. value provided via the Load Connection Parameters interface.
  19799. @item @code{max-connection-interval} (default: @code{#f})
  19800. LE default maximum connection interval. This value is superseded by any specific
  19801. value provided via the Load Connection Parameters interface.
  19802. @item @code{connection-latency} (default: @code{#f})
  19803. LE default connection latency. This value is superseded by any specific
  19804. value provided via the Load Connection Parameters interface.
  19805. @item @code{connection-supervision-timeout} (default: @code{#f})
  19806. LE default connection supervision timeout. This value is superseded by any specific
  19807. value provided via the Load Connection Parameters interface.
  19808. @item @code{autoconnect-timeout} (default: @code{#f})
  19809. LE default autoconnect timeout. This value is superseded by any specific
  19810. value provided via the Load Connection Parameters interface.
  19811. @item @code{adv-mon-allowlist-scan-duration} (default: @code{300})
  19812. Allowlist scan duration during interleaving scan. Only used when scanning for ADV
  19813. monitors. The units are msec.
  19814. @item @code{adv-mon-no-filter-scan-duration} (default: @code{500})
  19815. No filter scan duration during interleaving scan. Only used when scanning for ADV
  19816. monitors. The units are msec.
  19817. @item @code{enable-adv-mon-interleave-scan?} (default: @code{#t})
  19818. Enable/Disable Advertisement Monitor interleave scan for power saving.
  19819. @item @code{cache} (default: @code{'always})
  19820. GATT attribute cache.
  19821. Possible values are:
  19822. @itemize @bullet
  19823. @item
  19824. @code{'always}: Always cache attributes even for devices not paired, this is
  19825. recommended as it is best for interoperability, with more consistent
  19826. reconnection times and enables proper tracking of notifications for all
  19827. devices
  19828. @item
  19829. @code{'yes}: Only cache attributes of paired devices
  19830. @item
  19831. @code{'no}: Never cache attributes.
  19832. @end itemize
  19833. @item @code{key-size} (default: @code{0})
  19834. Minimum required Encryption Key Size for accessing secured characteristics.
  19835. Possible values are:
  19836. @itemize @bullet
  19837. @item
  19838. @code{0}: Don't care
  19839. @item
  19840. @code{7 <= N <= 16}
  19841. @end itemize
  19842. @item @code{exchange-mtu} (default: @code{517})
  19843. Exchange MTU size. Possible values are:
  19844. @itemize @bullet
  19845. @item
  19846. @code{23 <= N <= 517}
  19847. @end itemize
  19848. @item @code{att-channels} (default: @code{3})
  19849. Number of ATT channels. Possible values are:
  19850. @itemize @bullet
  19851. @item
  19852. @code{1}: Disables EATT
  19853. @item
  19854. @code{2 <= N <= 5}
  19855. @end itemize
  19856. @item @code{session-mode} (default: @code{'basic})
  19857. AVDTP L2CAP signalling channel mode.
  19858. Possible values are:
  19859. @itemize @bullet
  19860. @item
  19861. @code{'basic}: Use L2CAP basic mode
  19862. @item
  19863. @code{'ertm}: Use L2CAP enhanced retransmission mode.
  19864. @end itemize
  19865. @item @code{stream-mode} (default: @code{'basic})
  19866. AVDTP L2CAP transport channel mode.
  19867. Possible values are:
  19868. @itemize @bullet
  19869. @item
  19870. @code{'basic}: Use L2CAP basic mode
  19871. @item
  19872. @code{'streaming}: Use L2CAP streaming mode.
  19873. @end itemize
  19874. @item @code{reconnect-uuids} (default: @code{'()})
  19875. The ReconnectUUIDs defines the set of remote services that should try
  19876. to be reconnected to in case of a link loss (link supervision
  19877. timeout). The policy plugin should contain a sane set of values by
  19878. default, but this list can be overridden here. By setting the list to
  19879. empty the reconnection feature gets disabled.
  19880. Possible values:
  19881. @itemize @bullet
  19882. @item
  19883. @code{'()}
  19884. @item
  19885. @code{(list (uuid <uuid-1>) (uuid <uuid-2>) ...)}.
  19886. @end itemize
  19887. @item @code{reconnect-attempts} (default: @code{7})
  19888. Defines the number of attempts to reconnect after a link lost. Setting
  19889. the value to 0 disables reconnecting feature.
  19890. @item @code{reconnect-intervals} (default: @code{'(1 2 4 8 16 32 64)})
  19891. Defines a list of intervals in seconds to use in between attempts. If
  19892. the number of attempts defined in @var{reconnect-attempts} is bigger than
  19893. the list of intervals the last interval is repeated until the last attempt.
  19894. @item @code{auto-enable?} (default: @code{#f})
  19895. Defines option to enable all controllers when they are found. This includes
  19896. adapters present on start as well as adapters that are plugged in later on.
  19897. @item @code{resume-delay} (default: @code{2})
  19898. Audio devices that were disconnected due to suspend will be reconnected on
  19899. resume. @var{resume-delay} determines the delay between when the controller
  19900. resumes from suspend and a connection attempt is made. A longer delay is
  19901. better for better co-existence with Wi-Fi. The value is in seconds.
  19902. @item @code{rssi-sampling-period} (default: @code{#xFF})
  19903. Default RSSI Sampling Period. This is used when a client registers an
  19904. advertisement monitor and leaves the RSSISamplingPeriod unset.
  19905. Possible values are:
  19906. @itemize @bullet
  19907. @item
  19908. @code{#x0}: Report all advertisements
  19909. @item
  19910. @code{N = #xXX}: Report advertisements every N x 100 msec (range: #x01 to #xFE)
  19911. @item
  19912. @code{#xFF}: Report only one advertisement per device during monitoring period.
  19913. @end itemize
  19914. @end table
  19915. @end deftp
  19916. @defvar gnome-keyring-service-type
  19917. This is the type of the service that adds the
  19918. @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
  19919. value is a @code{gnome-keyring-configuration} object (see below).
  19920. This service adds the @code{gnome-keyring} package to the system profile
  19921. and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
  19922. a user's login keyring when they log in or setting its password with passwd.
  19923. @end defvar
  19924. @deftp {Data Type} gnome-keyring-configuration
  19925. Configuration record for the GNOME Keyring service.
  19926. @table @asis
  19927. @item @code{keyring} (default: @code{gnome-keyring})
  19928. The GNOME keyring package to use.
  19929. @item @code{pam-services}
  19930. A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
  19931. services to extend, where @var{service} is the name of an existing
  19932. service to extend and @var{kind} is one of @code{login} or
  19933. @code{passwd}.
  19934. If @code{login} is given, it adds an optional
  19935. @code{pam_gnome_keyring.so} to the auth block without arguments and to
  19936. the session block with @code{auto_start}. If @code{passwd} is given, it
  19937. adds an optional @code{pam_gnome_keyring.so} to the password block
  19938. without arguments.
  19939. By default, this field contains ``gdm-password'' with the value @code{login}
  19940. and ``passwd'' is with the value @code{passwd}.
  19941. @end table
  19942. @end deftp
  19943. @defvar seatd-service-type
  19944. @uref{https://sr.ht/~kennylevinsen/seatd/, seatd} is a minimal seat
  19945. management daemon.
  19946. Seat management takes care of mediating access to shared devices (graphics,
  19947. input), without requiring the applications needing access to be root.
  19948. @lisp
  19949. (append
  19950. (list
  19951. ;; make sure seatd is running
  19952. (service seatd-service-type))
  19953. ;; normally one would want %base-services
  19954. %base-services)
  19955. @end lisp
  19956. @code{seatd} operates over a UNIX domain socket, with @code{libseat}
  19957. providing the client side of the protocol. Applications that acquire
  19958. access to the shared resources via @code{seatd} (e.g. @code{sway})
  19959. need to be able to talk to this socket.
  19960. This can be achieved by adding the user they run under to the group
  19961. owning @code{seatd}'s socket (usually ``seat''), like so:
  19962. @lisp
  19963. (user-account
  19964. (name "alice")
  19965. (group "users")
  19966. (supplementary-groups '("wheel" ; allow use of sudo, etc.
  19967. "seat" ; seat management
  19968. "audio" ; sound card
  19969. "video" ; video devices such as webcams
  19970. "cdrom")) ; the good ol' CD-ROM
  19971. (comment "Bob's sister"))
  19972. @end lisp
  19973. Depending on your setup, you will have to not only add regular users,
  19974. but also system users to this group. For instance, some greetd greeters
  19975. require graphics and therefore also need to negotiate with seatd.
  19976. @end defvar
  19977. @deftp {Data Type} seatd-configuration
  19978. Configuration record for the seatd daemon service.
  19979. @table @asis
  19980. @item @code{seatd} (default: @code{seatd})
  19981. The seatd package to use.
  19982. @item @code{group} (default: @samp{"seat"})
  19983. Group to own the seatd socket.
  19984. @item @code{socket} (default: @samp{"/run/seatd.sock"})
  19985. Where to create the seatd socket.
  19986. @item @code{logfile} (default: @samp{"/var/log/seatd.log"})
  19987. Log file to write to.
  19988. @item @code{loglevel} (default: @samp{"error"})
  19989. Log level to output logs. Possible values: @samp{"silent"}, @samp{"error"},
  19990. @samp{"info"} and @samp{"debug"}.
  19991. @end table
  19992. @end deftp
  19993. @node Sound Services
  19994. @subsection Sound Services
  19995. @cindex sound support
  19996. @cindex ALSA
  19997. @cindex PulseAudio, sound support
  19998. The @code{(gnu services sound)} module provides a service to configure the
  19999. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  20000. preferred ALSA output driver.
  20001. @defvar alsa-service-type
  20002. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  20003. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  20004. configuration file. The value for this type is a @command{alsa-configuration}
  20005. record as in this example:
  20006. @lisp
  20007. (service alsa-service-type)
  20008. @end lisp
  20009. See below for details about @code{alsa-configuration}.
  20010. @end defvar
  20011. @deftp {Data Type} alsa-configuration
  20012. Data type representing the configuration for @code{alsa-service}.
  20013. @table @asis
  20014. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  20015. @code{alsa-plugins} package to use.
  20016. @item @code{pulseaudio?} (default: @var{#t})
  20017. Whether ALSA applications should transparently be made to use the
  20018. @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
  20019. Using PulseAudio allows you to run several sound-producing applications
  20020. at the same time and to individual control them @i{via}
  20021. @command{pavucontrol}, among other things.
  20022. @item @code{extra-options} (default: @var{""})
  20023. String to append to the @file{/etc/asound.conf} file.
  20024. @end table
  20025. @end deftp
  20026. Individual users who want to override the system configuration of ALSA can do
  20027. it with the @file{~/.asoundrc} file:
  20028. @example
  20029. # In guix, we have to specify the absolute path for plugins.
  20030. pcm_type.jack @{
  20031. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  20032. @}
  20033. # Routing ALSA to jack:
  20034. # <http://jackaudio.org/faq/routing_alsa.html>.
  20035. pcm.rawjack @{
  20036. type jack
  20037. playback_ports @{
  20038. 0 system:playback_1
  20039. 1 system:playback_2
  20040. @}
  20041. capture_ports @{
  20042. 0 system:capture_1
  20043. 1 system:capture_2
  20044. @}
  20045. @}
  20046. pcm.!default @{
  20047. type plug
  20048. slave @{
  20049. pcm "rawjack"
  20050. @}
  20051. @}
  20052. @end example
  20053. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  20054. details.
  20055. @defvar pulseaudio-service-type
  20056. This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
  20057. sound server. It exists to allow system overrides of the default settings
  20058. via @code{pulseaudio-configuration}, see below.
  20059. @quotation Warning
  20060. This service overrides per-user configuration files. If you want
  20061. PulseAudio to honor configuration files in @file{~/.config/pulse} you
  20062. have to unset the environment variables @env{PULSE_CONFIG} and
  20063. @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
  20064. @end quotation
  20065. @quotation Warning
  20066. This service on its own does not ensure, that the @code{pulseaudio} package
  20067. exists on your machine. It merely adds configuration files for it, as
  20068. detailed below. In the (admittedly unlikely) case, that you find yourself
  20069. without a @code{pulseaudio} package, consider enabling it through the
  20070. @code{alsa-service-type} above.
  20071. @end quotation
  20072. @end defvar
  20073. @deftp {Data Type} pulseaudio-configuration
  20074. Data type representing the configuration for @code{pulseaudio-service}.
  20075. @table @asis
  20076. @item @code{client-conf} (default: @code{'()})
  20077. List of settings to set in @file{client.conf}.
  20078. Accepts a list of strings or symbol-value pairs. A string will be
  20079. inserted as-is with a newline added. A pair will be formatted as
  20080. ``key = value'', again with a newline added.
  20081. @item @code{daemon-conf} (default: @code{'((flat-volumes . no))})
  20082. List of settings to set in @file{daemon.conf}, formatted just like
  20083. @var{client-conf}.
  20084. @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
  20085. Script file to use as @file{default.pa}. In case the
  20086. @code{extra-script-files} field below is used, an @code{.include}
  20087. directive pointing to @file{/etc/pulse/default.pa.d} is appended to the
  20088. provided script.
  20089. @item @code{extra-script-files} (default: @code{'()})
  20090. A list of file-like objects defining extra PulseAudio scripts to run at
  20091. the initialization of the @command{pulseaudio} daemon, after the main
  20092. @code{script-file}. The scripts are deployed to the
  20093. @file{/etc/pulse/default.pa.d} directory; they should have the
  20094. @samp{.pa} file name extension. For a reference of the available
  20095. commands, refer to @command{man pulse-cli-syntax}.
  20096. @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
  20097. Script file to use as @file{system.pa}.
  20098. @end table
  20099. The example below sets the default PulseAudio card profile, the default
  20100. sink and the default source to use for a old SoundBlaster Audigy sound
  20101. card:
  20102. @lisp
  20103. (pulseaudio-configuration
  20104. (extra-script-files
  20105. (list (plain-file "audigy.pa"
  20106. (string-append "\
  20107. set-card-profile alsa_card.pci-0000_01_01.0 \
  20108. output:analog-surround-40+input:analog-mono
  20109. set-default-source alsa_input.pci-0000_01_01.0.analog-mono
  20110. set-default-sink alsa_output.pci-0000_01_01.0.analog-surround-40\n")))))
  20111. @end lisp
  20112. Note that @code{pulseaudio-service-type} is part of
  20113. @code{%desktop-services}; if your operating system declaration was
  20114. derived from one of the desktop templates, you'll want to adjust the
  20115. above example to modify the existing @code{pulseaudio-service-type} via
  20116. @code{modify-services} (@pxref{Service Reference,
  20117. @code{modify-services}}), instead of defining a new one.
  20118. @end deftp
  20119. @defvar ladspa-service-type
  20120. This service sets the @var{LADSPA_PATH} variable, so that programs, which
  20121. respect it, e.g. PulseAudio, can load LADSPA plugins.
  20122. The following example will setup the service to enable modules from the
  20123. @code{swh-plugins} package:
  20124. @lisp
  20125. (service ladspa-service-type
  20126. (ladspa-configuration (plugins (list swh-plugins))))
  20127. @end lisp
  20128. See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
  20129. details.
  20130. @end defvar
  20131. @node File Search Services
  20132. @subsection File Search Services
  20133. @cindex file search
  20134. @cindex searching for a file
  20135. The services in this section populate @dfn{file databases} that let you
  20136. search for files on your machine. These services are provided by the
  20137. @code{(gnu services admin)} module.
  20138. The first one, @code{file-database-service-type}, periodically runs the
  20139. venerable @command{updatedb} command (@pxref{Invoking updatedb,,, find,
  20140. GNU Findutils}). That command populates a database of file names that
  20141. you can then search with the @command{locate} command (@pxref{Invoing
  20142. locate,,, find, GNU Findutils}), as in this example:
  20143. @example
  20144. locate important-notes.txt
  20145. @end example
  20146. You can enable this service with its default settings by adding this
  20147. snippet to your operating system services:
  20148. @lisp
  20149. (service file-database-service-type)
  20150. @end lisp
  20151. This updates the database once a week, excluding files from
  20152. @file{/gnu/store}---these are more usefully handled by @command{guix
  20153. locate} (@pxref{Invoking guix locate}). You can of course provide a
  20154. custom configuration, as described below.
  20155. @defvar file-database-service-type
  20156. This is the type of the file database service, which runs
  20157. @command{updatedb} periodically. Its associated value must be a
  20158. @code{file-database-configuration} record, as described below.
  20159. @end defvar
  20160. @deftp {Data Type} file-database-configuration
  20161. Record type for the @code{file-database-service-type} configuration,
  20162. with the following fields:
  20163. @table @asis
  20164. @item @code{package} (default: @code{findutils})
  20165. The GNU@tie{}Findutils package from which the @command{updatedb} command
  20166. is taken.
  20167. @item @code{schedule} (default: @code{%default-file-database-update-schedule})
  20168. String or G-exp denoting an mcron schedule for the periodic
  20169. @command{updatedb} job (@pxref{Guile Syntax,,, mcron, GNU@tie{}mcron}).
  20170. @item @code{excluded-directories} (default @code{%default-file-database-excluded-directories})
  20171. List of regular expressions of directories to ignore when building the
  20172. file database. By default, this includes @file{/tmp} and @file{/gnu/store};
  20173. the latter should instead be indexed by @command{guix locate} (@pxref{Invoking
  20174. guix locate}). This list is passed to the @option{--prunepaths} option of
  20175. @command{updatedb} (@pxref{Invoking updatedb,,, find, GNU@tie{}Findutils}).
  20176. @end table
  20177. @end deftp
  20178. The second service, @code{package-database-service-type}, builds the
  20179. database used by @command{guix locate}, which lets you search for
  20180. packages that contain a given file (@pxref{Invoking guix locate}). The
  20181. service periodically updates a system-wide database, which will be
  20182. readily available to anyone running @command{guix locate} on the system.
  20183. To use this service with its default settings, add this snippet to your
  20184. service list:
  20185. @lisp
  20186. (service package-database-service-type)
  20187. @end lisp
  20188. This will run @command{guix locate --update} once a week.
  20189. @defvar package-database-service-type
  20190. This is the service type for periodic @command{guix locate} updates
  20191. (@pxref{Invoking guix locate}). Its value must be a
  20192. @code{package-database-configuration} record, as shown below.
  20193. @end defvar
  20194. @deftp {Data Type} package-database-configuration
  20195. Data type to configure periodic package database updates. It has the
  20196. following fields:
  20197. @table @asis
  20198. @item @code{package} (default: @code{guix})
  20199. The Guix package to use.
  20200. @item @code{schedule} (default: @code{%default-package-database-update-schedule})
  20201. String or G-exp denoting an mcron schedule for the periodic
  20202. @command{guix locate --update} job (@pxref{Guile Syntax,,, mcron,
  20203. GNU@tie{}mcron}).
  20204. @item @code{method} (default: @code{'store})
  20205. Indexing method for @command{guix locate}. The default value,
  20206. @code{'store}, yields a more complete database but is relatively
  20207. expensive in terms of CPU and input/output.
  20208. @item @code{channels} (default: @code{#~%default-channels})
  20209. G-exp denoting the channels to use when updating the database
  20210. (@pxref{Channels}).
  20211. @end table
  20212. @end deftp
  20213. @node Database Services
  20214. @subsection Database Services
  20215. @cindex database
  20216. @cindex SQL
  20217. The @code{(gnu services databases)} module provides the following services.
  20218. @subsubheading PostgreSQL
  20219. The following example describes a PostgreSQL service with the default
  20220. configuration.
  20221. @lisp
  20222. (service postgresql-service-type
  20223. (postgresql-configuration
  20224. (postgresql postgresql-10)))
  20225. @end lisp
  20226. If the services fails to start, it may be due to an incompatible
  20227. cluster already present in @var{data-directory}. Adjust it (or, if you
  20228. don't need the cluster anymore, delete @var{data-directory}), then
  20229. restart the service.
  20230. Peer authentication is used by default and the @code{postgres} user
  20231. account has no shell, which prevents the direct execution of @code{psql}
  20232. commands as this user. To use @code{psql}, you can temporarily log in
  20233. as @code{postgres} using a shell, create a PostgreSQL superuser with the
  20234. same name as one of the system users and then create the associated
  20235. database.
  20236. @example
  20237. sudo -u postgres -s /bin/sh
  20238. createuser --interactive
  20239. createdb $MY_USER_LOGIN # Replace appropriately.
  20240. @end example
  20241. @deftp {Data Type} postgresql-configuration
  20242. Data type representing the configuration for the
  20243. @code{postgresql-service-type}.
  20244. @table @asis
  20245. @item @code{postgresql}
  20246. PostgreSQL package to use for the service.
  20247. @item @code{port} (default: @code{5432})
  20248. Port on which PostgreSQL should listen.
  20249. @item @code{locale} (default: @code{"en_US.utf8"})
  20250. Locale to use as the default when creating the database cluster.
  20251. @item @code{config-file} (default: @code{(postgresql-config-file)})
  20252. The configuration file to use when running PostgreSQL@. The default
  20253. behaviour uses the postgresql-config-file record with the default values
  20254. for the fields.
  20255. @item @code{log-directory} (default: @code{"/var/log/postgresql"})
  20256. The directory where @command{pg_ctl} output will be written in a file
  20257. named @code{"pg_ctl.log"}. This file can be useful to debug PostgreSQL
  20258. configuration errors for instance.
  20259. @item @code{data-directory} (default: @code{"/var/lib/postgresql/data"})
  20260. Directory in which to store the data.
  20261. @item @code{extension-packages} (default: @code{'()})
  20262. @cindex postgresql extension-packages
  20263. Additional extensions are loaded from packages listed in
  20264. @var{extension-packages}. Extensions are available at runtime. For instance,
  20265. to create a geographic database using the @code{postgis} extension, a user can
  20266. configure the postgresql-service as in this example:
  20267. @cindex postgis
  20268. @lisp
  20269. (use-package-modules databases geo)
  20270. (operating-system
  20271. ...
  20272. ;; postgresql is required to run `psql' but postgis is not required for
  20273. ;; proper operation.
  20274. (packages (cons* postgresql %base-packages))
  20275. (services
  20276. (cons*
  20277. (service postgresql-service-type
  20278. (postgresql-configuration
  20279. (postgresql postgresql-10)
  20280. (extension-packages (list postgis))))
  20281. %base-services)))
  20282. @end lisp
  20283. Then the extension becomes visible and you can initialise an empty geographic
  20284. database in this way:
  20285. @example
  20286. psql -U postgres
  20287. > create database postgistest;
  20288. > \connect postgistest;
  20289. > create extension postgis;
  20290. > create extension postgis_topology;
  20291. @end example
  20292. There is no need to add this field for contrib extensions such as hstore or
  20293. dblink as they are already loadable by postgresql. This field is only
  20294. required to add extensions provided by other packages.
  20295. @item @code{create-account?} (default: @code{#t})
  20296. Whether or not the @code{postgres} user and group should be created.
  20297. @item @code{uid} (default: @code{#f})
  20298. Explicitly specify the UID of the @code{postgres} daemon account.
  20299. You normally do not need to specify this, in which case a free UID will
  20300. be automatically assigned.
  20301. One situation where this option might be useful is if the @var{data-directory}
  20302. is located on a mounted network share.
  20303. @item @code{gid} (default: @code{#f})
  20304. Explicitly specify the GID of the @code{postgres} group.
  20305. @end table
  20306. @end deftp
  20307. @deftp {Data Type} postgresql-config-file
  20308. Data type representing the PostgreSQL configuration file. As shown in
  20309. the following example, this can be used to customize the configuration
  20310. of PostgreSQL@. Note that you can use any G-expression or filename in
  20311. place of this record, if you already have a configuration file you'd
  20312. like to use for example.
  20313. @lisp
  20314. (service postgresql-service-type
  20315. (postgresql-configuration
  20316. (config-file
  20317. (postgresql-config-file
  20318. (log-destination "stderr")
  20319. (hba-file
  20320. (plain-file "pg_hba.conf"
  20321. "
  20322. local all all trust
  20323. host all all 127.0.0.1/32 md5
  20324. host all all ::1/128 md5"))
  20325. (extra-config
  20326. '(("session_preload_libraries" "auto_explain")
  20327. ("random_page_cost" 2)
  20328. ("auto_explain.log_min_duration" "100 ms")
  20329. ("work_mem" "500 MB")
  20330. ("logging_collector" #t)
  20331. ("log_directory" "/var/log/postgresql")))))))
  20332. @end lisp
  20333. @table @asis
  20334. @item @code{log-destination} (default: @code{"syslog"})
  20335. The logging method to use for PostgreSQL@. Multiple values are accepted,
  20336. separated by commas.
  20337. @item @code{hba-file} (default: @code{%default-postgres-hba})
  20338. Filename or G-expression for the host-based authentication
  20339. configuration.
  20340. @item @code{ident-file} (default: @code{%default-postgres-ident})
  20341. Filename or G-expression for the user name mapping configuration.
  20342. @item @code{socket-directory} (default: @code{"/var/run/postgresql"})
  20343. Specifies the directory of the Unix-domain socket(s) on which PostgreSQL
  20344. is to listen for connections from client applications. If set to
  20345. @code{""} PostgreSQL does not listen on any Unix-domain sockets, in
  20346. which case only TCP/IP sockets can be used to connect to the server.
  20347. By default, the @code{#false} value means the PostgreSQL default value
  20348. will be used, which is currently @samp{/tmp}.
  20349. @item @code{extra-config} (default: @code{'()})
  20350. List of additional keys and values to include in the PostgreSQL config
  20351. file. Each entry in the list should be a list where the first element
  20352. is the key, and the remaining elements are the values.
  20353. The values can be numbers, booleans or strings and will be mapped to
  20354. PostgreSQL parameters types @code{Boolean}, @code{String},
  20355. @code{Numeric}, @code{Numeric with Unit} and @code{Enumerated} described
  20356. @uref{https://www.postgresql.org/docs/current/config-setting.html,
  20357. here}.
  20358. @end table
  20359. @end deftp
  20360. @defvar postgresql-role-service-type
  20361. This service allows to create PostgreSQL roles and databases after
  20362. PostgreSQL service start. Here is an example of its use.
  20363. @lisp
  20364. (service postgresql-role-service-type
  20365. (postgresql-role-configuration
  20366. (roles
  20367. (list (postgresql-role
  20368. (name "test")
  20369. (create-database? #t))))))
  20370. @end lisp
  20371. This service can be extended with extra roles, as in this
  20372. example:
  20373. @lisp
  20374. (service-extension postgresql-role-service-type
  20375. (const (postgresql-role
  20376. (name "alice")
  20377. (create-database? #t))))
  20378. @end lisp
  20379. @end defvar
  20380. @deftp {Data Type} postgresql-role
  20381. PostgreSQL manages database access permissions using the concept of
  20382. roles. A role can be thought of as either a database user, or a group
  20383. of database users, depending on how the role is set up. Roles can own
  20384. database objects (for example, tables) and can assign privileges on
  20385. those objects to other roles to control who has access to which objects.
  20386. @table @asis
  20387. @item @code{name}
  20388. The role name.
  20389. @item @code{permissions} (default: @code{'(createdb login)})
  20390. The role permissions list. Supported permissions are @code{bypassrls},
  20391. @code{createdb}, @code{createrole}, @code{login}, @code{replication} and
  20392. @code{superuser}.
  20393. @item @code{create-database?} (default: @code{#f})
  20394. whether to create a database with the same name as the role.
  20395. @item @code{encoding} (default: @code{"UTF8"})
  20396. The character set to use for storing text in the database.
  20397. @item @code{collation} (default: @code{"en_US.utf8"})
  20398. The string sort order locale setting.
  20399. @item @code{ctype} (default: @code{"en_US.utf8"})
  20400. The character classification locale setting.
  20401. @item @code{template} (default: @code{"template1"})
  20402. The default template to copy the new database from when creating it.
  20403. Use @code{"template0"} for a pristine database with no system-local
  20404. modifications.
  20405. @end table
  20406. @end deftp
  20407. @deftp {Data Type} postgresql-role-configuration
  20408. Data type representing the configuration of
  20409. @var{postgresql-role-service-type}.
  20410. @table @asis
  20411. @item @code{host} (default: @code{"/var/run/postgresql"})
  20412. The PostgreSQL host to connect to.
  20413. @item @code{log} (default: @code{"/var/log/postgresql_roles.log"})
  20414. File name of the log file.
  20415. @item @code{roles} (default: @code{'()})
  20416. The initial PostgreSQL roles to create.
  20417. @end table
  20418. @end deftp
  20419. @subsubheading MariaDB/MySQL
  20420. @defvar mysql-service-type
  20421. This is the service type for a MySQL or MariaDB database server. Its value
  20422. is a @code{mysql-configuration} object that specifies which package to use,
  20423. as well as various settings for the @command{mysqld} daemon.
  20424. @end defvar
  20425. @deftp {Data Type} mysql-configuration
  20426. Data type representing the configuration of @var{mysql-service-type}.
  20427. @table @asis
  20428. @item @code{mysql} (default: @var{mariadb})
  20429. Package object of the MySQL database server, can be either @var{mariadb}
  20430. or @var{mysql}.
  20431. For MySQL, a temporary root password will be displayed at activation time.
  20432. For MariaDB, the root password is empty.
  20433. @item @code{bind-address} (default: @code{"127.0.0.1"})
  20434. The IP on which to listen for network connections. Use @code{"0.0.0.0"}
  20435. to bind to all available network interfaces.
  20436. @item @code{port} (default: @code{3306})
  20437. TCP port on which the database server listens for incoming connections.
  20438. @item @code{socket} (default: @code{"/run/mysqld/mysqld.sock"})
  20439. Socket file to use for local (non-network) connections.
  20440. @item @code{extra-content} (default: @code{""})
  20441. Additional settings for the @file{my.cnf} configuration file.
  20442. @item @code{extra-environment} (default: @code{#~'()})
  20443. List of environment variables passed to the @command{mysqld} process.
  20444. @item @code{auto-upgrade?} (default: @code{#t})
  20445. Whether to automatically run @command{mysql_upgrade} after starting the
  20446. service. This is necessary to upgrade the @dfn{system schema} after
  20447. ``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can
  20448. be disabled if you would rather do that manually.
  20449. @end table
  20450. @end deftp
  20451. @subsubheading Memcached
  20452. @defvar memcached-service-type
  20453. This is the service type for the @uref{https://memcached.org/,
  20454. Memcached} service, which provides a distributed in memory cache. The
  20455. value for the service type is a @code{memcached-configuration} object.
  20456. @end defvar
  20457. @lisp
  20458. (service memcached-service-type)
  20459. @end lisp
  20460. @deftp {Data Type} memcached-configuration
  20461. Data type representing the configuration of memcached.
  20462. @table @asis
  20463. @item @code{memcached} (default: @code{memcached})
  20464. The Memcached package to use.
  20465. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  20466. Network interfaces on which to listen.
  20467. @item @code{tcp-port} (default: @code{11211})
  20468. Port on which to accept connections.
  20469. @item @code{udp-port} (default: @code{11211})
  20470. Port on which to accept UDP connections on, a value of 0 will disable
  20471. listening on a UDP socket.
  20472. @item @code{additional-options} (default: @code{'()})
  20473. Additional command line options to pass to @code{memcached}.
  20474. @end table
  20475. @end deftp
  20476. @subsubheading Redis
  20477. @defvar redis-service-type
  20478. This is the service type for the @uref{https://redis.io/, Redis}
  20479. key/value store, whose value is a @code{redis-configuration} object.
  20480. @end defvar
  20481. @deftp {Data Type} redis-configuration
  20482. Data type representing the configuration of redis.
  20483. @table @asis
  20484. @item @code{redis} (default: @code{redis})
  20485. The Redis package to use.
  20486. @item @code{bind} (default: @code{"127.0.0.1"})
  20487. Network interface on which to listen.
  20488. @item @code{port} (default: @code{6379})
  20489. Port on which to accept connections on, a value of 0 will disable
  20490. listening on a TCP socket.
  20491. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  20492. Directory in which to store the database and related files.
  20493. @end table
  20494. @end deftp
  20495. @node Mail Services
  20496. @subsection Mail Services
  20497. @cindex mail
  20498. @cindex email
  20499. The @code{(gnu services mail)} module provides Guix service definitions
  20500. for email services: IMAP, POP3, and LMTP servers, as well as mail
  20501. transport agents (MTAs). Lots of acronyms! These services are detailed
  20502. in the subsections below.
  20503. @subsubheading Dovecot Service
  20504. @defvar dovecot-service-type
  20505. Type for the service that runs the Dovecot IMAP/POP3/LMTP mail server,
  20506. whose value is a @code{<dovecot-configuration>} object.
  20507. @end defvar
  20508. By default, Dovecot does not need much configuration; the default
  20509. configuration object created by @code{(dovecot-configuration)} will
  20510. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  20511. certificate will be generated for TLS-protected connections, though
  20512. Dovecot will also listen on cleartext ports by default. There are a
  20513. number of options, though, which mail administrators might need to change,
  20514. and as is the case with other services, Guix allows the system
  20515. administrator to specify these parameters via a uniform Scheme interface.
  20516. For example, to specify that mail is located at @code{maildir~/.mail},
  20517. one would instantiate the Dovecot service like this:
  20518. @lisp
  20519. (service dovecot-service-type
  20520. (dovecot-configuration
  20521. (mail-location "maildir:~/.mail")))
  20522. @end lisp
  20523. The available configuration parameters follow. Each parameter
  20524. definition is preceded by its type; for example, @samp{string-list foo}
  20525. indicates that the @code{foo} parameter should be specified as a list of
  20526. strings. There is also a way to specify the configuration as a string,
  20527. if you have an old @code{dovecot.conf} file that you want to port over
  20528. from some other system; see the end for more details.
  20529. @c The following documentation was initially generated by
  20530. @c (generate-documentation) in (gnu services mail). Manually maintained
  20531. @c documentation is better, so we shouldn't hesitate to edit below as
  20532. @c needed. However if the change you want to make to this documentation
  20533. @c can be done in an automated way, it's probably easier to change
  20534. @c (generate-documentation) than to make it below and have to deal with
  20535. @c the churn as dovecot updates.
  20536. Available @code{dovecot-configuration} fields are:
  20537. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  20538. The dovecot package.
  20539. @end deftypevr
  20540. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  20541. A list of IPs or hosts where to listen for connections. @samp{*}
  20542. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  20543. interfaces. If you want to specify non-default ports or anything more
  20544. complex, customize the address and port fields of the
  20545. @samp{inet-listener} of the specific services you are interested in.
  20546. @end deftypevr
  20547. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  20548. List of protocols we want to serve. Available protocols include
  20549. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  20550. Available @code{protocol-configuration} fields are:
  20551. @deftypevr {@code{protocol-configuration} parameter} string name
  20552. The name of the protocol.
  20553. @end deftypevr
  20554. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  20555. UNIX socket path to the master authentication server to find users.
  20556. This is used by imap (for shared users) and lda.
  20557. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  20558. @end deftypevr
  20559. @deftypevr {@code{protocol-configuration} parameter} boolean imap-metadata?
  20560. Whether to enable the @code{IMAP METADATA} extension as defined in
  20561. @uref{https://tools.ietf.org/html/rfc5464,RFC@tie{}5464}, which provides
  20562. a means for clients to set and retrieve per-mailbox, per-user metadata
  20563. and annotations over IMAP.
  20564. If this is @samp{#t}, you must also specify a dictionary @i{via} the
  20565. @code{mail-attribute-dict} setting.
  20566. Defaults to @samp{#f}.
  20567. @end deftypevr
  20568. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-notify-capabilities
  20569. Which NOTIFY capabilities to report to clients that first connect to
  20570. the ManageSieve service, before authentication. These may differ from the
  20571. capabilities offered to authenticated users. If this field is left empty,
  20572. report what the Sieve interpreter supports by default.
  20573. Defaults to @samp{'()}.
  20574. @end deftypevr
  20575. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-sieve-capability
  20576. Which SIEVE capabilities to report to clients that first connect to
  20577. the ManageSieve service, before authentication. These may differ from the
  20578. capabilities offered to authenticated users. If this field is left empty,
  20579. report what the Sieve interpreter supports by default.
  20580. Defaults to @samp{'()}.
  20581. @end deftypevr
  20582. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  20583. Space separated list of plugins to load.
  20584. @end deftypevr
  20585. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  20586. Maximum number of IMAP connections allowed for a user from each IP
  20587. address. NOTE: The username is compared case-sensitively.
  20588. Defaults to @samp{10}.
  20589. @end deftypevr
  20590. @end deftypevr
  20591. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  20592. List of services to enable. Available services include @samp{imap},
  20593. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  20594. @samp{lmtp}.
  20595. Available @code{service-configuration} fields are:
  20596. @deftypevr {@code{service-configuration} parameter} string kind
  20597. The service kind. Valid values include @code{director},
  20598. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  20599. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  20600. @code{tcpwrap}, @code{quota-warning}, or anything else.
  20601. @end deftypevr
  20602. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  20603. Listeners for the service. A listener is either a
  20604. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  20605. an @code{inet-listener-configuration}.
  20606. Defaults to @samp{'()}.
  20607. Available @code{unix-listener-configuration} fields are:
  20608. @deftypevr {@code{unix-listener-configuration} parameter} string path
  20609. Path to the file, relative to @code{base-dir} field. This is also used as
  20610. the section name.
  20611. @end deftypevr
  20612. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  20613. The access mode for the socket.
  20614. Defaults to @samp{"0600"}.
  20615. @end deftypevr
  20616. @deftypevr {@code{unix-listener-configuration} parameter} string user
  20617. The user to own the socket.
  20618. Defaults to @samp{""}.
  20619. @end deftypevr
  20620. @deftypevr {@code{unix-listener-configuration} parameter} string group
  20621. The group to own the socket.
  20622. Defaults to @samp{""}.
  20623. @end deftypevr
  20624. Available @code{fifo-listener-configuration} fields are:
  20625. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  20626. Path to the file, relative to @code{base-dir} field. This is also used as
  20627. the section name.
  20628. @end deftypevr
  20629. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  20630. The access mode for the socket.
  20631. Defaults to @samp{"0600"}.
  20632. @end deftypevr
  20633. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  20634. The user to own the socket.
  20635. Defaults to @samp{""}.
  20636. @end deftypevr
  20637. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  20638. The group to own the socket.
  20639. Defaults to @samp{""}.
  20640. @end deftypevr
  20641. Available @code{inet-listener-configuration} fields are:
  20642. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  20643. The protocol to listen for.
  20644. @end deftypevr
  20645. @deftypevr {@code{inet-listener-configuration} parameter} string address
  20646. The address on which to listen, or empty for all addresses.
  20647. Defaults to @samp{""}.
  20648. @end deftypevr
  20649. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  20650. The port on which to listen.
  20651. @end deftypevr
  20652. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  20653. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  20654. @samp{required}.
  20655. Defaults to @samp{#t}.
  20656. @end deftypevr
  20657. @end deftypevr
  20658. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  20659. Maximum number of simultaneous client connections per process. Once
  20660. this number of connections is received, the next incoming connection
  20661. will prompt Dovecot to spawn another process. If set to 0,
  20662. @code{default-client-limit} is used instead.
  20663. Defaults to @samp{0}.
  20664. @end deftypevr
  20665. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  20666. Number of connections to handle before starting a new process.
  20667. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  20668. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  20669. Defaults to @samp{1}.
  20670. @end deftypevr
  20671. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  20672. Maximum number of processes that can exist for this service. If set to
  20673. 0, @code{default-process-limit} is used instead.
  20674. Defaults to @samp{0}.
  20675. @end deftypevr
  20676. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  20677. Number of processes to always keep waiting for more connections.
  20678. Defaults to @samp{0}.
  20679. @end deftypevr
  20680. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  20681. If you set @samp{service-count 0}, you probably need to grow
  20682. this.
  20683. Defaults to @samp{256000000}.
  20684. @end deftypevr
  20685. @end deftypevr
  20686. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  20687. Dict configuration, as created by the @code{dict-configuration}
  20688. constructor.
  20689. Available @code{dict-configuration} fields are:
  20690. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  20691. A list of key-value pairs that this dict should hold.
  20692. Defaults to @samp{'()}.
  20693. @end deftypevr
  20694. @end deftypevr
  20695. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  20696. A list of passdb configurations, each one created by the
  20697. @code{passdb-configuration} constructor.
  20698. Available @code{passdb-configuration} fields are:
  20699. @deftypevr {@code{passdb-configuration} parameter} string driver
  20700. The driver that the passdb should use. Valid values include
  20701. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  20702. @samp{static}.
  20703. Defaults to @samp{"pam"}.
  20704. @end deftypevr
  20705. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  20706. Space separated list of arguments to the passdb driver.
  20707. Defaults to @samp{""}.
  20708. @end deftypevr
  20709. @end deftypevr
  20710. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  20711. List of userdb configurations, each one created by the
  20712. @code{userdb-configuration} constructor.
  20713. Available @code{userdb-configuration} fields are:
  20714. @deftypevr {@code{userdb-configuration} parameter} string driver
  20715. The driver that the userdb should use. Valid values include
  20716. @samp{passwd} and @samp{static}.
  20717. Defaults to @samp{"passwd"}.
  20718. @end deftypevr
  20719. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  20720. Space separated list of arguments to the userdb driver.
  20721. Defaults to @samp{""}.
  20722. @end deftypevr
  20723. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  20724. Override fields from passwd.
  20725. Defaults to @samp{'()}.
  20726. @end deftypevr
  20727. @end deftypevr
  20728. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  20729. Plug-in configuration, created by the @code{plugin-configuration}
  20730. constructor.
  20731. @end deftypevr
  20732. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  20733. List of namespaces. Each item in the list is created by the
  20734. @code{namespace-configuration} constructor.
  20735. Available @code{namespace-configuration} fields are:
  20736. @deftypevr {@code{namespace-configuration} parameter} string name
  20737. Name for this namespace.
  20738. @end deftypevr
  20739. @deftypevr {@code{namespace-configuration} parameter} string type
  20740. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  20741. Defaults to @samp{"private"}.
  20742. @end deftypevr
  20743. @deftypevr {@code{namespace-configuration} parameter} string separator
  20744. Hierarchy separator to use. You should use the same separator for
  20745. all namespaces or some clients get confused. @samp{/} is usually a good
  20746. one. The default however depends on the underlying mail storage
  20747. format.
  20748. Defaults to @samp{""}.
  20749. @end deftypevr
  20750. @deftypevr {@code{namespace-configuration} parameter} string prefix
  20751. Prefix required to access this namespace. This needs to be
  20752. different for all namespaces. For example @samp{Public/}.
  20753. Defaults to @samp{""}.
  20754. @end deftypevr
  20755. @deftypevr {@code{namespace-configuration} parameter} string location
  20756. Physical location of the mailbox. This is in the same format as
  20757. mail_location, which is also the default for it.
  20758. Defaults to @samp{""}.
  20759. @end deftypevr
  20760. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  20761. There can be only one INBOX, and this setting defines which
  20762. namespace has it.
  20763. Defaults to @samp{#f}.
  20764. @end deftypevr
  20765. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  20766. If namespace is hidden, it's not advertised to clients via NAMESPACE
  20767. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  20768. useful when converting from another server with different namespaces
  20769. which you want to deprecate but still keep working. For example you can
  20770. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  20771. and @samp{mail/}.
  20772. Defaults to @samp{#f}.
  20773. @end deftypevr
  20774. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  20775. Show the mailboxes under this namespace with the LIST command. This
  20776. makes the namespace visible for clients that do not support the NAMESPACE
  20777. extension. The special @code{children} value lists child mailboxes, but
  20778. hides the namespace prefix.
  20779. Defaults to @samp{#t}.
  20780. @end deftypevr
  20781. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  20782. Namespace handles its own subscriptions. If set to @code{#f}, the
  20783. parent namespace handles them. The empty prefix should always have this
  20784. as @code{#t}).
  20785. Defaults to @samp{#t}.
  20786. @end deftypevr
  20787. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  20788. List of predefined mailboxes in this namespace.
  20789. Defaults to @samp{'()}.
  20790. Available @code{mailbox-configuration} fields are:
  20791. @deftypevr {@code{mailbox-configuration} parameter} string name
  20792. Name for this mailbox.
  20793. @end deftypevr
  20794. @deftypevr {@code{mailbox-configuration} parameter} string auto
  20795. @samp{create} will automatically create this mailbox.
  20796. @samp{subscribe} will both create and subscribe to the mailbox.
  20797. Defaults to @samp{"no"}.
  20798. @end deftypevr
  20799. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  20800. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  20801. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  20802. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  20803. Defaults to @samp{'()}.
  20804. @end deftypevr
  20805. @end deftypevr
  20806. @end deftypevr
  20807. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  20808. Base directory where to store runtime data.
  20809. Defaults to @samp{"/var/run/dovecot/"}.
  20810. @end deftypevr
  20811. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  20812. Greeting message for clients.
  20813. Defaults to @samp{"Dovecot ready."}.
  20814. @end deftypevr
  20815. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  20816. List of trusted network ranges. Connections from these IPs are
  20817. allowed to override their IP addresses and ports (for logging and for
  20818. authentication checks). @samp{disable-plaintext-auth} is also ignored
  20819. for these networks. Typically you would specify your IMAP proxy servers
  20820. here.
  20821. Defaults to @samp{'()}.
  20822. @end deftypevr
  20823. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  20824. List of login access check sockets (e.g.@: tcpwrap).
  20825. Defaults to @samp{'()}.
  20826. @end deftypevr
  20827. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  20828. Show more verbose process titles (in ps). Currently shows user name
  20829. and IP address. Useful for seeing who is actually using the IMAP
  20830. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  20831. accounts).
  20832. Defaults to @samp{#f}.
  20833. @end deftypevr
  20834. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  20835. Should all processes be killed when Dovecot master process shuts down.
  20836. Setting this to @code{#f} means that Dovecot can be upgraded without
  20837. forcing existing client connections to close (although that could also
  20838. be a problem if the upgrade is e.g.@: due to a security fix).
  20839. Defaults to @samp{#t}.
  20840. @end deftypevr
  20841. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  20842. If non-zero, run mail commands via this many connections to doveadm
  20843. server, instead of running them directly in the same process.
  20844. Defaults to @samp{0}.
  20845. @end deftypevr
  20846. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  20847. UNIX socket or host:port used for connecting to doveadm server.
  20848. Defaults to @samp{"doveadm-server"}.
  20849. @end deftypevr
  20850. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  20851. List of environment variables that are preserved on Dovecot startup
  20852. and passed down to all of its child processes. You can also give
  20853. key=value pairs to always set specific settings.
  20854. @end deftypevr
  20855. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  20856. Disable LOGIN command and all other plaintext authentications unless
  20857. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  20858. matches the local IP (i.e.@: you're connecting from the same computer),
  20859. the connection is considered secure and plaintext authentication is
  20860. allowed. See also ssl=required setting.
  20861. Defaults to @samp{#t}.
  20862. @end deftypevr
  20863. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  20864. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  20865. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  20866. for caching to be used.
  20867. Defaults to @samp{0}.
  20868. @end deftypevr
  20869. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  20870. Time to live for cached data. After TTL expires the cached record
  20871. is no longer used, *except* if the main database lookup returns internal
  20872. failure. We also try to handle password changes automatically: If
  20873. user's previous authentication was successful, but this one wasn't, the
  20874. cache isn't used. For now this works only with plaintext
  20875. authentication.
  20876. Defaults to @samp{"1 hour"}.
  20877. @end deftypevr
  20878. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  20879. TTL for negative hits (user not found, password mismatch).
  20880. 0 disables caching them completely.
  20881. Defaults to @samp{"1 hour"}.
  20882. @end deftypevr
  20883. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  20884. List of realms for SASL authentication mechanisms that need them.
  20885. You can leave it empty if you don't want to support multiple realms.
  20886. Many clients simply use the first one listed here, so keep the default
  20887. realm first.
  20888. Defaults to @samp{'()}.
  20889. @end deftypevr
  20890. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  20891. Default realm/domain to use if none was specified. This is used for
  20892. both SASL realms and appending @@domain to username in plaintext
  20893. logins.
  20894. Defaults to @samp{""}.
  20895. @end deftypevr
  20896. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  20897. List of allowed characters in username. If the user-given username
  20898. contains a character not listed in here, the login automatically fails.
  20899. This is just an extra check to make sure user can't exploit any
  20900. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  20901. you want to allow all characters, set this value to empty.
  20902. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  20903. @end deftypevr
  20904. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  20905. Username character translations before it's looked up from
  20906. databases. The value contains series of from -> to characters. For
  20907. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  20908. translated to @samp{@@}.
  20909. Defaults to @samp{""}.
  20910. @end deftypevr
  20911. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  20912. Username formatting before it's looked up from databases. You can
  20913. use the standard variables here, e.g.@: %Lu would lowercase the username,
  20914. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  20915. change the @samp{@@} into @samp{-AT-}. This translation is done after
  20916. @samp{auth-username-translation} changes.
  20917. Defaults to @samp{"%Lu"}.
  20918. @end deftypevr
  20919. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  20920. If you want to allow master users to log in by specifying the master
  20921. username within the normal username string (i.e.@: not using SASL
  20922. mechanism's support for it), you can specify the separator character
  20923. here. The format is then <username><separator><master username>.
  20924. UW-IMAP uses @samp{*} as the separator, so that could be a good
  20925. choice.
  20926. Defaults to @samp{""}.
  20927. @end deftypevr
  20928. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  20929. Username to use for users logging in with ANONYMOUS SASL
  20930. mechanism.
  20931. Defaults to @samp{"anonymous"}.
  20932. @end deftypevr
  20933. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  20934. Maximum number of dovecot-auth worker processes. They're used to
  20935. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  20936. They're automatically created and destroyed as needed.
  20937. Defaults to @samp{30}.
  20938. @end deftypevr
  20939. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  20940. Host name to use in GSSAPI principal names. The default is to use
  20941. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  20942. allow all keytab entries.
  20943. Defaults to @samp{""}.
  20944. @end deftypevr
  20945. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  20946. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  20947. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  20948. need to change the auth service to run as root to be able to read this
  20949. file.
  20950. Defaults to @samp{""}.
  20951. @end deftypevr
  20952. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  20953. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  20954. and @samp{ntlm-auth} helper.
  20955. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  20956. Defaults to @samp{#f}.
  20957. @end deftypevr
  20958. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  20959. Path for Samba's @samp{ntlm-auth} helper binary.
  20960. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  20961. @end deftypevr
  20962. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  20963. Time to delay before replying to failed authentications.
  20964. Defaults to @samp{"2 secs"}.
  20965. @end deftypevr
  20966. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  20967. Require a valid SSL client certificate or the authentication
  20968. fails.
  20969. Defaults to @samp{#f}.
  20970. @end deftypevr
  20971. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  20972. Take the username from client's SSL certificate, using
  20973. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  20974. CommonName.
  20975. Defaults to @samp{#f}.
  20976. @end deftypevr
  20977. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  20978. List of wanted authentication mechanisms. Supported mechanisms are:
  20979. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  20980. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  20981. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  20982. @samp{disable-plaintext-auth} setting.
  20983. @end deftypevr
  20984. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  20985. List of IPs or hostnames to all director servers, including ourself.
  20986. Ports can be specified as ip:port. The default port is the same as what
  20987. director service's @samp{inet-listener} is using.
  20988. Defaults to @samp{'()}.
  20989. @end deftypevr
  20990. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  20991. List of IPs or hostnames to all backend mail servers. Ranges are
  20992. allowed too, like 10.0.0.10-10.0.0.30.
  20993. Defaults to @samp{'()}.
  20994. @end deftypevr
  20995. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  20996. How long to redirect users to a specific server after it no longer
  20997. has any connections.
  20998. Defaults to @samp{"15 min"}.
  20999. @end deftypevr
  21000. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  21001. How the username is translated before being hashed. Useful values
  21002. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  21003. are shared within domain.
  21004. Defaults to @samp{"%Lu"}.
  21005. @end deftypevr
  21006. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  21007. Log file to use for error messages. @samp{syslog} logs to syslog,
  21008. @samp{/dev/stderr} logs to stderr.
  21009. Defaults to @samp{"syslog"}.
  21010. @end deftypevr
  21011. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  21012. Log file to use for informational messages. Defaults to
  21013. @samp{log-path}.
  21014. Defaults to @samp{""}.
  21015. @end deftypevr
  21016. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  21017. Log file to use for debug messages. Defaults to
  21018. @samp{info-log-path}.
  21019. Defaults to @samp{""}.
  21020. @end deftypevr
  21021. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  21022. Syslog facility to use if you're logging to syslog. Usually if you
  21023. don't want to use @samp{mail}, you'll use local0..local7. Also other
  21024. standard facilities are supported.
  21025. Defaults to @samp{"mail"}.
  21026. @end deftypevr
  21027. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  21028. Log unsuccessful authentication attempts and the reasons why they
  21029. failed.
  21030. Defaults to @samp{#f}.
  21031. @end deftypevr
  21032. @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
  21033. In case of password mismatches, log the attempted password. Valid
  21034. values are no, plain and sha1. sha1 can be useful for detecting brute
  21035. force password attempts vs. user simply trying the same password over
  21036. and over again. You can also truncate the value to n chars by appending
  21037. ":n" (e.g.@: sha1:6).
  21038. Defaults to @samp{"no"}.
  21039. @end deftypevr
  21040. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  21041. Even more verbose logging for debugging purposes. Shows for example
  21042. SQL queries.
  21043. Defaults to @samp{#f}.
  21044. @end deftypevr
  21045. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  21046. In case of password mismatches, log the passwords and used scheme so
  21047. the problem can be debugged. Enabling this also enables
  21048. @samp{auth-debug}.
  21049. Defaults to @samp{#f}.
  21050. @end deftypevr
  21051. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  21052. Enable mail process debugging. This can help you figure out why
  21053. Dovecot isn't finding your mails.
  21054. Defaults to @samp{#f}.
  21055. @end deftypevr
  21056. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  21057. Show protocol level SSL errors.
  21058. Defaults to @samp{#f}.
  21059. @end deftypevr
  21060. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  21061. Prefix for each line written to log file. % codes are in
  21062. strftime(3) format.
  21063. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  21064. @end deftypevr
  21065. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  21066. List of elements we want to log. The elements which have a
  21067. non-empty variable value are joined together to form a comma-separated
  21068. string.
  21069. @end deftypevr
  21070. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  21071. Login log format. %s contains @samp{login-log-format-elements}
  21072. string, %$ contains the data we want to log.
  21073. Defaults to @samp{"%$: %s"}.
  21074. @end deftypevr
  21075. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  21076. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  21077. of possible variables you can use.
  21078. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  21079. @end deftypevr
  21080. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  21081. Format to use for logging mail deliveries. You can use variables:
  21082. @table @code
  21083. @item %$
  21084. Delivery status message (e.g.@: @samp{saved to INBOX})
  21085. @item %m
  21086. Message-ID
  21087. @item %s
  21088. Subject
  21089. @item %f
  21090. From address
  21091. @item %p
  21092. Physical size
  21093. @item %w
  21094. Virtual size.
  21095. @end table
  21096. Defaults to @samp{"msgid=%m: %$"}.
  21097. @end deftypevr
  21098. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  21099. Location for users' mailboxes. The default is empty, which means
  21100. that Dovecot tries to find the mailboxes automatically. This won't work
  21101. if the user doesn't yet have any mail, so you should explicitly tell
  21102. Dovecot the full location.
  21103. If you're using mbox, giving a path to the INBOX
  21104. file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
  21105. where the other mailboxes are kept. This is called the @emph{root mail
  21106. directory}, and it must be the first path given in the
  21107. @samp{mail-location} setting.
  21108. There are a few special variables you can use, e.g.:
  21109. @table @samp
  21110. @item %u
  21111. username
  21112. @item %n
  21113. user part in user@@domain, same as %u if there's no domain
  21114. @item %d
  21115. domain part in user@@domain, empty if there's no domain
  21116. @item %h
  21117. home director
  21118. @end table
  21119. See doc/wiki/Variables.txt for full list. Some examples:
  21120. @table @samp
  21121. @item maildir:~/Maildir
  21122. @item mbox:~/mail:INBOX=/var/mail/%u
  21123. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  21124. @end table
  21125. Defaults to @samp{""}.
  21126. @end deftypevr
  21127. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  21128. System user and group used to access mails. If you use multiple,
  21129. userdb can override these by returning uid or gid fields. You can use
  21130. either numbers or names. <doc/wiki/UserIds.txt>.
  21131. Defaults to @samp{""}.
  21132. @end deftypevr
  21133. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  21134. Defaults to @samp{""}.
  21135. @end deftypevr
  21136. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  21137. Group to enable temporarily for privileged operations. Currently
  21138. this is used only with INBOX when either its initial creation or
  21139. dotlocking fails. Typically this is set to @samp{"mail"} to give access to
  21140. @file{/var/mail}.
  21141. Defaults to @samp{""}.
  21142. @end deftypevr
  21143. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  21144. Grant access to these supplementary groups for mail processes.
  21145. Typically these are used to set up access to shared mailboxes. Note
  21146. that it may be dangerous to set these if users can create symlinks
  21147. (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
  21148. could allow a user to delete others' mailboxes, or @code{ln -s
  21149. /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
  21150. @samp{""}.
  21151. @end deftypevr
  21152. @deftypevr {@code{dovecot-configuration} parameter} string mail-attribute-dict
  21153. The location of a dictionary used to store @code{IMAP METADATA}
  21154. as defined by @uref{https://tools.ietf.org/html/rfc5464, RFC@tie{}5464}.
  21155. The IMAP METADATA commands are available only if the ``imap''
  21156. protocol configuration's @code{imap-metadata?} field is @samp{#t}.
  21157. Defaults to @samp{""}.
  21158. @end deftypevr
  21159. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  21160. Allow full file system access to clients. There's no access checks
  21161. other than what the operating system does for the active UID/GID@. It
  21162. works with both maildir and mboxes, allowing you to prefix mailboxes
  21163. names with e.g.@: @file{/path/} or @file{~user/}.
  21164. Defaults to @samp{#f}.
  21165. @end deftypevr
  21166. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  21167. Don't use @code{mmap()} at all. This is required if you store indexes to
  21168. shared file systems (NFS or clustered file system).
  21169. Defaults to @samp{#f}.
  21170. @end deftypevr
  21171. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  21172. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  21173. supports @samp{O_EXCL} since version 3, so this should be safe to use
  21174. nowadays by default.
  21175. Defaults to @samp{#t}.
  21176. @end deftypevr
  21177. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  21178. When to use fsync() or fdatasync() calls:
  21179. @table @code
  21180. @item optimized
  21181. Whenever necessary to avoid losing important data
  21182. @item always
  21183. Useful with e.g.@: NFS when @code{write()}s are delayed
  21184. @item never
  21185. Never use it (best performance, but crashes can lose data).
  21186. @end table
  21187. Defaults to @samp{"optimized"}.
  21188. @end deftypevr
  21189. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  21190. Mail storage exists in NFS@. Set this to yes to make Dovecot flush
  21191. NFS caches whenever needed. If you're using only a single mail server
  21192. this isn't needed.
  21193. Defaults to @samp{#f}.
  21194. @end deftypevr
  21195. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  21196. Mail index files also exist in NFS@. Setting this to yes requires
  21197. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  21198. Defaults to @samp{#f}.
  21199. @end deftypevr
  21200. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  21201. Locking method for index files. Alternatives are fcntl, flock and
  21202. dotlock. Dotlocking uses some tricks which may create more disk I/O
  21203. than other locking methods. NFS users: flock doesn't work, remember to
  21204. change @samp{mmap-disable}.
  21205. Defaults to @samp{"fcntl"}.
  21206. @end deftypevr
  21207. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  21208. Directory in which LDA/LMTP temporarily stores incoming mails >128
  21209. kB.
  21210. Defaults to @samp{"/tmp"}.
  21211. @end deftypevr
  21212. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  21213. Valid UID range for users. This is mostly to make sure that users can't
  21214. log in as daemons or other system users. Note that denying root logins is
  21215. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  21216. is set to 0.
  21217. Defaults to @samp{500}.
  21218. @end deftypevr
  21219. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  21220. Defaults to @samp{0}.
  21221. @end deftypevr
  21222. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  21223. Valid GID range for users. Users having non-valid GID as primary group ID
  21224. aren't allowed to log in. If user belongs to supplementary groups with
  21225. non-valid GIDs, those groups are not set.
  21226. Defaults to @samp{1}.
  21227. @end deftypevr
  21228. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  21229. Defaults to @samp{0}.
  21230. @end deftypevr
  21231. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  21232. Maximum allowed length for mail keyword name. It's only forced when
  21233. trying to create new keywords.
  21234. Defaults to @samp{50}.
  21235. @end deftypevr
  21236. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  21237. List of directories under which chrooting is allowed for mail
  21238. processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
  21239. too). This setting doesn't affect @samp{login-chroot}
  21240. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  21241. @samp{/./} in home dirs are ignored. WARNING: Never add directories here
  21242. which local users can modify, that may lead to root exploit. Usually
  21243. this should be done only if you don't allow shell access for users.
  21244. <doc/wiki/Chrooting.txt>.
  21245. Defaults to @samp{'()}.
  21246. @end deftypevr
  21247. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  21248. Default chroot directory for mail processes. This can be overridden
  21249. for specific users in user database by giving @samp{/./} in user's home
  21250. directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
  21251. there is no real need to do chrooting, Dovecot doesn't allow users to
  21252. access files outside their mail directory anyway. If your home
  21253. directories are prefixed with the chroot directory, append @samp{/.} to
  21254. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  21255. Defaults to @samp{""}.
  21256. @end deftypevr
  21257. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  21258. UNIX socket path to master authentication server to find users.
  21259. This is used by imap (for shared users) and lda.
  21260. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  21261. @end deftypevr
  21262. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  21263. Directory where to look up mail plugins.
  21264. Defaults to @samp{"/usr/lib/dovecot"}.
  21265. @end deftypevr
  21266. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  21267. List of plugins to load for all services. Plugins specific to IMAP,
  21268. LDA, etc.@: are added to this list in their own .conf files.
  21269. Defaults to @samp{'()}.
  21270. @end deftypevr
  21271. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  21272. The minimum number of mails in a mailbox before updates are done to
  21273. cache file. This allows optimizing Dovecot's behavior to do less disk
  21274. writes at the cost of more disk reads.
  21275. Defaults to @samp{0}.
  21276. @end deftypevr
  21277. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  21278. When IDLE command is running, mailbox is checked once in a while to
  21279. see if there are any new mails or other changes. This setting defines
  21280. the minimum time to wait between those checks. Dovecot can also use
  21281. dnotify, inotify and kqueue to find out immediately when changes
  21282. occur.
  21283. Defaults to @samp{"30 secs"}.
  21284. @end deftypevr
  21285. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  21286. Save mails with CR+LF instead of plain LF@. This makes sending those
  21287. mails take less CPU, especially with sendfile() syscall with Linux and
  21288. FreeBSD@. But it also creates a bit more disk I/O which may just make it
  21289. slower. Also note that if other software reads the mboxes/maildirs,
  21290. they may handle the extra CRs wrong and cause problems.
  21291. Defaults to @samp{#f}.
  21292. @end deftypevr
  21293. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  21294. By default LIST command returns all entries in maildir beginning
  21295. with a dot. Enabling this option makes Dovecot return only entries
  21296. which are directories. This is done by stat()ing each entry, so it
  21297. causes more disk I/O.
  21298. (For systems setting struct @samp{dirent->d_type} this check is free
  21299. and it's done always regardless of this setting).
  21300. Defaults to @samp{#f}.
  21301. @end deftypevr
  21302. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  21303. When copying a message, do it with hard links whenever possible.
  21304. This makes the performance much better, and it's unlikely to have any
  21305. side effects.
  21306. Defaults to @samp{#t}.
  21307. @end deftypevr
  21308. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  21309. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  21310. directory only when its mtime changes unexpectedly or when we can't find
  21311. the mail otherwise.
  21312. Defaults to @samp{#f}.
  21313. @end deftypevr
  21314. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  21315. Which locking methods to use for locking mbox. There are four
  21316. available:
  21317. @table @code
  21318. @item dotlock
  21319. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  21320. solution. If you want to use /var/mail/ like directory, the users will
  21321. need write access to that directory.
  21322. @item dotlock-try
  21323. Same as dotlock, but if it fails because of permissions or because there
  21324. isn't enough disk space, just skip it.
  21325. @item fcntl
  21326. Use this if possible. Works with NFS too if lockd is used.
  21327. @item flock
  21328. May not exist in all systems. Doesn't work with NFS.
  21329. @item lockf
  21330. May not exist in all systems. Doesn't work with NFS.
  21331. @end table
  21332. You can use multiple locking methods; if you do the order they're declared
  21333. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  21334. locking methods as well. Some operating systems don't allow using some of
  21335. them simultaneously.
  21336. @end deftypevr
  21337. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  21338. @end deftypevr
  21339. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  21340. Maximum time to wait for lock (all of them) before aborting.
  21341. Defaults to @samp{"5 mins"}.
  21342. @end deftypevr
  21343. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  21344. If dotlock exists but the mailbox isn't modified in any way,
  21345. override the lock file after this much time.
  21346. Defaults to @samp{"2 mins"}.
  21347. @end deftypevr
  21348. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  21349. When mbox changes unexpectedly we have to fully read it to find out
  21350. what changed. If the mbox is large this can take a long time. Since
  21351. the change is usually just a newly appended mail, it'd be faster to
  21352. simply read the new mails. If this setting is enabled, Dovecot does
  21353. this but still safely fallbacks to re-reading the whole mbox file
  21354. whenever something in mbox isn't how it's expected to be. The only real
  21355. downside to this setting is that if some other MUA changes message
  21356. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  21357. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  21358. Defaults to @samp{#t}.
  21359. @end deftypevr
  21360. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  21361. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  21362. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  21363. @samp{mbox-dirty-syncs} is ignored.
  21364. Defaults to @samp{#f}.
  21365. @end deftypevr
  21366. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  21367. Delay writing mbox headers until doing a full write sync (EXPUNGE
  21368. and CHECK commands and when closing the mailbox). This is especially
  21369. useful for POP3 where clients often delete all mails. The downside is
  21370. that our changes aren't immediately visible to other MUAs.
  21371. Defaults to @samp{#t}.
  21372. @end deftypevr
  21373. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  21374. If mbox size is smaller than this (e.g.@: 100k), don't write index
  21375. files. If an index file already exists it's still read, just not
  21376. updated.
  21377. Defaults to @samp{0}.
  21378. @end deftypevr
  21379. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  21380. Maximum dbox file size until it's rotated.
  21381. Defaults to @samp{10000000}.
  21382. @end deftypevr
  21383. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  21384. Maximum dbox file age until it's rotated. Typically in days. Day
  21385. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  21386. disabled.
  21387. Defaults to @samp{"1d"}.
  21388. @end deftypevr
  21389. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  21390. When creating new mdbox files, immediately preallocate their size to
  21391. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  21392. with some file systems (ext4, xfs).
  21393. Defaults to @samp{#f}.
  21394. @end deftypevr
  21395. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  21396. sdbox and mdbox support saving mail attachments to external files,
  21397. which also allows single instance storage for them. Other backends
  21398. don't support this for now.
  21399. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  21400. Directory root where to store mail attachments. Disabled, if empty.
  21401. Defaults to @samp{""}.
  21402. @end deftypevr
  21403. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  21404. Attachments smaller than this aren't saved externally. It's also
  21405. possible to write a plugin to disable saving specific attachments
  21406. externally.
  21407. Defaults to @samp{128000}.
  21408. @end deftypevr
  21409. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  21410. File system backend to use for saving attachments:
  21411. @table @code
  21412. @item posix
  21413. No SiS done by Dovecot (but this might help FS's own deduplication)
  21414. @item sis posix
  21415. SiS with immediate byte-by-byte comparison during saving
  21416. @item sis-queue posix
  21417. SiS with delayed comparison and deduplication.
  21418. @end table
  21419. Defaults to @samp{"sis posix"}.
  21420. @end deftypevr
  21421. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  21422. Hash format to use in attachment filenames. You can add any text and
  21423. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  21424. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  21425. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  21426. Defaults to @samp{"%@{sha1@}"}.
  21427. @end deftypevr
  21428. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  21429. Defaults to @samp{100}.
  21430. @end deftypevr
  21431. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  21432. Defaults to @samp{1000}.
  21433. @end deftypevr
  21434. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  21435. Default VSZ (virtual memory size) limit for service processes.
  21436. This is mainly intended to catch and kill processes that leak memory
  21437. before they eat up everything.
  21438. Defaults to @samp{256000000}.
  21439. @end deftypevr
  21440. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  21441. Login user is internally used by login processes. This is the most
  21442. untrusted user in Dovecot system. It shouldn't have access to anything
  21443. at all.
  21444. Defaults to @samp{"dovenull"}.
  21445. @end deftypevr
  21446. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  21447. Internal user is used by unprivileged processes. It should be
  21448. separate from login user, so that login processes can't disturb other
  21449. processes.
  21450. Defaults to @samp{"dovecot"}.
  21451. @end deftypevr
  21452. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  21453. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  21454. Defaults to @samp{"required"}.
  21455. @end deftypevr
  21456. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  21457. PEM encoded X.509 SSL/TLS certificate (public key).
  21458. Defaults to @samp{"</etc/dovecot/default.pem"}.
  21459. @end deftypevr
  21460. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  21461. PEM encoded SSL/TLS private key. The key is opened before
  21462. dropping root privileges, so keep the key file unreadable by anyone but
  21463. root.
  21464. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  21465. @end deftypevr
  21466. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  21467. If key file is password protected, give the password here.
  21468. Alternatively give it when starting dovecot with -p parameter. Since
  21469. this file is often world-readable, you may want to place this setting
  21470. instead to a different.
  21471. Defaults to @samp{""}.
  21472. @end deftypevr
  21473. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  21474. PEM encoded trusted certificate authority. Set this only if you
  21475. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  21476. contain the CA certificate(s) followed by the matching
  21477. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  21478. Defaults to @samp{""}.
  21479. @end deftypevr
  21480. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  21481. Require that CRL check succeeds for client certificates.
  21482. Defaults to @samp{#t}.
  21483. @end deftypevr
  21484. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  21485. Request client to send a certificate. If you also want to require
  21486. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  21487. Defaults to @samp{#f}.
  21488. @end deftypevr
  21489. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  21490. Which field from certificate to use for username. commonName and
  21491. x500UniqueIdentifier are the usual choices. You'll also need to set
  21492. @samp{auth-ssl-username-from-cert? #t}.
  21493. Defaults to @samp{"commonName"}.
  21494. @end deftypevr
  21495. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  21496. Minimum SSL protocol version to accept.
  21497. Defaults to @samp{"TLSv1"}.
  21498. @end deftypevr
  21499. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  21500. SSL ciphers to use.
  21501. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  21502. @end deftypevr
  21503. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  21504. SSL crypto device to use, for valid values run "openssl engine".
  21505. Defaults to @samp{""}.
  21506. @end deftypevr
  21507. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  21508. Address to use when sending rejection mails.
  21509. %d expands to recipient domain.
  21510. Defaults to @samp{"postmaster@@%d"}.
  21511. @end deftypevr
  21512. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  21513. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  21514. and in LMTP replies. Default is the system's real hostname@@domain.
  21515. Defaults to @samp{""}.
  21516. @end deftypevr
  21517. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  21518. If user is over quota, return with temporary failure instead of
  21519. bouncing the mail.
  21520. Defaults to @samp{#f}.
  21521. @end deftypevr
  21522. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  21523. Binary to use for sending mails.
  21524. Defaults to @samp{"/usr/sbin/sendmail"}.
  21525. @end deftypevr
  21526. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  21527. If non-empty, send mails via this SMTP host[:port] instead of
  21528. sendmail.
  21529. Defaults to @samp{""}.
  21530. @end deftypevr
  21531. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  21532. Subject: header to use for rejection mails. You can use the same
  21533. variables as for @samp{rejection-reason} below.
  21534. Defaults to @samp{"Rejected: %s"}.
  21535. @end deftypevr
  21536. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  21537. Human readable error message for rejection mails. You can use
  21538. variables:
  21539. @table @code
  21540. @item %n
  21541. CRLF
  21542. @item %r
  21543. reason
  21544. @item %s
  21545. original subject
  21546. @item %t
  21547. recipient
  21548. @end table
  21549. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  21550. @end deftypevr
  21551. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  21552. Delimiter character between local-part and detail in email
  21553. address.
  21554. Defaults to @samp{"+"}.
  21555. @end deftypevr
  21556. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  21557. Header where the original recipient address (SMTP's RCPT TO:
  21558. address) is taken from if not available elsewhere. With dovecot-lda -a
  21559. parameter overrides this. A commonly used header for this is
  21560. X-Original-To.
  21561. Defaults to @samp{""}.
  21562. @end deftypevr
  21563. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  21564. Should saving a mail to a nonexistent mailbox automatically create
  21565. it?.
  21566. Defaults to @samp{#f}.
  21567. @end deftypevr
  21568. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  21569. Should automatically created mailboxes be also automatically
  21570. subscribed?.
  21571. Defaults to @samp{#f}.
  21572. @end deftypevr
  21573. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  21574. Maximum IMAP command line length. Some clients generate very long
  21575. command lines with huge mailboxes, so you may need to raise this if you
  21576. get "Too long argument" or "IMAP command line too large" errors
  21577. often.
  21578. Defaults to @samp{64000}.
  21579. @end deftypevr
  21580. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  21581. IMAP logout format string:
  21582. @table @code
  21583. @item %i
  21584. total number of bytes read from client
  21585. @item %o
  21586. total number of bytes sent to client.
  21587. @end table
  21588. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  21589. 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@}"}.
  21590. @end deftypevr
  21591. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  21592. Override the IMAP CAPABILITY response. If the value begins with '+',
  21593. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  21594. Defaults to @samp{""}.
  21595. @end deftypevr
  21596. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  21597. How long to wait between "OK Still here" notifications when client
  21598. is IDLEing.
  21599. Defaults to @samp{"2 mins"}.
  21600. @end deftypevr
  21601. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  21602. ID field names and values to send to clients. Using * as the value
  21603. makes Dovecot use the default value. The following fields have default
  21604. values currently: name, version, os, os-version, support-url,
  21605. support-email.
  21606. Defaults to @samp{""}.
  21607. @end deftypevr
  21608. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  21609. ID fields sent by client to log. * means everything.
  21610. Defaults to @samp{""}.
  21611. @end deftypevr
  21612. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  21613. Workarounds for various client bugs:
  21614. @table @code
  21615. @item delay-newmail
  21616. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  21617. CHECK commands. Some clients ignore them otherwise, for example OSX
  21618. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  21619. may show user "Message no longer in server" errors. Note that OE6
  21620. still breaks even with this workaround if synchronization is set to
  21621. "Headers Only".
  21622. @item tb-extra-mailbox-sep
  21623. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  21624. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  21625. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  21626. @item tb-lsub-flags
  21627. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  21628. This makes Thunderbird realize they aren't selectable and show them
  21629. greyed out, instead of only later giving "not selectable" popup error.
  21630. @end table
  21631. Defaults to @samp{'()}.
  21632. @end deftypevr
  21633. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  21634. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  21635. Defaults to @samp{""}.
  21636. @end deftypevr
  21637. Whew! Lots of configuration options. The nice thing about it though is
  21638. that Guix has a complete interface to Dovecot's configuration
  21639. language. This allows not only a nice way to declare configurations,
  21640. but also offers reflective capabilities as well: users can write code to
  21641. inspect and transform configurations from within Scheme.
  21642. However, it could be that you just want to get a @code{dovecot.conf} up
  21643. and running. In that case, you can pass an
  21644. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  21645. @code{dovecot-service}. As its name indicates, an opaque configuration
  21646. does not have easy reflective capabilities.
  21647. Available @code{opaque-dovecot-configuration} fields are:
  21648. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  21649. The dovecot package.
  21650. @end deftypevr
  21651. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  21652. The contents of the @code{dovecot.conf}, as a string.
  21653. @end deftypevr
  21654. For example, if your @code{dovecot.conf} is just the empty string, you
  21655. could instantiate a dovecot service like this:
  21656. @lisp
  21657. (dovecot-service #:config
  21658. (opaque-dovecot-configuration
  21659. (string "")))
  21660. @end lisp
  21661. @subsubheading OpenSMTPD Service
  21662. @defvar opensmtpd-service-type
  21663. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  21664. service, whose value should be an @code{opensmtpd-configuration} object
  21665. as in this example:
  21666. @lisp
  21667. (service opensmtpd-service-type
  21668. (opensmtpd-configuration
  21669. (config-file (local-file "./my-smtpd.conf"))))
  21670. @end lisp
  21671. @end defvar
  21672. @deftp {Data Type} opensmtpd-configuration
  21673. Data type representing the configuration of opensmtpd.
  21674. @table @asis
  21675. @item @code{package} (default: @var{opensmtpd})
  21676. Package object of the OpenSMTPD SMTP server.
  21677. @item @code{shepherd-requirement} (default: @code{'()})
  21678. This option can be used to provide a list of symbols naming Shepherd services
  21679. that this service will depend on, such as @code{'networking}
  21680. if you want to configure OpenSMTPD to listen on non-loopback interfaces.
  21681. @item @code{config-file} (default: @code{%default-opensmtpd-config-file})
  21682. File-like object of the OpenSMTPD configuration file to use. By default
  21683. it listens on the loopback network interface, and allows for mail from
  21684. users and daemons on the local machine, as well as permitting email to
  21685. remote servers. Run @command{man smtpd.conf} for more information.
  21686. @item @code{setgid-commands?} (default: @code{#t})
  21687. Make the following commands setgid to @code{smtpq} so they can be
  21688. executed: @command{smtpctl}, @command{sendmail}, @command{send-mail},
  21689. @command{makemap}, @command{mailq}, and @command{newaliases}.
  21690. @xref{Setuid Programs}, for more information on setgid programs.
  21691. @end table
  21692. @end deftp
  21693. @subsubheading Exim Service
  21694. @cindex mail transfer agent (MTA)
  21695. @cindex MTA (mail transfer agent)
  21696. @cindex SMTP
  21697. @defvar exim-service-type
  21698. This is the type of the @uref{https://exim.org, Exim} mail transfer
  21699. agent (MTA), whose value should be an @code{exim-configuration} object
  21700. as in this example:
  21701. @lisp
  21702. (service exim-service-type
  21703. (exim-configuration
  21704. (config-file (local-file "./my-exim.conf"))))
  21705. @end lisp
  21706. @end defvar
  21707. In order to use an @code{exim-service-type} service you must also have a
  21708. @code{mail-aliases-service-type} service present in your
  21709. @code{operating-system} (even if it has no aliases).
  21710. @deftp {Data Type} exim-configuration
  21711. Data type representing the configuration of exim.
  21712. @table @asis
  21713. @item @code{package} (default: @var{exim})
  21714. Package object of the Exim server.
  21715. @item @code{config-file} (default: @code{#f})
  21716. File-like object of the Exim configuration file to use. If its value is
  21717. @code{#f} then use the default configuration file from the package
  21718. provided in @code{package}. The resulting configuration file is loaded
  21719. after setting the @code{exim_user} and @code{exim_group} configuration
  21720. variables.
  21721. @end table
  21722. @end deftp
  21723. @subsubheading Getmail service
  21724. @cindex IMAP
  21725. @cindex POP
  21726. @defvar getmail-service-type
  21727. This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
  21728. mail retriever, whose value should be a @code{getmail-configuration}.
  21729. @end defvar
  21730. Available @code{getmail-configuration} fields are:
  21731. @deftypevr {@code{getmail-configuration} parameter} symbol name
  21732. A symbol to identify the getmail service.
  21733. Defaults to @samp{"unset"}.
  21734. @end deftypevr
  21735. @deftypevr {@code{getmail-configuration} parameter} package package
  21736. The getmail package to use.
  21737. @end deftypevr
  21738. @deftypevr {@code{getmail-configuration} parameter} string user
  21739. The user to run getmail as.
  21740. Defaults to @samp{"getmail"}.
  21741. @end deftypevr
  21742. @deftypevr {@code{getmail-configuration} parameter} string group
  21743. The group to run getmail as.
  21744. Defaults to @samp{"getmail"}.
  21745. @end deftypevr
  21746. @deftypevr {@code{getmail-configuration} parameter} string directory
  21747. The getmail directory to use.
  21748. Defaults to @samp{"/var/lib/getmail/default"}.
  21749. @end deftypevr
  21750. @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
  21751. The getmail configuration file to use.
  21752. Available @code{getmail-configuration-file} fields are:
  21753. @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
  21754. What mail account to retrieve mail from, and how to access that account.
  21755. Available @code{getmail-retriever-configuration} fields are:
  21756. @deftypevr {@code{getmail-retriever-configuration} parameter} string type
  21757. The type of mail retriever to use. Valid values include @samp{passwd}
  21758. and @samp{static}.
  21759. Defaults to @samp{"SimpleIMAPSSLRetriever"}.
  21760. @end deftypevr
  21761. @deftypevr {@code{getmail-retriever-configuration} parameter} string server
  21762. Username to login to the mail server with.
  21763. Defaults to @samp{unset}.
  21764. @end deftypevr
  21765. @deftypevr {@code{getmail-retriever-configuration} parameter} string username
  21766. Username to login to the mail server with.
  21767. Defaults to @samp{unset}.
  21768. @end deftypevr
  21769. @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
  21770. Port number to connect to.
  21771. Defaults to @samp{#f}.
  21772. @end deftypevr
  21773. @deftypevr {@code{getmail-retriever-configuration} parameter} string password
  21774. Override fields from passwd.
  21775. Defaults to @samp{""}.
  21776. @end deftypevr
  21777. @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
  21778. Override fields from passwd.
  21779. Defaults to @samp{'()}.
  21780. @end deftypevr
  21781. @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
  21782. PEM-formatted key file to use for the TLS negotiation.
  21783. Defaults to @samp{""}.
  21784. @end deftypevr
  21785. @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
  21786. PEM-formatted certificate file to use for the TLS negotiation.
  21787. Defaults to @samp{""}.
  21788. @end deftypevr
  21789. @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
  21790. CA certificates to use.
  21791. Defaults to @samp{""}.
  21792. @end deftypevr
  21793. @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
  21794. Extra retriever parameters.
  21795. Defaults to @samp{'()}.
  21796. @end deftypevr
  21797. @end deftypevr
  21798. @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
  21799. What to do with retrieved messages.
  21800. Available @code{getmail-destination-configuration} fields are:
  21801. @deftypevr {@code{getmail-destination-configuration} parameter} string type
  21802. The type of mail destination. Valid values include @samp{Maildir},
  21803. @samp{Mboxrd} and @samp{MDA_external}.
  21804. Defaults to @samp{unset}.
  21805. @end deftypevr
  21806. @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
  21807. The path option for the mail destination. The behaviour depends on the
  21808. chosen type.
  21809. Defaults to @samp{""}.
  21810. @end deftypevr
  21811. @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
  21812. Extra destination parameters
  21813. Defaults to @samp{'()}.
  21814. @end deftypevr
  21815. @end deftypevr
  21816. @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
  21817. Configure getmail.
  21818. Available @code{getmail-options-configuration} fields are:
  21819. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
  21820. If set to @samp{0}, getmail will only print warnings and errors. A
  21821. value of @samp{1} means that messages will be printed about retrieving
  21822. and deleting messages. If set to @samp{2}, getmail will print messages
  21823. about each of its actions.
  21824. Defaults to @samp{1}.
  21825. @end deftypevr
  21826. @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
  21827. If true, getmail will retrieve all available messages. Otherwise it
  21828. will only retrieve messages it hasn't seen previously.
  21829. Defaults to @samp{#t}.
  21830. @end deftypevr
  21831. @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
  21832. If set to true, messages will be deleted from the server after
  21833. retrieving and successfully delivering them. Otherwise, messages will
  21834. be left on the server.
  21835. Defaults to @samp{#f}.
  21836. @end deftypevr
  21837. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
  21838. Getmail will delete messages this number of days after seeing them, if
  21839. they have been delivered. This means messages will be left on the
  21840. server this number of days after delivering them. A value of @samp{0}
  21841. disabled this feature.
  21842. Defaults to @samp{0}.
  21843. @end deftypevr
  21844. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
  21845. Delete messages larger than this of bytes after retrieving them, even if
  21846. the delete and delete-after options are disabled. A value of @samp{0}
  21847. disables this feature.
  21848. Defaults to @samp{0}.
  21849. @end deftypevr
  21850. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
  21851. Retrieve messages totalling up to this number of bytes before closing
  21852. the session with the server. A value of @samp{0} disables this feature.
  21853. Defaults to @samp{0}.
  21854. @end deftypevr
  21855. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
  21856. Don't retrieve messages larger than this number of bytes. A value of
  21857. @samp{0} disables this feature.
  21858. Defaults to @samp{0}.
  21859. @end deftypevr
  21860. @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
  21861. If true, getmail will add a Delivered-To header to messages.
  21862. Defaults to @samp{#t}.
  21863. @end deftypevr
  21864. @deftypevr {@code{getmail-options-configuration} parameter} boolean received
  21865. If set, getmail adds a Received header to the messages.
  21866. Defaults to @samp{#t}.
  21867. @end deftypevr
  21868. @deftypevr {@code{getmail-options-configuration} parameter} string message-log
  21869. Getmail will record a log of its actions to the named file. A value of
  21870. @samp{""} disables this feature.
  21871. Defaults to @samp{""}.
  21872. @end deftypevr
  21873. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
  21874. If true, getmail will record a log of its actions using the system
  21875. logger.
  21876. Defaults to @samp{#f}.
  21877. @end deftypevr
  21878. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
  21879. If true, getmail will log information about messages not retrieved and
  21880. the reason for not retrieving them, as well as starting and ending
  21881. information lines.
  21882. Defaults to @samp{#f}.
  21883. @end deftypevr
  21884. @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
  21885. Extra options to include.
  21886. Defaults to @samp{'()}.
  21887. @end deftypevr
  21888. @end deftypevr
  21889. @end deftypevr
  21890. @deftypevr {@code{getmail-configuration} parameter} list idle
  21891. A list of mailboxes that getmail should wait on the server for new mail
  21892. notifications. This depends on the server supporting the IDLE
  21893. extension.
  21894. Defaults to @samp{'()}.
  21895. @end deftypevr
  21896. @deftypevr {@code{getmail-configuration} parameter} list environment-variables
  21897. Environment variables to set for getmail.
  21898. Defaults to @samp{'()}.
  21899. @end deftypevr
  21900. @subsubheading Mail Aliases Service
  21901. @cindex email aliases
  21902. @cindex aliases, for email addresses
  21903. @defvar mail-aliases-service-type
  21904. This is the type of the service which provides @code{/etc/aliases},
  21905. specifying how to deliver mail to users on this system.
  21906. @lisp
  21907. (service mail-aliases-service-type
  21908. '(("postmaster" "bob")
  21909. ("bob" "bob@@example.com" "bob@@example2.com")))
  21910. @end lisp
  21911. @end defvar
  21912. The configuration for a @code{mail-aliases-service-type} service is an
  21913. association list denoting how to deliver mail that comes to this
  21914. system. Each entry is of the form @code{(alias addresses ...)}, with
  21915. @code{alias} specifying the local alias and @code{addresses} specifying
  21916. where to deliver this user's mail.
  21917. The aliases aren't required to exist as users on the local system. In
  21918. the above example, there doesn't need to be a @code{postmaster} entry in
  21919. the @code{operating-system}'s @code{user-accounts} in order to deliver
  21920. the @code{postmaster} mail to @code{bob} (which subsequently would
  21921. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  21922. @subsubheading GNU Mailutils IMAP4 Daemon
  21923. @cindex GNU Mailutils IMAP4 Daemon
  21924. @defvar imap4d-service-type
  21925. This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
  21926. mailutils, GNU Mailutils Manual}), whose value should be an
  21927. @code{imap4d-configuration} object as in this example:
  21928. @lisp
  21929. (service imap4d-service-type
  21930. (imap4d-configuration
  21931. (config-file (local-file "imap4d.conf"))))
  21932. @end lisp
  21933. @end defvar
  21934. @deftp {Data Type} imap4d-configuration
  21935. Data type representing the configuration of @command{imap4d}.
  21936. @table @asis
  21937. @item @code{package} (default: @code{mailutils})
  21938. The package that provides @command{imap4d}.
  21939. @item @code{config-file} (default: @code{%default-imap4d-config-file})
  21940. File-like object of the configuration file to use, by default it will listen
  21941. on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
  21942. Mailutils Manual}, for details.
  21943. @end table
  21944. @end deftp
  21945. @subsubheading Radicale Service
  21946. @cindex CalDAV
  21947. @cindex CardDAV
  21948. @defvar radicale-service-type
  21949. This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV
  21950. server whose value should be a @code{radicale-configuration}.
  21951. @end defvar
  21952. @deftp {Data Type} radicale-configuration
  21953. Data type representing the configuration of @command{radicale}.
  21954. @table @asis
  21955. @item @code{package} (default: @code{radicale})
  21956. The package that provides @command{radicale}.
  21957. @item @code{config-file} (default: @code{%default-radicale-config-file})
  21958. File-like object of the configuration file to use, by default it will listen
  21959. on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at
  21960. @file{/var/lib/radicale/users} with no (@code{plain}) encryption.
  21961. @end table
  21962. @end deftp
  21963. @node Messaging Services
  21964. @subsection Messaging Services
  21965. @cindex messaging
  21966. @cindex jabber
  21967. @cindex XMPP
  21968. The @code{(gnu services messaging)} module provides Guix service
  21969. definitions for messaging services. Currently it provides the following
  21970. services:
  21971. @subsubheading Prosody Service
  21972. @defvar prosody-service-type
  21973. This is the type for the @uref{https://prosody.im, Prosody XMPP
  21974. communication server}. Its value must be a @code{prosody-configuration}
  21975. record as in this example:
  21976. @lisp
  21977. (service prosody-service-type
  21978. (prosody-configuration
  21979. (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
  21980. (int-components
  21981. (list
  21982. (int-component-configuration
  21983. (hostname "conference.example.net")
  21984. (plugin "muc")
  21985. (mod-muc (mod-muc-configuration)))))
  21986. (virtualhosts
  21987. (list
  21988. (virtualhost-configuration
  21989. (domain "example.net"))))))
  21990. @end lisp
  21991. See below for details about @code{prosody-configuration}.
  21992. @end defvar
  21993. By default, Prosody does not need much configuration. Only one
  21994. @code{virtualhosts} field is needed: it specifies the domain you wish
  21995. Prosody to serve.
  21996. You can perform various sanity checks on the generated configuration
  21997. with the @code{prosodyctl check} command.
  21998. Prosodyctl will also help you to import certificates from the
  21999. @code{letsencrypt} directory so that the @code{prosody} user can access
  22000. them. See @url{https://prosody.im/doc/letsencrypt}.
  22001. @example
  22002. prosodyctl --root cert import /etc/letsencrypt/live
  22003. @end example
  22004. The available configuration parameters follow. Each parameter
  22005. definition is preceded by its type; for example, @samp{string-list foo}
  22006. indicates that the @code{foo} parameter should be specified as a list of
  22007. strings. Types starting with @code{maybe-} denote parameters that won't
  22008. show up in @code{prosody.cfg.lua} when their value is left unspecified.
  22009. There is also a way to specify the configuration as a string, if you
  22010. have an old @code{prosody.cfg.lua} file that you want to port over from
  22011. some other system; see the end for more details.
  22012. The @code{file-object} type designates either a file-like object
  22013. (@pxref{G-Expressions, file-like objects}) or a file name.
  22014. @c The following documentation was initially generated by
  22015. @c (generate-documentation) in (gnu services messaging). Manually maintained
  22016. @c documentation is better, so we shouldn't hesitate to edit below as
  22017. @c needed. However if the change you want to make to this documentation
  22018. @c can be done in an automated way, it's probably easier to change
  22019. @c (generate-documentation) than to make it below and have to deal with
  22020. @c the churn as Prosody updates.
  22021. Available @code{prosody-configuration} fields are:
  22022. @deftypevr {@code{prosody-configuration} parameter} package prosody
  22023. The Prosody package.
  22024. @end deftypevr
  22025. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  22026. Location of the Prosody data storage directory. See
  22027. @url{https://prosody.im/doc/configure}.
  22028. Defaults to @samp{"/var/lib/prosody"}.
  22029. @end deftypevr
  22030. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  22031. Additional plugin directories. They are searched in all the specified
  22032. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  22033. Defaults to @samp{'()}.
  22034. @end deftypevr
  22035. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  22036. Every virtual host and component needs a certificate so that clients and
  22037. servers can securely verify its identity. Prosody will automatically load
  22038. certificates/keys from the directory specified here.
  22039. Defaults to @samp{"/etc/prosody/certs"}.
  22040. @end deftypevr
  22041. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  22042. This is a list of accounts that are admins for the server. Note that you
  22043. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  22044. @url{https://prosody.im/doc/creating_accounts}.
  22045. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  22046. Defaults to @samp{'()}.
  22047. @end deftypevr
  22048. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  22049. Enable use of libevent for better performance under high load. See
  22050. @url{https://prosody.im/doc/libevent}.
  22051. Defaults to @samp{#f}.
  22052. @end deftypevr
  22053. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  22054. This is the list of modules Prosody will load on startup. It looks for
  22055. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  22056. Documentation on modules can be found at:
  22057. @url{https://prosody.im/doc/modules}.
  22058. Defaults to @samp{'("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  22059. @end deftypevr
  22060. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  22061. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  22062. should you want to disable them then add them to this list.
  22063. Defaults to @samp{'()}.
  22064. @end deftypevr
  22065. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  22066. Path to a text file where the shared groups are defined. If this path is
  22067. empty then @samp{mod_groups} does nothing. See
  22068. @url{https://prosody.im/doc/modules/mod_groups}.
  22069. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  22070. @end deftypevr
  22071. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  22072. Disable account creation by default, for security. See
  22073. @url{https://prosody.im/doc/creating_accounts}.
  22074. Defaults to @samp{#f}.
  22075. @end deftypevr
  22076. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  22077. These are the SSL/TLS-related settings. Most of them are disabled so to
  22078. use Prosody's defaults. If you do not completely understand these options, do
  22079. not add them to your config, it is easy to lower the security of your server
  22080. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  22081. Available @code{ssl-configuration} fields are:
  22082. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  22083. This determines what handshake to use.
  22084. @end deftypevr
  22085. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  22086. Path to your private key file.
  22087. @end deftypevr
  22088. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  22089. Path to your certificate file.
  22090. @end deftypevr
  22091. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  22092. Path to directory containing root certificates that you wish Prosody to
  22093. trust when verifying the certificates of remote servers.
  22094. Defaults to @samp{"/etc/ssl/certs"}.
  22095. @end deftypevr
  22096. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  22097. Path to a file containing root certificates that you wish Prosody to trust.
  22098. Similar to @code{capath} but with all certificates concatenated together.
  22099. @end deftypevr
  22100. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  22101. A list of verification options (these mostly map to OpenSSL's
  22102. @code{set_verify()} flags).
  22103. @end deftypevr
  22104. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  22105. A list of general options relating to SSL/TLS@. These map to OpenSSL's
  22106. @code{set_options()}. For a full list of options available in LuaSec, see the
  22107. LuaSec source.
  22108. @end deftypevr
  22109. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  22110. How long a chain of certificate authorities to check when looking for a
  22111. trusted root certificate.
  22112. @end deftypevr
  22113. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  22114. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  22115. clients, and in what order.
  22116. @end deftypevr
  22117. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  22118. A path to a file containing parameters for Diffie-Hellman key exchange. You
  22119. can create such a file with:
  22120. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  22121. @end deftypevr
  22122. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  22123. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  22124. @samp{"secp384r1"}.
  22125. @end deftypevr
  22126. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  22127. A list of ``extra'' verification options.
  22128. @end deftypevr
  22129. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  22130. Password for encrypted private keys.
  22131. @end deftypevr
  22132. @end deftypevr
  22133. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  22134. Whether to force all client-to-server connections to be encrypted or not.
  22135. See @url{https://prosody.im/doc/modules/mod_tls}.
  22136. Defaults to @samp{#f}.
  22137. @end deftypevr
  22138. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  22139. Set of mechanisms that will never be offered. See
  22140. @url{https://prosody.im/doc/modules/mod_saslauth}.
  22141. Defaults to @samp{'("DIGEST-MD5")}.
  22142. @end deftypevr
  22143. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  22144. Whether to force all server-to-server connections to be encrypted or not.
  22145. See @url{https://prosody.im/doc/modules/mod_tls}.
  22146. Defaults to @samp{#f}.
  22147. @end deftypevr
  22148. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  22149. Whether to require encryption and certificate authentication. This
  22150. provides ideal security, but requires servers you communicate with to support
  22151. encryption AND present valid, trusted certificates. See
  22152. @url{https://prosody.im/doc/s2s#security}.
  22153. Defaults to @samp{#f}.
  22154. @end deftypevr
  22155. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  22156. Many servers don't support encryption or have invalid or self-signed
  22157. certificates. You can list domains here that will not be required to
  22158. authenticate using certificates. They will be authenticated using DNS@. See
  22159. @url{https://prosody.im/doc/s2s#security}.
  22160. Defaults to @samp{'()}.
  22161. @end deftypevr
  22162. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  22163. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  22164. valid certificates for some domains by specifying a list here. See
  22165. @url{https://prosody.im/doc/s2s#security}.
  22166. Defaults to @samp{'()}.
  22167. @end deftypevr
  22168. @deftypevr {@code{prosody-configuration} parameter} string authentication
  22169. Select the authentication backend to use. The default provider stores
  22170. passwords in plaintext and uses Prosody's configured data storage to store the
  22171. authentication data. If you do not trust your server please see
  22172. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  22173. about using the hashed backend. See also
  22174. @url{https://prosody.im/doc/authentication}
  22175. Defaults to @samp{"internal_plain"}.
  22176. @end deftypevr
  22177. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  22178. Set logging options. Advanced logging configuration is not yet supported
  22179. by the Prosody service. See @url{https://prosody.im/doc/logging}.
  22180. Defaults to @samp{"*syslog"}.
  22181. @end deftypevr
  22182. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  22183. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  22184. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  22185. @end deftypevr
  22186. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  22187. Maximum allowed size of the HTTP body (in bytes).
  22188. @end deftypevr
  22189. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  22190. Some modules expose their own URL in various ways. This URL is built
  22191. from the protocol, host and port used. If Prosody sits behind a proxy, the
  22192. public URL will be @code{http-external-url} instead. See
  22193. @url{https://prosody.im/doc/http#external_url}.
  22194. @end deftypevr
  22195. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  22196. A host in Prosody is a domain on which user accounts can be created. For
  22197. example if you want your users to have addresses like
  22198. @samp{"john.smith@@example.com"} then you need to add a host
  22199. @samp{"example.com"}. All options in this list will apply only to this host.
  22200. @quotation Note
  22201. The name @emph{virtual} host is used in configuration to avoid confusion with
  22202. the actual physical host that Prosody is installed on. A single Prosody
  22203. instance can serve many domains, each one defined as a VirtualHost entry in
  22204. Prosody's configuration. Conversely a server that hosts a single domain would
  22205. have just one VirtualHost entry.
  22206. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  22207. @end quotation
  22208. Available @code{virtualhost-configuration} fields are:
  22209. 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:
  22210. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  22211. Domain you wish Prosody to serve.
  22212. @end deftypevr
  22213. @end deftypevr
  22214. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  22215. Components are extra services on a server which are available to clients,
  22216. usually on a subdomain of the main server (such as
  22217. @samp{"mycomponent.example.com"}). Example components might be chatroom
  22218. servers, user directories, or gateways to other protocols.
  22219. Internal components are implemented with Prosody-specific plugins. To add an
  22220. internal component, you simply fill the hostname field, and the plugin you wish
  22221. to use for the component.
  22222. See @url{https://prosody.im/doc/components}.
  22223. Defaults to @samp{'()}.
  22224. Available @code{int-component-configuration} fields are:
  22225. 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:
  22226. @deftypevr {@code{int-component-configuration} parameter} string hostname
  22227. Hostname of the component.
  22228. @end deftypevr
  22229. @deftypevr {@code{int-component-configuration} parameter} string plugin
  22230. Plugin you wish to use for the component.
  22231. @end deftypevr
  22232. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  22233. Multi-user chat (MUC) is Prosody's module for allowing you to create
  22234. hosted chatrooms/conferences for XMPP users.
  22235. General information on setting up and using multi-user chatrooms can be found
  22236. in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
  22237. which you should read if you are new to XMPP chatrooms.
  22238. See also @url{https://prosody.im/doc/modules/mod_muc}.
  22239. Available @code{mod-muc-configuration} fields are:
  22240. @deftypevr {@code{mod-muc-configuration} parameter} string name
  22241. The name to return in service discovery responses.
  22242. Defaults to @samp{"Prosody Chatrooms"}.
  22243. @end deftypevr
  22244. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  22245. If @samp{#t}, this will only allow admins to create new chatrooms.
  22246. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  22247. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  22248. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  22249. restricts to service administrators only.
  22250. Defaults to @samp{#f}.
  22251. @end deftypevr
  22252. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  22253. Maximum number of history messages that will be sent to the member that has
  22254. just joined the room.
  22255. Defaults to @samp{20}.
  22256. @end deftypevr
  22257. @end deftypevr
  22258. @end deftypevr
  22259. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  22260. External components use XEP-0114, which most standalone components
  22261. support. To add an external component, you simply fill the hostname field. See
  22262. @url{https://prosody.im/doc/components}.
  22263. Defaults to @samp{'()}.
  22264. Available @code{ext-component-configuration} fields are:
  22265. 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:
  22266. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  22267. Password which the component will use to log in.
  22268. @end deftypevr
  22269. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  22270. Hostname of the component.
  22271. @end deftypevr
  22272. @end deftypevr
  22273. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  22274. Port(s) Prosody listens on for component connections.
  22275. Defaults to @samp{'(5347)}.
  22276. @end deftypevr
  22277. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  22278. Interface Prosody listens on for component connections.
  22279. Defaults to @samp{"127.0.0.1"}.
  22280. @end deftypevr
  22281. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  22282. Raw content that will be added to the configuration file.
  22283. @end deftypevr
  22284. It could be that you just want to get a @code{prosody.cfg.lua}
  22285. up and running. In that case, you can pass an
  22286. @code{opaque-prosody-configuration} record as the value of
  22287. @code{prosody-service-type}. As its name indicates, an opaque configuration
  22288. does not have easy reflective capabilities.
  22289. Available @code{opaque-prosody-configuration} fields are:
  22290. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  22291. The prosody package.
  22292. @end deftypevr
  22293. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  22294. The contents of the @code{prosody.cfg.lua} to use.
  22295. @end deftypevr
  22296. For example, if your @code{prosody.cfg.lua} is just the empty
  22297. string, you could instantiate a prosody service like this:
  22298. @lisp
  22299. (service prosody-service-type
  22300. (opaque-prosody-configuration
  22301. (prosody.cfg.lua "")))
  22302. @end lisp
  22303. @c end of Prosody auto-generated documentation
  22304. @subsubheading BitlBee Service
  22305. @cindex IRC (Internet Relay Chat)
  22306. @cindex IRC gateway
  22307. @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
  22308. interface to a variety of messaging protocols such as XMPP.
  22309. @defvar bitlbee-service-type
  22310. This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
  22311. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  22312. below).
  22313. To have BitlBee listen on port 6667 on localhost, add this line to your
  22314. services:
  22315. @lisp
  22316. (service bitlbee-service-type)
  22317. @end lisp
  22318. @end defvar
  22319. @deftp {Data Type} bitlbee-configuration
  22320. This is the configuration for BitlBee, with the following fields:
  22321. @table @asis
  22322. @item @code{interface} (default: @code{"127.0.0.1"})
  22323. @itemx @code{port} (default: @code{6667})
  22324. Listen on the network interface corresponding to the IP address
  22325. specified in @var{interface}, on @var{port}.
  22326. When @var{interface} is @code{127.0.0.1}, only local clients can
  22327. connect; when it is @code{0.0.0.0}, connections can come from any
  22328. networking interface.
  22329. @item @code{bitlbee} (default: @code{bitlbee})
  22330. The BitlBee package to use.
  22331. @item @code{plugins} (default: @code{'()})
  22332. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  22333. @item @code{extra-settings} (default: @code{""})
  22334. Configuration snippet added as-is to the BitlBee configuration file.
  22335. @end table
  22336. @end deftp
  22337. @subsubheading Quassel Service
  22338. @cindex IRC (Internet Relay Chat)
  22339. @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
  22340. meaning that one or more clients can attach to and detach from the
  22341. central core.
  22342. @defvar quassel-service-type
  22343. This is the service type for the @url{https://quassel-irc.org/,Quassel}
  22344. IRC backend daemon. Its value is a @code{quassel-configuration}
  22345. (see below).
  22346. @end defvar
  22347. @deftp {Data Type} quassel-configuration
  22348. This is the configuration for Quassel, with the following fields:
  22349. @table @asis
  22350. @item @code{quassel} (default: @code{quassel})
  22351. The Quassel package to use.
  22352. @item @code{interface} (default: @code{"::,0.0.0.0"})
  22353. @item @code{port} (default: @code{4242})
  22354. Listen on the network interface(s) corresponding to the IPv4 or IPv6
  22355. interfaces specified in the comma delimited @var{interface}, on
  22356. @var{port}.
  22357. @item @code{loglevel} (default: @code{"Info"})
  22358. The level of logging desired. Accepted values are Debug, Info, Warning
  22359. and Error.
  22360. @end table
  22361. @end deftp
  22362. @node Telephony Services
  22363. @subsection Telephony Services
  22364. @cindex telephony, services
  22365. The @code{(gnu services telephony)} module contains Guix service
  22366. definitions for telephony services. Currently it provides the following
  22367. services:
  22368. @subsubheading Jami
  22369. @cindex jami, service
  22370. This section describes how to configure a Jami server that can be used
  22371. to host video (or audio) conferences, among other uses. The following
  22372. example demonstrates how to specify Jami account archives (backups) to
  22373. be provisioned automatically:
  22374. @lisp
  22375. (service jami-service-type
  22376. (jami-configuration
  22377. (accounts
  22378. (list (jami-account
  22379. (archive "/etc/jami/unencrypted-account-1.gz"))
  22380. (jami-account
  22381. (archive "/etc/jami/unencrypted-account-2.gz"))))))
  22382. @end lisp
  22383. When the accounts field is specified, the Jami account files of the
  22384. service found under @file{/var/lib/jami} are recreated every time the
  22385. service starts.
  22386. Jami accounts and their corresponding backup archives can be generated
  22387. using the @code{jami} or @code{jami-gnome} Jami clients. The accounts
  22388. should not be password-protected, but it is wise to ensure their files
  22389. are only readable by @samp{root}.
  22390. The next example shows how to declare that only some contacts should be
  22391. allowed to communicate with a given account:
  22392. @lisp
  22393. (service jami-service-type
  22394. (jami-configuration
  22395. (accounts
  22396. (list (jami-account
  22397. (archive "/etc/jami/unencrypted-account-1.gz")
  22398. (peer-discovery? #t)
  22399. (rendezvous-point? #t)
  22400. (allowed-contacts
  22401. '("1dbcb0f5f37324228235564b79f2b9737e9a008f"
  22402. "2dbcb0f5f37324228235564b79f2b9737e9a008f")))))))
  22403. @end lisp
  22404. In this mode, only the declared @code{allowed-contacts} can initiate
  22405. communication with the Jami account. This can be used, for example,
  22406. with rendezvous point accounts to create a private video conferencing
  22407. space.
  22408. To put the system administrator in full control of the conferences
  22409. hosted on their system, the Jami service supports the following actions:
  22410. @example sh
  22411. # herd doc jami list-actions
  22412. (list-accounts
  22413. list-account-details
  22414. list-banned-contacts
  22415. list-contacts
  22416. list-moderators
  22417. add-moderator
  22418. ban-contact
  22419. enable-account
  22420. disable-account)
  22421. @end example
  22422. The above actions aim to provide the most valuable actions for
  22423. moderation purposes, not to cover the whole Jami API. Users wanting to
  22424. interact with the Jami daemon from Guile may be interested in
  22425. experimenting with the @code{(gnu build jami-service)} module, which
  22426. powers the above Shepherd actions.
  22427. @c TODO: This should be auto-generated from the doc already defined on
  22428. @c the shepherd-actions themselves in (gnu services telephony).
  22429. The @code{add-moderator} and @code{ban-contact} actions accept a contact
  22430. @emph{fingerprint} (40 characters long hash) as first argument and an
  22431. account fingerprint or username as second argument:
  22432. @example sh
  22433. # herd add-moderator jami 1dbcb0f5f37324228235564b79f2b9737e9a008f \
  22434. f3345f2775ddfe07a4b0d95daea111d15fbc1199
  22435. # herd list-moderators jami
  22436. Moderators for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
  22437. - 1dbcb0f5f37324228235564b79f2b9737e9a008f
  22438. @end example
  22439. In the case of @code{ban-contact}, the second username argument is
  22440. optional; when omitted, the account is banned from all Jami accounts:
  22441. @example sh
  22442. # herd ban-contact jami 1dbcb0f5f37324228235564b79f2b9737e9a008f
  22443. # herd list-banned-contacts jami
  22444. Banned contacts for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
  22445. - 1dbcb0f5f37324228235564b79f2b9737e9a008f
  22446. @end example
  22447. Banned contacts are also stripped from their moderation privileges.
  22448. The @code{disable-account} action allows to completely disconnect an
  22449. account from the network, making it unreachable, while
  22450. @code{enable-account} does the inverse. They accept a single account
  22451. username or fingerprint as first argument:
  22452. @example sh
  22453. # herd disable-account jami f3345f2775ddfe07a4b0d95daea111d15fbc1199
  22454. # herd list-accounts jami
  22455. The following Jami accounts are available:
  22456. - f3345f2775ddfe07a4b0d95daea111d15fbc1199 (dummy) [disabled]
  22457. @end example
  22458. The @code{list-account-details} action prints the detailed parameters of
  22459. each accounts in the Recutils format, which means the @command{recsel}
  22460. command can be used to select accounts of interest (@pxref{Selection
  22461. Expressions,,,recutils, GNU recutils manual}). Note that period
  22462. characters (@samp{.}) found in the account parameter keys are mapped to
  22463. underscores (@samp{_}) in the output, to meet the requirements of the
  22464. Recutils format. The following example shows how to print the account
  22465. fingerprints for all accounts operating in the rendezvous point mode:
  22466. @example sh
  22467. # herd list-account-details jami | \
  22468. recsel -p Account.username -e 'Account.rendezVous ~ "true"'
  22469. Account_username: f3345f2775ddfe07a4b0d95daea111d15fbc1199
  22470. @end example
  22471. The remaining actions should be self-explanatory.
  22472. The complete set of available configuration options is detailed below.
  22473. @c TODO: Ideally, the following fragments would be auto-generated at
  22474. @c build time, so that they needn't be manually duplicated.
  22475. @c Auto-generated via (configuration->documentation 'jami-configuration)
  22476. @deftp {Data Type} jami-configuration
  22477. Available @code{jami-configuration} fields are:
  22478. @table @asis
  22479. @item @code{libjami} (default: @code{libjami}) (type: package)
  22480. The Jami daemon package to use.
  22481. @item @code{dbus} (default: @code{dbus-for-jami}) (type: package)
  22482. The D-Bus package to use to start the required D-Bus session.
  22483. @item @code{nss-certs} (default: @code{nss-certs}) (type: package)
  22484. The nss-certs package to use to provide TLS certificates.
  22485. @item @code{enable-logging?} (default: @code{#t}) (type: boolean)
  22486. Whether to enable logging to syslog.
  22487. @item @code{debug?} (default: @code{#f}) (type: boolean)
  22488. Whether to enable debug level messages.
  22489. @item @code{auto-answer?} (default: @code{#f}) (type: boolean)
  22490. Whether to force automatic answer to incoming calls.
  22491. @item @code{accounts} (type: maybe-jami-account-list)
  22492. A list of Jami accounts to be (re-)provisioned every time the Jami
  22493. daemon service starts. When providing this field, the account
  22494. directories under @file{/var/lib/jami/} are recreated every time the
  22495. service starts, ensuring a consistent state.
  22496. @end table
  22497. @end deftp
  22498. @c Auto-generated via (configuration->documentation 'jami-account)
  22499. @deftp {Data Type} jami-account
  22500. Available @code{jami-account} fields are:
  22501. @table @asis
  22502. @item @code{archive} (type: string-or-computed-file)
  22503. The account archive (backup) file name of the account. This is used to
  22504. provision the account when the service starts. The account archive
  22505. should @emph{not} be encrypted. It is highly recommended to make it
  22506. readable only to the @samp{root} user (i.e., not in the store), to guard
  22507. against leaking the secret key material of the Jami account it contains.
  22508. @item @code{allowed-contacts} (type: maybe-account-fingerprint-list)
  22509. The list of allowed contacts for the account, entered as their 40
  22510. characters long fingerprint. Messages or calls from accounts not in
  22511. that list will be rejected. When left specified, the configuration of
  22512. the account archive is used as-is with respect to contacts and public
  22513. inbound calls/messaging allowance, which typically defaults to allow any
  22514. contact to communicate with the account.
  22515. @item @code{moderators} (type: maybe-account-fingerprint-list)
  22516. The list of contacts that should have moderation privileges (to ban,
  22517. mute, etc. other users) in rendezvous conferences, entered as their 40
  22518. characters long fingerprint. When left unspecified, the configuration
  22519. of the account archive is used as-is with respect to moderation, which
  22520. typically defaults to allow anyone to moderate.
  22521. @item @code{rendezvous-point?} (type: maybe-boolean)
  22522. Whether the account should operate in the rendezvous mode. In this
  22523. mode, all the incoming audio/video calls are mixed into a conference.
  22524. When left unspecified, the value from the account archive prevails.
  22525. @item @code{peer-discovery?} (type: maybe-boolean)
  22526. Whether peer discovery should be enabled. Peer discovery is used to
  22527. discover other OpenDHT nodes on the local network, which can be useful
  22528. to maintain communication between devices on such network even when the
  22529. connection to the Internet has been lost. When left unspecified,
  22530. the value from the account archive prevails.
  22531. @item @code{bootstrap-hostnames} (type: maybe-string-list)
  22532. A list of hostnames or IPs pointing to OpenDHT nodes, that should be
  22533. used to initially join the OpenDHT network. When left unspecified, the
  22534. value from the account archive prevails.
  22535. @item @code{name-server-uri} (type: maybe-string)
  22536. The URI of the name server to use, that can be used to retrieve the
  22537. account fingerprint for a registered username.
  22538. @end table
  22539. @end deftp
  22540. @subsubheading Mumble server
  22541. @cindex Mumble
  22542. @cindex Murmur
  22543. @cindex VoIP server
  22544. This section describes how to set up and run a
  22545. @uref{https://mumble.info, Mumble} server (formerly known as Murmur).
  22546. @deftp {Data Type} mumble-server-configuration
  22547. The service type for the Mumble server. An example configuration can
  22548. look like this:
  22549. @lisp
  22550. (service mumble-server-service-type
  22551. (mumble-server-configuration
  22552. (welcome-text
  22553. "Welcome to this Mumble server running on Guix!")
  22554. (cert-required? #t) ;disallow text password logins
  22555. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  22556. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  22557. @end lisp
  22558. After reconfiguring your system, you can manually set the mumble-server
  22559. @code{SuperUser}
  22560. password with the command that is printed during the activation phase.
  22561. It is recommended to register a normal Mumble user account
  22562. and grant it admin or moderator rights.
  22563. You can use the @code{mumble} client to
  22564. login as new normal user, register yourself, and log out.
  22565. For the next step login with the name @code{SuperUser} use
  22566. the @code{SuperUser} password that you set previously,
  22567. and grant your newly registered mumble user administrator or moderator
  22568. rights and create some channels.
  22569. Available @code{mumble-server-configuration} fields are:
  22570. @table @asis
  22571. @item @code{package} (default: @code{mumble})
  22572. Package that contains @code{bin/mumble-server}.
  22573. @item @code{user} (default: @code{"mumble-server"})
  22574. User who will run the Mumble-Server server.
  22575. @item @code{group} (default: @code{"mumble-server"})
  22576. Group of the user who will run the mumble-server server.
  22577. @item @code{port} (default: @code{64738})
  22578. Port on which the server will listen.
  22579. @item @code{welcome-text} (default: @code{""})
  22580. Welcome text sent to clients when they connect.
  22581. @item @code{server-password} (default: @code{""})
  22582. Password the clients have to enter in order to connect.
  22583. @item @code{max-users} (default: @code{100})
  22584. Maximum of users that can be connected to the server at once.
  22585. @item @code{max-user-bandwidth} (default: @code{#f})
  22586. Maximum voice traffic a user can send per second.
  22587. @item @code{database-file} (default: @code{"/var/lib/mumble-server/db.sqlite"})
  22588. File name of the sqlite database.
  22589. The service's user will become the owner of the directory.
  22590. @item @code{log-file} (default: @code{"/var/log/mumble-server/mumble-server.log"})
  22591. File name of the log file.
  22592. The service's user will become the owner of the directory.
  22593. @item @code{autoban-attempts} (default: @code{10})
  22594. Maximum number of logins a user can make in @code{autoban-timeframe}
  22595. without getting auto banned for @code{autoban-time}.
  22596. @item @code{autoban-timeframe} (default: @code{120})
  22597. Timeframe for autoban in seconds.
  22598. @item @code{autoban-time} (default: @code{300})
  22599. Amount of time in seconds for which a client gets banned
  22600. when violating the autoban limits.
  22601. @item @code{opus-threshold} (default: @code{100})
  22602. Percentage of clients that need to support opus
  22603. before switching over to opus audio codec.
  22604. @item @code{channel-nesting-limit} (default: @code{10})
  22605. How deep channels can be nested at maximum.
  22606. @item @code{channelname-regex} (default: @code{#f})
  22607. A string in form of a Qt regular expression that channel names must conform to.
  22608. @item @code{username-regex} (default: @code{#f})
  22609. A string in form of a Qt regular expression that user names must conform to.
  22610. @item @code{text-message-length} (default: @code{5000})
  22611. Maximum size in bytes that a user can send in one text chat message.
  22612. @item @code{image-message-length} (default: @code{(* 128 1024)})
  22613. Maximum size in bytes that a user can send in one image message.
  22614. @item @code{cert-required?} (default: @code{#f})
  22615. If it is set to @code{#t} clients that use weak password authentication
  22616. will not be accepted. Users must have completed the certificate wizard to join.
  22617. @item @code{remember-channel?} (default: @code{#f})
  22618. Should mumble-server remember the last channel each user was in when
  22619. they disconnected and put them into the remembered channel when they
  22620. rejoin.
  22621. @item @code{allow-html?} (default: @code{#f})
  22622. Should html be allowed in text messages, user comments, and channel descriptions.
  22623. @item @code{allow-ping?} (default: @code{#f})
  22624. Setting to true exposes the current user count, the maximum user count, and
  22625. the server's maximum bandwidth per client to unauthenticated users. In the
  22626. Mumble client, this information is shown in the Connect dialog.
  22627. Disabling this setting will prevent public listing of the server.
  22628. @item @code{bonjour?} (default: @code{#f})
  22629. Should the server advertise itself in the local network through the bonjour protocol.
  22630. @item @code{send-version?} (default: @code{#f})
  22631. Should the mumble-server server version be exposed in ping requests.
  22632. @item @code{log-days} (default: @code{31})
  22633. Mumble also stores logs in the database, which are accessible via RPC.
  22634. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  22635. or -1 to disable logging to the database.
  22636. @item @code{obfuscate-ips?} (default: @code{#t})
  22637. Should logged ips be obfuscated to protect the privacy of users.
  22638. @item @code{ssl-cert} (default: @code{#f})
  22639. File name of the SSL/TLS certificate used for encrypted connections.
  22640. @lisp
  22641. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  22642. @end lisp
  22643. @item @code{ssl-key} (default: @code{#f})
  22644. Filepath to the ssl private key used for encrypted connections.
  22645. @lisp
  22646. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  22647. @end lisp
  22648. @item @code{ssl-dh-params} (default: @code{#f})
  22649. File name of a PEM-encoded file with Diffie-Hellman parameters
  22650. for the SSL/TLS encryption. Alternatively you set it to
  22651. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  22652. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  22653. @item @code{ssl-ciphers} (default: @code{#f})
  22654. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  22655. in SSL/TLS.
  22656. This option is specified using
  22657. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  22658. OpenSSL cipher list notation}.
  22659. It is recommended that you try your cipher string using
  22660. 'openssl ciphers <string>' before setting it here, to get a feel for
  22661. which cipher suites you will get.
  22662. After setting this option, it is recommend that you inspect your Mumble
  22663. server log to ensure that Mumble is using the cipher suites that you
  22664. expected it to.
  22665. @quotation Note
  22666. Changing this option may impact the backwards compatibility of your
  22667. Mumble-Server server, and can remove the ability for older Mumble clients to be able to connect to it.
  22668. @end quotation
  22669. @item @code{public-registration} (default: @code{#f})
  22670. Must be a @code{<mumble-server-public-registration-configuration>}
  22671. record or @code{#f}.
  22672. You can optionally register your server in the public server list that the
  22673. @code{mumble} client shows on startup.
  22674. You cannot register your server if you have set a @code{server-password},
  22675. or set @code{allow-ping} to @code{#f}.
  22676. It might take a few hours until it shows up in the public list.
  22677. @item @code{file} (default: @code{#f})
  22678. Optional alternative override for this configuration.
  22679. @end table
  22680. @end deftp
  22681. @deftp {Data Type} mumble-server-public-registration-configuration
  22682. Configuration for public registration of a mumble-server service.
  22683. @table @asis
  22684. @item @code{name}
  22685. This is a display name for your server. Not to be confused with the hostname.
  22686. @item @code{password}
  22687. A password to identify your registration.
  22688. Subsequent updates will need the same password. Don't lose your password.
  22689. @item @code{url}
  22690. This should be a @code{http://} or @code{https://} link to your web
  22691. site.
  22692. @item @code{hostname} (default: @code{#f})
  22693. By default your server will be listed by its IP address.
  22694. If it is set your server will be linked by this host name instead.
  22695. @end table
  22696. @end deftp
  22697. @quotation Deprecation notice
  22698. Due to historical reasons, all of the above @code{mumble-server-}
  22699. procedures are also exported with the @code{murmur-} prefix.
  22700. It is recommended that you switch to using @code{mumble-server-}
  22701. going forward.
  22702. @end quotation
  22703. @node File-Sharing Services
  22704. @subsection File-Sharing Services
  22705. The @code{(gnu services file-sharing)} module provides services that
  22706. assist with transferring files over peer-to-peer file-sharing networks.
  22707. @subsubheading Transmission Daemon Service
  22708. @uref{https://transmissionbt.com/, Transmission} is a flexible
  22709. BitTorrent client that offers a variety of graphical and command-line
  22710. interfaces. A @code{transmission-daemon-service-type} service provides
  22711. Transmission's headless variant, @command{transmission-daemon}, as a
  22712. system service, allowing users to share files via BitTorrent even when
  22713. they are not logged in.
  22714. @defvar transmission-daemon-service-type
  22715. The service type for the Transmission Daemon BitTorrent client. Its
  22716. value must be a @code{transmission-daemon-configuration} object as in
  22717. this example:
  22718. @lisp
  22719. (service transmission-daemon-service-type
  22720. (transmission-daemon-configuration
  22721. ;; Restrict access to the RPC ("control") interface
  22722. (rpc-authentication-required? #t)
  22723. (rpc-username "transmission")
  22724. (rpc-password
  22725. (transmission-password-hash
  22726. "transmission" ; desired password
  22727. "uKd1uMs9")) ; arbitrary salt value
  22728. ;; Accept requests from this and other hosts on the
  22729. ;; local network
  22730. (rpc-whitelist-enabled? #t)
  22731. (rpc-whitelist '("::1" "127.0.0.1" "192.168.0.*"))
  22732. ;; Limit bandwidth use during work hours
  22733. (alt-speed-down (* 1024 2)) ; 2 MB/s
  22734. (alt-speed-up 512) ; 512 kB/s
  22735. (alt-speed-time-enabled? #t)
  22736. (alt-speed-time-day 'weekdays)
  22737. (alt-speed-time-begin
  22738. (+ (* 60 8) 30)) ; 8:30 am
  22739. (alt-speed-time-end
  22740. (+ (* 60 (+ 12 5)) 30)))) ; 5:30 pm
  22741. @end lisp
  22742. @end defvar
  22743. Once the service is started, users can interact with the daemon through
  22744. its Web interface (at @code{http://localhost:9091/}) or by using the
  22745. @command{transmission-remote} command-line tool, available in the
  22746. @code{transmission} package. (Emacs users may want to also consider the
  22747. @code{emacs-transmission} package.) Both communicate with the daemon
  22748. through its remote procedure call (RPC) interface, which by default is
  22749. available to all users on the system; you may wish to change this by
  22750. assigning values to the @code{rpc-authentication-required?},
  22751. @code{rpc-username} and @code{rpc-password} settings, as shown in the
  22752. example above and documented further below.
  22753. The value for @code{rpc-password} must be a password hash of the type
  22754. generated and used by Transmission clients. This can be copied verbatim
  22755. from an existing @file{settings.json} file, if another Transmission
  22756. client is already being used. Otherwise, the
  22757. @code{transmission-password-hash} and @code{transmission-random-salt}
  22758. procedures provided by this module can be used to obtain a suitable hash
  22759. value.
  22760. @deffn {Procedure} transmission-password-hash password salt
  22761. Returns a string containing the result of hashing @var{password}
  22762. together with @var{salt}, in the format recognized by Transmission
  22763. clients for their @code{rpc-password} configuration setting.
  22764. @var{salt} must be an eight-character string. The
  22765. @code{transmission-random-salt} procedure can be used to generate a
  22766. suitable salt value at random.
  22767. @end deffn
  22768. @deffn {Procedure} transmission-random-salt
  22769. Returns a string containing a random, eight-character salt value of the
  22770. type generated and used by Transmission clients, suitable for passing to
  22771. the @code{transmission-password-hash} procedure.
  22772. @end deffn
  22773. These procedures are accessible from within a Guile REPL started with
  22774. the @command{guix repl} command (@pxref{Invoking guix repl}). This is
  22775. useful for obtaining a random salt value to provide as the second
  22776. parameter to `transmission-password-hash`, as in this example session:
  22777. @example
  22778. $ guix repl
  22779. scheme@@(guix-user)> ,use (gnu services file-sharing)
  22780. scheme@@(guix-user)> (transmission-random-salt)
  22781. $1 = "uKd1uMs9"
  22782. @end example
  22783. Alternatively, a complete password hash can generated in a single step:
  22784. @example
  22785. scheme@@(guix-user)> (transmission-password-hash "transmission"
  22786. (transmission-random-salt))
  22787. $2 = "@{c8bbc6d1740cd8dc819a6e25563b67812c1c19c9VtFPfdsX"
  22788. @end example
  22789. The resulting string can be used as-is for the value of
  22790. @code{rpc-password}, allowing the password to be kept hidden even in the
  22791. operating-system configuration.
  22792. Torrent files downloaded by the daemon are directly accessible only to
  22793. users in the ``transmission'' user group, who receive read-only access
  22794. to the directory specified by the @code{download-dir} configuration
  22795. setting (and also the directory specified by @code{incomplete-dir}, if
  22796. @code{incomplete-dir-enabled?} is @code{#t}). Downloaded files can be
  22797. moved to another directory or deleted altogether using
  22798. @command{transmission-remote} with its @code{--move} and
  22799. @code{--remove-and-delete} options.
  22800. If the @code{watch-dir-enabled?} setting is set to @code{#t}, users in
  22801. the ``transmission'' group are able also to place @file{.torrent} files
  22802. in the directory specified by @code{watch-dir} to have the corresponding
  22803. torrents added by the daemon. (The @code{trash-original-torrent-files?}
  22804. setting controls whether the daemon deletes these files after processing
  22805. them.)
  22806. Some of the daemon's configuration settings can be changed temporarily
  22807. by @command{transmission-remote} and similar tools. To undo these
  22808. changes, use the service's @code{reload} action to have the daemon
  22809. reload its settings from disk:
  22810. @example
  22811. # herd reload transmission-daemon
  22812. @end example
  22813. The full set of available configuration settings is defined by the
  22814. @code{transmission-daemon-configuration} data type.
  22815. @deftp {Data Type} transmission-daemon-configuration
  22816. The data type representing configuration settings for Transmission
  22817. Daemon. These correspond directly to the settings recognized by
  22818. Transmission clients in their @file{settings.json} file.
  22819. @end deftp
  22820. @c The following documentation was initially generated by
  22821. @c (generate-transmission-daemon-documentation) in (gnu services
  22822. @c file-sharing). Manually maintained documentation is better, so we
  22823. @c shouldn't hesitate to edit below as needed. However if the change
  22824. @c you want to make to this documentation can be done in an automated
  22825. @c way, it's probably easier to change (generate-documentation) than to
  22826. @c make it below and have to deal with the churn as Transmission Daemon
  22827. @c updates.
  22828. @c %start of fragment
  22829. Available @code{transmission-daemon-configuration} fields are:
  22830. @deftypevr {@code{transmission-daemon-configuration} parameter} package transmission
  22831. The Transmission package to use.
  22832. @end deftypevr
  22833. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer stop-wait-period
  22834. The period, in seconds, to wait when stopping the service for
  22835. @command{transmission-daemon} to exit before killing its process. This
  22836. allows the daemon time to complete its housekeeping and send a final
  22837. update to trackers as it shuts down. On slow hosts, or hosts with a
  22838. slow network connection, this value may need to be increased.
  22839. Defaults to @samp{10}.
  22840. @end deftypevr
  22841. @deftypevr {@code{transmission-daemon-configuration} parameter} string download-dir
  22842. The directory to which torrent files are downloaded.
  22843. Defaults to @samp{"/var/lib/transmission-daemon/downloads"}.
  22844. @end deftypevr
  22845. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean incomplete-dir-enabled?
  22846. If @code{#t}, files will be held in @code{incomplete-dir} while their
  22847. torrent is being downloaded, then moved to @code{download-dir} once the
  22848. torrent is complete. Otherwise, files for all torrents (including those
  22849. still being downloaded) will be placed in @code{download-dir}.
  22850. Defaults to @samp{#f}.
  22851. @end deftypevr
  22852. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string incomplete-dir
  22853. The directory in which files from incompletely downloaded torrents will
  22854. be held when @code{incomplete-dir-enabled?} is @code{#t}.
  22855. Defaults to @samp{disabled}.
  22856. @end deftypevr
  22857. @deftypevr {@code{transmission-daemon-configuration} parameter} umask umask
  22858. The file mode creation mask used for downloaded files. (See the
  22859. @command{umask} man page for more information.)
  22860. Defaults to @samp{18}.
  22861. @end deftypevr
  22862. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rename-partial-files?
  22863. When @code{#t}, ``.part'' is appended to the name of partially
  22864. downloaded files.
  22865. Defaults to @samp{#t}.
  22866. @end deftypevr
  22867. @deftypevr {@code{transmission-daemon-configuration} parameter} preallocation-mode preallocation
  22868. The mode by which space should be preallocated for downloaded files, one
  22869. of @code{none}, @code{fast} (or @code{sparse}) and @code{full}.
  22870. Specifying @code{full} will minimize disk fragmentation at a cost to
  22871. file-creation speed.
  22872. Defaults to @samp{fast}.
  22873. @end deftypevr
  22874. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean watch-dir-enabled?
  22875. If @code{#t}, the directory specified by @code{watch-dir} will be
  22876. watched for new @file{.torrent} files and the torrents they describe
  22877. added automatically (and the original files removed, if
  22878. @code{trash-original-torrent-files?} is @code{#t}).
  22879. Defaults to @samp{#f}.
  22880. @end deftypevr
  22881. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string watch-dir
  22882. The directory to be watched for @file{.torrent} files indicating new
  22883. torrents to be added, when @code{watch-dir-enabled} is @code{#t}.
  22884. Defaults to @samp{disabled}.
  22885. @end deftypevr
  22886. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean trash-original-torrent-files?
  22887. When @code{#t}, @file{.torrent} files will be deleted from the watch
  22888. directory once their torrent has been added (see
  22889. @code{watch-directory-enabled?}).
  22890. Defaults to @samp{#f}.
  22891. @end deftypevr
  22892. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-down-enabled?
  22893. When @code{#t}, the daemon's download speed will be limited to the rate
  22894. specified by @code{speed-limit-down}.
  22895. Defaults to @samp{#f}.
  22896. @end deftypevr
  22897. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-down
  22898. The default global-maximum download speed, in kilobytes per second.
  22899. Defaults to @samp{100}.
  22900. @end deftypevr
  22901. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-up-enabled?
  22902. When @code{#t}, the daemon's upload speed will be limited to the rate
  22903. specified by @code{speed-limit-up}.
  22904. Defaults to @samp{#f}.
  22905. @end deftypevr
  22906. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-up
  22907. The default global-maximum upload speed, in kilobytes per second.
  22908. Defaults to @samp{100}.
  22909. @end deftypevr
  22910. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-enabled?
  22911. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  22912. @code{alt-speed-up} are used (in place of @code{speed-limit-down} and
  22913. @code{speed-limit-up}, if they are enabled) to constrain the daemon's
  22914. bandwidth usage. This can be scheduled to occur automatically at
  22915. certain times during the week; see @code{alt-speed-time-enabled?}.
  22916. Defaults to @samp{#f}.
  22917. @end deftypevr
  22918. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-down
  22919. The alternate global-maximum download speed, in kilobytes per second.
  22920. Defaults to @samp{50}.
  22921. @end deftypevr
  22922. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-up
  22923. The alternate global-maximum upload speed, in kilobytes per second.
  22924. Defaults to @samp{50}.
  22925. @end deftypevr
  22926. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-time-enabled?
  22927. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  22928. @code{alt-speed-up} will be enabled automatically during the periods
  22929. specified by @code{alt-speed-time-day}, @code{alt-speed-time-begin} and
  22930. @code{alt-time-speed-end}.
  22931. Defaults to @samp{#f}.
  22932. @end deftypevr
  22933. @deftypevr {@code{transmission-daemon-configuration} parameter} day-list alt-speed-time-day
  22934. The days of the week on which the alternate-speed schedule should be
  22935. used, specified either as a list of days (@code{sunday}, @code{monday},
  22936. and so on) or using one of the symbols @code{weekdays}, @code{weekends}
  22937. or @code{all}.
  22938. Defaults to @samp{all}.
  22939. @end deftypevr
  22940. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-begin
  22941. The time of day at which to enable the alternate speed limits, expressed
  22942. as a number of minutes since midnight.
  22943. Defaults to @samp{540}.
  22944. @end deftypevr
  22945. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-end
  22946. The time of day at which to disable the alternate speed limits,
  22947. expressed as a number of minutes since midnight.
  22948. Defaults to @samp{1020}.
  22949. @end deftypevr
  22950. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv4
  22951. The IP address at which to listen for peer connections, or ``0.0.0.0''
  22952. to listen at all available IP addresses.
  22953. Defaults to @samp{"0.0.0.0"}.
  22954. @end deftypevr
  22955. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv6
  22956. The IPv6 address at which to listen for peer connections, or ``::'' to
  22957. listen at all available IPv6 addresses.
  22958. Defaults to @samp{"::"}.
  22959. @end deftypevr
  22960. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean peer-port-random-on-start?
  22961. If @code{#t}, when the daemon starts it will select a port at random on
  22962. which to listen for peer connections, from the range specified
  22963. (inclusively) by @code{peer-port-random-low} and
  22964. @code{peer-port-random-high}. Otherwise, it listens on the port
  22965. specified by @code{peer-port}.
  22966. Defaults to @samp{#f}.
  22967. @end deftypevr
  22968. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-low
  22969. The lowest selectable port number when @code{peer-port-random-on-start?}
  22970. is @code{#t}.
  22971. Defaults to @samp{49152}.
  22972. @end deftypevr
  22973. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-high
  22974. The highest selectable port number when @code{peer-port-random-on-start}
  22975. is @code{#t}.
  22976. Defaults to @samp{65535}.
  22977. @end deftypevr
  22978. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port
  22979. The port on which to listen for peer connections when
  22980. @code{peer-port-random-on-start?} is @code{#f}.
  22981. Defaults to @samp{51413}.
  22982. @end deftypevr
  22983. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean port-forwarding-enabled?
  22984. If @code{#t}, the daemon will attempt to configure port-forwarding on an
  22985. upstream gateway automatically using @acronym{UPnP} and
  22986. @acronym{NAT-PMP}.
  22987. Defaults to @samp{#t}.
  22988. @end deftypevr
  22989. @deftypevr {@code{transmission-daemon-configuration} parameter} encryption-mode encryption
  22990. The encryption preference for peer connections, one of
  22991. @code{prefer-unencrypted-connections},
  22992. @code{prefer-encrypted-connections} or
  22993. @code{require-encrypted-connections}.
  22994. Defaults to @samp{prefer-encrypted-connections}.
  22995. @end deftypevr
  22996. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
  22997. The TCP congestion-control algorithm to use for peer connections,
  22998. specified using a string recognized by the operating system in calls to
  22999. @code{setsockopt}. When left unspecified, the operating-system default
  23000. is used.
  23001. Note that on GNU/Linux systems, the kernel must be configured to allow
  23002. processes to use a congestion-control algorithm not in the default set;
  23003. otherwise, it will deny these requests with ``Operation not permitted''.
  23004. To see which algorithms are available on your system and which are
  23005. currently permitted for use, look at the contents of the files
  23006. @file{tcp_available_congestion_control} and
  23007. @file{tcp_allowed_congestion_control} in the @file{/proc/sys/net/ipv4}
  23008. directory.
  23009. As an example, to have Transmission Daemon use
  23010. @uref{http://www-ece.rice.edu/networks/TCP-LP/,the TCP Low Priority
  23011. congestion-control algorithm}, you'll need to modify your kernel
  23012. configuration to build in support for the algorithm, then update your
  23013. operating-system configuration to allow its use by adding a
  23014. @code{sysctl-service-type} service (or updating the existing one's
  23015. configuration) with lines like the following:
  23016. @lisp
  23017. (service sysctl-service-type
  23018. (sysctl-configuration
  23019. (settings
  23020. ("net.ipv4.tcp_allowed_congestion_control" .
  23021. "reno cubic lp"))))
  23022. @end lisp
  23023. The Transmission Daemon configuration can then be updated with
  23024. @lisp
  23025. (peer-congestion-algorithm "lp")
  23026. @end lisp
  23027. and the system reconfigured to have the changes take effect.
  23028. Defaults to @samp{disabled}.
  23029. @end deftypevr
  23030. @deftypevr {@code{transmission-daemon-configuration} parameter} tcp-type-of-service peer-socket-tos
  23031. The type of service to request in outgoing @acronym{TCP} packets, one of
  23032. @code{default}, @code{low-cost}, @code{throughput}, @code{low-delay} and
  23033. @code{reliability}.
  23034. Defaults to @samp{default}.
  23035. @end deftypevr
  23036. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-global
  23037. The global limit on the number of connected peers.
  23038. Defaults to @samp{200}.
  23039. @end deftypevr
  23040. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-per-torrent
  23041. The per-torrent limit on the number of connected peers.
  23042. Defaults to @samp{50}.
  23043. @end deftypevr
  23044. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer upload-slots-per-torrent
  23045. The maximum number of peers to which the daemon will upload data
  23046. simultaneously for each torrent.
  23047. Defaults to @samp{14}.
  23048. @end deftypevr
  23049. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-id-ttl-hours
  23050. The maximum lifespan, in hours, of the peer ID associated with each
  23051. public torrent before it is regenerated.
  23052. Defaults to @samp{6}.
  23053. @end deftypevr
  23054. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean blocklist-enabled?
  23055. When @code{#t}, the daemon will ignore peers mentioned in the blocklist
  23056. it has most recently downloaded from @code{blocklist-url}.
  23057. Defaults to @samp{#f}.
  23058. @end deftypevr
  23059. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string blocklist-url
  23060. The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
  23061. @file{.dat} format) to be periodically downloaded and applied when
  23062. @code{blocklist-enabled?} is @code{#t}.
  23063. Defaults to @samp{disabled}.
  23064. @end deftypevr
  23065. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean download-queue-enabled?
  23066. If @code{#t}, the daemon will be limited to downloading at most
  23067. @code{download-queue-size} non-stalled torrents simultaneously.
  23068. Defaults to @samp{#t}.
  23069. @end deftypevr
  23070. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer download-queue-size
  23071. The size of the daemon's download queue, which limits the number of
  23072. non-stalled torrents it will download at any one time when
  23073. @code{download-queue-enabled?} is @code{#t}.
  23074. Defaults to @samp{5}.
  23075. @end deftypevr
  23076. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean seed-queue-enabled?
  23077. If @code{#t}, the daemon will be limited to seeding at most
  23078. @code{seed-queue-size} non-stalled torrents simultaneously.
  23079. Defaults to @samp{#f}.
  23080. @end deftypevr
  23081. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer seed-queue-size
  23082. The size of the daemon's seed queue, which limits the number of
  23083. non-stalled torrents it will seed at any one time when
  23084. @code{seed-queue-enabled?} is @code{#t}.
  23085. Defaults to @samp{10}.
  23086. @end deftypevr
  23087. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean queue-stalled-enabled?
  23088. When @code{#t}, the daemon will consider torrents for which it has not
  23089. shared data in the past @code{queue-stalled-minutes} minutes to be
  23090. stalled and not count them against its @code{download-queue-size} and
  23091. @code{seed-queue-size} limits.
  23092. Defaults to @samp{#t}.
  23093. @end deftypevr
  23094. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer queue-stalled-minutes
  23095. The maximum period, in minutes, a torrent may be idle before it is
  23096. considered to be stalled, when @code{queue-stalled-enabled?} is
  23097. @code{#t}.
  23098. Defaults to @samp{30}.
  23099. @end deftypevr
  23100. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean ratio-limit-enabled?
  23101. When @code{#t}, a torrent being seeded will automatically be paused once
  23102. it reaches the ratio specified by @code{ratio-limit}.
  23103. Defaults to @samp{#f}.
  23104. @end deftypevr
  23105. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-rational ratio-limit
  23106. The ratio at which a torrent being seeded will be paused, when
  23107. @code{ratio-limit-enabled?} is @code{#t}.
  23108. Defaults to @samp{2.0}.
  23109. @end deftypevr
  23110. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean idle-seeding-limit-enabled?
  23111. When @code{#t}, a torrent being seeded will automatically be paused once
  23112. it has been idle for @code{idle-seeding-limit} minutes.
  23113. Defaults to @samp{#f}.
  23114. @end deftypevr
  23115. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer idle-seeding-limit
  23116. The maximum period, in minutes, a torrent being seeded may be idle
  23117. before it is paused, when @code{idle-seeding-limit-enabled?} is
  23118. @code{#t}.
  23119. Defaults to @samp{30}.
  23120. @end deftypevr
  23121. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean dht-enabled?
  23122. Enable @uref{http://bittorrent.org/beps/bep_0005.html,the distributed
  23123. hash table (@acronym{DHT}) protocol}, which supports the use of
  23124. trackerless torrents.
  23125. Defaults to @samp{#t}.
  23126. @end deftypevr
  23127. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean lpd-enabled?
  23128. Enable @uref{https://en.wikipedia.org/wiki/Local_Peer_Discovery,local
  23129. peer discovery} (@acronym{LPD}), which allows the discovery of peers on
  23130. the local network and may reduce the amount of data sent over the public
  23131. Internet.
  23132. Defaults to @samp{#f}.
  23133. @end deftypevr
  23134. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean pex-enabled?
  23135. Enable @uref{https://en.wikipedia.org/wiki/Peer_exchange,peer exchange}
  23136. (@acronym{PEX}), which reduces the daemon's reliance on external
  23137. trackers and may improve its performance.
  23138. Defaults to @samp{#t}.
  23139. @end deftypevr
  23140. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean utp-enabled?
  23141. Enable @uref{http://bittorrent.org/beps/bep_0029.html,the micro
  23142. transport protocol} (@acronym{uTP}), which aims to reduce the impact of
  23143. BitTorrent traffic on other users of the local network while maintaining
  23144. full utilization of the available bandwidth.
  23145. Defaults to @samp{#t}.
  23146. @end deftypevr
  23147. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-enabled?
  23148. If @code{#t}, enable the remote procedure call (@acronym{RPC})
  23149. interface, which allows remote control of the daemon via its Web
  23150. interface, the @command{transmission-remote} command-line client, and
  23151. similar tools.
  23152. Defaults to @samp{#t}.
  23153. @end deftypevr
  23154. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-bind-address
  23155. The IP address at which to listen for @acronym{RPC} connections, or
  23156. ``0.0.0.0'' to listen at all available IP addresses.
  23157. Defaults to @samp{"0.0.0.0"}.
  23158. @end deftypevr
  23159. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number rpc-port
  23160. The port on which to listen for @acronym{RPC} connections.
  23161. Defaults to @samp{9091}.
  23162. @end deftypevr
  23163. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-url
  23164. The path prefix to use in the @acronym{RPC}-endpoint @acronym{URL}.
  23165. Defaults to @samp{"/transmission/"}.
  23166. @end deftypevr
  23167. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-authentication-required?
  23168. When @code{#t}, clients must authenticate (see @code{rpc-username} and
  23169. @code{rpc-password}) when using the @acronym{RPC} interface. Note this
  23170. has the side effect of disabling host-name whitelisting (see
  23171. @code{rpc-host-whitelist-enabled?}.
  23172. Defaults to @samp{#f}.
  23173. @end deftypevr
  23174. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string rpc-username
  23175. The username required by clients to access the @acronym{RPC} interface
  23176. when @code{rpc-authentication-required?} is @code{#t}.
  23177. Defaults to @samp{disabled}.
  23178. @end deftypevr
  23179. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-transmission-password-hash rpc-password
  23180. The password required by clients to access the @acronym{RPC} interface
  23181. when @code{rpc-authentication-required?} is @code{#t}. This must be
  23182. specified using a password hash in the format recognized by Transmission
  23183. clients, either copied from an existing @file{settings.json} file or
  23184. generated using the @code{transmission-password-hash} procedure.
  23185. Defaults to @samp{disabled}.
  23186. @end deftypevr
  23187. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-whitelist-enabled?
  23188. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  23189. originate from an address specified in @code{rpc-whitelist}.
  23190. Defaults to @samp{#t}.
  23191. @end deftypevr
  23192. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-whitelist
  23193. The list of IP and IPv6 addresses from which @acronym{RPC} requests will
  23194. be accepted when @code{rpc-whitelist-enabled?} is @code{#t}. Wildcards
  23195. may be specified using @samp{*}.
  23196. Defaults to @samp{'("127.0.0.1" "::1")}.
  23197. @end deftypevr
  23198. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-host-whitelist-enabled?
  23199. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  23200. are addressed to a host named in @code{rpc-host-whitelist}. Note that
  23201. requests to ``localhost'' or ``localhost.'', or to a numeric address,
  23202. are always accepted regardless of these settings.
  23203. Note also this functionality is disabled when
  23204. @code{rpc-authentication-required?} is @code{#t}.
  23205. Defaults to @samp{#t}.
  23206. @end deftypevr
  23207. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-host-whitelist
  23208. The list of host names recognized by the @acronym{RPC} server when
  23209. @code{rpc-host-whitelist-enabled?} is @code{#t}.
  23210. Defaults to @samp{'()}.
  23211. @end deftypevr
  23212. @deftypevr {@code{transmission-daemon-configuration} parameter} message-level message-level
  23213. The minimum severity level of messages to be logged (to
  23214. @file{/var/log/transmission.log}) by the daemon, one of @code{none} (no
  23215. logging), @code{error}, @code{info} and @code{debug}.
  23216. Defaults to @samp{info}.
  23217. @end deftypevr
  23218. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean start-added-torrents?
  23219. When @code{#t}, torrents are started as soon as they are added;
  23220. otherwise, they are added in ``paused'' state.
  23221. Defaults to @samp{#t}.
  23222. @end deftypevr
  23223. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean script-torrent-done-enabled?
  23224. When @code{#t}, the script specified by
  23225. @code{script-torrent-done-filename} will be invoked each time a torrent
  23226. completes.
  23227. Defaults to @samp{#f}.
  23228. @end deftypevr
  23229. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-file-object script-torrent-done-filename
  23230. A file name or file-like object specifying a script to run each time a
  23231. torrent completes, when @code{script-torrent-done-enabled?} is
  23232. @code{#t}.
  23233. Defaults to @samp{disabled}.
  23234. @end deftypevr
  23235. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean scrape-paused-torrents-enabled?
  23236. When @code{#t}, the daemon will scrape trackers for a torrent even when
  23237. the torrent is paused.
  23238. Defaults to @samp{#t}.
  23239. @end deftypevr
  23240. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer cache-size-mb
  23241. The amount of memory, in megabytes, to allocate for the daemon's
  23242. in-memory cache. A larger value may increase performance by reducing
  23243. the frequency of disk I/O.
  23244. Defaults to @samp{4}.
  23245. @end deftypevr
  23246. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean prefetch-enabled?
  23247. When @code{#t}, the daemon will try to improve I/O performance by
  23248. hinting to the operating system which data is likely to be read next
  23249. from disk to satisfy requests from peers.
  23250. Defaults to @samp{#t}.
  23251. @end deftypevr
  23252. @c %end of fragment
  23253. @node Monitoring Services
  23254. @subsection Monitoring Services
  23255. @subsubheading Tailon Service
  23256. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  23257. viewing and searching log files.
  23258. The following example will configure the service with default values.
  23259. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  23260. @lisp
  23261. (service tailon-service-type)
  23262. @end lisp
  23263. The following example customises more of the Tailon configuration,
  23264. adding @command{sed} to the list of allowed commands.
  23265. @lisp
  23266. (service tailon-service-type
  23267. (tailon-configuration
  23268. (config-file
  23269. (tailon-configuration-file
  23270. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  23271. @end lisp
  23272. @deftp {Data Type} tailon-configuration
  23273. Data type representing the configuration of Tailon.
  23274. This type has the following parameters:
  23275. @table @asis
  23276. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  23277. The configuration file to use for Tailon. This can be set to a
  23278. @dfn{tailon-configuration-file} record value, or any gexp
  23279. (@pxref{G-Expressions}).
  23280. For example, to instead use a local file, the @code{local-file} function
  23281. can be used:
  23282. @lisp
  23283. (service tailon-service-type
  23284. (tailon-configuration
  23285. (config-file (local-file "./my-tailon.conf"))))
  23286. @end lisp
  23287. @item @code{package} (default: @code{tailon})
  23288. The tailon package to use.
  23289. @end table
  23290. @end deftp
  23291. @deftp {Data Type} tailon-configuration-file
  23292. Data type representing the configuration options for Tailon.
  23293. This type has the following parameters:
  23294. @table @asis
  23295. @item @code{files} (default: @code{(list "/var/log")})
  23296. List of files to display. The list can include strings for a single file
  23297. or directory, or a list, where the first item is the name of a
  23298. subsection, and the remaining items are the files or directories in that
  23299. subsection.
  23300. @item @code{bind} (default: @code{"localhost:8080"})
  23301. Address and port to which Tailon should bind on.
  23302. @item @code{relative-root} (default: @code{#f})
  23303. URL path to use for Tailon, set to @code{#f} to not use a path.
  23304. @item @code{allow-transfers?} (default: @code{#t})
  23305. Allow downloading the log files in the web interface.
  23306. @item @code{follow-names?} (default: @code{#t})
  23307. Allow tailing of not-yet existent files.
  23308. @item @code{tail-lines} (default: @code{200})
  23309. Number of lines to read initially from each file.
  23310. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  23311. Commands to allow running. By default, @code{sed} is disabled.
  23312. @item @code{debug?} (default: @code{#f})
  23313. Set @code{debug?} to @code{#t} to show debug messages.
  23314. @item @code{wrap-lines} (default: @code{#t})
  23315. Initial line wrapping state in the web interface. Set to @code{#t} to
  23316. initially wrap lines (the default), or to @code{#f} to initially not
  23317. wrap lines.
  23318. @item @code{http-auth} (default: @code{#f})
  23319. HTTP authentication type to use. Set to @code{#f} to disable
  23320. authentication (the default). Supported values are @code{"digest"} or
  23321. @code{"basic"}.
  23322. @item @code{users} (default: @code{#f})
  23323. If HTTP authentication is enabled (see @code{http-auth}), access will be
  23324. restricted to the credentials provided here. To configure users, use a
  23325. list of pairs, where the first element of the pair is the username, and
  23326. the 2nd element of the pair is the password.
  23327. @lisp
  23328. (tailon-configuration-file
  23329. (http-auth "basic")
  23330. (users '(("user1" . "password1")
  23331. ("user2" . "password2"))))
  23332. @end lisp
  23333. @end table
  23334. @end deftp
  23335. @subsubheading Darkstat Service
  23336. @cindex darkstat
  23337. Darkstat is a packet sniffer that captures network traffic, calculates
  23338. statistics about usage, and serves reports over HTTP.
  23339. @defvar darkstat-service-type
  23340. This is the service type for the
  23341. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  23342. service, its value must be a @code{darkstat-configuration} record as in
  23343. this example:
  23344. @lisp
  23345. (service darkstat-service-type
  23346. (darkstat-configuration
  23347. (interface "eno1")))
  23348. @end lisp
  23349. @end defvar
  23350. @deftp {Data Type} darkstat-configuration
  23351. Data type representing the configuration of @command{darkstat}.
  23352. @table @asis
  23353. @item @code{package} (default: @code{darkstat})
  23354. The darkstat package to use.
  23355. @item @code{interface}
  23356. Capture traffic on the specified network interface.
  23357. @item @code{port} (default: @code{"667"})
  23358. Bind the web interface to the specified port.
  23359. @item @code{bind-address} (default: @code{"127.0.0.1"})
  23360. Bind the web interface to the specified address.
  23361. @item @code{base} (default: @code{"/"})
  23362. Specify the path of the base URL@. This can be useful if
  23363. @command{darkstat} is accessed via a reverse proxy.
  23364. @end table
  23365. @end deftp
  23366. @anchor{prometheus-node-exporter}
  23367. @subsubheading Prometheus Node Exporter Service
  23368. @cindex prometheus-node-exporter
  23369. The Prometheus ``node exporter'' makes hardware and operating system statistics
  23370. provided by the Linux kernel available for the Prometheus monitoring system.
  23371. This service should be deployed on all physical nodes and virtual machines,
  23372. where monitoring these statistics is desirable.
  23373. @defvar prometheus-node-exporter-service-type
  23374. This is the service type for the
  23375. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  23376. service, its value must be a @code{prometheus-node-exporter-configuration}.
  23377. @lisp
  23378. (service prometheus-node-exporter-service-type)
  23379. @end lisp
  23380. @end defvar
  23381. @deftp {Data Type} prometheus-node-exporter-configuration
  23382. Data type representing the configuration of @command{node_exporter}.
  23383. @table @asis
  23384. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  23385. The prometheus-node-exporter package to use.
  23386. @item @code{web-listen-address} (default: @code{":9100"})
  23387. Bind the web interface to the specified address.
  23388. @item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"})
  23389. This directory can be used to export metrics specific to this machine.
  23390. Files containing metrics in the text format, with the filename ending in
  23391. @code{.prom} should be placed in this directory.
  23392. @item @code{extra-options} (default: @code{'()})
  23393. Extra options to pass to the Prometheus node exporter.
  23394. @end table
  23395. @end deftp
  23396. @anchor{vnstat}
  23397. @subsubheading vnStat Network Traffic Monitor
  23398. @cindex vnstat
  23399. vnStat is a network traffic monitor that uses interface statistics provided
  23400. by the kernel rather than traffic sniffing. This makes it a light resource
  23401. monitor, regardless of network traffic rate.
  23402. @defvar vnstat-service-type
  23403. This is the service type for the @uref{https://humdi.net/vnstat/,vnStat} daemon
  23404. and accepts a @code{vnstat-configuration} value.
  23405. The following example will configure the service with default values:
  23406. @lisp
  23407. (service vnstat-service-type)
  23408. @end lisp
  23409. @end defvar
  23410. @c %start of fragment
  23411. @deftp {Data Type} vnstat-configuration
  23412. Available @code{vnstat-configuration} fields are:
  23413. @table @asis
  23414. @item @code{package} (default: @code{vnstat}) (type: file-like)
  23415. The vnstat package.
  23416. @item @code{database-directory} (default: @code{"/var/lib/vnstat"}) (type: string)
  23417. Specifies the directory where the database is to be stored. A full path
  23418. must be given and a leading '/' isn't required.
  23419. @item @code{5-minute-hours} (default: @code{48}) (type: maybe-integer)
  23420. Data retention duration for the 5 minute resolution entries. The
  23421. configuration defines for how many past hours entries will be stored.
  23422. Set to @code{-1} for unlimited entries or to @code{0} to disable the
  23423. data collection of this resolution.
  23424. @item @code{64bit-interface-counters} (default: @code{-2}) (type: maybe-integer)
  23425. Select interface counter handling. Set to @code{1} for defining that
  23426. all interfaces use 64-bit counters on the kernel side and @code{0} for
  23427. defining 32-bit counter. Set to @code{-1} for using the old style logic
  23428. used in earlier versions where counter values within 32-bits are assumed
  23429. to be 32-bit and anything larger is assumed to be a 64-bit counter. This
  23430. may produce false results if a 64-bit counter is reset within the
  23431. 32-bits. Set to @code{-2} for using automatic detection based on
  23432. available kernel datastructures.
  23433. @item @code{always-add-new-interfaces?} (default: @code{#t}) (type: maybe-boolean)
  23434. Enable or disable automatic creation of new database entries for
  23435. interfaces not currently in the database even if the database file
  23436. already exists when the daemon is started. New database entries will
  23437. also get created for new interfaces seen while the daemon is running.
  23438. Pseudo interfaces @samp{lo}, @samp{lo0} and @samp{sit0} are always excluded from getting
  23439. added.
  23440. @item @code{bandwidth-detection?} (default: @code{#t}) (type: maybe-boolean)
  23441. Try to automatically detect @var{max-bandwidth} value for each monitored
  23442. interface. Mostly only ethernet interfaces support this feature.
  23443. @var{max-bandwidth} will be used as fallback value if detection fails.
  23444. Any interface specific @var{max-BW} configuration will disable the
  23445. detection for the specified interface. In Linux, the detection is
  23446. disabled for tun interfaces due to the Linux kernel always reporting 10
  23447. Mbit regardless of the used real interface.
  23448. @item @code{bandwidth-detection-interval} (default: @code{5}) (type: maybe-integer)
  23449. How often in minutes interface specific detection of @var{max-bandwidth}
  23450. is done for detecting possible changes when @var{bandwidth-detection} is
  23451. enabled. Can be disabled by setting to @code{0}. Value range:
  23452. @samp{0}..@samp{30}
  23453. @item @code{boot-variation} (default: @code{15}) (type: maybe-integer)
  23454. Time in seconds how much the boot time reported by system kernel can
  23455. variate between updates. Value range: @samp{0}..@samp{300}
  23456. @item @code{check-disk-space?} (default: @code{#t}) (type: maybe-boolean)
  23457. Enable or disable the availability check of at least some free disk
  23458. space before a database write.
  23459. @item @code{create-directories?} (default: @code{#t}) (type: maybe-boolean)
  23460. Enable or disable the creation of directories when a configured path
  23461. doesn't exist. This includes @var{database-directory}.
  23462. @item @code{daemon-group} (type: maybe-user-group)
  23463. Specify the group to which the daemon process should switch during
  23464. startup. Set to @code{%unset-value} to disable group switching.
  23465. @item @code{daemon-user} (type: maybe-user-account)
  23466. Specify the user to which the daemon process should switch during
  23467. startup. Set to @code{%unset-value} to disable user switching.
  23468. @item @code{daily-days} (default: @code{62}) (type: maybe-integer)
  23469. Data retention duration for the one day resolution entries. The
  23470. configuration defines for how many past days entries will be stored. Set
  23471. to @code{-1} for unlimited entries or to @code{0} to disable the data
  23472. collection of this resolution.
  23473. @item @code{database-synchronous} (default: @code{-1}) (type: maybe-integer)
  23474. Change the setting of the SQLite "synchronous" flag which controls how
  23475. much care is taken to ensure disk writes have fully completed when
  23476. writing data to the database before continuing other actions. Higher
  23477. values take extra steps to ensure data safety at the cost of slower
  23478. performance. A value of @code{0} will result in all handling being left
  23479. to the filesystem itself. Set to @code{-1} to select the default value
  23480. according to database mode controlled by
  23481. @var{database-write-ahead-logging} setting. See SQLite documentation
  23482. for more details regarding values from @code{1} to @code{3}. Value
  23483. range: @samp{-1}..@samp{3}
  23484. @item @code{database-write-ahead-logging?} (default: @code{#f}) (type: maybe-boolean)
  23485. Enable or disable SQLite Write-Ahead Logging mode for the database. See
  23486. SQLite documentation for more details and note that support for
  23487. read-only operations isn't available in older SQLite versions.
  23488. @item @code{hourly-days} (default: @code{4}) (type: maybe-integer)
  23489. Data retention duration for the one hour resolution entries. The
  23490. configuration defines for how many past days entries will be stored. Set
  23491. to @code{-1} for unlimited entries or to @code{0} to disable the data
  23492. collection of this resolution.
  23493. @item @code{log-file} (type: maybe-string)
  23494. Specify log file path and name to be used if @var{use-logging} is set to
  23495. @code{1}.
  23496. @item @code{max-bandwidth} (type: maybe-integer)
  23497. Maximum bandwidth for all interfaces. If the interface specific traffic
  23498. exceeds the given value then the data is assumed to be invalid and
  23499. rejected. Set to 0 in order to disable the feature. Value range:
  23500. @samp{0}..@samp{50000}
  23501. @item @code{max-bw} (type: maybe-alist)
  23502. Same as @var{max-bandwidth} but can be used for setting individual
  23503. limits for selected interfaces. This is an association list of
  23504. interfaces as strings to integer values. For example,
  23505. @lisp
  23506. (max-bw `(("eth0" . 15000)
  23507. ("ppp0" . 10000)))
  23508. @end lisp
  23509. @var{bandwidth-detection} is disabled on an interface specific level for
  23510. each @var{max-bw} configuration. Value range: @samp{0}..@samp{50000}
  23511. @item @code{monthly-months} (default: @code{25}) (type: maybe-integer)
  23512. Data retention duration for the one month resolution entries. The
  23513. configuration defines for how many past months entries will be stored.
  23514. Set to @code{-1} for unlimited entries or to @code{0} to disable the
  23515. data collection of this resolution.
  23516. @item @code{month-rotate} (default: @code{1}) (type: maybe-integer)
  23517. Day of month that months are expected to change. Usually set to 1 but
  23518. can be set to alternative values for example for tracking monthly billed
  23519. traffic where the billing period doesn't start on the first day. For
  23520. example, if set to 7, days of February up to and including the 6th will
  23521. count for January. Changing this option will not cause existing data to
  23522. be recalculated. Value range: @samp{1}..@samp{28}
  23523. @item @code{month-rotate-affects-years?} (default: @code{#f}) (type: maybe-boolean)
  23524. Enable or disable @var{month-rotate} also affecting yearly data.
  23525. Applicable only when @var{month-rotate} has a value greater than one.
  23526. @item @code{offline-save-interval} (default: @code{30}) (type: maybe-integer)
  23527. How often in minutes cached interface data is saved to file when all
  23528. monitored interfaces are offline. Value range:
  23529. @var{save-interval}..@samp{60}
  23530. @item @code{pid-file} (default: @code{"/var/run/vnstatd.pid"}) (type: maybe-string)
  23531. Specify pid file path and name to be used.
  23532. @item @code{poll-interval} (default: @code{5}) (type: maybe-integer)
  23533. How often in seconds interfaces are checked for status changes. Value
  23534. range: @samp{2}..@samp{60}
  23535. @item @code{rescan-database-on-save?} (type: maybe-boolean)
  23536. Automatically discover added interfaces from the database and start
  23537. monitoring. The rescan is done every @var{save-interval} or
  23538. @var{offline-save-interval} minutes depending on the current activity
  23539. state.
  23540. @item @code{save-interval} (default: @code{5}) (type: maybe-integer)
  23541. How often in minutes cached interface data is saved to file. Value
  23542. range: ( @var{update-interval} / 60 )..@samp{60}
  23543. @item @code{save-on-status-change?} (default: @code{#t}) (type: maybe-boolean)
  23544. Enable or disable the additional saving to file of cached interface data
  23545. when the availability of an interface changes, i.e., when an interface
  23546. goes offline or comes online.
  23547. @item @code{time-sync-wait} (default: @code{5}) (type: maybe-integer)
  23548. How many minutes to wait during daemon startup for system clock to sync
  23549. if most recent database update appears to be in the future. This may be
  23550. needed in systems without a real-time clock (RTC) which require some
  23551. time after boot to query and set the correct time. @code{0} = wait
  23552. disabled. Value range: @samp{0}..@samp{60}
  23553. @item @code{top-day-entries} (default: @code{20}) (type: maybe-integer)
  23554. Data retention duration for the top day entries. The configuration
  23555. defines how many of the past top day entries will be stored. Set to
  23556. @code{-1} for unlimited entries or to @code{0} to disable the data
  23557. collection of this resolution.
  23558. @item @code{trafficless-entries?} (default: @code{#t}) (type: maybe-boolean)
  23559. Create database entries even when there is no traffic during the entry's
  23560. time period.
  23561. @item @code{update-file-owner?} (default: @code{#t}) (type: maybe-boolean)
  23562. Enable or disable the update of file ownership during daemon process
  23563. startup. During daemon startup, only database, log and pid files will
  23564. be modified if the user or group change feature ( @var{daemon-user} or
  23565. @var{daemon-group} ) is enabled and the files don't match the requested
  23566. user or group. During manual database creation, this option will cause
  23567. file ownership to be inherited from the database directory if the
  23568. directory already exists. This option only has effect when the process
  23569. is started as root or via sudo.
  23570. @item @code{update-interval} (default: @code{20}) (type: maybe-integer)
  23571. How often in seconds the interface data is updated. Value range:
  23572. @var{poll-interval}..@samp{300}
  23573. @item @code{use-logging} (default: @code{2}) (type: maybe-integer)
  23574. Enable or disable logging. Accepted values are: @code{0} = disabled,
  23575. @code{1} = logfile and @code{2} = syslog.
  23576. @item @code{use-utc?} (type: maybe-boolean)
  23577. Enable or disable using UTC as timezone in the database for all entries.
  23578. When enabled, all entries added to the database will use UTC regardless
  23579. of the configured system timezone. When disabled, the configured system
  23580. timezone will be used. Changing this setting will not result in already
  23581. existing data to be modified.
  23582. @item @code{yearly-years} (default: @code{-1}) (type: maybe-integer)
  23583. Data retention duration for the one year resolution entries. The
  23584. configuration defines for how many past years entries will be stored.
  23585. Set to @code{-1} for unlimited entries or to @code{0} to disable the
  23586. data collection of this resolution.
  23587. @end table
  23588. @end deftp
  23589. @c %end of fragment
  23590. @subsubheading Zabbix server
  23591. @cindex zabbix zabbix-server
  23592. Zabbix is a high performance monitoring system that can collect data from a
  23593. variety of sources and provide the results in a web-based interface. Alerting
  23594. and reporting is built-in, as well as @dfn{templates} for common operating
  23595. system metrics such as network utilization, CPU load, and disk space consumption.
  23596. This service provides the central Zabbix monitoring service; you also need
  23597. @ref{zabbix-front-end,@code{zabbix-front-end-service-type}} to configure Zabbix
  23598. and display results, and optionally @ref{zabbix-agent,
  23599. @code{zabbix-agent-service-type}} on machines that should be monitored (other
  23600. data sources are supported, such as @ref{prometheus-node-exporter,
  23601. Prometheus Node Exporter}).
  23602. @defvar zabbix-server-service-type
  23603. This is the service type for the Zabbix server service. Its value must be a
  23604. @code{zabbix-server-configuration} record, shown below.
  23605. @end defvar
  23606. @c %start of fragment
  23607. @deftp {Data Type} zabbix-server-configuration
  23608. Available @code{zabbix-server-configuration} fields are:
  23609. @table @asis
  23610. @item @code{zabbix-server} (default: @code{zabbix-server}) (type: file-like)
  23611. The zabbix-server package.
  23612. @item @code{user} (default: @code{"zabbix"}) (type: string)
  23613. User who will run the Zabbix server.
  23614. @item @code{group} (default: @code{"zabbix"}) (type: string)
  23615. Group who will run the Zabbix server.
  23616. @item @code{db-host} (default: @code{"127.0.0.1"}) (type: string)
  23617. Database host name.
  23618. @item @code{db-name} (default: @code{"zabbix"}) (type: string)
  23619. Database name.
  23620. @item @code{db-user} (default: @code{"zabbix"}) (type: string)
  23621. Database user.
  23622. @item @code{db-password} (default: @code{""}) (type: string)
  23623. Database password. Please, use @code{include-files} with
  23624. @code{DBPassword=SECRET} inside a specified file instead.
  23625. @item @code{db-port} (default: @code{5432}) (type: number)
  23626. Database port.
  23627. @item @code{log-type} (default: @code{""}) (type: string)
  23628. Specifies where log messages are written to:
  23629. @itemize @bullet
  23630. @item @code{system} - syslog.
  23631. @item @code{file} - file specified with @code{log-file} parameter.
  23632. @item @code{console} - standard output.
  23633. @end itemize
  23634. @item @code{log-file} (default: @code{"/var/log/zabbix/server.log"}) (type: string)
  23635. Log file name for @code{log-type} @code{file} parameter.
  23636. @item @code{pid-file} (default: @code{"/var/run/zabbix/zabbix_server.pid"}) (type: string)
  23637. Name of PID file.
  23638. @item @code{ssl-ca-location} (default: @code{"/etc/ssl/certs/ca-certificates.crt"}) (type: string)
  23639. The location of certificate authority (CA) files for SSL server
  23640. certificate verification.
  23641. @item @code{ssl-cert-location} (default: @code{"/etc/ssl/certs"}) (type: string)
  23642. Location of SSL client certificates.
  23643. @item @code{extra-options} (default: @code{""}) (type: extra-options)
  23644. Extra options will be appended to Zabbix server configuration file.
  23645. @item @code{include-files} (default: @code{'()}) (type: include-files)
  23646. You may include individual files or all files in a directory in the
  23647. configuration file.
  23648. @end table
  23649. @end deftp
  23650. @c %end of fragment
  23651. @anchor{zabbix-agent}
  23652. @subsubheading Zabbix agent
  23653. @cindex zabbix zabbix-agent
  23654. The Zabbix agent gathers information about the running system for the Zabbix
  23655. monitoring server. It has a variety of built-in checks, and can be extended
  23656. with custom
  23657. @uref{https://www.zabbix.com/documentation/current/en/manual/config/items/userparameters,
  23658. @dfn{user parameters}}.
  23659. @defvar zabbix-agent-service-type
  23660. This is the service type for the Zabbix agent service. Its value must be a
  23661. @code{zabbix-agent-configuration} record, shown below.
  23662. @end defvar
  23663. @c %start of fragment
  23664. @deftp {Data Type} zabbix-agent-configuration
  23665. Available @code{zabbix-agent-configuration} fields are:
  23666. @table @asis
  23667. @item @code{zabbix-agent} (default: @code{zabbix-agentd}) (type: file-like)
  23668. The zabbix-agent package.
  23669. @item @code{user} (default: @code{"zabbix"}) (type: string)
  23670. User who will run the Zabbix agent.
  23671. @item @code{group} (default: @code{"zabbix"}) (type: string)
  23672. Group who will run the Zabbix agent.
  23673. @item @code{hostname} (default: @code{""}) (type: string)
  23674. Unique, case sensitive hostname which is required for active checks and
  23675. must match hostname as configured on the server.
  23676. @item @code{log-type} (default: @code{""}) (type: string)
  23677. Specifies where log messages are written to:
  23678. @itemize @bullet
  23679. @item
  23680. @code{system} - syslog.
  23681. @item @code{file} - file specified with
  23682. @code{log-file} parameter.
  23683. @item @code{console} - standard output.
  23684. @end itemize
  23685. @item @code{log-file} (default: @code{"/var/log/zabbix/agent.log"}) (type: string)
  23686. Log file name for @code{log-type} @code{file} parameter.
  23687. @item @code{pid-file} (default: @code{"/var/run/zabbix/zabbix_agent.pid"}) (type: string)
  23688. Name of PID file.
  23689. @item @code{server} (default: @code{'("127.0.0.1")}) (type: list)
  23690. List of IP addresses, optionally in CIDR notation, or hostnames of
  23691. Zabbix servers and Zabbix proxies. Incoming connections will be
  23692. accepted only from the hosts listed here.
  23693. @item @code{server-active} (default: @code{'("127.0.0.1")}) (type: list)
  23694. List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
  23695. proxies for active checks. If port is not specified, default port is
  23696. used. If this parameter is not specified, active checks are disabled.
  23697. @item @code{extra-options} (default: @code{""}) (type: extra-options)
  23698. Extra options will be appended to Zabbix server configuration file.
  23699. @item @code{include-files} (default: @code{'()}) (type: include-files)
  23700. You may include individual files or all files in a directory in the
  23701. configuration file.
  23702. @end table
  23703. @end deftp
  23704. @c %end of fragment
  23705. @anchor{zabbix-front-end}
  23706. @subsubheading Zabbix front-end
  23707. @cindex zabbix zabbix-front-end
  23708. The Zabbix front-end provides a web interface to Zabbix. It does not need
  23709. to run on the same machine as the Zabbix server. This service works by
  23710. extending the @ref{PHP-FPM} and @ref{NGINX} services with the configuration
  23711. necessary for loading the Zabbix user interface.
  23712. @defvar zabbix-front-end-service-type
  23713. This is the service type for the Zabbix web frontend. Its value must be a
  23714. @code{zabbix-front-end-configuration} record, shown below.
  23715. @end defvar
  23716. @c %start of fragment
  23717. @deftp {Data Type} zabbix-front-end-configuration
  23718. Available @code{zabbix-front-end-configuration} fields are:
  23719. @table @asis
  23720. @item @code{zabbix-server} (default: @code{zabbix-server}) (type: file-like)
  23721. The Zabbix server package to use.
  23722. @item @code{nginx} (default: @code{'()}) (type: list)
  23723. List of @ref{nginx-server-configuration,@code{nginx-server-configuration}}
  23724. blocks for the Zabbix front-end. When empty, a default that listens on
  23725. port 80 is used.
  23726. @item @code{db-host} (default: @code{"localhost"}) (type: string)
  23727. Database host name.
  23728. @item @code{db-port} (default: @code{5432}) (type: number)
  23729. Database port.
  23730. @item @code{db-name} (default: @code{"zabbix"}) (type: string)
  23731. Database name.
  23732. @item @code{db-user} (default: @code{"zabbix"}) (type: string)
  23733. Database user.
  23734. @item @code{db-password} (default: @code{""}) (type: string)
  23735. Database password. Please, use @code{db-secret-file} instead.
  23736. @item @code{db-secret-file} (default: @code{""}) (type: string)
  23737. Secret file which will be appended to @file{zabbix.conf.php} file. This
  23738. file contains credentials for use by Zabbix front-end. You are expected
  23739. to create it manually.
  23740. @item @code{zabbix-host} (default: @code{"localhost"}) (type: string)
  23741. Zabbix server hostname.
  23742. @item @code{zabbix-port} (default: @code{10051}) (type: number)
  23743. Zabbix server port.
  23744. @end table
  23745. @end deftp
  23746. @c %end of fragment
  23747. @node Kerberos Services
  23748. @subsection Kerberos Services
  23749. @cindex Kerberos
  23750. The @code{(gnu services kerberos)} module provides services relating to
  23751. the authentication protocol @dfn{Kerberos}.
  23752. @subsubheading Krb5 Service
  23753. Programs using a Kerberos client library normally
  23754. expect a configuration file in @file{/etc/krb5.conf}.
  23755. This service generates such a file from a definition provided in the
  23756. operating system declaration.
  23757. It does not cause any daemon to be started.
  23758. No ``keytab'' files are provided by this service---you must explicitly create them.
  23759. This service is known to work with the MIT client library, @code{mit-krb5}.
  23760. Other implementations have not been tested.
  23761. @defvar krb5-service-type
  23762. A service type for Kerberos 5 clients.
  23763. @end defvar
  23764. @noindent
  23765. Here is an example of its use:
  23766. @lisp
  23767. (service krb5-service-type
  23768. (krb5-configuration
  23769. (default-realm "EXAMPLE.COM")
  23770. (allow-weak-crypto? #t)
  23771. (realms (list
  23772. (krb5-realm
  23773. (name "EXAMPLE.COM")
  23774. (admin-server "groucho.example.com")
  23775. (kdc "karl.example.com"))
  23776. (krb5-realm
  23777. (name "ARGRX.EDU")
  23778. (admin-server "kerb-admin.argrx.edu")
  23779. (kdc "keys.argrx.edu"))))))
  23780. @end lisp
  23781. @noindent
  23782. This example provides a Kerberos@tie{}5 client configuration which:
  23783. @itemize
  23784. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  23785. of which have distinct administration servers and key distribution centers;
  23786. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  23787. specified by clients;
  23788. @item Accepts services which only support encryption types known to be weak.
  23789. @end itemize
  23790. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  23791. Only the most commonly used ones are described here.
  23792. For a full list, and more detailed explanation of each, see the MIT
  23793. @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  23794. documentation.
  23795. @deftp {Data Type} krb5-realm
  23796. @cindex realm, kerberos
  23797. @table @asis
  23798. @item @code{name}
  23799. This field is a string identifying the name of the realm.
  23800. A common convention is to use the fully qualified DNS name of your organization,
  23801. converted to upper case.
  23802. @item @code{admin-server}
  23803. This field is a string identifying the host where the administration server is
  23804. running.
  23805. @item @code{kdc}
  23806. This field is a string identifying the key distribution center
  23807. for the realm.
  23808. @end table
  23809. @end deftp
  23810. @deftp {Data Type} krb5-configuration
  23811. @table @asis
  23812. @item @code{allow-weak-crypto?} (default: @code{#f})
  23813. If this flag is @code{#t} then services which only offer encryption algorithms
  23814. known to be weak will be accepted.
  23815. @item @code{default-realm} (default: @code{#f})
  23816. This field should be a string identifying the default Kerberos
  23817. realm for the client.
  23818. You should set this field to the name of your Kerberos realm.
  23819. If this value is @code{#f}
  23820. then a realm must be specified with every Kerberos principal when invoking programs
  23821. such as @command{kinit}.
  23822. @item @code{realms}
  23823. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  23824. access.
  23825. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  23826. field.
  23827. @end table
  23828. @end deftp
  23829. @subsubheading PAM krb5 Service
  23830. @cindex pam-krb5
  23831. The @code{pam-krb5} service allows for login authentication and password
  23832. management via Kerberos.
  23833. You will need this service if you want PAM enabled applications to authenticate
  23834. users using Kerberos.
  23835. @defvar pam-krb5-service-type
  23836. A service type for the Kerberos 5 PAM module.
  23837. @end defvar
  23838. @deftp {Data Type} pam-krb5-configuration
  23839. Data type representing the configuration of the Kerberos 5 PAM module.
  23840. This type has the following parameters:
  23841. @table @asis
  23842. @item @code{pam-krb5} (default: @code{pam-krb5})
  23843. The pam-krb5 package to use.
  23844. @item @code{minimum-uid} (default: @code{1000})
  23845. The smallest user ID for which Kerberos authentications should be attempted.
  23846. Local accounts with lower values will silently fail to authenticate.
  23847. @end table
  23848. @end deftp
  23849. @node LDAP Services
  23850. @subsection LDAP Services
  23851. @cindex LDAP
  23852. @subsubheading Authentication against LDAP with nslcd
  23853. @cindex nslcd, LDAP service
  23854. The @code{(gnu services authentication)} module provides the
  23855. @code{nslcd-service-type}, which can be used to authenticate against an LDAP
  23856. server. In addition to configuring the service itself, you may want to add
  23857. @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
  23858. Switch} for detailed information.
  23859. Here is a simple operating system declaration with a default configuration of
  23860. the @code{nslcd-service-type} and a Name Service Switch configuration that
  23861. consults the @code{ldap} name service last:
  23862. @lisp
  23863. (use-service-modules authentication)
  23864. (use-modules (gnu system nss))
  23865. ...
  23866. (operating-system
  23867. ...
  23868. (services
  23869. (cons*
  23870. (service nslcd-service-type)
  23871. (service dhcp-client-service-type)
  23872. %base-services))
  23873. (name-service-switch
  23874. (let ((services (list (name-service (name "db"))
  23875. (name-service (name "files"))
  23876. (name-service (name "ldap")))))
  23877. (name-service-switch
  23878. (inherit %mdns-host-lookup-nss)
  23879. (password services)
  23880. (shadow services)
  23881. (group services)
  23882. (netgroup services)
  23883. (gshadow services)))))
  23884. @end lisp
  23885. @c %start of generated documentation for nslcd-configuration
  23886. Available @code{nslcd-configuration} fields are:
  23887. @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
  23888. The @code{nss-pam-ldapd} package to use.
  23889. @end deftypevr
  23890. @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
  23891. The number of threads to start that can handle requests and perform LDAP
  23892. queries. Each thread opens a separate connection to the LDAP server.
  23893. The default is to start 5 threads.
  23894. Defaults to @samp{disabled}.
  23895. @end deftypevr
  23896. @deftypevr {@code{nslcd-configuration} parameter} string uid
  23897. This specifies the user id with which the daemon should be run.
  23898. Defaults to @samp{"nslcd"}.
  23899. @end deftypevr
  23900. @deftypevr {@code{nslcd-configuration} parameter} string gid
  23901. This specifies the group id with which the daemon should be run.
  23902. Defaults to @samp{"nslcd"}.
  23903. @end deftypevr
  23904. @deftypevr {@code{nslcd-configuration} parameter} log-option log
  23905. This option controls the way logging is done via a list containing
  23906. SCHEME and LEVEL@. The SCHEME argument may either be the symbols
  23907. @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
  23908. argument is optional and specifies the log level. The log level may be
  23909. one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
  23910. @samp{notice}, @samp{info} or @samp{debug}. All messages with the
  23911. specified log level or higher are logged.
  23912. Defaults to @samp{'("/var/log/nslcd" info)}.
  23913. @end deftypevr
  23914. @deftypevr {@code{nslcd-configuration} parameter} list uri
  23915. The list of LDAP server URIs. Normally, only the first server will be
  23916. used with the following servers as fall-back.
  23917. Defaults to @samp{'("ldap://localhost:389/")}.
  23918. @end deftypevr
  23919. @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
  23920. The version of the LDAP protocol to use. The default is to use the
  23921. maximum version supported by the LDAP library.
  23922. Defaults to @samp{disabled}.
  23923. @end deftypevr
  23924. @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
  23925. Specifies the distinguished name with which to bind to the directory
  23926. server for lookups. The default is to bind anonymously.
  23927. Defaults to @samp{disabled}.
  23928. @end deftypevr
  23929. @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
  23930. Specifies the credentials with which to bind. This option is only
  23931. applicable when used with binddn.
  23932. Defaults to @samp{disabled}.
  23933. @end deftypevr
  23934. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
  23935. Specifies the distinguished name to use when the root user tries to
  23936. modify a user's password using the PAM module.
  23937. Defaults to @samp{disabled}.
  23938. @end deftypevr
  23939. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
  23940. Specifies the credentials with which to bind if the root user tries to
  23941. change a user's password. This option is only applicable when used with
  23942. rootpwmoddn
  23943. Defaults to @samp{disabled}.
  23944. @end deftypevr
  23945. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
  23946. Specifies the SASL mechanism to be used when performing SASL
  23947. authentication.
  23948. Defaults to @samp{disabled}.
  23949. @end deftypevr
  23950. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
  23951. Specifies the SASL realm to be used when performing SASL authentication.
  23952. Defaults to @samp{disabled}.
  23953. @end deftypevr
  23954. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
  23955. Specifies the authentication identity to be used when performing SASL
  23956. authentication.
  23957. Defaults to @samp{disabled}.
  23958. @end deftypevr
  23959. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
  23960. Specifies the authorization identity to be used when performing SASL
  23961. authentication.
  23962. Defaults to @samp{disabled}.
  23963. @end deftypevr
  23964. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
  23965. Determines whether the LDAP server host name should be canonicalised. If
  23966. this is enabled the LDAP library will do a reverse host name lookup. By
  23967. default, it is left up to the LDAP library whether this check is
  23968. performed or not.
  23969. Defaults to @samp{disabled}.
  23970. @end deftypevr
  23971. @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
  23972. Set the name for the GSS-API Kerberos credentials cache.
  23973. Defaults to @samp{disabled}.
  23974. @end deftypevr
  23975. @deftypevr {@code{nslcd-configuration} parameter} string base
  23976. The directory search base.
  23977. Defaults to @samp{"dc=example,dc=com"}.
  23978. @end deftypevr
  23979. @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
  23980. Specifies the search scope (subtree, onelevel, base or children). The
  23981. default scope is subtree; base scope is almost never useful for name
  23982. service lookups; children scope is not supported on all servers.
  23983. Defaults to @samp{'(subtree)}.
  23984. @end deftypevr
  23985. @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
  23986. Specifies the policy for dereferencing aliases. The default policy is
  23987. to never dereference aliases.
  23988. Defaults to @samp{disabled}.
  23989. @end deftypevr
  23990. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
  23991. Specifies whether automatic referral chasing should be enabled. The
  23992. default behaviour is to chase referrals.
  23993. Defaults to @samp{disabled}.
  23994. @end deftypevr
  23995. @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
  23996. This option allows for custom attributes to be looked up instead of the
  23997. default RFC 2307 attributes. It is a list of maps, each consisting of
  23998. the name of a map, the RFC 2307 attribute to match and the query
  23999. expression for the attribute as it is available in the directory.
  24000. Defaults to @samp{'()}.
  24001. @end deftypevr
  24002. @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
  24003. A list of filters consisting of the name of a map to which the filter
  24004. applies and an LDAP search filter expression.
  24005. Defaults to @samp{'()}.
  24006. @end deftypevr
  24007. @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
  24008. Specifies the time limit in seconds to use when connecting to the
  24009. directory server. The default value is 10 seconds.
  24010. Defaults to @samp{disabled}.
  24011. @end deftypevr
  24012. @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
  24013. Specifies the time limit (in seconds) to wait for a response from the
  24014. LDAP server. A value of zero, which is the default, is to wait
  24015. indefinitely for searches to be completed.
  24016. Defaults to @samp{disabled}.
  24017. @end deftypevr
  24018. @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
  24019. Specifies the period if inactivity (in seconds) after which the con‐
  24020. nection to the LDAP server will be closed. The default is not to time
  24021. out connections.
  24022. Defaults to @samp{disabled}.
  24023. @end deftypevr
  24024. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
  24025. Specifies the number of seconds to sleep when connecting to all LDAP
  24026. servers fails. By default one second is waited between the first
  24027. failure and the first retry.
  24028. Defaults to @samp{disabled}.
  24029. @end deftypevr
  24030. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
  24031. Specifies the time after which the LDAP server is considered to be
  24032. permanently unavailable. Once this time is reached retries will be done
  24033. only once per this time period. The default value is 10 seconds.
  24034. Defaults to @samp{disabled}.
  24035. @end deftypevr
  24036. @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
  24037. Specifies whether to use SSL/TLS or not (the default is not to). If
  24038. 'start-tls is specified then StartTLS is used rather than raw LDAP over
  24039. SSL.
  24040. Defaults to @samp{disabled}.
  24041. @end deftypevr
  24042. @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
  24043. Specifies what checks to perform on a server-supplied certificate. The
  24044. meaning of the values is described in the ldap.conf(5) manual page.
  24045. Defaults to @samp{disabled}.
  24046. @end deftypevr
  24047. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
  24048. Specifies the directory containing X.509 certificates for peer authen‐
  24049. tication. This parameter is ignored when using GnuTLS.
  24050. Defaults to @samp{disabled}.
  24051. @end deftypevr
  24052. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
  24053. Specifies the path to the X.509 certificate for peer authentication.
  24054. Defaults to @samp{disabled}.
  24055. @end deftypevr
  24056. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
  24057. Specifies the path to an entropy source. This parameter is ignored when
  24058. using GnuTLS.
  24059. Defaults to @samp{disabled}.
  24060. @end deftypevr
  24061. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
  24062. Specifies the ciphers to use for TLS as a string.
  24063. Defaults to @samp{disabled}.
  24064. @end deftypevr
  24065. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
  24066. Specifies the path to the file containing the local certificate for
  24067. client TLS authentication.
  24068. Defaults to @samp{disabled}.
  24069. @end deftypevr
  24070. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
  24071. Specifies the path to the file containing the private key for client TLS
  24072. authentication.
  24073. Defaults to @samp{disabled}.
  24074. @end deftypevr
  24075. @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
  24076. Set this to a number greater than 0 to request paged results from the
  24077. LDAP server in accordance with RFC2696. The default (0) is to not
  24078. request paged results.
  24079. Defaults to @samp{disabled}.
  24080. @end deftypevr
  24081. @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
  24082. This option prevents group membership lookups through LDAP for the
  24083. specified users. Alternatively, the value 'all-local may be used. With
  24084. that value nslcd builds a full list of non-LDAP users on startup.
  24085. Defaults to @samp{disabled}.
  24086. @end deftypevr
  24087. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
  24088. This option ensures that LDAP users with a numeric user id lower than
  24089. the specified value are ignored.
  24090. Defaults to @samp{disabled}.
  24091. @end deftypevr
  24092. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
  24093. This option specifies an offset that is added to all LDAP numeric user
  24094. ids. This can be used to avoid user id collisions with local users.
  24095. Defaults to @samp{disabled}.
  24096. @end deftypevr
  24097. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
  24098. This option specifies an offset that is added to all LDAP numeric group
  24099. ids. This can be used to avoid user id collisions with local groups.
  24100. Defaults to @samp{disabled}.
  24101. @end deftypevr
  24102. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
  24103. If this option is set, the member attribute of a group may point to
  24104. another group. Members of nested groups are also returned in the higher
  24105. level group and parent groups are returned when finding groups for a
  24106. specific user. The default is not to perform extra searches for nested
  24107. groups.
  24108. Defaults to @samp{disabled}.
  24109. @end deftypevr
  24110. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
  24111. If this option is set, the group member list is not retrieved when
  24112. looking up groups. Lookups for finding which groups a user belongs to
  24113. will remain functional so the user will likely still get the correct
  24114. groups assigned on login.
  24115. Defaults to @samp{disabled}.
  24116. @end deftypevr
  24117. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
  24118. If this option is set, functions which cause all user/group entries to
  24119. be loaded from the directory will not succeed in doing so. This can
  24120. dramatically reduce LDAP server load in situations where there are a
  24121. great number of users and/or groups. This option is not recommended for
  24122. most configurations.
  24123. Defaults to @samp{disabled}.
  24124. @end deftypevr
  24125. @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
  24126. This option can be used to specify how user and group names are verified
  24127. within the system. This pattern is used to check all user and group
  24128. names that are requested and returned from LDAP.
  24129. Defaults to @samp{disabled}.
  24130. @end deftypevr
  24131. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
  24132. This specifies whether or not to perform searches using case-insensitive
  24133. matching. Enabling this could open up the system to authorization
  24134. bypass vulnerabilities and introduce nscd cache poisoning
  24135. vulnerabilities which allow denial of service.
  24136. Defaults to @samp{disabled}.
  24137. @end deftypevr
  24138. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
  24139. This option specifies whether password policy controls are requested and
  24140. handled from the LDAP server when performing user authentication.
  24141. Defaults to @samp{disabled}.
  24142. @end deftypevr
  24143. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
  24144. By default nslcd performs an LDAP search with the user's credentials
  24145. after BIND (authentication) to ensure that the BIND operation was
  24146. successful. The default search is a simple check to see if the user's
  24147. DN exists. A search filter can be specified that will be used instead.
  24148. It should return at least one entry.
  24149. Defaults to @samp{disabled}.
  24150. @end deftypevr
  24151. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
  24152. This option allows flexible fine tuning of the authorisation check that
  24153. should be performed. The search filter specified is executed and if any
  24154. entries match, access is granted, otherwise access is denied.
  24155. Defaults to @samp{disabled}.
  24156. @end deftypevr
  24157. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
  24158. If this option is set password modification using pam_ldap will be
  24159. denied and the specified message will be presented to the user instead.
  24160. The message can be used to direct the user to an alternative means of
  24161. changing their password.
  24162. Defaults to @samp{disabled}.
  24163. @end deftypevr
  24164. @deftypevr {@code{nslcd-configuration} parameter} list pam-services
  24165. List of pam service names for which LDAP authentication should suffice.
  24166. Defaults to @samp{'()}.
  24167. @end deftypevr
  24168. @c %end of generated documentation for nslcd-configuration
  24169. @subsubheading LDAP Directory Server
  24170. @cindex LDAP, server
  24171. The @code{(gnu services ldap)} module provides the
  24172. @code{directory-server-service-type}, which can be used to create and
  24173. launch an LDAP server instance.
  24174. Here is an example configuration of the
  24175. @code{directory-server-service-type}:
  24176. @lisp
  24177. (use-service-modules ldap)
  24178. ...
  24179. (operating-system
  24180. ...
  24181. (services
  24182. (cons
  24183. (service directory-server-service-type
  24184. (directory-server-instance-configuration
  24185. (slapd
  24186. (slapd-configuration
  24187. (root-password "@{PBKDF2_SHA256@}AAAgAG@dots{}ABSOLUTELYSECRET")))))
  24188. %base-services)))
  24189. @end lisp
  24190. The root password should be generated with the @command{pwdhash} utility
  24191. that is provided by the @code{389-ds-base} package.
  24192. Note that changes to the directory server configuration will not be
  24193. applied to existing instances. You will need to back up and restore
  24194. server data manually. Only new directory server instances will be
  24195. created upon system reconfiguration.
  24196. @c %start of generated documentation for directory-server-instance-configuration
  24197. @deftp {Data Type} directory-server-instance-configuration
  24198. Available @code{directory-server-instance-configuration} fields are:
  24199. @table @asis
  24200. @item @code{package} (default: @code{389-ds-base}) (type: file-like)
  24201. The @code{389-ds-base} package.
  24202. @item @code{config-version} (default: @code{2}) (type: number)
  24203. Sets the format version of the configuration file. To use the INF file
  24204. with @command{dscreate}, this parameter must be 2.
  24205. @item @code{full-machine-name} (default: @code{"localhost"}) (type: string)
  24206. Sets the fully qualified hostname (FQDN) of this system.
  24207. @item @code{selinux} (default: @code{#false}) (type: boolean)
  24208. Enables SELinux detection and integration during the installation of
  24209. this instance. If set to @code{#true}, @command{dscreate} auto-detects
  24210. whether SELinux is enabled.
  24211. @item @code{strict-host-checking} (default: @code{#true}) (type: boolean)
  24212. Sets whether the server verifies the forward and reverse record set in
  24213. the @code{full-machine-name} parameter. When installing this instance with
  24214. GSSAPI authentication behind a load balancer, set this parameter to
  24215. @code{#false}.
  24216. @item @code{systemd} (default: @code{#false}) (type: boolean)
  24217. Enables systemd platform features. If set to @code{#true},
  24218. @command{dscreate} auto-detects whether systemd is installed.
  24219. @item @code{slapd} (type: slapd-configuration)
  24220. Configuration of slapd.
  24221. @deftp {Data Type} slapd-configuration
  24222. Available @code{slapd-configuration} fields are:
  24223. @table @asis
  24224. @item @code{instance-name} (default: @code{"localhost"}) (type: string)
  24225. Sets the name of the instance. You can refer to this value in other
  24226. parameters of this INF file using the @code{@{instance_name@}} variable.
  24227. Note that this name cannot be changed after the installation!
  24228. @item @code{user} (default: @code{"dirsrv"}) (type: string)
  24229. Sets the user name the ns-slapd process will use after the service
  24230. started.
  24231. @item @code{group} (default: @code{"dirsrv"}) (type: string)
  24232. Sets the group name the ns-slapd process will use after the service
  24233. started.
  24234. @item @code{port} (default: @code{389}) (type: number)
  24235. Sets the TCP port the instance uses for LDAP connections.
  24236. @item @code{secure-port} (default: @code{636}) (type: number)
  24237. Sets the TCP port the instance uses for TLS-secured LDAP connections
  24238. (LDAPS).
  24239. @item @code{root-dn} (default: @code{"cn=Directory Manager"}) (type: string)
  24240. Sets the @dfn{Distinquished Name} (DN) of the administrator account for this
  24241. instance.
  24242. @item @code{root-password} (default: @code{"@{invalid@}YOU-SHOULD-CHANGE-THIS"}) (type: string)
  24243. Sets the password of the account specified in the @code{root-dn}
  24244. parameter. You can either set this parameter to a plain text password
  24245. @command{dscreate} hashes during the installation or to a
  24246. "@{algorithm@}hash" string generated by the @command{pwdhash} utility.
  24247. Note that setting a plain text password can be a security risk if
  24248. unprivileged users can read this INF file!
  24249. @item @code{self-sign-cert} (default: @code{#true}) (type: boolean)
  24250. Sets whether the setup creates a self-signed certificate and enables TLS
  24251. encryption during the installation. This is not suitable for
  24252. production, but it enables administrators to use TLS right after the
  24253. installation. You can replace the self-signed certificate with a
  24254. certificate issued by a certificate authority.
  24255. @item @code{self-sign-cert-valid-months} (default: @code{24}) (type: number)
  24256. Set the number of months the issued self-signed certificate will be
  24257. valid.
  24258. @item @code{backup-dir} (default: @code{"/var/lib/dirsrv/slapd-@{instance_name@}/bak"}) (type: string)
  24259. Set the backup directory of the instance.
  24260. @item @code{cert-dir} (default: @code{"/etc/dirsrv/slapd-@{instance_name@}"}) (type: string)
  24261. Sets the directory of the instance's Network Security Services (NSS)
  24262. database.
  24263. @item @code{config-dir} (default: @code{"/etc/dirsrv/slapd-@{instance_name@}"}) (type: string)
  24264. Sets the configuration directory of the instance.
  24265. @item @code{db-dir} (default: @code{"/var/lib/dirsrv/slapd-@{instance_name@}/db"}) (type: string)
  24266. Sets the database directory of the instance.
  24267. @item @code{initconfig-dir} (default: @code{"/etc/dirsrv/registry"}) (type: string)
  24268. Sets the directory of the operating system's rc configuration directory.
  24269. @item @code{ldif-dir} (default: @code{"/var/lib/dirsrv/slapd-@{instance_name@}/ldif"}) (type: string)
  24270. Sets the LDIF export and import directory of the instance.
  24271. @item @code{lock-dir} (default: @code{"/var/lock/dirsrv/slapd-@{instance_name@}"}) (type: string)
  24272. Sets the lock directory of the instance.
  24273. @item @code{log-dir} (default: @code{"/var/log/dirsrv/slapd-@{instance_name@}"}) (type: string)
  24274. Sets the log directory of the instance.
  24275. @item @code{run-dir} (default: @code{"/run/dirsrv"}) (type: string)
  24276. Sets PID directory of the instance.
  24277. @item @code{schema-dir} (default: @code{"/etc/dirsrv/slapd-@{instance_name@}/schema"}) (type: string)
  24278. Sets schema directory of the instance.
  24279. @item @code{tmp-dir} (default: @code{"/tmp"}) (type: string)
  24280. Sets the temporary directory of the instance.
  24281. @end table
  24282. @end deftp
  24283. @item @code{backend-userroot} (type: backend-userroot-configuration)
  24284. Configuration of the userroot backend.
  24285. @deftp {Data Type} backend-userroot-configuration
  24286. Available @code{backend-userroot-configuration} fields are:
  24287. @table @asis
  24288. @item @code{create-suffix-entry?} (default: @code{#false}) (type: boolean)
  24289. Set this parameter to @code{#true} to create a generic root node entry
  24290. for the suffix in the database.
  24291. @item @code{require-index?} (default: @code{#false}) (type: boolean)
  24292. Set this parameter to @code{#true} to refuse unindexed searches in this
  24293. database.
  24294. @item @code{sample-entries} (default: @code{"no"}) (type: string)
  24295. Set this parameter to @code{"yes"} to add latest version of sample
  24296. entries to this database. Or, use @code{"001003006"} to use the 1.3.6
  24297. version sample entries. Use this option, for example, to create a
  24298. database for testing purposes.
  24299. @item @code{suffix} (type: maybe-string)
  24300. Sets the root suffix stored in this database. If you do not set the
  24301. suffix attribute the install process will not create the backend/suffix.
  24302. You can also create multiple backends/suffixes by duplicating this
  24303. section.
  24304. @end table
  24305. @end deftp
  24306. @end table
  24307. @end deftp
  24308. @c end of generated documentation for directory-server
  24309. @node Web Services
  24310. @subsection Web Services
  24311. @cindex web
  24312. @cindex www
  24313. @cindex HTTP
  24314. The @code{(gnu services web)} module provides the Apache HTTP Server,
  24315. the nginx web server, and also a fastcgi wrapper daemon.
  24316. @subsubheading Apache HTTP Server
  24317. @defvar httpd-service-type
  24318. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  24319. (@dfn{httpd}). The value for this service type is a
  24320. @code{httpd-configuration} record.
  24321. A simple example configuration is given below.
  24322. @lisp
  24323. (service httpd-service-type
  24324. (httpd-configuration
  24325. (config
  24326. (httpd-config-file
  24327. (server-name "www.example.com")
  24328. (document-root "/srv/http/www.example.com")))))
  24329. @end lisp
  24330. Other services can also extend the @code{httpd-service-type} to add to
  24331. the configuration.
  24332. @lisp
  24333. (simple-service 'www.example.com-server httpd-service-type
  24334. (list
  24335. (httpd-virtualhost
  24336. "*:80"
  24337. (list (string-join '("ServerName www.example.com"
  24338. "DocumentRoot /srv/http/www.example.com")
  24339. "\n")))))
  24340. @end lisp
  24341. @end defvar
  24342. The details for the @code{httpd-configuration}, @code{httpd-module},
  24343. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  24344. given below.
  24345. @deftp {Data Type} httpd-configuration
  24346. This data type represents the configuration for the httpd service.
  24347. @table @asis
  24348. @item @code{package} (default: @code{httpd})
  24349. The httpd package to use.
  24350. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  24351. The pid file used by the shepherd-service.
  24352. @item @code{config} (default: @code{(httpd-config-file)})
  24353. The configuration file to use with the httpd service. The default value
  24354. is a @code{httpd-config-file} record, but this can also be a different
  24355. G-expression that generates a file, for example a @code{plain-file}. A
  24356. file outside of the store can also be specified through a string.
  24357. @end table
  24358. @end deftp
  24359. @deftp {Data Type} httpd-module
  24360. This data type represents a module for the httpd service.
  24361. @table @asis
  24362. @item @code{name}
  24363. The name of the module.
  24364. @item @code{file}
  24365. The file for the module. This can be relative to the httpd package being
  24366. used, the absolute location of a file, or a G-expression for a file
  24367. within the store, for example @code{(file-append mod-wsgi
  24368. "/modules/mod_wsgi.so")}.
  24369. @end table
  24370. @end deftp
  24371. @defvar %default-httpd-modules
  24372. A default list of @code{httpd-module} objects.
  24373. @end defvar
  24374. @deftp {Data Type} httpd-config-file
  24375. This data type represents a configuration file for the httpd service.
  24376. @table @asis
  24377. @item @code{modules} (default: @code{%default-httpd-modules})
  24378. The modules to load. Additional modules can be added here, or loaded by
  24379. additional configuration.
  24380. For example, in order to handle requests for PHP files, you can use Apache’s
  24381. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  24382. @lisp
  24383. (service httpd-service-type
  24384. (httpd-configuration
  24385. (config
  24386. (httpd-config-file
  24387. (modules (cons*
  24388. (httpd-module
  24389. (name "proxy_module")
  24390. (file "modules/mod_proxy.so"))
  24391. (httpd-module
  24392. (name "proxy_fcgi_module")
  24393. (file "modules/mod_proxy_fcgi.so"))
  24394. %default-httpd-modules))
  24395. (extra-config (list "\
  24396. <FilesMatch \\.php$>
  24397. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  24398. </FilesMatch>"))))))
  24399. (service php-fpm-service-type
  24400. (php-fpm-configuration
  24401. (socket "/var/run/php-fpm.sock")
  24402. (socket-group "httpd")))
  24403. @end lisp
  24404. @item @code{server-root} (default: @code{httpd})
  24405. The @code{ServerRoot} in the configuration file, defaults to the httpd
  24406. package. Directives including @code{Include} and @code{LoadModule} are
  24407. taken as relative to the server root.
  24408. @item @code{server-name} (default: @code{#f})
  24409. The @code{ServerName} in the configuration file, used to specify the
  24410. request scheme, hostname and port that the server uses to identify
  24411. itself.
  24412. This doesn't need to be set in the server config, and can be specified
  24413. in virtual hosts. The default is @code{#f} to not specify a
  24414. @code{ServerName}.
  24415. @item @code{document-root} (default: @code{"/srv/http"})
  24416. The @code{DocumentRoot} from which files will be served.
  24417. @item @code{listen} (default: @code{'("80")})
  24418. The list of values for the @code{Listen} directives in the config
  24419. file. The value should be a list of strings, when each string can
  24420. specify the port number to listen on, and optionally the IP address and
  24421. protocol to use.
  24422. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  24423. The @code{PidFile} to use. This should match the @code{pid-file} set in
  24424. the @code{httpd-configuration} so that the Shepherd service is
  24425. configured correctly.
  24426. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  24427. The @code{ErrorLog} to which the server will log errors.
  24428. @item @code{user} (default: @code{"httpd"})
  24429. The @code{User} which the server will answer requests as.
  24430. @item @code{group} (default: @code{"httpd"})
  24431. The @code{Group} which the server will answer requests as.
  24432. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  24433. A flat list of strings and G-expressions which will be added to the end
  24434. of the configuration file.
  24435. Any values which the service is extended with will be appended to this
  24436. list.
  24437. @end table
  24438. @end deftp
  24439. @deftp {Data Type} httpd-virtualhost
  24440. This data type represents a virtualhost configuration block for the httpd service.
  24441. These should be added to the extra-config for the httpd-service.
  24442. @lisp
  24443. (simple-service 'www.example.com-server httpd-service-type
  24444. (list
  24445. (httpd-virtualhost
  24446. "*:80"
  24447. (list (string-join '("ServerName www.example.com"
  24448. "DocumentRoot /srv/http/www.example.com")
  24449. "\n")))))
  24450. @end lisp
  24451. @table @asis
  24452. @item @code{addresses-and-ports}
  24453. The addresses and ports for the @code{VirtualHost} directive.
  24454. @item @code{contents}
  24455. The contents of the @code{VirtualHost} directive, this should be a list
  24456. of strings and G-expressions.
  24457. @end table
  24458. @end deftp
  24459. @anchor{NGINX}
  24460. @subsubheading NGINX
  24461. @defvar nginx-service-type
  24462. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  24463. value for this service type is a @code{<nginx-configuration>} record.
  24464. A simple example configuration is given below.
  24465. @lisp
  24466. (service nginx-service-type
  24467. (nginx-configuration
  24468. (server-blocks
  24469. (list (nginx-server-configuration
  24470. (server-name '("www.example.com"))
  24471. (root "/srv/http/www.example.com"))))))
  24472. @end lisp
  24473. In addition to adding server blocks to the service configuration
  24474. directly, this service can be extended by other services to add server
  24475. blocks, as in this example:
  24476. @lisp
  24477. (simple-service 'my-extra-server nginx-service-type
  24478. (list (nginx-server-configuration
  24479. (root "/srv/http/extra-website")
  24480. (try-files (list "$uri" "$uri/index.html")))))
  24481. @end lisp
  24482. @end defvar
  24483. At startup, @command{nginx} has not yet read its configuration file, so
  24484. it uses a default file to log error messages. If it fails to load its
  24485. configuration file, that is where error messages are logged. After the
  24486. configuration file is loaded, the default error log file changes as per
  24487. configuration. In our case, startup error messages can be found in
  24488. @file{/var/run/nginx/logs/error.log}, and after configuration in
  24489. @file{/var/log/nginx/error.log}. The second location can be changed
  24490. with the @var{log-directory} configuration option.
  24491. @deftp {Data Type} nginx-configuration
  24492. This data type represents the configuration for NGinx. Some
  24493. configuration can be done through this and the other provided record
  24494. types, or alternatively, a config file can be provided.
  24495. @table @asis
  24496. @item @code{nginx} (default: @code{nginx})
  24497. The nginx package to use.
  24498. @item @code{shepherd-requirement} (default: @code{'()})
  24499. This is a list of symbols naming Shepherd services the nginx service
  24500. will depend on.
  24501. This is useful if you would like @command{nginx} to be started after a
  24502. back-end web server or a logging service such as Anonip has been
  24503. started.
  24504. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  24505. The directory to which NGinx will write log files.
  24506. @item @code{log-level} (default: @code{'error}) (type: symbol)
  24507. Logging level, which can be any of the following values: @code{'debug},
  24508. @code{'info}, @code{'notice}, @code{'warn}, @code{'error}, @code{'crit},
  24509. @code{'alert}, or @code{'emerg}.
  24510. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  24511. The directory in which NGinx will create a pid file, and write temporary
  24512. files.
  24513. @item @code{server-blocks} (default: @code{'()})
  24514. A list of @dfn{server blocks} to create in the generated configuration
  24515. file, the elements should be of type
  24516. @code{<nginx-server-configuration>}.
  24517. The following example would setup NGinx to serve @code{www.example.com}
  24518. from the @code{/srv/http/www.example.com} directory, without using
  24519. HTTPS.
  24520. @lisp
  24521. (service nginx-service-type
  24522. (nginx-configuration
  24523. (server-blocks
  24524. (list (nginx-server-configuration
  24525. (server-name '("www.example.com"))
  24526. (root "/srv/http/www.example.com"))))))
  24527. @end lisp
  24528. @item @code{upstream-blocks} (default: @code{'()})
  24529. A list of @dfn{upstream blocks} to create in the generated configuration
  24530. file, the elements should be of type
  24531. @code{<nginx-upstream-configuration>}.
  24532. Configuring upstreams through the @code{upstream-blocks} can be useful
  24533. when combined with @code{locations} in the
  24534. @code{<nginx-server-configuration>} records. The following example
  24535. creates a server configuration with one location configuration, that
  24536. will proxy requests to a upstream configuration, which will handle
  24537. requests with two servers.
  24538. @lisp
  24539. (service
  24540. nginx-service-type
  24541. (nginx-configuration
  24542. (server-blocks
  24543. (list (nginx-server-configuration
  24544. (server-name '("www.example.com"))
  24545. (root "/srv/http/www.example.com")
  24546. (locations
  24547. (list
  24548. (nginx-location-configuration
  24549. (uri "/path1")
  24550. (body '("proxy_pass http://server-proxy;"))))))))
  24551. (upstream-blocks
  24552. (list (nginx-upstream-configuration
  24553. (name "server-proxy")
  24554. (servers (list "server1.example.com"
  24555. "server2.example.com")))))))
  24556. @end lisp
  24557. @item @code{file} (default: @code{#f})
  24558. If a configuration @var{file} is provided, this will be used, rather than
  24559. generating a configuration file from the provided @code{log-directory},
  24560. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  24561. proper operation, these arguments should match what is in @var{file} to ensure
  24562. that the directories are created when the service is activated.
  24563. This can be useful if you have an existing configuration file, or it's
  24564. not possible to do what is required through the other parts of the
  24565. nginx-configuration record.
  24566. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  24567. Bucket size for the server names hash tables, defaults to @code{#f} to
  24568. use the size of the processors cache line.
  24569. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  24570. Maximum bucket size for the server names hash tables.
  24571. @item @code{modules} (default: @code{'()})
  24572. List of nginx dynamic modules to load. This should be a list of file
  24573. names of loadable modules, as in this example:
  24574. @lisp
  24575. (modules
  24576. (list
  24577. (file-append nginx-accept-language-module "\
  24578. /etc/nginx/modules/ngx_http_accept_language_module.so")
  24579. (file-append nginx-lua-module "\
  24580. /etc/nginx/modules/ngx_http_lua_module.so")))
  24581. @end lisp
  24582. @item @code{lua-package-path} (default: @code{'()})
  24583. List of nginx lua packages to load. This should be a list of package
  24584. names of loadable lua modules, as in this example:
  24585. @lisp
  24586. (lua-package-path (list lua-resty-core
  24587. lua-resty-lrucache
  24588. lua-resty-signal
  24589. lua-tablepool
  24590. lua-resty-shell))
  24591. @end lisp
  24592. @item @code{lua-package-cpath} (default: @code{'()})
  24593. List of nginx lua C packages to load. This should be a list of package
  24594. names of loadable lua C modules, as in this example:
  24595. @lisp
  24596. (lua-package-cpath (list lua-resty-signal))
  24597. @end lisp
  24598. @item @code{global-directives} (default: @code{'((events . ()))})
  24599. Association list of global directives for the top level of the nginx
  24600. configuration. Values may themselves be association lists.
  24601. @lisp
  24602. (global-directives
  24603. `((worker_processes . 16)
  24604. (pcre_jit . on)
  24605. (events . ((worker_connections . 1024)))))
  24606. @end lisp
  24607. @item @code{extra-content} (default: @code{""})
  24608. Extra content for the @code{http} block. Should be string or a string
  24609. valued G-expression.
  24610. @end table
  24611. @end deftp
  24612. @anchor{nginx-server-configuration}
  24613. @deftp {Data Type} nginx-server-configuration
  24614. Data type representing the configuration of an nginx server block.
  24615. This type has the following parameters:
  24616. @table @asis
  24617. @item @code{listen} (default: @code{'("80" "443 ssl")})
  24618. Each @code{listen} directive sets the address and port for IP, or the
  24619. path for a UNIX-domain socket on which the server will accept requests.
  24620. Both address and port, or only address or only port can be specified.
  24621. An address may also be a hostname, for example:
  24622. @lisp
  24623. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  24624. @end lisp
  24625. @item @code{server-name} (default: @code{(list 'default)})
  24626. A list of server names this server represents. @code{'default} represents the
  24627. default server for connections matching no other server.
  24628. @item @code{root} (default: @code{"/srv/http"})
  24629. Root of the website nginx will serve.
  24630. @item @code{locations} (default: @code{'()})
  24631. A list of @dfn{nginx-location-configuration} or
  24632. @dfn{nginx-named-location-configuration} records to use within this
  24633. server block.
  24634. @item @code{index} (default: @code{(list "index.html")})
  24635. Index files to look for when clients ask for a directory. If it cannot be found,
  24636. Nginx will send the list of files in the directory.
  24637. @item @code{try-files} (default: @code{'()})
  24638. A list of files whose existence is checked in the specified order.
  24639. @code{nginx} will use the first file it finds to process the request.
  24640. @item @code{ssl-certificate} (default: @code{#f})
  24641. Where to find the certificate for secure connections. Set it to @code{#f} if
  24642. you don't have a certificate or you don't want to use HTTPS.
  24643. @item @code{ssl-certificate-key} (default: @code{#f})
  24644. Where to find the private key for secure connections. Set it to @code{#f} if
  24645. you don't have a key or you don't want to use HTTPS.
  24646. @item @code{server-tokens?} (default: @code{#f})
  24647. Whether the server should add its configuration to response.
  24648. @item @code{raw-content} (default: @code{'()})
  24649. A list of raw lines added to the server block.
  24650. @end table
  24651. @end deftp
  24652. @deftp {Data Type} nginx-upstream-configuration
  24653. Data type representing the configuration of an nginx @code{upstream}
  24654. block. This type has the following parameters:
  24655. @table @asis
  24656. @item @code{name}
  24657. Name for this group of servers.
  24658. @item @code{servers}
  24659. Specify the addresses of the servers in the group. The address can be
  24660. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  24661. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  24662. prefix @samp{unix:}. For addresses using an IP address or domain name,
  24663. the default port is 80, and a different port can be specified
  24664. explicitly.
  24665. @item @code{extra-content}
  24666. A string or list of strings to add to the upstream block.
  24667. @end table
  24668. @end deftp
  24669. @deftp {Data Type} nginx-location-configuration
  24670. Data type representing the configuration of an nginx @code{location}
  24671. block. This type has the following parameters:
  24672. @table @asis
  24673. @item @code{uri}
  24674. URI which this location block matches.
  24675. @anchor{nginx-location-configuration body}
  24676. @item @code{body}
  24677. Body of the location block, specified as a list of strings. This can contain
  24678. many
  24679. configuration directives. For example, to pass requests to a upstream
  24680. server group defined using an @code{nginx-upstream-configuration} block,
  24681. the following directive would be specified in the body @samp{(list "proxy_pass
  24682. http://upstream-name;")}.
  24683. @end table
  24684. @end deftp
  24685. @deftp {Data Type} nginx-named-location-configuration
  24686. Data type representing the configuration of an nginx named location
  24687. block. Named location blocks are used for request redirection, and not
  24688. used for regular request processing. This type has the following
  24689. parameters:
  24690. @table @asis
  24691. @item @code{name}
  24692. Name to identify this location block.
  24693. @item @code{body}
  24694. @xref{nginx-location-configuration body}, as the body for named location
  24695. blocks can be used in a similar way to the
  24696. @code{nginx-location-configuration body}. One restriction is that the
  24697. body of a named location block cannot contain location blocks.
  24698. @end table
  24699. @end deftp
  24700. @subsubheading Varnish Cache
  24701. @cindex Varnish
  24702. Varnish is a fast cache server that sits in between web applications
  24703. and end users. It proxies requests from clients and caches the
  24704. accessed URLs such that multiple requests for the same resource only
  24705. creates one request to the back-end.
  24706. @defvar varnish-service-type
  24707. Service type for the Varnish daemon.
  24708. @end defvar
  24709. @deftp {Data Type} varnish-configuration
  24710. Data type representing the @code{varnish} service configuration.
  24711. This type has the following parameters:
  24712. @table @asis
  24713. @item @code{package} (default: @code{varnish})
  24714. The Varnish package to use.
  24715. @item @code{name} (default: @code{"default"})
  24716. A name for this Varnish instance. Varnish will create a directory in
  24717. @file{/var/varnish/} with this name and keep temporary files there. If
  24718. the name starts with a forward slash, it is interpreted as an absolute
  24719. directory name.
  24720. Pass the @code{-n} argument to other Varnish programs to connect to the
  24721. named instance, e.g.@: @command{varnishncsa -n default}.
  24722. @item @code{backend} (default: @code{"localhost:8080"})
  24723. The backend to use. This option has no effect if @code{vcl} is set.
  24724. @item @code{vcl} (default: #f)
  24725. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  24726. is @code{#f}, Varnish will proxy @code{backend} using the default
  24727. configuration. Otherwise this must be a file-like object with valid
  24728. VCL syntax.
  24729. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  24730. For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
  24731. can do something along these lines:
  24732. @lisp
  24733. (define %gnu-mirror
  24734. (plain-file "gnu.vcl"
  24735. "vcl 4.1;
  24736. backend gnu @{ .host = \"www.gnu.org\"; @}"))
  24737. (operating-system
  24738. ;; @dots{}
  24739. (services (cons (service varnish-service-type
  24740. (varnish-configuration
  24741. (listen '(":80"))
  24742. (vcl %gnu-mirror)))
  24743. %base-services)))
  24744. @end lisp
  24745. The configuration of an already running Varnish instance can be inspected
  24746. and changed using the @command{varnishadm} program.
  24747. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  24748. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  24749. comprehensive documentation on Varnish and its configuration language.
  24750. @item @code{listen} (default: @code{'("localhost:80")})
  24751. List of addresses Varnish will listen on.
  24752. @item @code{storage} (default: @code{'("malloc,128m")})
  24753. List of storage backends that will be available in VCL.
  24754. @item @code{parameters} (default: @code{'()})
  24755. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  24756. @item @code{extra-options} (default: @code{'()})
  24757. Additional arguments to pass to the @command{varnishd} process.
  24758. @end table
  24759. @end deftp
  24760. @subsubheading Patchwork
  24761. @cindex Patchwork
  24762. Patchwork is a patch tracking system. It can collect patches sent to a
  24763. mailing list, and display them in a web interface.
  24764. @defvar patchwork-service-type
  24765. Service type for Patchwork.
  24766. @end defvar
  24767. The following example is an example of a minimal service for Patchwork, for
  24768. the @code{patchwork.example.com} domain.
  24769. @lisp
  24770. (service patchwork-service-type
  24771. (patchwork-configuration
  24772. (domain "patchwork.example.com")
  24773. (settings-module
  24774. (patchwork-settings-module
  24775. (allowed-hosts (list domain))
  24776. (default-from-email "patchwork@@patchwork.example.com")))
  24777. (getmail-retriever-config
  24778. (getmail-retriever-configuration
  24779. (type "SimpleIMAPSSLRetriever")
  24780. (server "imap.example.com")
  24781. (port 993)
  24782. (username "patchwork")
  24783. (password-command
  24784. (list (file-append coreutils "/bin/cat")
  24785. "/etc/getmail-patchwork-imap-password"))
  24786. (extra-parameters
  24787. '((mailboxes . ("Patches"))))))))
  24788. @end lisp
  24789. There are three records for configuring the Patchwork service. The
  24790. @code{<patchwork-configuration>} relates to the configuration for Patchwork
  24791. within the HTTPD service.
  24792. The @code{settings-module} field within the @code{<patchwork-configuration>}
  24793. record can be populated with the @code{<patchwork-settings-module>} record,
  24794. which describes a settings module that is generated within the Guix store.
  24795. For the @code{database-configuration} field within the
  24796. @code{<patchwork-settings-module>}, the
  24797. @code{<patchwork-database-configuration>} must be used.
  24798. @deftp {Data Type} patchwork-configuration
  24799. Data type representing the Patchwork service configuration. This type has the
  24800. following parameters:
  24801. @table @asis
  24802. @item @code{patchwork} (default: @code{patchwork})
  24803. The Patchwork package to use.
  24804. @item @code{domain}
  24805. The domain to use for Patchwork, this is used in the HTTPD service virtual
  24806. host.
  24807. @item @code{settings-module}
  24808. The settings module to use for Patchwork. As a Django application, Patchwork
  24809. is configured with a Python module containing the settings. This can either be
  24810. an instance of the @code{<patchwork-settings-module>} record, any other record
  24811. that represents the settings in the store, or a directory outside of the
  24812. store.
  24813. @item @code{static-path} (default: @code{"/static/"})
  24814. The path under which the HTTPD service should serve the static files.
  24815. @item @code{getmail-retriever-config}
  24816. The getmail-retriever-configuration record value to use with
  24817. Patchwork. Getmail will be configured with this value, the messages will be
  24818. delivered to Patchwork.
  24819. @end table
  24820. @end deftp
  24821. @deftp {Data Type} patchwork-settings-module
  24822. Data type representing a settings module for Patchwork. Some of these
  24823. settings relate directly to Patchwork, but others relate to Django, the web
  24824. framework used by Patchwork, or the Django Rest Framework library. This type
  24825. has the following parameters:
  24826. @table @asis
  24827. @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
  24828. The database connection settings used for Patchwork. See the
  24829. @code{<patchwork-database-configuration>} record type for more information.
  24830. @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
  24831. Patchwork, as a Django web application uses a secret key for cryptographically
  24832. signing values. This file should contain a unique unpredictable value.
  24833. If this file does not exist, it will be created and populated with a random
  24834. value by the patchwork-setup shepherd service.
  24835. This setting relates to Django.
  24836. @item @code{allowed-hosts}
  24837. A list of valid hosts for this Patchwork service. This should at least include
  24838. the domain specified in the @code{<patchwork-configuration>} record.
  24839. This is a Django setting.
  24840. @item @code{default-from-email}
  24841. The email address from which Patchwork should send email by default.
  24842. This is a Patchwork setting.
  24843. @item @code{static-url} (default: @code{#f})
  24844. The URL to use when serving static assets. It can be part of a URL, or a full
  24845. URL, but must end in a @code{/}.
  24846. If the default value is used, the @code{static-path} value from the
  24847. @code{<patchwork-configuration>} record will be used.
  24848. This is a Django setting.
  24849. @item @code{admins} (default: @code{'()})
  24850. Email addresses to send the details of errors that occur. Each value should
  24851. be a list containing two elements, the name and then the email address.
  24852. This is a Django setting.
  24853. @item @code{debug?} (default: @code{#f})
  24854. Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
  24855. messages will be shown.
  24856. This is a Django setting.
  24857. @item @code{enable-rest-api?} (default: @code{#t})
  24858. Whether to enable the Patchwork REST API.
  24859. This is a Patchwork setting.
  24860. @item @code{enable-xmlrpc?} (default: @code{#t})
  24861. Whether to enable the XML RPC API.
  24862. This is a Patchwork setting.
  24863. @item @code{force-https-links?} (default: @code{#t})
  24864. Whether to use HTTPS links on Patchwork pages.
  24865. This is a Patchwork setting.
  24866. @item @code{extra-settings} (default: @code{""})
  24867. Extra code to place at the end of the Patchwork settings module.
  24868. @end table
  24869. @end deftp
  24870. @deftp {Data Type} patchwork-database-configuration
  24871. Data type representing the database configuration for Patchwork.
  24872. @table @asis
  24873. @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
  24874. The database engine to use.
  24875. @item @code{name} (default: @code{"patchwork"})
  24876. The name of the database to use.
  24877. @item @code{user} (default: @code{"httpd"})
  24878. The user to connect to the database as.
  24879. @item @code{password} (default: @code{""})
  24880. The password to use when connecting to the database.
  24881. @item @code{host} (default: @code{""})
  24882. The host to make the database connection to.
  24883. @item @code{port} (default: @code{""})
  24884. The port on which to connect to the database.
  24885. @end table
  24886. @end deftp
  24887. @subsubheading Mumi
  24888. @cindex Mumi, Debbugs Web interface
  24889. @cindex Debbugs, Mumi Web interface
  24890. @uref{https://git.savannah.gnu.org/cgit/guix/mumi.git/, Mumi} is a
  24891. Web interface to the Debbugs bug tracker, by default for
  24892. @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
  24893. but it also fetches and indexes mail retrieved from Debbugs.
  24894. @defvar mumi-service-type
  24895. This is the service type for Mumi.
  24896. @end defvar
  24897. @deftp {Data Type} mumi-configuration
  24898. Data type representing the Mumi service configuration. This type has the
  24899. following fields:
  24900. @table @asis
  24901. @item @code{mumi} (default: @code{mumi})
  24902. The Mumi package to use.
  24903. @item @code{mailer?} (default: @code{#true})
  24904. Whether to enable or disable the mailer component.
  24905. @item @code{mumi-configuration-sender}
  24906. The email address used as the sender for comments.
  24907. @item @code{mumi-configuration-smtp}
  24908. A URI to configure the SMTP settings for Mailutils. This could be
  24909. something like @code{sendmail:///path/to/bin/msmtp} or any other URI
  24910. supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
  24911. mailutils, GNU@tie{}Mailutils}.
  24912. @end table
  24913. @end deftp
  24914. @subsubheading FastCGI
  24915. @cindex fastcgi
  24916. @cindex fcgiwrap
  24917. FastCGI is an interface between the front-end and the back-end of a web
  24918. service. It is a somewhat legacy facility; new web services should
  24919. generally just talk HTTP between the front-end and the back-end.
  24920. However there are a number of back-end services such as PHP or the
  24921. optimized HTTP Git repository access that use FastCGI, so we have
  24922. support for it in Guix.
  24923. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  24924. dispatch some subset of its requests to the fastcgi backend, which
  24925. listens on a local TCP or UNIX socket. There is an intermediary
  24926. @code{fcgiwrap} program that sits between the actual backend process and
  24927. the web server. The front-end indicates which backend program to run,
  24928. passing that information to the @code{fcgiwrap} process.
  24929. @defvar fcgiwrap-service-type
  24930. A service type for the @code{fcgiwrap} FastCGI proxy.
  24931. @end defvar
  24932. @deftp {Data Type} fcgiwrap-configuration
  24933. Data type representing the configuration of the @code{fcgiwrap} service.
  24934. This type has the following parameters:
  24935. @table @asis
  24936. @item @code{package} (default: @code{fcgiwrap})
  24937. The fcgiwrap package to use.
  24938. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  24939. The socket on which the @code{fcgiwrap} process should listen, as a
  24940. string. Valid @var{socket} values include
  24941. @code{unix:@var{/path/to/unix/socket}},
  24942. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  24943. @code{tcp6:[@var{ipv6_addr}]:port}.
  24944. @item @code{user} (default: @code{fcgiwrap})
  24945. @itemx @code{group} (default: @code{fcgiwrap})
  24946. The user and group names, as strings, under which to run the
  24947. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  24948. the user asks for the specific user or group names @code{fcgiwrap} that
  24949. the corresponding user and/or group is present on the system.
  24950. It is possible to configure a FastCGI-backed web service to pass HTTP
  24951. authentication information from the front-end to the back-end, and to
  24952. allow @code{fcgiwrap} to run the back-end process as a corresponding
  24953. local user. To enable this capability on the back-end, run
  24954. @code{fcgiwrap} as the @code{root} user and group. Note that this
  24955. capability also has to be configured on the front-end as well.
  24956. @end table
  24957. @end deftp
  24958. @anchor{PHP-FPM}
  24959. @subsubheading PHP-FPM
  24960. @cindex php-fpm
  24961. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  24962. with some additional features useful for sites of any size.
  24963. These features include:
  24964. @itemize @bullet
  24965. @item Adaptive process spawning
  24966. @item Basic statistics (similar to Apache's mod_status)
  24967. @item Advanced process management with graceful stop/start
  24968. @item Ability to start workers with different uid/gid/chroot/environment
  24969. and different php.ini (replaces safe_mode)
  24970. @item Stdout & stderr logging
  24971. @item Emergency restart in case of accidental opcode cache destruction
  24972. @item Accelerated upload support
  24973. @item Support for a "slowlog"
  24974. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  24975. a special function to finish request & flush all data while continuing to do
  24976. something time-consuming (video converting, stats processing, etc.)
  24977. @end itemize
  24978. ...@: and much more.
  24979. @defvar php-fpm-service-type
  24980. A Service type for @code{php-fpm}.
  24981. @end defvar
  24982. @deftp {Data Type} php-fpm-configuration
  24983. Data Type for php-fpm service configuration.
  24984. @table @asis
  24985. @item @code{php} (default: @code{php})
  24986. The php package to use.
  24987. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  24988. The address on which to accept FastCGI requests. Valid syntaxes are:
  24989. @table @asis
  24990. @item @code{"ip.add.re.ss:port"}
  24991. Listen on a TCP socket to a specific address on a specific port.
  24992. @item @code{"port"}
  24993. Listen on a TCP socket to all addresses on a specific port.
  24994. @item @code{"/path/to/unix/socket"}
  24995. Listen on a unix socket.
  24996. @end table
  24997. @item @code{user} (default: @code{php-fpm})
  24998. User who will own the php worker processes.
  24999. @item @code{group} (default: @code{php-fpm})
  25000. Group of the worker processes.
  25001. @item @code{socket-user} (default: @code{php-fpm})
  25002. User who can speak to the php-fpm socket.
  25003. @item @code{socket-group} (default: @code{nginx})
  25004. Group that can speak to the php-fpm socket.
  25005. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  25006. The process id of the php-fpm process is written to this file
  25007. once the service has started.
  25008. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  25009. Log for the php-fpm master process.
  25010. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  25011. Detailed settings for the php-fpm process manager.
  25012. Must be one of:
  25013. @table @asis
  25014. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  25015. @item @code{<php-fpm-static-process-manager-configuration>}
  25016. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  25017. @end table
  25018. @item @code{display-errors} (default @code{#f})
  25019. Determines whether php errors and warning should be sent to clients
  25020. and displayed in their browsers.
  25021. This is useful for local php development, but a security risk for public sites,
  25022. as error messages can reveal passwords and personal data.
  25023. @item @code{timezone} (default @code{#f})
  25024. Specifies @code{php_admin_value[date.timezone]} parameter.
  25025. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  25026. This file will log the @code{stderr} outputs of php worker processes.
  25027. Can be set to @code{#f} to disable logging.
  25028. @item @code{file} (default @code{#f})
  25029. An optional override of the whole configuration.
  25030. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  25031. @item @code{php-ini-file} (default @code{#f})
  25032. An optional override of the default php settings.
  25033. It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
  25034. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  25035. For local development it is useful to set a higher timeout and memory
  25036. limit for spawned php processes. This be accomplished with the
  25037. following operating system configuration snippet:
  25038. @lisp
  25039. (define %local-php-ini
  25040. (plain-file "php.ini"
  25041. "memory_limit = 2G
  25042. max_execution_time = 1800"))
  25043. (operating-system
  25044. ;; @dots{}
  25045. (services (cons (service php-fpm-service-type
  25046. (php-fpm-configuration
  25047. (php-ini-file %local-php-ini)))
  25048. %base-services)))
  25049. @end lisp
  25050. Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
  25051. directives} for comprehensive documentation on the acceptable
  25052. @file{php.ini} directives.
  25053. @end table
  25054. @end deftp
  25055. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  25056. Data Type for the @code{dynamic} php-fpm process manager. With the
  25057. @code{dynamic} process manager, spare worker processes are kept around
  25058. based on its configured limits.
  25059. @table @asis
  25060. @item @code{max-children} (default: @code{5})
  25061. Maximum of worker processes.
  25062. @item @code{start-servers} (default: @code{2})
  25063. How many worker processes should be started on start-up.
  25064. @item @code{min-spare-servers} (default: @code{1})
  25065. How many spare worker processes should be kept around at minimum.
  25066. @item @code{max-spare-servers} (default: @code{3})
  25067. How many spare worker processes should be kept around at maximum.
  25068. @end table
  25069. @end deftp
  25070. @deftp {Data type} php-fpm-static-process-manager-configuration
  25071. Data Type for the @code{static} php-fpm process manager. With the
  25072. @code{static} process manager, an unchanging number of worker processes
  25073. are created.
  25074. @table @asis
  25075. @item @code{max-children} (default: @code{5})
  25076. Maximum of worker processes.
  25077. @end table
  25078. @end deftp
  25079. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  25080. Data Type for the @code{on-demand} php-fpm process manager. With the
  25081. @code{on-demand} process manager, worker processes are only created as
  25082. requests arrive.
  25083. @table @asis
  25084. @item @code{max-children} (default: @code{5})
  25085. Maximum of worker processes.
  25086. @item @code{process-idle-timeout} (default: @code{10})
  25087. The time in seconds after which a process with no requests is killed.
  25088. @end table
  25089. @end deftp
  25090. @deffn {Procedure} nginx-php-location [#:nginx-package nginx] @
  25091. [socket (string-append "/var/run/php" @
  25092. (version-major (package-version php)) "-fpm.sock")]
  25093. A helper function to quickly add php to an @code{nginx-server-configuration}.
  25094. @end deffn
  25095. A simple services setup for nginx with php can look like this:
  25096. @lisp
  25097. (services (cons* (service dhcp-client-service-type)
  25098. (service php-fpm-service-type)
  25099. (service nginx-service-type
  25100. (nginx-server-configuration
  25101. (server-name '("example.com"))
  25102. (root "/srv/http/")
  25103. (locations
  25104. (list (nginx-php-location)))
  25105. (listen '("80"))
  25106. (ssl-certificate #f)
  25107. (ssl-certificate-key #f)))
  25108. %base-services))
  25109. @end lisp
  25110. @cindex cat-avatar-generator
  25111. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  25112. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  25113. the hash of a user's email address.
  25114. @deffn {Procedure} cat-avatar-generator-service @
  25115. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  25116. [#:package cat-avatar-generator] @
  25117. [#:configuration (nginx-server-configuration)]
  25118. Returns an nginx-server-configuration that inherits @code{configuration}. It
  25119. extends the nginx configuration to add a server block that serves @code{package},
  25120. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  25121. be able to use @code{cache-dir} as its cache directory.
  25122. @end deffn
  25123. A simple setup for cat-avatar-generator can look like this:
  25124. @lisp
  25125. (services (cons* (cat-avatar-generator-service
  25126. #:configuration
  25127. (nginx-server-configuration
  25128. (server-name '("example.com"))))
  25129. ...
  25130. %base-services))
  25131. @end lisp
  25132. @subsubheading Hpcguix-web
  25133. @cindex hpcguix-web
  25134. The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
  25135. program is a customizable web interface to browse Guix packages,
  25136. initially designed for users of high-performance computing (HPC)
  25137. clusters.
  25138. @defvar hpcguix-web-service-type
  25139. The service type for @code{hpcguix-web}.
  25140. @end defvar
  25141. @deftp {Data Type} hpcguix-web-configuration
  25142. Data type for the hpcguix-web service configuration.
  25143. @table @asis
  25144. @item @code{specs} (default: @code{#f})
  25145. Either @code{#f} or a gexp (@pxref{G-Expressions}) specifying the
  25146. hpcguix-web service configuration as an @code{hpcguix-web-configuration}
  25147. record. The main fields of that record type are:
  25148. @table @asis
  25149. @item @code{title-prefix} (default: @code{"hpcguix | "})
  25150. The page title prefix.
  25151. @item @code{guix-command} (default: @code{"guix"})
  25152. The @command{guix} command to use in examples that appear on HTML pages.
  25153. @item @code{package-filter-proc} (default: @code{(const #t)})
  25154. A procedure specifying how to filter packages that are displayed.
  25155. @item @code{package-page-extension-proc} (default: @code{(const '())})
  25156. Extension package for @code{hpcguix-web}.
  25157. @item @code{menu} (default: @code{'()})
  25158. Additional entry in page @code{menu}.
  25159. @item @code{channels} (default: @code{%default-channels})
  25160. List of channels from which the package list is built (@pxref{Channels}).
  25161. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  25162. The expiration time, in seconds, after which the package list is rebuilt from
  25163. the latest instances of the given channels.
  25164. @end table
  25165. See the hpcguix-web repository for a
  25166. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  25167. complete example}.
  25168. @item @code{package} (default: @code{hpcguix-web})
  25169. The hpcguix-web package to use.
  25170. @item @code{address} (default: @code{"127.0.0.1"})
  25171. The IP address to listen to.
  25172. @item @code{port} (default: @code{5000})
  25173. The port number to listen to.
  25174. @end table
  25175. @end deftp
  25176. A typical hpcguix-web service declaration looks like this:
  25177. @lisp
  25178. (service hpcguix-web-service-type
  25179. (hpcguix-web-configuration
  25180. (specs
  25181. #~(hpcweb-configuration
  25182. (title-prefix "Guix-HPC - ")
  25183. (menu '(("/about" "ABOUT")))))))
  25184. @end lisp
  25185. @quotation Note
  25186. The hpcguix-web service periodically updates the package list it publishes by
  25187. pulling channels from Git. To that end, it needs to access X.509 certificates
  25188. so that it can authenticate Git servers when communicating over HTTPS, and it
  25189. assumes that @file{/etc/ssl/certs} contains those certificates.
  25190. Thus, make sure to add @code{nss-certs} or another certificate package to the
  25191. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  25192. more information on X.509 certificates.
  25193. @end quotation
  25194. @subsubheading gmnisrv
  25195. @cindex gmnisrv
  25196. The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
  25197. simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
  25198. @defvar gmnisrv-service-type
  25199. This is the type of the gmnisrv service, whose value should be a
  25200. @code{gmnisrv-configuration} object, as in this example:
  25201. @lisp
  25202. (service gmnisrv-service-type
  25203. (gmnisrv-configuration
  25204. (config-file (local-file "./my-gmnisrv.ini"))))
  25205. @end lisp
  25206. @end defvar
  25207. @deftp {Data Type} gmnisrv-configuration
  25208. Data type representing the configuration of gmnisrv.
  25209. @table @asis
  25210. @item @code{package} (default: @var{gmnisrv})
  25211. Package object of the gmnisrv server.
  25212. @item @code{config-file} (default: @code{%default-gmnisrv-config-file})
  25213. File-like object of the gmnisrv configuration file to use. The default
  25214. configuration listens on port 1965 and serves files from
  25215. @file{/srv/gemini}. Certificates are stored in
  25216. @file{/var/lib/gemini/certs}. For more information, run @command{man
  25217. gmnisrv} and @command{man gmnisrv.ini}.
  25218. @end table
  25219. @end deftp
  25220. @subsubheading Agate
  25221. @cindex agate
  25222. The @uref{gemini://qwertqwefsday.eu/agate.gmi, Agate}
  25223. (@uref{https://github.com/mbrubeck/agate, GitHub page over HTTPS})
  25224. program is a simple @uref{https://gemini.circumlunar.space/, Gemini}
  25225. protocol server written in Rust.
  25226. @defvar agate-service-type
  25227. This is the type of the agate service, whose value should be an
  25228. @code{agate-service-type} object, as in this example:
  25229. @lisp
  25230. (service agate-service-type
  25231. (agate-configuration
  25232. (content "/srv/gemini")
  25233. (cert "/srv/cert.pem")
  25234. (key "/srv/key.rsa")))
  25235. @end lisp
  25236. The example above represents the minimal tweaking necessary to get Agate
  25237. up and running. Specifying the path to the certificate and key is
  25238. always necessary, as the Gemini protocol requires TLS by default.
  25239. To obtain a certificate and a key, you could, for example, use OpenSSL,
  25240. running a command similar to the following example:
  25241. @example
  25242. openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
  25243. -days 3650 -nodes -subj "/CN=example.com"
  25244. @end example
  25245. Of course, you'll have to replace @i{example.com} with your own domain
  25246. name, and then point the Agate configuration towards the path of the
  25247. generated key and certificate.
  25248. @end defvar
  25249. @deftp {Data Type} agate-configuration
  25250. Data type representing the configuration of Agate.
  25251. @table @asis
  25252. @item @code{package} (default: @code{agate})
  25253. The package object of the Agate server.
  25254. @item @code{content} (default: @file{"/srv/gemini"})
  25255. The directory from which Agate will serve files.
  25256. @item @code{cert} (default: @code{#f})
  25257. The path to the TLS certificate PEM file to be used for encrypted
  25258. connections. Must be filled in with a value from the user.
  25259. @item @code{key} (default: @code{#f})
  25260. The path to the PKCS8 private key file to be used for encrypted
  25261. connections. Must be filled in with a value from the user.
  25262. @item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
  25263. A list of the addresses to listen on.
  25264. @item @code{hostname} (default: @code{#f})
  25265. The domain name of this Gemini server. Optional.
  25266. @item @code{lang} (default: @code{#f})
  25267. RFC 4646 language code(s) for text/gemini documents. Optional.
  25268. @item @code{silent?} (default: @code{#f})
  25269. Set to @code{#t} to disable logging output.
  25270. @item @code{serve-secret?} (default: @code{#f})
  25271. Set to @code{#t} to serve secret files (files/directories starting with
  25272. a dot).
  25273. @item @code{log-ip?} (default: @code{#t})
  25274. Whether or not to output IP addresses when logging.
  25275. @item @code{user} (default: @code{"agate"})
  25276. Owner of the @code{agate} process.
  25277. @item @code{group} (default: @code{"agate"})
  25278. Owner's group of the @code{agate} process.
  25279. @item @code{log-file} (default: @file{"/var/log/agate.log"})
  25280. The file which should store the logging output of Agate.
  25281. @end table
  25282. @end deftp
  25283. @node Certificate Services
  25284. @subsection Certificate Services
  25285. @cindex Web
  25286. @cindex HTTP, HTTPS
  25287. @cindex Let's Encrypt
  25288. @cindex TLS certificates
  25289. The @code{(gnu services certbot)} module provides a service to
  25290. automatically obtain a valid TLS certificate from the Let's Encrypt
  25291. certificate authority. These certificates can then be used to serve
  25292. content securely over HTTPS or other TLS-based protocols, with the
  25293. knowledge that the client will be able to verify the server's
  25294. authenticity.
  25295. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  25296. @code{certbot} tool to automate the certification process. This tool
  25297. first securely generates a key on the server. It then makes a request
  25298. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  25299. checks that the request originates from the host in question by using a
  25300. challenge-response protocol, requiring the server to provide its
  25301. response over HTTP@. If that protocol completes successfully, the CA
  25302. signs the key, resulting in a certificate. That certificate is valid
  25303. for a limited period of time, and therefore to continue to provide TLS
  25304. services, the server needs to periodically ask the CA to renew its
  25305. signature.
  25306. The certbot service automates this process: the initial key
  25307. generation, the initial certification request to the Let's Encrypt
  25308. service, the web server challenge/response integration, writing the
  25309. certificate to disk, the automated periodic renewals, and the deployment
  25310. tasks associated with the renewal (e.g.@: reloading services, copying keys
  25311. with different permissions).
  25312. Certbot is run twice a day, at a random minute within the hour. It
  25313. won't do anything until your certificates are due for renewal or
  25314. revoked, but running it regularly would give your service a chance of
  25315. staying online in case a Let's Encrypt-initiated revocation happened for
  25316. some reason.
  25317. By using this service, you agree to the ACME Subscriber Agreement, which
  25318. can be found there:
  25319. @url{https://acme-v01.api.letsencrypt.org/directory}.
  25320. @defvar certbot-service-type
  25321. A service type for the @code{certbot} Let's Encrypt client. Its value
  25322. must be a @code{certbot-configuration} record as in this example:
  25323. @lisp
  25324. (define %nginx-deploy-hook
  25325. (program-file
  25326. "nginx-deploy-hook"
  25327. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  25328. (kill pid SIGHUP))))
  25329. (service certbot-service-type
  25330. (certbot-configuration
  25331. (email "foo@@example.net")
  25332. (certificates
  25333. (list
  25334. (certificate-configuration
  25335. (domains '("example.net" "www.example.net"))
  25336. (deploy-hook %nginx-deploy-hook))
  25337. (certificate-configuration
  25338. (domains '("bar.example.net")))))))
  25339. @end lisp
  25340. See below for details about @code{certbot-configuration}.
  25341. @end defvar
  25342. @deftp {Data Type} certbot-configuration
  25343. Data type representing the configuration of the @code{certbot} service.
  25344. This type has the following parameters:
  25345. @table @asis
  25346. @item @code{package} (default: @code{certbot})
  25347. The certbot package to use.
  25348. @item @code{webroot} (default: @code{/var/www})
  25349. The directory from which to serve the Let's Encrypt challenge/response
  25350. files.
  25351. @item @code{certificates} (default: @code{'()})
  25352. A list of @code{certificates-configuration}s for which to generate
  25353. certificates and request signatures. Each certificate has a @code{name}
  25354. and several @code{domains}.
  25355. @item @code{email} (default: @code{#f})
  25356. Optional email address used for registration and recovery contact.
  25357. Setting this is encouraged as it allows you to receive important
  25358. notifications about the account and issued certificates.
  25359. @item @code{server} (default: @code{#f})
  25360. Optional URL of ACME server. Setting this overrides certbot's default,
  25361. which is the Let's Encrypt server.
  25362. @item @code{rsa-key-size} (default: @code{2048})
  25363. Size of the RSA key.
  25364. @item @code{default-location} (default: @i{see below})
  25365. The default @code{nginx-location-configuration}. Because @code{certbot}
  25366. needs to be able to serve challenges and responses, it needs to be able
  25367. to run a web server. It does so by extending the @code{nginx} web
  25368. service with an @code{nginx-server-configuration} listening on the
  25369. @var{domains} on port 80, and which has a
  25370. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  25371. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  25372. these nginx configuration data types.
  25373. Requests to other URL paths will be matched by the
  25374. @code{default-location}, which if present is added to all
  25375. @code{nginx-server-configuration}s.
  25376. By default, the @code{default-location} will issue a redirect from
  25377. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  25378. you to define what to serve on your site via @code{https}.
  25379. Pass @code{#f} to not issue a default location.
  25380. @end table
  25381. @end deftp
  25382. @deftp {Data Type} certificate-configuration
  25383. Data type representing the configuration of a certificate.
  25384. This type has the following parameters:
  25385. @table @asis
  25386. @item @code{name} (default: @i{see below})
  25387. This name is used by Certbot for housekeeping and in file paths; it
  25388. doesn't affect the content of the certificate itself. To see
  25389. certificate names, run @code{certbot certificates}.
  25390. Its default is the first provided domain.
  25391. @item @code{domains} (default: @code{'()})
  25392. The first domain provided will be the subject CN of the certificate, and
  25393. all domains will be Subject Alternative Names on the certificate.
  25394. @item @code{challenge} (default: @code{#f})
  25395. The challenge type that has to be run by certbot. If @code{#f} is specified,
  25396. default to the HTTP challenge. If a value is specified, defaults to the
  25397. manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
  25398. the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
  25399. and gives Let's Encrypt permission to log the public IP address of the
  25400. requesting machine.
  25401. @item @code{csr} (default: @code{#f})
  25402. File name of Certificate Signing Request (CSR) in DER or PEM format.
  25403. If @code{#f} is specified, this argument will not be passed to certbot.
  25404. If a value is specified, certbot will use it to obtain a certificate, instead of
  25405. using a self-generated CSR.
  25406. The domain-name(s) mentioned in @code{domains}, must be consistent with the
  25407. domain-name(s) mentioned in CSR file.
  25408. @item @code{authentication-hook} (default: @code{#f})
  25409. Command to be run in a shell once for each certificate challenge to be
  25410. answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
  25411. will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
  25412. contains the validation string and @code{$CERTBOT_TOKEN} contains the
  25413. file name of the resource requested when performing an HTTP-01 challenge.
  25414. @item @code{cleanup-hook} (default: @code{#f})
  25415. Command to be run in a shell once for each certificate challenge that
  25416. have been answered by the @code{auth-hook}. For this command, the shell
  25417. variables available in the @code{auth-hook} script are still available, and
  25418. additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
  25419. of the @code{auth-hook} script.
  25420. @item @code{deploy-hook} (default: @code{#f})
  25421. Command to be run in a shell once for each successfully issued
  25422. certificate. For this command, the shell variable
  25423. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  25424. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  25425. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  25426. contain a space-delimited list of renewed certificate domains (for
  25427. example, @samp{"example.com www.example.com"}.
  25428. @end table
  25429. @end deftp
  25430. For each @code{certificate-configuration}, the certificate is saved to
  25431. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  25432. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  25433. @node DNS Services
  25434. @subsection DNS Services
  25435. @cindex DNS (domain name system)
  25436. @cindex domain name system (DNS)
  25437. The @code{(gnu services dns)} module provides services related to the
  25438. @dfn{domain name system} (DNS). It provides a server service for hosting
  25439. an @emph{authoritative} DNS server for multiple zones, slave or master.
  25440. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  25441. caching and forwarding DNS server for the LAN, which uses
  25442. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  25443. @subsubheading Knot Service
  25444. An example configuration of an authoritative server for two zones, one master
  25445. and one slave, is:
  25446. @lisp
  25447. (define-zone-entries example.org.zone
  25448. ;; Name TTL Class Type Data
  25449. ("@@" "" "IN" "A" "127.0.0.1")
  25450. ("@@" "" "IN" "NS" "ns")
  25451. ("ns" "" "IN" "A" "127.0.0.1"))
  25452. (define master-zone
  25453. (knot-zone-configuration
  25454. (domain "example.org")
  25455. (zone (zone-file
  25456. (origin "example.org")
  25457. (entries example.org.zone)))))
  25458. (define slave-zone
  25459. (knot-zone-configuration
  25460. (domain "plop.org")
  25461. (dnssec-policy "default")
  25462. (master (list "plop-master"))))
  25463. (define plop-master
  25464. (knot-remote-configuration
  25465. (id "plop-master")
  25466. (address (list "208.76.58.171"))))
  25467. (operating-system
  25468. ;; ...
  25469. (services (cons* (service knot-service-type
  25470. (knot-configuration
  25471. (remotes (list plop-master))
  25472. (zones (list master-zone slave-zone))))
  25473. ;; ...
  25474. %base-services)))
  25475. @end lisp
  25476. @defvar knot-service-type
  25477. This is the type for the Knot DNS server.
  25478. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  25479. zones, that is to say domain names you would buy from a registrar. This server
  25480. is not a resolver, meaning that it can only resolve names for which it is
  25481. authoritative. This server can be configured to serve zones as a master server
  25482. or a slave server as a per-zone basis. Slave zones will get their data from
  25483. masters, and will serve it as an authoritative server. From the point of view
  25484. of a resolver, there is no difference between master and slave.
  25485. The following data types are used to configure the Knot DNS server:
  25486. @end defvar
  25487. @deftp {Data Type} knot-key-configuration
  25488. Data type representing a key.
  25489. This type has the following parameters:
  25490. @table @asis
  25491. @item @code{id} (default: @code{""})
  25492. An identifier for other configuration fields to refer to this key. IDs must
  25493. be unique and must not be empty.
  25494. @item @code{algorithm} (default: @code{#f})
  25495. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  25496. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  25497. and @code{'hmac-sha512}.
  25498. @item @code{secret} (default: @code{""})
  25499. The secret key itself.
  25500. @end table
  25501. @end deftp
  25502. @deftp {Data Type} knot-acl-configuration
  25503. Data type representing an Access Control List (ACL) configuration.
  25504. This type has the following parameters:
  25505. @table @asis
  25506. @item @code{id} (default: @code{""})
  25507. An identifier for other configuration fields to refer to this key. IDs must be
  25508. unique and must not be empty.
  25509. @item @code{address} (default: @code{'()})
  25510. An ordered list of IP addresses, network subnets, or network ranges represented
  25511. with strings. The query must match one of them. Empty value means that
  25512. address match is not required.
  25513. @item @code{key} (default: @code{'()})
  25514. An ordered list of references to keys represented with strings. The string
  25515. must match a key ID defined in a @code{knot-key-configuration}. No key means
  25516. that a key is not require to match that ACL.
  25517. @item @code{action} (default: @code{'()})
  25518. An ordered list of actions that are permitted or forbidden by this ACL@. Possible
  25519. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  25520. and @code{'update}.
  25521. @item @code{deny?} (default: @code{#f})
  25522. When true, the ACL defines restrictions. Listed actions are forbidden. When
  25523. false, listed actions are allowed.
  25524. @end table
  25525. @end deftp
  25526. @deftp {Data Type} zone-entry
  25527. Data type representing a record entry in a zone file.
  25528. This type has the following parameters:
  25529. @table @asis
  25530. @item @code{name} (default: @code{"@@"})
  25531. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  25532. are relative to the origin of the zone. For example, in the @code{example.org}
  25533. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  25534. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  25535. refers to @code{ns.example.org}.
  25536. @item @code{ttl} (default: @code{""})
  25537. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  25538. @item @code{class} (default: @code{"IN"})
  25539. The class of the record. Knot currently supports only @code{"IN"} and
  25540. partially @code{"CH"}.
  25541. @item @code{type} (default: @code{"A"})
  25542. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  25543. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  25544. defined.
  25545. @item @code{data} (default: @code{""})
  25546. The data contained in the record. For instance an IP address associated with
  25547. an A record, or a domain name associated with an NS record. Remember that
  25548. domain names are relative to the origin unless they end with a dot.
  25549. @end table
  25550. @end deftp
  25551. @deftp {Data Type} zone-file
  25552. Data type representing the content of a zone file.
  25553. This type has the following parameters:
  25554. @table @asis
  25555. @item @code{entries} (default: @code{'()})
  25556. The list of entries. The SOA record is taken care of, so you don't need to
  25557. put it in the list of entries. This list should probably contain an entry
  25558. for your primary authoritative DNS server. Other than using a list of entries
  25559. directly, you can use @code{define-zone-entries} to define a object containing
  25560. the list of entries more easily, that you can later pass to the @code{entries}
  25561. field of the @code{zone-file}.
  25562. @item @code{origin} (default: @code{""})
  25563. The name of your zone. This parameter cannot be empty.
  25564. @item @code{ns} (default: @code{"ns"})
  25565. The domain of your primary authoritative DNS server. The name is relative to
  25566. the origin, unless it ends with a dot. It is mandatory that this primary
  25567. DNS server corresponds to an NS record in the zone and that it is associated
  25568. to an IP address in the list of entries.
  25569. @item @code{mail} (default: @code{"hostmaster"})
  25570. An email address people can contact you at, as the owner of the zone. This
  25571. is translated as @code{<mail>@@<origin>}.
  25572. @item @code{serial} (default: @code{1})
  25573. The serial number of the zone. As this is used to keep track of changes by
  25574. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  25575. Always increment it when you make a change in your zone.
  25576. @item @code{refresh} (default: @code{(* 2 24 3600)})
  25577. The frequency at which slaves will do a zone transfer. This value is a number
  25578. of seconds. It can be computed by multiplications or with
  25579. @code{(string->duration)}.
  25580. @item @code{retry} (default: @code{(* 15 60)})
  25581. The period after which a slave will retry to contact its master when it fails
  25582. to do so a first time.
  25583. @item @code{expiry} (default: @code{(* 14 24 3600)})
  25584. Default TTL of records. Existing records are considered correct for at most
  25585. this amount of time. After this period, resolvers will invalidate their cache
  25586. and check again that it still exists.
  25587. @item @code{nx} (default: @code{3600})
  25588. Default TTL of inexistent records. This delay is usually short because you want
  25589. your new domains to reach everyone quickly.
  25590. @end table
  25591. @end deftp
  25592. @deftp {Data Type} knot-remote-configuration
  25593. Data type representing a remote configuration.
  25594. This type has the following parameters:
  25595. @table @asis
  25596. @item @code{id} (default: @code{""})
  25597. An identifier for other configuration fields to refer to this remote. IDs must
  25598. be unique and must not be empty.
  25599. @item @code{address} (default: @code{'()})
  25600. An ordered list of destination IP addresses. Addresses are tried in sequence.
  25601. An optional port can be given with the @@ separator. For instance:
  25602. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  25603. @item @code{via} (default: @code{'()})
  25604. An ordered list of source IP addresses. An empty list will have Knot choose
  25605. an appropriate source IP@. An optional port can be given with the @@ separator.
  25606. The default is to choose at random.
  25607. @item @code{key} (default: @code{#f})
  25608. A reference to a key, that is a string containing the identifier of a key
  25609. defined in a @code{knot-key-configuration} field.
  25610. @end table
  25611. @end deftp
  25612. @deftp {Data Type} knot-keystore-configuration
  25613. Data type representing a keystore to hold dnssec keys.
  25614. This type has the following parameters:
  25615. @table @asis
  25616. @item @code{id} (default: @code{""})
  25617. The id of the keystore. It must not be empty.
  25618. @item @code{backend} (default: @code{'pem})
  25619. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  25620. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  25621. The configuration string of the backend. An example for the PKCS#11 is:
  25622. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  25623. For the pem backend, the string represents a path in the file system.
  25624. @end table
  25625. @end deftp
  25626. @deftp {Data Type} knot-policy-configuration
  25627. Data type representing a dnssec policy. Knot DNS is able to automatically
  25628. sign your zones. It can either generate and manage your keys automatically or
  25629. use keys that you generate.
  25630. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  25631. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  25632. zone. In order to be trusted, the KSK needs to be present in the parent zone
  25633. (usually a top-level domain). If your registrar supports dnssec, you will
  25634. have to send them your KSK's hash so they can add a DS record in their zone.
  25635. This is not automated and need to be done each time you change your KSK.
  25636. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  25637. easily and use weaker cryptographic functions (they use lower parameters) in
  25638. order to sign records quickly, so they are changed often. The KSK however
  25639. requires manual interaction with the registrar, so they are changed less often
  25640. and use stronger parameters because they sign only one record.
  25641. This type has the following parameters:
  25642. @table @asis
  25643. @item @code{id} (default: @code{""})
  25644. The id of the policy. It must not be empty.
  25645. @item @code{keystore} (default: @code{"default"})
  25646. A reference to a keystore, that is a string containing the identifier of a
  25647. keystore defined in a @code{knot-keystore-configuration} field. The
  25648. @code{"default"} identifier means the default keystore (a kasp database that
  25649. was setup by this service).
  25650. @item @code{manual?} (default: @code{#f})
  25651. Whether the key management is manual or automatic.
  25652. @item @code{single-type-signing?} (default: @code{#f})
  25653. When @code{#t}, use the Single-Type Signing Scheme.
  25654. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  25655. An algorithm of signing keys and issued signatures.
  25656. @item @code{ksk-size} (default: @code{256})
  25657. The length of the KSK@. Note that this value is correct for the default
  25658. algorithm, but would be unsecure for other algorithms.
  25659. @item @code{zsk-size} (default: @code{256})
  25660. The length of the ZSK@. Note that this value is correct for the default
  25661. algorithm, but would be unsecure for other algorithms.
  25662. @item @code{dnskey-ttl} (default: @code{'default})
  25663. The TTL value for DNSKEY records added into zone apex. The special
  25664. @code{'default} value means same as the zone SOA TTL.
  25665. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  25666. The period between ZSK publication and the next rollover initiation.
  25667. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  25668. An extra delay added for each key rollover step. This value should be high
  25669. enough to cover propagation of data from the master server to all slaves.
  25670. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  25671. A validity period of newly issued signatures.
  25672. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  25673. A period how long before a signature expiration the signature will be refreshed.
  25674. @item @code{nsec3?} (default: @code{#f})
  25675. When @code{#t}, NSEC3 will be used instead of NSEC.
  25676. @item @code{nsec3-iterations} (default: @code{5})
  25677. The number of additional times the hashing is performed.
  25678. @item @code{nsec3-salt-length} (default: @code{8})
  25679. The length of a salt field in octets, which is appended to the original owner
  25680. name before hashing.
  25681. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  25682. The validity period of newly issued salt field.
  25683. @end table
  25684. @end deftp
  25685. @deftp {Data Type} knot-zone-configuration
  25686. Data type representing a zone served by Knot.
  25687. This type has the following parameters:
  25688. @table @asis
  25689. @item @code{domain} (default: @code{""})
  25690. The domain served by this configuration. It must not be empty.
  25691. @item @code{file} (default: @code{""})
  25692. The file where this zone is saved. This parameter is ignored by master zones.
  25693. Empty means default location that depends on the domain name.
  25694. @item @code{zone} (default: @code{(zone-file)})
  25695. The content of the zone file. This parameter is ignored by slave zones. It
  25696. must contain a zone-file record.
  25697. @item @code{master} (default: @code{'()})
  25698. A list of master remotes. When empty, this zone is a master. When set, this
  25699. zone is a slave. This is a list of remotes identifiers.
  25700. @item @code{ddns-master} (default: @code{#f})
  25701. The main master. When empty, it defaults to the first master in the list of
  25702. masters.
  25703. @item @code{notify} (default: @code{'()})
  25704. A list of slave remote identifiers.
  25705. @item @code{acl} (default: @code{'()})
  25706. A list of acl identifiers.
  25707. @item @code{semantic-checks?} (default: @code{#f})
  25708. When set, this adds more semantic checks to the zone.
  25709. @item @code{zonefile-sync} (default: @code{0})
  25710. The delay between a modification in memory and on disk. 0 means immediate
  25711. synchronization.
  25712. @item @code{zonefile-load} (default: @code{#f})
  25713. The way the zone file contents are applied during zone load. Possible values
  25714. are:
  25715. @itemize
  25716. @item @code{#f} for using the default value from Knot,
  25717. @item @code{'none} for not using the zone file at all,
  25718. @item @code{'difference} for computing the difference between already available
  25719. contents and zone contents and applying it to the current zone contents,
  25720. @item @code{'difference-no-serial} for the same as @code{'difference}, but
  25721. ignoring the SOA serial in the zone file, while the server takes care of it
  25722. automatically.
  25723. @item @code{'whole} for loading zone contents from the zone file.
  25724. @end itemize
  25725. @item @code{journal-content} (default: @code{#f})
  25726. The way the journal is used to store zone and its changes. Possible values
  25727. are @code{'none} to not use it at all, @code{'changes} to store changes and
  25728. @code{'all} to store contents. @code{#f} does not set this option, so the
  25729. default value from Knot is used.
  25730. @item @code{max-journal-usage} (default: @code{#f})
  25731. The maximum size for the journal on disk. @code{#f} does not set this option,
  25732. so the default value from Knot is used.
  25733. @item @code{max-journal-depth} (default: @code{#f})
  25734. The maximum size of the history. @code{#f} does not set this option, so the
  25735. default value from Knot is used.
  25736. @item @code{max-zone-size} (default: @code{#f})
  25737. The maximum size of the zone file. This limit is enforced for incoming
  25738. transfer and updates. @code{#f} does not set this option, so the default
  25739. value from Knot is used.
  25740. @item @code{dnssec-policy} (default: @code{#f})
  25741. A reference to a @code{knot-policy-configuration} record, or the special
  25742. name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
  25743. on this zone.
  25744. @item @code{serial-policy} (default: @code{'increment})
  25745. A policy between @code{'increment} and @code{'unixtime}.
  25746. @end table
  25747. @end deftp
  25748. @deftp {Data Type} knot-configuration
  25749. Data type representing the Knot configuration.
  25750. This type has the following parameters:
  25751. @table @asis
  25752. @item @code{knot} (default: @code{knot})
  25753. The Knot package.
  25754. @item @code{run-directory} (default: @code{"/var/run/knot"})
  25755. The run directory. This directory will be used for pid file and sockets.
  25756. @item @code{includes} (default: @code{'()})
  25757. A list of strings or file-like objects denoting other files that must be
  25758. included at the top of the configuration file.
  25759. @cindex secrets, Knot service
  25760. This can be used to manage secrets out-of-band. For example, secret
  25761. keys may be stored in an out-of-band file not managed by Guix, and
  25762. thus not visible in @file{/gnu/store}---e.g., you could store secret
  25763. key configuration in @file{/etc/knot/secrets.conf} and add this file
  25764. to the @code{includes} list.
  25765. One can generate a secret tsig key (for nsupdate and zone transfers with the
  25766. keymgr command from the knot package. Note that the package is not automatically
  25767. installed by the service. The following example shows how to generate a new
  25768. tsig key:
  25769. @example
  25770. keymgr -t mysecret > /etc/knot/secrets.conf
  25771. chmod 600 /etc/knot/secrets.conf
  25772. @end example
  25773. Also note that the generated key will be named @var{mysecret}, so it is the
  25774. name that needs to be used in the @var{key} field of the
  25775. @code{knot-acl-configuration} record and in other places that need to refer
  25776. to that key.
  25777. It can also be used to add configuration not supported by this interface.
  25778. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  25779. An ip address on which to listen.
  25780. @item @code{listen-v6} (default: @code{"::"})
  25781. An ip address on which to listen.
  25782. @item @code{listen-port} (default: @code{53})
  25783. A port on which to listen.
  25784. @item @code{keys} (default: @code{'()})
  25785. The list of knot-key-configuration used by this configuration.
  25786. @item @code{acls} (default: @code{'()})
  25787. The list of knot-acl-configuration used by this configuration.
  25788. @item @code{remotes} (default: @code{'()})
  25789. The list of knot-remote-configuration used by this configuration.
  25790. @item @code{zones} (default: @code{'()})
  25791. The list of knot-zone-configuration used by this configuration.
  25792. @end table
  25793. @end deftp
  25794. @subsubheading Knot Resolver Service
  25795. @defvar knot-resolver-service-type
  25796. This is the type of the knot resolver service, whose value should be
  25797. a @code{knot-resolver-configuration} object as in this example:
  25798. @lisp
  25799. (service knot-resolver-service-type
  25800. (knot-resolver-configuration
  25801. (kresd-config-file (plain-file "kresd.conf" "
  25802. net.listen('192.168.0.1', 5353)
  25803. user('knot-resolver', 'knot-resolver')
  25804. modules = @{ 'hints > iterate', 'stats', 'predict' @}
  25805. cache.size = 100 * MB
  25806. "))))
  25807. @end lisp
  25808. For more information, refer its @url{https://knot-resolver.readthedocs.io/en/stable/config-overview.html, manual}.
  25809. @end defvar
  25810. @deftp {Data Type} knot-resolver-configuration
  25811. Data type representing the configuration of knot-resolver.
  25812. @table @asis
  25813. @item @code{package} (default: @var{knot-resolver})
  25814. Package object of the knot DNS resolver.
  25815. @item @code{kresd-config-file} (default: %kresd.conf)
  25816. File-like object of the kresd configuration file to use, by default it
  25817. will listen on @code{127.0.0.1} and @code{::1}.
  25818. @item @code{garbage-collection-interval} (default: 1000)
  25819. Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
  25820. @end table
  25821. @end deftp
  25822. @subsubheading Dnsmasq Service
  25823. @defvar dnsmasq-service-type
  25824. This is the type of the dnsmasq service, whose value should be a
  25825. @code{dnsmasq-configuration} object as in this example:
  25826. @lisp
  25827. (service dnsmasq-service-type
  25828. (dnsmasq-configuration
  25829. (no-resolv? #t)
  25830. (servers '("192.168.1.1"))))
  25831. @end lisp
  25832. @end defvar
  25833. @deftp {Data Type} dnsmasq-configuration
  25834. Data type representing the configuration of dnsmasq.
  25835. @table @asis
  25836. @item @code{package} (default: @var{dnsmasq})
  25837. Package object of the dnsmasq server.
  25838. @item @code{no-hosts?} (default: @code{#f})
  25839. When true, don't read the hostnames in /etc/hosts.
  25840. @item @code{port} (default: @code{53})
  25841. The port to listen on. Setting this to zero completely disables DNS
  25842. responses, leaving only DHCP and/or TFTP functions.
  25843. @item @code{local-service?} (default: @code{#t})
  25844. Accept DNS queries only from hosts whose address is on a local subnet,
  25845. ie a subnet for which an interface exists on the server.
  25846. @item @code{listen-addresses} (default: @code{'()})
  25847. Listen on the given IP addresses.
  25848. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  25849. The file to read the IP address of the upstream nameservers from.
  25850. @item @code{no-resolv?} (default: @code{#f})
  25851. When true, don't read @var{resolv-file}.
  25852. @item @code{forward-private-reverse-lookup?} (default: @code{#t})
  25853. When false, all reverse lookups for private IP ranges are answered with
  25854. "no such domain" rather than being forwarded upstream.
  25855. @item @code{query-servers-in-order?} (default: @code{#f})
  25856. When true, dnsmasq queries the servers in the same order as they appear
  25857. in @var{servers}.
  25858. @item @code{servers} (default: @code{'()})
  25859. Specify IP address of upstream servers directly.
  25860. @item @code{servers-file} (default: @code{#f})
  25861. Specify file containing upstream servers. This file is re-read when dnsmasq receives SIGHUP.
  25862. Could be either a string or a file-like object.
  25863. @item @code{addresses} (default: @code{'()})
  25864. For each entry, specify an IP address to return for any host in the
  25865. given domains. Queries in the domains are never forwarded and always
  25866. replied to with the specified IP address.
  25867. This is useful for redirecting hosts locally, for example:
  25868. @lisp
  25869. (service dnsmasq-service-type
  25870. (dnsmasq-configuration
  25871. (addresses
  25872. '(; Redirect to a local web-server.
  25873. "/example.org/127.0.0.1"
  25874. ; Redirect subdomain to a specific IP.
  25875. "/subdomain.example.org/192.168.1.42"))))
  25876. @end lisp
  25877. Note that rules in @file{/etc/hosts} take precedence over this.
  25878. @item @code{cache-size} (default: @code{150})
  25879. Set the size of dnsmasq's cache. Setting the cache size to zero
  25880. disables caching.
  25881. @item @code{negative-cache?} (default: @code{#t})
  25882. When false, disable negative caching.
  25883. @item @code{cpe-id} (default: @code{#f})
  25884. If set, add a CPE (Customer-Premises Equipment) identifier to DNS
  25885. queries which are forwarded upstream.
  25886. @item @code{tftp-enable?} (default: @code{#f})
  25887. Whether to enable the built-in TFTP server.
  25888. @item @code{tftp-no-fail?} (default: @code{#f})
  25889. If true, does not fail dnsmasq if the TFTP server could not start up.
  25890. @item @code{tftp-single-port?} (default: @code{#f})
  25891. Whether to use only one single port for TFTP.
  25892. @item @code{tftp-secure?} (default: @code{#f})
  25893. If true, only files owned by the user running the dnsmasq process are accessible.
  25894. If dnsmasq is being run as root, different rules apply:
  25895. @code{tftp-secure?} has no effect, but only files which have the
  25896. world-readable bit set are accessible.
  25897. @item @code{tftp-max} (default: @code{#f})
  25898. If set, sets the maximal number of concurrent connections allowed.
  25899. @item @code{tftp-mtu} (default: @code{#f})
  25900. If set, sets the MTU for TFTP packets to that value.
  25901. @item @code{tftp-no-blocksize?} (default: @code{#f})
  25902. If true, stops the TFTP server from negotiating the blocksize with a client.
  25903. @item @code{tftp-lowercase?} (default: @code{#f})
  25904. Whether to convert all filenames in TFTP requests to lowercase.
  25905. @item @code{tftp-port-range} (default: @code{#f})
  25906. If set, fixes the dynamical ports (one per client) to the given range
  25907. (@code{"<start>,<end>"}).
  25908. @item @code{tftp-root} (default: @code{/var/empty,lo})
  25909. Look for files to transfer using TFTP relative to the given directory.
  25910. When this is set, TFTP paths which include @samp{..} are rejected, to stop clients
  25911. getting outside the specified root. Absolute paths (starting with @samp{/}) are
  25912. allowed, but they must be within the TFTP-root. If the optional interface
  25913. argument is given, the directory is only used for TFTP requests via that
  25914. interface.
  25915. @item @code{tftp-unique-root} (default: @code{#f})
  25916. If set, add the IP or hardware address of the TFTP client as a path component
  25917. on the end of the TFTP-root. Only valid if a TFTP root is set and the
  25918. directory exists. Defaults to adding IP address (in standard dotted-quad
  25919. format).
  25920. For instance, if @option{--tftp-root} is @samp{/tftp} and client
  25921. @samp{1.2.3.4} requests file @file{myfile} then the effective path will
  25922. be @file{/tftp/1.2.3.4/myfile} if @file{/tftp/1.2.3.4} exists or
  25923. @file{/tftp/myfile} otherwise. When @samp{=mac} is specified it will
  25924. append the MAC address instead, using lowercase zero padded digits
  25925. separated by dashes, e.g.: @samp{01-02-03-04-aa-bb}. Note that
  25926. resolving MAC addresses is only possible if the client is in the local
  25927. network or obtained a DHCP lease from dnsmasq.
  25928. @end table
  25929. @end deftp
  25930. @node VNC Services
  25931. @subsection VNC Services
  25932. @cindex VNC (virtual network computing)
  25933. @cindex XDMCP (x display manager control protocol)
  25934. The @code{(gnu services vnc)} module provides services related to
  25935. @dfn{Virtual Network Computing} (VNC), which makes it possible to
  25936. locally use graphical Xorg applications running on a remote machine.
  25937. Combined with a graphical manager that supports the @dfn{X Display
  25938. Manager Control Protocol}, such as GDM (@pxref{gdm}) or LightDM
  25939. (@pxref{lightdm}), it is possible to remote an entire desktop for a
  25940. multi-user environment.
  25941. @subsubheading Xvnc
  25942. Xvnc is a VNC server that spawns its own X window server; which means it
  25943. can run on headless servers. The Xvnc implementations provided by the
  25944. @code{tigervnc-server} and @code{turbovnc} aim to be fast and efficient.
  25945. @defvar xvnc-service-type
  25946. The @code{xvnc-service-type} service can be configured via the
  25947. @code{xvnc-configuration} record, documented below. A second virtual
  25948. display could be made available on a remote machine via the
  25949. following configuration:
  25950. @end defvar
  25951. @lisp
  25952. (service xvnc-service-type
  25953. (xvnc-configuration (display-number 10)))
  25954. @end lisp
  25955. As a demonstration, the @command{xclock} command could then be started
  25956. on the remote machine on display number 10, and it could be displayed
  25957. locally via the @command{vncviewer} command:
  25958. @example
  25959. # Start xclock on the remote machine.
  25960. ssh -L5910:localhost:5910 @var{your-host} -- guix shell xclock \
  25961. -- env DISPLAY=:10 xclock
  25962. # Access it via VNC.
  25963. guix shell tigervnc-client -- vncviewer localhost:5910
  25964. @end example
  25965. The following configuration combines XDMCP and Inetd to allow multiple
  25966. users to concurrently use the remote system and login graphically via
  25967. the GDM display manager:
  25968. @lisp
  25969. (operating-system
  25970. [...]
  25971. (services (cons*
  25972. [...]
  25973. (service xvnc-service-type (xvnc-configuration
  25974. (display-number 5)
  25975. (localhost? #f)
  25976. (xdmcp? #t)
  25977. (inetd? #t)))
  25978. (modify-services %desktop-services
  25979. (gdm-service-type config => (gdm-configuration
  25980. (inherit config)
  25981. (auto-suspend? #f)
  25982. (xdmcp? #t)))))))
  25983. @end lisp
  25984. A remote user could then connect to it by using the @command{vncviewer}
  25985. command or a compatible VNC client and start a desktop session of their
  25986. choosing:
  25987. @example
  25988. vncviewer remote-host:5905
  25989. @end example
  25990. @quotation Warning
  25991. Unless your machine is in a controlled environment, for security
  25992. reasons, the @code{localhost?} configuration of the
  25993. @code{xvnc-configuration} record should be left to its default @code{#t}
  25994. value and exposed via a secure means such as an SSH port forward. The
  25995. XDMCP port, UDP 177 should also be blocked from the outside by a
  25996. firewall, as it is not a secure protocol and can expose login
  25997. credentials in clear.
  25998. @end quotation
  25999. @c Use (configuration->documentation 'xvnc-configuration) to regenerate
  26000. @c the documentation.
  26001. @c %start of fragment
  26002. @deftp {Data Type} xvnc-configuration
  26003. Available @code{xvnc-configuration} fields are:
  26004. @table @asis
  26005. @item @code{xvnc} (default: @code{tigervnc-server}) (type: file-like)
  26006. The package that provides the Xvnc binary.
  26007. @item @code{display-number} (default: @code{0}) (type: number)
  26008. The display number used by Xvnc. You should set this to a number not
  26009. already used a Xorg server.
  26010. @item @code{geometry} (default: @code{"1024x768"}) (type: string)
  26011. The size of the desktop to be created.
  26012. @item @code{depth} (default: @code{24}) (type: color-depth)
  26013. The pixel depth in bits of the desktop to be created. Accepted values
  26014. are 16, 24 or 32.
  26015. @item @code{port} (type: maybe-port)
  26016. The port on which to listen for connections from viewers. When left
  26017. unspecified, it defaults to 5900 plus the display number.
  26018. @item @code{ipv4?} (default: @code{#t}) (type: boolean)
  26019. Use IPv4 for incoming and outgoing connections.
  26020. @item @code{ipv6?} (default: @code{#t}) (type: boolean)
  26021. Use IPv6 for incoming and outgoing connections.
  26022. @item @code{password-file} (type: maybe-string)
  26023. The password file to use, if any. Refer to vncpasswd(1) to learn how to
  26024. generate such a file.
  26025. @item @code{xdmcp?} (default: @code{#f}) (type: boolean)
  26026. Query the XDMCP server for a session. This enables users to log in a
  26027. desktop session from the login manager screen. For a multiple users
  26028. scenario, you'll want to enable the @code{inetd?} option as well, so
  26029. that each connection to the VNC server is handled separately rather than
  26030. shared.
  26031. @item @code{inetd?} (default: @code{#f}) (type: boolean)
  26032. Use an Inetd-style service, which runs the Xvnc server on demand.
  26033. @item @code{frame-rate} (default: @code{60}) (type: number)
  26034. The maximum number of updates per second sent to each client.
  26035. @item @code{security-types} (default: @code{'("None")}) (type: security-types)
  26036. The allowed security schemes to use for incoming connections. The
  26037. default is "None", which is safe given that Xvnc is configured to
  26038. authenticate the user via the display manager, and only for local
  26039. connections. Accepted values are any of the following: ("None"
  26040. "VncAuth" "Plain" "TLSNone" "TLSVnc" "TLSPlain" "X509None" "X509Vnc")
  26041. @item @code{localhost?} (default: @code{#t}) (type: boolean)
  26042. Only allow connections from the same machine. It is set to #true by
  26043. default for security, which means SSH or another secure means should be
  26044. used to expose the remote port.
  26045. @item @code{log-level} (default: @code{30}) (type: log-level)
  26046. The log level, a number between 0 and 100, 100 meaning most verbose
  26047. output. The log messages are output to syslog.
  26048. @item @code{extra-options} (default: @code{'()}) (type: strings)
  26049. This can be used to provide extra Xvnc options not exposed via this
  26050. <xvnc-configuration> record.
  26051. @end table
  26052. @end deftp
  26053. @c %end of fragment
  26054. @node VPN Services
  26055. @subsection VPN Services
  26056. @cindex VPN (virtual private network)
  26057. @cindex virtual private network (VPN)
  26058. The @code{(gnu services vpn)} module provides services related to
  26059. @dfn{virtual private networks} (VPNs).
  26060. @subsubheading Bitmask
  26061. @defvar bitmask-service-type
  26062. A service type for the @uref{https://bitmask.net, Bitmask} VPN client. It makes
  26063. the client available in the system and loads its polkit policy. Please note that
  26064. the client expects an active polkit-agent, which is either run by your
  26065. desktop-environment or should be run manually.
  26066. @end defvar
  26067. @subsubheading OpenVPN
  26068. It provides a @emph{client} service for your machine to connect to a
  26069. VPN, and a @emph{server} service for your machine to host a VPN@.
  26070. Both @code{openvpn-client-service-type} and
  26071. @code{openvpn-server-service-type} can be run simultaneously.
  26072. @defvar openvpn-client-service-type
  26073. Type of the service that runs @command{openvpn}, a VPN daemon, as a client.
  26074. The value for this service is a @code{<openvpn-client-configuration>}
  26075. object.
  26076. @end defvar
  26077. @defvar openvpn-server-service-type
  26078. Type of the service that runs @command{openvpn}, a VPN daemon, as a server.
  26079. The value for this service is a @code{<openvpn-server-configuration>}
  26080. object.
  26081. @end defvar
  26082. @c %automatically generated documentation
  26083. @deftp {Data Type} openvpn-client-configuration
  26084. Available @code{openvpn-client-configuration} fields are:
  26085. @table @asis
  26086. @item @code{openvpn} (default: @code{openvpn}) (type: file-like)
  26087. The OpenVPN package.
  26088. @item @code{pid-file} (default: @code{"/var/run/openvpn/openvpn.pid"}) (type: string)
  26089. The OpenVPN pid file.
  26090. @item @code{proto} (default: @code{udp}) (type: proto)
  26091. The protocol (UDP or TCP) used to open a channel between clients and
  26092. servers.
  26093. @item @code{dev} (default: @code{tun}) (type: dev)
  26094. The device type used to represent the VPN connection.
  26095. @item @code{ca} (default: @code{"/etc/openvpn/ca.crt"}) (type: maybe-string)
  26096. The certificate authority to check connections against.
  26097. @item @code{cert} (default: @code{"/etc/openvpn/client.crt"}) (type: maybe-string)
  26098. The certificate of the machine the daemon is running on. It should be
  26099. signed by the authority given in @code{ca}.
  26100. @item @code{key} (default: @code{"/etc/openvpn/client.key"}) (type: maybe-string)
  26101. The key of the machine the daemon is running on. It must be the key
  26102. whose certificate is @code{cert}.
  26103. @item @code{comp-lzo?} (default: @code{#t}) (type: boolean)
  26104. Whether to use the lzo compression algorithm.
  26105. @item @code{persist-key?} (default: @code{#t}) (type: boolean)
  26106. Don't re-read key files across SIGUSR1 or --ping-restart.
  26107. @item @code{persist-tun?} (default: @code{#t}) (type: boolean)
  26108. Don't close and reopen TUN/TAP device or run up/down scripts across
  26109. SIGUSR1 or --ping-restart restarts.
  26110. @item @code{fast-io?} (default: @code{#f}) (type: boolean)
  26111. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  26112. poll/epoll/select prior to the write operation.
  26113. @item @code{verbosity} (default: @code{3}) (type: number)
  26114. Verbosity level.
  26115. @item @code{tls-auth} (default: @code{#f}) (type: tls-auth-client)
  26116. Add an additional layer of HMAC authentication on top of the TLS control
  26117. channel to protect against DoS attacks.
  26118. @item @code{auth-user-pass} (type: maybe-string)
  26119. Authenticate with server using username/password. The option is a file
  26120. containing username/password on 2 lines. Do not use a file-like object
  26121. as it would be added to the store and readable by any user.
  26122. @item @code{verify-key-usage?} (default: @code{#t}) (type: key-usage)
  26123. Whether to check the server certificate has server usage extension.
  26124. @item @code{bind?} (default: @code{#f}) (type: bind)
  26125. Bind to a specific local port number.
  26126. @item @code{resolv-retry?} (default: @code{#t}) (type: resolv-retry)
  26127. Retry resolving server address.
  26128. @item @code{remote} (default: @code{'()}) (type: openvpn-remote-list)
  26129. A list of remote servers to connect to.
  26130. @deftp {Data Type} openvpn-remote-configuration
  26131. Available @code{openvpn-remote-configuration} fields are:
  26132. @table @asis
  26133. @item @code{name} (default: @code{"my-server"}) (type: string)
  26134. Server name.
  26135. @item @code{port} (default: @code{1194}) (type: number)
  26136. Port number the server listens to.
  26137. @end table
  26138. @end deftp
  26139. @end table
  26140. @end deftp
  26141. @c %end of automatic openvpn-client documentation
  26142. @c %automatically generated documentation
  26143. @deftp {Data Type} openvpn-server-configuration
  26144. Available @code{openvpn-server-configuration} fields are:
  26145. @table @asis
  26146. @item @code{openvpn} (default: @code{openvpn}) (type: file-like)
  26147. The OpenVPN package.
  26148. @item @code{pid-file} (default: @code{"/var/run/openvpn/openvpn.pid"}) (type: string)
  26149. The OpenVPN pid file.
  26150. @item @code{proto} (default: @code{udp}) (type: proto)
  26151. The protocol (UDP or TCP) used to open a channel between clients and
  26152. servers.
  26153. @item @code{dev} (default: @code{tun}) (type: dev)
  26154. The device type used to represent the VPN connection.
  26155. @item @code{ca} (default: @code{"/etc/openvpn/ca.crt"}) (type: maybe-string)
  26156. The certificate authority to check connections against.
  26157. @item @code{cert} (default: @code{"/etc/openvpn/client.crt"}) (type: maybe-string)
  26158. The certificate of the machine the daemon is running on. It should be
  26159. signed by the authority given in @code{ca}.
  26160. @item @code{key} (default: @code{"/etc/openvpn/client.key"}) (type: maybe-string)
  26161. The key of the machine the daemon is running on. It must be the key
  26162. whose certificate is @code{cert}.
  26163. @item @code{comp-lzo?} (default: @code{#t}) (type: boolean)
  26164. Whether to use the lzo compression algorithm.
  26165. @item @code{persist-key?} (default: @code{#t}) (type: boolean)
  26166. Don't re-read key files across SIGUSR1 or --ping-restart.
  26167. @item @code{persist-tun?} (default: @code{#t}) (type: boolean)
  26168. Don't close and reopen TUN/TAP device or run up/down scripts across
  26169. SIGUSR1 or --ping-restart restarts.
  26170. @item @code{fast-io?} (default: @code{#f}) (type: boolean)
  26171. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  26172. poll/epoll/select prior to the write operation.
  26173. @item @code{verbosity} (default: @code{3}) (type: number)
  26174. Verbosity level.
  26175. @item @code{tls-auth} (default: @code{#f}) (type: tls-auth-server)
  26176. Add an additional layer of HMAC authentication on top of the TLS control
  26177. channel to protect against DoS attacks.
  26178. @item @code{port} (default: @code{1194}) (type: number)
  26179. Specifies the port number on which the server listens.
  26180. @item @code{server} (default: @code{"10.8.0.0 255.255.255.0"}) (type: ip-mask)
  26181. An ip and mask specifying the subnet inside the virtual network.
  26182. @item @code{server-ipv6} (default: @code{#f}) (type: cidr6)
  26183. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  26184. @item @code{dh} (default: @code{"/etc/openvpn/dh2048.pem"}) (type: string)
  26185. The Diffie-Hellman parameters file.
  26186. @item @code{ifconfig-pool-persist} (default: @code{"/etc/openvpn/ipp.txt"}) (type: string)
  26187. The file that records client IPs.
  26188. @item @code{redirect-gateway?} (default: @code{#f}) (type: gateway)
  26189. When true, the server will act as a gateway for its clients.
  26190. @item @code{client-to-client?} (default: @code{#f}) (type: boolean)
  26191. When true, clients are allowed to talk to each other inside the VPN.
  26192. @item @code{keepalive} (default: @code{(10 120)}) (type: keepalive)
  26193. Causes ping-like messages to be sent back and forth over the link so
  26194. that each side knows when the other side has gone down. @code{keepalive}
  26195. requires a pair. The first element is the period of the ping sending,
  26196. and the second element is the timeout before considering the other side
  26197. down.
  26198. @item @code{max-clients} (default: @code{100}) (type: number)
  26199. The maximum number of clients.
  26200. @item @code{status} (default: @code{"/var/run/openvpn/status"}) (type: string)
  26201. The status file. This file shows a small report on current connection.
  26202. It is truncated and rewritten every minute.
  26203. @item @code{client-config-dir} (default: @code{'()}) (type: openvpn-ccd-list)
  26204. The list of configuration for some clients.
  26205. @end table
  26206. @end deftp
  26207. @c %end of automatic openvpn-server documentation
  26208. @subheading strongSwan
  26209. Currently, the strongSwan service only provides legacy-style configuration with
  26210. @file{ipsec.conf} and @file{ipsec.secrets} files.
  26211. @defvar strongswan-service-type
  26212. A service type for configuring strongSwan for IPsec @acronym{VPN,
  26213. Virtual Private Networking}. Its value must be a
  26214. @code{strongswan-configuration} record as in this example:
  26215. @lisp
  26216. (service strongswan-service-type
  26217. (strongswan-configuration
  26218. (ipsec-conf "/etc/ipsec.conf")
  26219. (ipsec-secrets "/etc/ipsec.secrets")))
  26220. @end lisp
  26221. @end defvar
  26222. @deftp {Data Type} strongswan-configuration
  26223. Data type representing the configuration of the StrongSwan service.
  26224. @table @asis
  26225. @item @code{strongswan}
  26226. The strongSwan package to use for this service.
  26227. @item @code{ipsec-conf} (default: @code{#f})
  26228. The file name of your @file{ipsec.conf}. If not @code{#f}, then this and
  26229. @code{ipsec-secrets} must both be strings.
  26230. @item @code{ipsec-secrets} (default @code{#f})
  26231. The file name of your @file{ipsec.secrets}. If not @code{#f}, then this and
  26232. @code{ipsec-conf} must both be strings.
  26233. @end table
  26234. @end deftp
  26235. @subsubheading Wireguard
  26236. @defvar wireguard-service-type
  26237. A service type for a Wireguard tunnel interface. Its value must be a
  26238. @code{wireguard-configuration} record as in this example:
  26239. @lisp
  26240. (service wireguard-service-type
  26241. (wireguard-configuration
  26242. (peers
  26243. (list
  26244. (wireguard-peer
  26245. (name "my-peer")
  26246. (endpoint "my.wireguard.com:51820")
  26247. (public-key "hzpKg9X1yqu1axN6iJp0mWf6BZGo8m1wteKwtTmDGF4=")
  26248. (allowed-ips '("10.0.0.2/32")))))))
  26249. @end lisp
  26250. @end defvar
  26251. @deftp {Data Type} wireguard-configuration
  26252. Data type representing the configuration of the Wireguard service.
  26253. @table @asis
  26254. @item @code{wireguard}
  26255. The wireguard package to use for this service.
  26256. @item @code{interface} (default: @code{"wg0"})
  26257. The interface name for the VPN.
  26258. @item @code{addresses} (default: @code{'("10.0.0.1/32")})
  26259. The IP addresses to be assigned to the above interface.
  26260. @item @code{port} (default: @code{51820})
  26261. The port on which to listen for incoming connections.
  26262. @item @code{dns} (default: @code{'())})
  26263. The DNS server(s) to announce to VPN clients via DHCP.
  26264. @item @code{monitor-ips?} (default: @code{#f})
  26265. @cindex Dynamic IP, with Wireguard
  26266. @cindex dyndns, usage with Wireguard
  26267. Whether to monitor the resolved Internet addresses (IPs) of the
  26268. endpoints of the configured peers, resetting the peer endpoints using an
  26269. IP address that no longer correspond to their freshly resolved host
  26270. name. Set this to @code{#t} if one or more endpoints use host names
  26271. provided by a dynamic DNS service to keep the sessions alive.
  26272. @item @code{monitor-ips-interval} (default: @code{'(next-minute (range 0 60 5))})
  26273. The time interval at which the IP monitoring job should run, provided as
  26274. an mcron time specification (@pxref{Guile Syntax,,,mcron}).
  26275. @item @code{private-key} (default: @code{"/etc/wireguard/private.key"})
  26276. The private key file for the interface. It is automatically generated
  26277. if the file does not exist.
  26278. @item @code{peers} (default: @code{'()})
  26279. The authorized peers on this interface. This is a list of
  26280. @var{wireguard-peer} records.
  26281. @item @code{pre-up} (default: @code{'()})
  26282. The script commands to be run before setting up the interface.
  26283. @item @code{post-up} (default: @code{'()})
  26284. The script commands to be run after setting up the interface.
  26285. @item @code{pre-down} (default: @code{'()})
  26286. The script commands to be run before tearing down the interface.
  26287. @item @code{post-down} (default: @code{'()})
  26288. The script commands to be run after tearing down the interface.
  26289. @item @code{table} (default: @code{"auto"})
  26290. The routing table to which routes are added, as a string. There are two
  26291. special values: @code{"off"} that disables the creation of routes
  26292. altogether, and @code{"auto"} (the default) that adds routes to the
  26293. default table and enables special handling of default routes.
  26294. @end table
  26295. @end deftp
  26296. @deftp {Data Type} wireguard-peer
  26297. Data type representing a Wireguard peer attached to a given interface.
  26298. @table @asis
  26299. @item @code{name}
  26300. The peer name.
  26301. @item @code{endpoint} (default: @code{#f})
  26302. The optional endpoint for the peer, such as
  26303. @code{"demo.wireguard.com:51820"}.
  26304. @item @code{public-key}
  26305. The peer public-key represented as a base64 string.
  26306. @item @code{preshared-key} (default: @code{#f})
  26307. An optional pre-shared key file for this peer. The given file will not
  26308. be autogenerated.
  26309. @item @code{allowed-ips}
  26310. A list of IP addresses from which incoming traffic for this peer is
  26311. allowed and to which incoming traffic for this peer is directed.
  26312. @item @code{keep-alive} (default: @code{#f})
  26313. An optional time interval in seconds. A packet will be sent to the
  26314. server endpoint once per time interval. This helps receiving
  26315. incoming connections from this peer when you are behind a NAT or
  26316. a firewall.
  26317. @end table
  26318. @end deftp
  26319. @node Network File System
  26320. @subsection Network File System
  26321. @cindex NFS
  26322. The @code{(gnu services nfs)} module provides the following services,
  26323. which are most commonly used in relation to mounting or exporting
  26324. directory trees as @dfn{network file systems} (NFS).
  26325. While it is possible to use the individual components that together make
  26326. up a Network File System service, we recommended to configure an NFS
  26327. server with the @code{nfs-service-type}.
  26328. @subsubheading NFS Service
  26329. @cindex NFS, server
  26330. The NFS service takes care of setting up all NFS component services,
  26331. kernel configuration file systems, and installs configuration files in
  26332. the locations that NFS expects.
  26333. @defvar nfs-service-type
  26334. A service type for a complete NFS server.
  26335. @end defvar
  26336. @deftp {Data Type} nfs-configuration
  26337. This data type represents the configuration of the NFS service and all
  26338. of its subsystems.
  26339. It has the following parameters:
  26340. @table @asis
  26341. @item @code{nfs-utils} (default: @code{nfs-utils})
  26342. The nfs-utils package to use.
  26343. @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
  26344. If a list of string values is provided, the @command{rpc.nfsd} daemon
  26345. will be limited to supporting the given versions of the NFS protocol.
  26346. @item @code{exports} (default: @code{'()})
  26347. This is a list of directories the NFS server should export. Each entry
  26348. is a list consisting of two elements: a directory name and a string
  26349. containing all options. This is an example in which the directory
  26350. @file{/export} is served to all NFS clients as a read-only share:
  26351. @lisp
  26352. (nfs-configuration
  26353. (exports
  26354. '(("/export"
  26355. "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
  26356. @end lisp
  26357. @item @code{rpcmountd-port} (default: @code{#f})
  26358. The network port that the @command{rpc.mountd} daemon should use.
  26359. @item @code{rpcstatd-port} (default: @code{#f})
  26360. The network port that the @command{rpc.statd} daemon should use.
  26361. @item @code{rpcbind} (default: @code{rpcbind})
  26362. The rpcbind package to use.
  26363. @item @code{idmap-domain} (default: @code{"localdomain"})
  26364. The local NFSv4 domain name.
  26365. @item @code{nfsd-port} (default: @code{2049})
  26366. The network port that the @command{nfsd} daemon should use.
  26367. @item @code{nfsd-threads} (default: @code{8})
  26368. The number of threads used by the @command{nfsd} daemon.
  26369. @item @code{nfsd-tcp?} (default: @code{#t})
  26370. Whether the @command{nfsd} daemon should listen on a TCP socket.
  26371. @item @code{nfsd-udp?} (default: @code{#f})
  26372. Whether the @command{nfsd} daemon should listen on a UDP socket.
  26373. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  26374. The directory where the pipefs file system is mounted.
  26375. @item @code{debug} (default: @code{'()"})
  26376. A list of subsystems for which debugging output should be enabled. This
  26377. is a list of symbols. Any of these symbols are valid: @code{nfsd},
  26378. @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
  26379. @end table
  26380. @end deftp
  26381. If you don't need a complete NFS service or prefer to build it yourself
  26382. you can use the individual component services that are documented below.
  26383. @subsubheading RPC Bind Service
  26384. @cindex rpcbind
  26385. The RPC Bind service provides a facility to map program numbers into
  26386. universal addresses.
  26387. Many NFS related services use this facility. Hence it is automatically
  26388. started when a dependent service starts.
  26389. @defvar rpcbind-service-type
  26390. A service type for the RPC portmapper daemon.
  26391. @end defvar
  26392. @deftp {Data Type} rpcbind-configuration
  26393. Data type representing the configuration of the RPC Bind Service.
  26394. This type has the following parameters:
  26395. @table @asis
  26396. @item @code{rpcbind} (default: @code{rpcbind})
  26397. The rpcbind package to use.
  26398. @item @code{warm-start?} (default: @code{#t})
  26399. If this parameter is @code{#t}, then the daemon will read a
  26400. state file on startup thus reloading state information saved by a previous
  26401. instance.
  26402. @end table
  26403. @end deftp
  26404. @subsubheading Pipefs Pseudo File System
  26405. @cindex pipefs
  26406. @cindex rpc_pipefs
  26407. The pipefs file system is used to transfer NFS related data
  26408. between the kernel and user space programs.
  26409. @defvar pipefs-service-type
  26410. A service type for the pipefs pseudo file system.
  26411. @end defvar
  26412. @deftp {Data Type} pipefs-configuration
  26413. Data type representing the configuration of the pipefs pseudo file system service.
  26414. This type has the following parameters:
  26415. @table @asis
  26416. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  26417. The directory to which the file system is to be attached.
  26418. @end table
  26419. @end deftp
  26420. @subsubheading GSS Daemon Service
  26421. @cindex GSSD
  26422. @cindex GSS
  26423. @cindex global security system
  26424. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  26425. based protocols.
  26426. Before exchanging RPC requests an RPC client must establish a security
  26427. context. Typically this is done using the Kerberos command @command{kinit}
  26428. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  26429. @defvar gss-service-type
  26430. A service type for the Global Security System (GSS) daemon.
  26431. @end defvar
  26432. @deftp {Data Type} gss-configuration
  26433. Data type representing the configuration of the GSS daemon service.
  26434. This type has the following parameters:
  26435. @table @asis
  26436. @item @code{nfs-utils} (default: @code{nfs-utils})
  26437. The package in which the @command{rpc.gssd} command is to be found.
  26438. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  26439. The directory where the pipefs file system is mounted.
  26440. @end table
  26441. @end deftp
  26442. @subsubheading IDMAP Daemon Service
  26443. @cindex idmapd
  26444. @cindex name mapper
  26445. The idmap daemon service provides mapping between user IDs and user names.
  26446. Typically it is required in order to access file systems mounted via NFSv4.
  26447. @defvar idmap-service-type
  26448. A service type for the Identity Mapper (IDMAP) daemon.
  26449. @end defvar
  26450. @deftp {Data Type} idmap-configuration
  26451. Data type representing the configuration of the IDMAP daemon service.
  26452. This type has the following parameters:
  26453. @table @asis
  26454. @item @code{nfs-utils} (default: @code{nfs-utils})
  26455. The package in which the @command{rpc.idmapd} command is to be found.
  26456. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  26457. The directory where the pipefs file system is mounted.
  26458. @item @code{domain} (default: @code{#f})
  26459. The local NFSv4 domain name.
  26460. This must be a string or @code{#f}.
  26461. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  26462. @item @code{verbosity} (default: @code{0})
  26463. The verbosity level of the daemon.
  26464. @end table
  26465. @end deftp
  26466. @node Samba Services, Continuous Integration, Network File System, Services
  26467. @subsection Samba Services
  26468. @cindex Samba
  26469. @cindex SMB
  26470. The @code{(gnu services samba)} module provides service definitions for
  26471. Samba as well as additional helper services. Currently it provides the
  26472. following services.
  26473. @subsubheading Samba
  26474. @uref{https://www.samba.org, Samba} provides network shares for folders
  26475. and printers using the SMB/CIFS protocol commonly used on Windows. It
  26476. can also act as an Active Directory Domain Controller (AD DC) for other
  26477. hosts in an heterougenious network with different types of Computer
  26478. systems.
  26479. @defvar samba-service-type
  26480. The service type to enable the samba services @code{samba}, @code{nmbd},
  26481. @code{smbd} and @code{winbindd}. By default this service type does not
  26482. run any of the Samba daemons; they must be enabled individually.
  26483. Below is a basic example that configures a simple, anonymous
  26484. (unauthenticated) Samba file share exposing the @file{/public}
  26485. directory.
  26486. @quotation Tip
  26487. The @file{/public} directory and its contents must be world
  26488. readable/writable, so you'll want to run @samp{chmod -R 777 /public} on
  26489. it.
  26490. @end quotation
  26491. @quotation Caution
  26492. Such a Samba configuration should only be used in controlled
  26493. environments, and you should not share any private files using it, as
  26494. anyone connecting to your network would be able to access them.
  26495. @end quotation
  26496. @lisp
  26497. (service samba-service-type (samba-configuration
  26498. (enable-smbd? #t)
  26499. (config-file (plain-file "smb.conf" "\
  26500. [global]
  26501. map to guest = Bad User
  26502. logging = syslog@@1
  26503. [public]
  26504. browsable = yes
  26505. path = /public
  26506. read only = no
  26507. guest ok = yes
  26508. guest only = yes\n"))))
  26509. @end lisp
  26510. @end defvar
  26511. @deftp {Data Type} samba-service-configuration
  26512. Configuration record for the Samba suite.
  26513. @table @asis
  26514. @item @code{package} (default: @code{samba})
  26515. The samba package to use.
  26516. @item @code{config-file} (default: @code{#f})
  26517. The config file to use. To learn about its syntax, run @samp{man
  26518. smb.conf}.
  26519. @item @code{enable-samba?} (default: @code{#f})
  26520. Enable the @code{samba} daemon.
  26521. @item @code{enable-smbd?} (default: @code{#f})
  26522. Enable the @code{smbd} daemon.
  26523. @item @code{enable-nmbd?} (default: @code{#f})
  26524. Enable the @code{nmbd} daemon.
  26525. @item @code{enable-winbindd?} (default: @code{#f})
  26526. Enable the @code{winbindd} daemon.
  26527. @end table
  26528. @end deftp
  26529. @cindex wsdd, Web service discovery daemon
  26530. @subsubheading Web Service Discovery Daemon
  26531. The @acronym{WSDD, Web Service Discovery daemon} implements the
  26532. @uref{http://docs.oasis-open.org/ws-dd/discovery/1.1/os/wsdd-discovery-1.1-spec-os.html,
  26533. Web Services Dynamic Discovery} protocol that enables host discovery
  26534. over Multicast DNS, similar to what Avahi does. It is a drop-in
  26535. replacement for SMB hosts that have had SMBv1 disabled for security
  26536. reasons.
  26537. @defvar wsdd-service-type
  26538. Service type for the WSD host daemon. The value for
  26539. this service type is a @code{wsdd-configuration} record. The details
  26540. for the @code{wsdd-configuration} record type are given below.
  26541. @end defvar
  26542. @deftp {Data Type} wsdd-configuration
  26543. This data type represents the configuration for the wsdd service.
  26544. @table @asis
  26545. @item @code{package} (default: @code{wsdd})
  26546. The wsdd package to use.
  26547. @item @code{ipv4only?} (default: @code{#f})
  26548. Only listen to IPv4 addresses.
  26549. @item @code{ipv6only} (default: @code{#f})
  26550. Only listen to IPv6 addresses. Please note: Activating both options is
  26551. not possible, since there would be no IP versions to listen to.
  26552. @item @code{chroot} (default: @code{#f})
  26553. Chroot into a separate directory to prevent access to other directories.
  26554. This is to increase security in case there is a vulnerability in
  26555. @command{wsdd}.
  26556. @item @code{hop-limit} (default: @code{1})
  26557. Limit to the level of hops for multicast packets. The default is
  26558. @var{1} which should prevent packets from leaving the local network.
  26559. @item @code{interface} (default: @code{'()})
  26560. Limit to the given list of interfaces to listen to. By default wsdd
  26561. will listen to all interfaces. Except the loopback interface is never
  26562. used.
  26563. @item @code{uuid-device} (default: @code{#f})
  26564. The WSD protocol requires a device to have a UUID. Set this to manually
  26565. assign the service a UUID.
  26566. @item @code{domain} (default: @code{#f})
  26567. Notify this host is a member of an Active Directory.
  26568. @item @code{host-name} (default: @code{#f})
  26569. Manually set the hostname rather than letting @command{wsdd} inherit
  26570. this host's hostname. Only the host name part of a possible FQDN will
  26571. be used in the default case.
  26572. @item @code{preserve-case?} (default: @code{#f})
  26573. By default @command{wsdd} will convert the hostname in workgroup to all
  26574. uppercase. The opposite is true for hostnames in domains. Setting this
  26575. parameter will preserve case.
  26576. @item @code{workgroup} (default: @var{"WORKGROUP"})
  26577. Change the name of the workgroup. By default @command{wsdd} reports
  26578. this host being member of a workgroup.
  26579. @end table
  26580. @end deftp
  26581. @node Continuous Integration
  26582. @subsection Continuous Integration
  26583. @cindex continuous integration
  26584. @uref{https://guix.gnu.org/cuirass/, Cuirass} is a continuous
  26585. integration tool for Guix. It can be used both for development and for
  26586. providing substitutes to others (@pxref{Substitutes}).
  26587. The @code{(gnu services cuirass)} module provides the following service.
  26588. @defvr {Procedure} cuirass-service-type
  26589. The type of the Cuirass service. Its value must be a
  26590. @code{cuirass-configuration} object, as described below.
  26591. @end defvr
  26592. To add build jobs, you have to set the @code{specifications} field of
  26593. the configuration. For instance, the following example will build all
  26594. the packages provided by the @code{my-channel} channel.
  26595. @lisp
  26596. (define %cuirass-specs
  26597. #~(list (specification
  26598. (name "my-channel")
  26599. (build '(channels my-channel))
  26600. (channels
  26601. (cons (channel
  26602. (name 'my-channel)
  26603. (url "https://my-channel.git"))
  26604. %default-channels)))))
  26605. (service cuirass-service-type
  26606. (cuirass-configuration
  26607. (specifications %cuirass-specs)))
  26608. @end lisp
  26609. To build the @code{linux-libre} package defined by the default Guix
  26610. channel, one can use the following configuration.
  26611. @lisp
  26612. (define %cuirass-specs
  26613. #~(list (specification
  26614. (name "my-linux")
  26615. (build '(packages "linux-libre")))))
  26616. (service cuirass-service-type
  26617. (cuirass-configuration
  26618. (specifications %cuirass-specs)))
  26619. @end lisp
  26620. The other configuration possibilities, as well as the specification
  26621. record itself are described in the Cuirass manual
  26622. (@pxref{Specifications,,, cuirass, Cuirass}).
  26623. While information related to build jobs is located directly in the
  26624. specifications, global settings for the @command{cuirass} process are
  26625. accessible in other @code{cuirass-configuration} fields.
  26626. @deftp {Data Type} cuirass-configuration
  26627. Data type representing the configuration of Cuirass.
  26628. @table @asis
  26629. @item @code{cuirass} (default: @code{cuirass})
  26630. The Cuirass package to use.
  26631. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  26632. Location of the log file.
  26633. @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
  26634. Location of the log file used by the web interface.
  26635. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  26636. Location of the repository cache.
  26637. @item @code{user} (default: @code{"cuirass"})
  26638. Owner of the @code{cuirass} process.
  26639. @item @code{group} (default: @code{"cuirass"})
  26640. Owner's group of the @code{cuirass} process.
  26641. @item @code{interval} (default: @code{60})
  26642. Number of seconds between the poll of the repositories followed by the
  26643. Cuirass jobs.
  26644. @item @code{parameters} (default: @code{#f})
  26645. Read parameters from the given @var{parameters} file. The supported
  26646. parameters are described here (@pxref{Parameters,,, cuirass, Cuirass}).
  26647. @item @code{remote-server} (default: @code{#f})
  26648. A @code{cuirass-remote-server-configuration} record to use the build
  26649. remote mechanism or @code{#f} to use the default build mechanism.
  26650. @item @code{database} (default: @code{"dbname=cuirass host=/var/run/postgresql"})
  26651. Use @var{database} as the database containing the jobs and the past
  26652. build results. Since Cuirass uses PostgreSQL as a database engine,
  26653. @var{database} must be a string such as @code{"dbname=cuirass
  26654. host=localhost"}.
  26655. @item @code{port} (default: @code{8081})
  26656. Port number used by the HTTP server.
  26657. @item @code{host} (default: @code{"localhost"})
  26658. Listen on the network interface for @var{host}. The default is to
  26659. accept connections from localhost.
  26660. @item @code{specifications} (default: @code{#~'()})
  26661. A gexp (@pxref{G-Expressions}) that evaluates to a list of
  26662. specifications records. The specification record is described in the
  26663. Cuirass manual (@pxref{Specifications,,, cuirass, Cuirass}).
  26664. @item @code{use-substitutes?} (default: @code{#f})
  26665. This allows using substitutes to avoid building every dependencies of a job
  26666. from source.
  26667. @item @code{one-shot?} (default: @code{#f})
  26668. Only evaluate specifications and build derivations once.
  26669. @item @code{fallback?} (default: @code{#f})
  26670. When substituting a pre-built binary fails, fall back to building
  26671. packages locally.
  26672. @item @code{extra-options} (default: @code{'()})
  26673. Extra options to pass when running the Cuirass processes.
  26674. @end table
  26675. @end deftp
  26676. @cindex remote build
  26677. @subsubheading Cuirass remote building
  26678. Cuirass supports two mechanisms to build derivations.
  26679. @itemize
  26680. @item Using the local Guix daemon.
  26681. This is the default build mechanism. Once the build jobs are
  26682. evaluated, they are sent to the local Guix daemon. Cuirass then
  26683. listens to the Guix daemon output to detect the various build events.
  26684. @item Using the remote build mechanism.
  26685. The build jobs are not submitted to the local Guix daemon. Instead, a
  26686. remote server dispatches build requests to the connect remote workers,
  26687. according to the build priorities.
  26688. @end itemize
  26689. To enable this build mode a @code{cuirass-remote-server-configuration}
  26690. record must be passed as @code{remote-server} argument of the
  26691. @code{cuirass-configuration} record. The
  26692. @code{cuirass-remote-server-configuration} record is described below.
  26693. This build mode scales way better than the default build mode. This is
  26694. the build mode that is used on the GNU Guix build farm at
  26695. @url{https://ci.guix.gnu.org}. It should be preferred when using
  26696. Cuirass to build large amount of packages.
  26697. @deftp {Data Type} cuirass-remote-server-configuration
  26698. Data type representing the configuration of the Cuirass remote-server.
  26699. @table @asis
  26700. @item @code{backend-port} (default: @code{5555})
  26701. The TCP port for communicating with @code{remote-worker} processes
  26702. using ZMQ. It defaults to @code{5555}.
  26703. @item @code{log-port} (default: @code{5556})
  26704. The TCP port of the log server. It defaults to @code{5556}.
  26705. @item @code{publish-port} (default: @code{5557})
  26706. The TCP port of the publish server. It defaults to @code{5557}.
  26707. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-server.log"})
  26708. Location of the log file.
  26709. @item @code{cache} (default: @code{"/var/cache/cuirass/remote"})
  26710. Use @var{cache} directory to cache build log files.
  26711. @item @code{trigger-url} (default: @code{#f})
  26712. Once a substitute is successfully fetched, trigger substitute baking at
  26713. @var{trigger-url}.
  26714. @item @code{publish?} (default: @code{#t})
  26715. If set to false, do not start a publish server and ignore the
  26716. @code{publish-port} argument. This can be useful if there is already a
  26717. standalone publish server standing next to the remote server.
  26718. @item @code{public-key}
  26719. @item @code{private-key}
  26720. Use the specific @var{file}s as the public/private key pair used to sign
  26721. the store items being published.
  26722. @end table
  26723. @end deftp
  26724. At least one remote worker must also be started on any machine of the
  26725. local network to actually perform the builds and report their status.
  26726. @deftp {Data Type} cuirass-remote-worker-configuration
  26727. Data type representing the configuration of the Cuirass remote-worker.
  26728. @table @asis
  26729. @item @code{cuirass} (default: @code{cuirass})
  26730. The Cuirass package to use.
  26731. @item @code{workers} (default: @code{1})
  26732. Start @var{workers} parallel workers.
  26733. @item @code{server} (default: @code{#f})
  26734. Do not use Avahi discovery and connect to the given @code{server} IP
  26735. address instead.
  26736. @item @code{systems} (default: @code{(list (%current-system))})
  26737. Only request builds for the given @var{systems}.
  26738. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-worker.log"})
  26739. Location of the log file.
  26740. @item @code{publish-port} (default: @code{5558})
  26741. The TCP port of the publish server. It defaults to @code{5558}.
  26742. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  26743. The list of URLs where to look for substitutes by default.
  26744. @item @code{public-key}
  26745. @item @code{private-key}
  26746. Use the specific @var{file}s as the public/private key pair used to sign
  26747. the store items being published.
  26748. @end table
  26749. @end deftp
  26750. @subsubheading Laminar
  26751. @uref{https://laminar.ohwg.net/, Laminar} is a lightweight and modular
  26752. Continuous Integration service. It doesn't have a configuration web UI
  26753. instead uses version-controllable configuration files and scripts.
  26754. Laminar encourages the use of existing tools such as bash and cron
  26755. instead of reinventing them.
  26756. @defvar laminar-service-type
  26757. The type of the Laminar service. Its value must be a
  26758. @code{laminar-configuration} object, as described below.
  26759. All configuration values have defaults, a minimal configuration to get
  26760. Laminar running is shown below. By default, the web interface is
  26761. available on port 8080.
  26762. @lisp
  26763. (service laminar-service-type)
  26764. @end lisp
  26765. @end defvar
  26766. @deftp {Data Type} laminar-configuration
  26767. Data type representing the configuration of Laminar.
  26768. @table @asis
  26769. @item @code{laminar} (default: @code{laminar})
  26770. The Laminar package to use.
  26771. @item @code{home-directory} (default: @code{"/var/lib/laminar"})
  26772. The directory for job configurations and run directories.
  26773. @item @code{bind-http} (default: @code{"*:8080"})
  26774. The interface/port or unix socket on which laminard should listen for
  26775. incoming connections to the web frontend.
  26776. @item @code{bind-rpc} (default: @code{"unix-abstract:laminar"})
  26777. The interface/port or unix socket on which laminard should listen for
  26778. incoming commands such as build triggers.
  26779. @item @code{title} (default: @code{"Laminar"})
  26780. The page title to show in the web frontend.
  26781. @item @code{keep-rundirs} (default: @code{0})
  26782. Set to an integer defining how many rundirs to keep per job. The
  26783. lowest-numbered ones will be deleted. The default is 0, meaning all run
  26784. dirs will be immediately deleted.
  26785. @item @code{archive-url} (default: @code{#f})
  26786. The web frontend served by laminard will use this URL to form links to
  26787. artefacts archived jobs.
  26788. @item @code{base-url} (default: @code{#f})
  26789. Base URL to use for links to laminar itself.
  26790. @end table
  26791. @end deftp
  26792. @node Power Management Services
  26793. @subsection Power Management Services
  26794. @cindex tlp
  26795. @cindex power management with TLP
  26796. @subsubheading TLP daemon
  26797. The @code{(gnu services pm)} module provides a Guix service definition
  26798. for the Linux power management tool TLP.
  26799. TLP enables various powersaving modes in userspace and kernel.
  26800. Contrary to @code{upower-service}, it is not a passive,
  26801. monitoring tool, as it will apply custom settings each time a new power
  26802. source is detected. More information can be found at
  26803. @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
  26804. @defvar tlp-service-type
  26805. The service type for the TLP tool. The default settings are optimised
  26806. for battery life on most systems, but you can tweak them to your heart's
  26807. content by adding a valid @code{tlp-configuration}:
  26808. @lisp
  26809. (service tlp-service-type
  26810. (tlp-configuration
  26811. (cpu-scaling-governor-on-ac (list "performance"))
  26812. (sched-powersave-on-bat? #t)))
  26813. @end lisp
  26814. @end defvar
  26815. Each parameter definition is preceded by its type; for example,
  26816. @samp{boolean foo} indicates that the @code{foo} parameter should be
  26817. specified as a boolean. Types starting with @code{maybe-} denote
  26818. parameters that won't show up in TLP config file when their value is
  26819. left unset, or is explicitly set to the @code{%unset-value} value.
  26820. @c The following documentation was initially generated by
  26821. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  26822. @c documentation is better, so we shouldn't hesitate to edit below as
  26823. @c needed. However if the change you want to make to this documentation
  26824. @c can be done in an automated way, it's probably easier to change
  26825. @c (generate-documentation) than to make it below and have to deal with
  26826. @c the churn as TLP updates.
  26827. Available @code{tlp-configuration} fields are:
  26828. @deftypevr {@code{tlp-configuration} parameter} package tlp
  26829. The TLP package.
  26830. @end deftypevr
  26831. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  26832. Set to true if you wish to enable TLP.
  26833. Defaults to @samp{#t}.
  26834. @end deftypevr
  26835. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  26836. Default mode when no power supply can be detected. Alternatives are AC
  26837. and BAT.
  26838. Defaults to @samp{"AC"}.
  26839. @end deftypevr
  26840. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  26841. Number of seconds Linux kernel has to wait after the disk goes idle,
  26842. before syncing on AC.
  26843. Defaults to @samp{0}.
  26844. @end deftypevr
  26845. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  26846. Same as @code{disk-idle-ac} but on BAT mode.
  26847. Defaults to @samp{2}.
  26848. @end deftypevr
  26849. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  26850. Dirty pages flushing periodicity, expressed in seconds.
  26851. Defaults to @samp{15}.
  26852. @end deftypevr
  26853. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  26854. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  26855. Defaults to @samp{60}.
  26856. @end deftypevr
  26857. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  26858. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  26859. alternatives are powersave and performance. With acpi-cpufreq driver,
  26860. alternatives are ondemand, powersave, performance and conservative.
  26861. Defaults to @samp{disabled}.
  26862. @end deftypevr
  26863. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  26864. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  26865. Defaults to @samp{disabled}.
  26866. @end deftypevr
  26867. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  26868. Set the min available frequency for the scaling governor on AC.
  26869. Defaults to @samp{disabled}.
  26870. @end deftypevr
  26871. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  26872. Set the max available frequency for the scaling governor on AC.
  26873. Defaults to @samp{disabled}.
  26874. @end deftypevr
  26875. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  26876. Set the min available frequency for the scaling governor on BAT.
  26877. Defaults to @samp{disabled}.
  26878. @end deftypevr
  26879. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  26880. Set the max available frequency for the scaling governor on BAT.
  26881. Defaults to @samp{disabled}.
  26882. @end deftypevr
  26883. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  26884. Limit the min P-state to control the power dissipation of the CPU, in AC
  26885. mode. Values are stated as a percentage of the available performance.
  26886. Defaults to @samp{disabled}.
  26887. @end deftypevr
  26888. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  26889. Limit the max P-state to control the power dissipation of the CPU, in AC
  26890. mode. Values are stated as a percentage of the available performance.
  26891. Defaults to @samp{disabled}.
  26892. @end deftypevr
  26893. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  26894. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  26895. Defaults to @samp{disabled}.
  26896. @end deftypevr
  26897. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  26898. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  26899. Defaults to @samp{disabled}.
  26900. @end deftypevr
  26901. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  26902. Enable CPU turbo boost feature on AC mode.
  26903. Defaults to @samp{disabled}.
  26904. @end deftypevr
  26905. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  26906. Same as @code{cpu-boost-on-ac?} on BAT mode.
  26907. Defaults to @samp{disabled}.
  26908. @end deftypevr
  26909. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  26910. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  26911. used under light load conditions.
  26912. Defaults to @samp{#f}.
  26913. @end deftypevr
  26914. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  26915. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  26916. Defaults to @samp{#t}.
  26917. @end deftypevr
  26918. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  26919. Enable Linux kernel NMI watchdog.
  26920. Defaults to @samp{#f}.
  26921. @end deftypevr
  26922. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  26923. For Linux kernels with PHC patch applied, change CPU voltages. An
  26924. example value would be @samp{"F:V F:V F:V F:V"}.
  26925. Defaults to @samp{disabled}.
  26926. @end deftypevr
  26927. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  26928. Set CPU performance versus energy saving policy on AC@. Alternatives are
  26929. performance, normal, powersave.
  26930. Defaults to @samp{"performance"}.
  26931. @end deftypevr
  26932. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  26933. Same as @code{energy-perf-policy-ac} but on BAT mode.
  26934. Defaults to @samp{"powersave"}.
  26935. @end deftypevr
  26936. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  26937. Hard disk devices.
  26938. @end deftypevr
  26939. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  26940. Hard disk advanced power management level.
  26941. @end deftypevr
  26942. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  26943. Same as @code{disk-apm-bat} but on BAT mode.
  26944. @end deftypevr
  26945. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  26946. Hard disk spin down timeout. One value has to be specified for each
  26947. declared hard disk.
  26948. Defaults to @samp{disabled}.
  26949. @end deftypevr
  26950. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  26951. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  26952. Defaults to @samp{disabled}.
  26953. @end deftypevr
  26954. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  26955. Select IO scheduler for disk devices. One value has to be specified for
  26956. each declared hard disk. Example alternatives are cfq, deadline and
  26957. noop.
  26958. Defaults to @samp{disabled}.
  26959. @end deftypevr
  26960. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  26961. SATA aggressive link power management (ALPM) level. Alternatives are
  26962. min_power, medium_power, max_performance.
  26963. Defaults to @samp{"max_performance"}.
  26964. @end deftypevr
  26965. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  26966. Same as @code{sata-linkpwr-ac} but on BAT mode.
  26967. Defaults to @samp{"min_power"}.
  26968. @end deftypevr
  26969. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  26970. Exclude specified SATA host devices for link power management.
  26971. Defaults to @samp{disabled}.
  26972. @end deftypevr
  26973. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  26974. Enable Runtime Power Management for AHCI controller and disks on AC
  26975. mode.
  26976. Defaults to @samp{disabled}.
  26977. @end deftypevr
  26978. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  26979. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  26980. Defaults to @samp{disabled}.
  26981. @end deftypevr
  26982. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  26983. Seconds of inactivity before disk is suspended.
  26984. Defaults to @samp{15}.
  26985. @end deftypevr
  26986. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  26987. PCI Express Active State Power Management level. Alternatives are
  26988. default, performance, powersave.
  26989. Defaults to @samp{"performance"}.
  26990. @end deftypevr
  26991. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  26992. Same as @code{pcie-aspm-ac} but on BAT mode.
  26993. Defaults to @samp{"powersave"}.
  26994. @end deftypevr
  26995. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer start-charge-thresh-bat0
  26996. Percentage when battery 0 should begin charging. Only supported on some laptops.
  26997. Defaults to @samp{disabled}.
  26998. @end deftypevr
  26999. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer stop-charge-thresh-bat0
  27000. Percentage when battery 0 should stop charging. Only supported on some laptops.
  27001. Defaults to @samp{disabled}.
  27002. @end deftypevr
  27003. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer start-charge-thresh-bat1
  27004. Percentage when battery 1 should begin charging. Only supported on some laptops.
  27005. Defaults to @samp{disabled}.
  27006. @end deftypevr
  27007. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer stop-charge-thresh-bat1
  27008. Percentage when battery 1 should stop charging. Only supported on some laptops.
  27009. Defaults to @samp{disabled}.
  27010. @end deftypevr
  27011. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  27012. Radeon graphics clock speed level. Alternatives are low, mid, high,
  27013. auto, default.
  27014. Defaults to @samp{"high"}.
  27015. @end deftypevr
  27016. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  27017. Same as @code{radeon-power-ac} but on BAT mode.
  27018. Defaults to @samp{"low"}.
  27019. @end deftypevr
  27020. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  27021. Radeon dynamic power management method (DPM). Alternatives are battery,
  27022. performance.
  27023. Defaults to @samp{"performance"}.
  27024. @end deftypevr
  27025. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  27026. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  27027. Defaults to @samp{"battery"}.
  27028. @end deftypevr
  27029. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  27030. Radeon DPM performance level. Alternatives are auto, low, high.
  27031. Defaults to @samp{"auto"}.
  27032. @end deftypevr
  27033. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  27034. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  27035. Defaults to @samp{"auto"}.
  27036. @end deftypevr
  27037. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  27038. Wifi power saving mode.
  27039. Defaults to @samp{#f}.
  27040. @end deftypevr
  27041. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  27042. Same as @code{wifi-power-ac?} but on BAT mode.
  27043. Defaults to @samp{#t}.
  27044. @end deftypevr
  27045. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  27046. Disable wake on LAN.
  27047. Defaults to @samp{#t}.
  27048. @end deftypevr
  27049. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  27050. Timeout duration in seconds before activating audio power saving on
  27051. Intel HDA and AC97 devices. A value of 0 disables power saving.
  27052. Defaults to @samp{0}.
  27053. @end deftypevr
  27054. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  27055. Same as @code{sound-powersave-ac} but on BAT mode.
  27056. Defaults to @samp{1}.
  27057. @end deftypevr
  27058. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  27059. Disable controller in powersaving mode on Intel HDA devices.
  27060. Defaults to @samp{#t}.
  27061. @end deftypevr
  27062. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  27063. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  27064. powered on again by releasing (and reinserting) the eject lever or by
  27065. pressing the disc eject button on newer models.
  27066. Defaults to @samp{#f}.
  27067. @end deftypevr
  27068. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  27069. Name of the optical drive device to power off.
  27070. Defaults to @samp{"sr0"}.
  27071. @end deftypevr
  27072. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  27073. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  27074. and auto.
  27075. Defaults to @samp{"on"}.
  27076. @end deftypevr
  27077. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  27078. Same as @code{runtime-pm-ac} but on BAT mode.
  27079. Defaults to @samp{"auto"}.
  27080. @end deftypevr
  27081. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  27082. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  27083. ones.
  27084. Defaults to @samp{#t}.
  27085. @end deftypevr
  27086. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  27087. Exclude specified PCI(e) device addresses from Runtime Power Management.
  27088. Defaults to @samp{disabled}.
  27089. @end deftypevr
  27090. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  27091. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  27092. Power Management.
  27093. @end deftypevr
  27094. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  27095. Enable USB autosuspend feature.
  27096. Defaults to @samp{#t}.
  27097. @end deftypevr
  27098. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  27099. Exclude specified devices from USB autosuspend.
  27100. Defaults to @samp{disabled}.
  27101. @end deftypevr
  27102. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  27103. Exclude WWAN devices from USB autosuspend.
  27104. Defaults to @samp{#t}.
  27105. @end deftypevr
  27106. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  27107. Include specified devices into USB autosuspend, even if they are already
  27108. excluded by the driver or via @code{usb-blacklist-wwan?}.
  27109. Defaults to @samp{disabled}.
  27110. @end deftypevr
  27111. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  27112. Enable USB autosuspend before shutdown.
  27113. Defaults to @samp{disabled}.
  27114. @end deftypevr
  27115. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  27116. Restore radio device state (bluetooth, wifi, wwan) from previous
  27117. shutdown on system startup.
  27118. Defaults to @samp{#f}.
  27119. @end deftypevr
  27120. @cindex thermald
  27121. @cindex CPU frequency scaling with thermald
  27122. @subsubheading Thermald daemon
  27123. The @code{(gnu services pm)} module provides an interface to
  27124. thermald, a CPU frequency scaling service which helps prevent overheating.
  27125. @defvar thermald-service-type
  27126. This is the service type for
  27127. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  27128. Thermal Daemon, which is responsible for controlling the thermal state
  27129. of processors and preventing overheating.
  27130. @end defvar
  27131. @deftp {Data Type} thermald-configuration
  27132. Data type representing the configuration of @code{thermald-service-type}.
  27133. @table @asis
  27134. @item @code{adaptive?} (default: @code{#f})
  27135. Use @acronym{DPTF, Dynamic Power and Thermal Framework} adaptive tables
  27136. when present.
  27137. @item @code{ignore-cpuid-check?} (default: @code{#f})
  27138. Ignore cpuid check for supported CPU models.
  27139. @item @code{thermald} (default: @var{thermald})
  27140. Package object of thermald.
  27141. @end table
  27142. @end deftp
  27143. @node Audio Services
  27144. @subsection Audio Services
  27145. The @code{(gnu services audio)} module provides a service to start MPD
  27146. (the Music Player Daemon).
  27147. @cindex mpd
  27148. @subsubheading Music Player Daemon
  27149. The Music Player Daemon (MPD) is a service that can play music while
  27150. being controlled from the local machine or over the network by a variety
  27151. of clients.
  27152. The following example shows the simplest configuration to locally
  27153. expose, via PulseAudio, a music collection kept at @file{/srv/music},
  27154. with @command{mpd} running as the default @samp{mpd} user. This user
  27155. will spawn its own PulseAudio daemon, which may compete for the sound
  27156. card access with that of your own user. In this configuration, you may
  27157. have to stop the playback of your user audio applications to hear MPD's
  27158. output and vice-versa.
  27159. @lisp
  27160. (service mpd-service-type
  27161. (mpd-configuration
  27162. (music-directory "/srv/music")))
  27163. @end lisp
  27164. @quotation Important
  27165. The music directory must be readable to the MPD user, by default,
  27166. @samp{mpd}. Permission problems will be reported via @samp{Permission
  27167. denied} errors in the MPD logs, which appear in @file{/var/log/messages}
  27168. by default.
  27169. @end quotation
  27170. Most MPD clients will trigger a database update upon connecting, but you
  27171. can also use the @code{update} action do to so:
  27172. @example
  27173. herd update mpd
  27174. @end example
  27175. All the MPD configuration fields are documented below, and a more
  27176. complex example follows.
  27177. @defvar mpd-service-type
  27178. The service type for @command{mpd}
  27179. @end defvar
  27180. @c %start of fragment
  27181. @deftp {Data Type} mpd-configuration
  27182. Available @code{mpd-configuration} fields are:
  27183. @table @asis
  27184. @item @code{package} (default: @code{mpd}) (type: file-like)
  27185. The MPD package.
  27186. @item @code{user} (type: user-account)
  27187. The user to run mpd as.
  27188. @item @code{group} (type: user-group)
  27189. The group to run mpd as.
  27190. The default @code{%mpd-group} is a system group with name ``mpd''.
  27191. @item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbol)
  27192. A list of symbols naming Shepherd services that this service
  27193. will depend on.
  27194. @item @code{environment-variables} (default: @code{'("PULSE_CLIENTCONFIG=/etc/pulse/client.conf" "PULSE_CONFIG=/etc/pulse/daemon.conf")}) (type: list-of-strings)
  27195. A list of strings specifying environment variables.
  27196. @item @code{log-file} (type: maybe-string)
  27197. The location of the log file. Unless specified, logs are sent to the
  27198. local syslog daemon. Alternatively, a log file name can be specified,
  27199. for example @file{/var/log/mpd.log}.
  27200. @item @code{log-level} (type: maybe-string)
  27201. Supress any messages below this threshold. The available values, in
  27202. decreasing order of verbosity, are: @code{verbose}, @code{info},
  27203. @code{notice}, @code{warning} and @code{error}.
  27204. @item @code{music-directory} (type: maybe-string)
  27205. The directory to scan for music files.
  27206. @item @code{music-dir} (type: maybe-string)
  27207. The directory to scan for music files.
  27208. @item @code{playlist-directory} (type: maybe-string)
  27209. The directory to store playlists.
  27210. @item @code{playlist-dir} (type: maybe-string)
  27211. The directory to store playlists.
  27212. @item @code{db-file} (type: maybe-string)
  27213. The location of the music database. When left unspecified,
  27214. @file{~/.cache/db} is used.
  27215. @item @code{state-file} (type: maybe-string)
  27216. The location of the file that stores current MPD's state.
  27217. @item @code{sticker-file} (type: maybe-string)
  27218. The location of the sticker database.
  27219. @item @code{default-port} (default: @code{6600}) (type: maybe-port)
  27220. The default port to run mpd on.
  27221. @item @code{endpoints} (type: maybe-list-of-strings)
  27222. The addresses that mpd will bind to. A port different from
  27223. @var{default-port} may be specified, e.g. @code{localhost:6602} and
  27224. IPv6 addresses must be enclosed in square brackets when a different port
  27225. is used. To use a Unix domain socket, an absolute path or a path
  27226. starting with @code{~} can be specified here.
  27227. @item @code{address} (type: maybe-string)
  27228. The address that mpd will bind to. To use a Unix domain socket, an
  27229. absolute path can be specified here.
  27230. @item @code{database} (type: maybe-mpd-plugin)
  27231. MPD database plugin configuration.
  27232. @item @code{partitions} (default: @code{'()}) (type: list-of-mpd-partition)
  27233. List of MPD "partitions".
  27234. @item @code{neighbors} (default: @code{'()}) (type: list-of-mpd-plugin)
  27235. List of MPD neighbor plugin configurations.
  27236. @item @code{inputs} (default: @code{'()}) (type: list-of-mpd-plugin)
  27237. List of MPD input plugin configurations.
  27238. @item @code{archive-plugins} (default: @code{'()}) (type: list-of-mpd-plugin)
  27239. List of MPD archive plugin configurations.
  27240. @item @code{auto-update?} (type: maybe-boolean)
  27241. Whether to automatically update the music database when files are
  27242. changed in the @var{music-directory}.
  27243. @item @code{input-cache-size} (type: maybe-string)
  27244. MPD input cache size.
  27245. @item @code{decoders} (default: @code{'()}) (type: list-of-mpd-plugin)
  27246. List of MPD decoder plugin configurations.
  27247. @item @code{resampler} (type: maybe-mpd-plugin)
  27248. MPD resampler plugin configuration.
  27249. @item @code{filters} (default: @code{'()}) (type: list-of-mpd-plugin)
  27250. List of MPD filter plugin configurations.
  27251. @item @code{outputs} (type: list-of-mpd-plugin-or-output)
  27252. The audio outputs that MPD can use. By default this is a single output
  27253. using pulseaudio.
  27254. @item @code{playlist-plugins} (default: @code{'()}) (type: list-of-mpd-plugin)
  27255. List of MPD playlist plugin configurations.
  27256. @item @code{extra-options} (default: @code{'()}) (type: alist)
  27257. An association list of option symbols/strings to string values to be
  27258. appended to the configuration.
  27259. @end table
  27260. @end deftp
  27261. @c %end of fragment
  27262. @deftp {Data Type} mpd-plugin
  27263. Data type representing a @command{mpd} plugin.
  27264. @table @asis
  27265. @item @code{plugin} (type: maybe-string)
  27266. Plugin name.
  27267. @item @code{name} (type: maybe-string)
  27268. Name.
  27269. @item @code{enabled?} (type: maybe-boolean)
  27270. Whether the plugin is enabled/disabled.
  27271. @item @code{extra-options} (default: @code{'()}) (type: alist)
  27272. An association list of option symbols/strings to string values to be
  27273. appended to the plugin configuration. See
  27274. @uref{https://mpd.readthedocs.io/en/latest/plugins.html,MPD plugin
  27275. reference} for available options.
  27276. @end table
  27277. @end deftp
  27278. @deftp {Data Type} mpd-partition
  27279. Data type representing a @command{mpd} partition.
  27280. @table @asis
  27281. @item @code{name} (type: string)
  27282. Partition name.
  27283. @item @code{extra-options} (default: @code{'()}) (type: alist)
  27284. An association list of option symbols/strings to string values to be
  27285. appended to the partition configuration. See
  27286. @uref{https://mpd.readthedocs.io/en/latest/user.html#configuring-partitions,Configuring
  27287. Partitions} for available options.
  27288. @end table
  27289. @end deftp
  27290. @c %start of fragment
  27291. @deftp {Data Type} mpd-output
  27292. Available @code{mpd-output} fields are:
  27293. @table @asis
  27294. @item @code{name} (default: @code{"MPD"}) (type: string)
  27295. The name of the audio output.
  27296. @item @code{type} (default: @code{"pulse"}) (type: string)
  27297. The type of audio output.
  27298. @item @code{enabled?} (default: @code{#t}) (type: boolean)
  27299. Specifies whether this audio output is enabled when MPD is started. By
  27300. default, all audio outputs are enabled. This is just the default
  27301. setting when there is no state file; with a state file, the previous
  27302. state is restored.
  27303. @item @code{format} (type: maybe-string)
  27304. Force a specific audio format on output. See
  27305. @uref{https://mpd.readthedocs.io/en/latest/user.html#audio-output-format,Global
  27306. Audio Format} for a more detailed description.
  27307. @item @code{tags?} (default: @code{#t}) (type: boolean)
  27308. If set to @code{#f}, then MPD will not send tags to this output. This
  27309. is only useful for output plugins that can receive tags, for example the
  27310. @code{httpd} output plugin.
  27311. @item @code{always-on?} (default: @code{#f}) (type: boolean)
  27312. If set to @code{#t}, then MPD attempts to keep this audio output always
  27313. open. This may be useful for streaming servers, when you don’t want to
  27314. disconnect all listeners even when playback is accidentally stopped.
  27315. @item @code{mixer-type} (type: maybe-string)
  27316. This field accepts a string that specifies which mixer should be used
  27317. for this audio output: the @code{hardware} mixer, the @code{software}
  27318. mixer, the @code{null} mixer (allows setting the volume, but with no
  27319. effect; this can be used as a trick to implement an external mixer
  27320. External Mixer) or no mixer (@code{none}). When left unspecified, a
  27321. @code{hardware} mixer is used for devices that support it.
  27322. @item @code{replay-gain-handler} (type: maybe-string)
  27323. This field accepts a string that specifies how
  27324. @uref{https://mpd.readthedocs.io/en/latest/user.html#replay-gain,Replay
  27325. Gain} is to be applied. @code{software} uses an internal software
  27326. volume control, @code{mixer} uses the configured (hardware) mixer
  27327. control and @code{none} disables replay gain on this audio output.
  27328. @item @code{extra-options} (default: @code{'()}) (type: alist)
  27329. An association list of option symbols/strings to string values to be
  27330. appended to the audio output configuration.
  27331. @end table
  27332. @end deftp
  27333. @c %end of fragment
  27334. The following example shows a configuration of @command{mpd} that
  27335. configures some of its plugins and provides a HTTP audio streaming output.
  27336. @lisp
  27337. (service mpd-service-type
  27338. (mpd-configuration
  27339. (outputs
  27340. (list (mpd-output
  27341. (name "streaming")
  27342. (type "httpd")
  27343. (mixer-type 'null)
  27344. (extra-options
  27345. `((encoder . "vorbis")
  27346. (port . "8080"))))))
  27347. (decoders
  27348. (list (mpd-plugin
  27349. (plugin "mikmod")
  27350. (enabled? #f))
  27351. (mpd-plugin
  27352. (plugin "openmpt")
  27353. (enabled? #t)
  27354. (extra-options `((repeat-count . -1)
  27355. (interpolation-filter . 1))))))
  27356. (resampler (mpd-plugin
  27357. (plugin "libsamplerate")
  27358. (extra-options `((type . 0)))))))
  27359. @end lisp
  27360. @subsubheading myMPD
  27361. @cindex MPD, web interface
  27362. @cindex myMPD service
  27363. @uref{https://jcorporation.github.io/myMPD/, myMPD} is a web server
  27364. frontend for MPD that provides a mobile friendly web client for MPD.
  27365. The following example shows a myMPD instance listening on port 80,
  27366. with album cover caching disabled.
  27367. @lisp
  27368. (service mympd-service-type
  27369. (mympd-configuration
  27370. (port 80)
  27371. (covercache-ttl 0)))
  27372. @end lisp
  27373. @defvar mympd-service-type
  27374. The service type for @command{mympd}.
  27375. @end defvar
  27376. @c %start of fragment
  27377. @deftp {Data Type} mympd-configuration
  27378. Available @code{mympd-configuration} fields are:
  27379. @table @asis
  27380. @item @code{package} (default: @code{mympd}) (type: file-like)
  27381. The package object of the myMPD server.
  27382. @item @code{shepherd-requirement} (default: @code{'()}) (type: list-of-symbol)
  27383. This is a list of symbols naming Shepherd services that this service
  27384. will depend on.
  27385. @item @code{user} (default: @code{%mympd-user}) (type: user-account)
  27386. Owner of the @command{mympd} process.
  27387. The default @code{%mympd-user} is a system user with the name ``mympd'',
  27388. who is a part of the group @var{group} (see below).
  27389. @item @code{group} (default: @code{%mympd-group}) (type: user-group)
  27390. Owner group of the @command{mympd} process.
  27391. The default @code{%mympd-group} is a system group with name ``mympd''.
  27392. @item @code{work-directory} (default: @code{"/var/lib/mympd"}) (type: string)
  27393. Where myMPD will store its data.
  27394. @item @code{cache-directory} (default: @code{"/var/cache/mympd"}) (type: string)
  27395. Where myMPD will store its cache.
  27396. @item @code{acl} (type: maybe-mympd-ip-acl)
  27397. ACL to access the myMPD webserver.
  27398. @item @code{covercache-ttl} (default: @code{31}) (type: maybe-integer)
  27399. How long to keep cached covers, @code{0} disables cover caching.
  27400. @item @code{http?} (default: @code{#t}) (type: boolean)
  27401. HTTP support.
  27402. @item @code{host} (default: @code{"[::]"}) (type: string)
  27403. Host name to listen on.
  27404. @item @code{port} (default: @code{80}) (type: maybe-port)
  27405. HTTP port to listen on.
  27406. @item @code{log-level} (default: @code{5}) (type: integer)
  27407. How much detail to include in logs, possible values: @code{0} to
  27408. @code{7}.
  27409. @item @code{log-to} (type: maybe-string)
  27410. Where to send logs. Unless specified, the service logs to the local
  27411. syslog service under the @samp{daemon} facility. Alternatively, a log
  27412. file name can be specified, for example @file{/var/log/mympd.log}.
  27413. @item @code{lualibs} (default: @code{"all"}) (type: maybe-string)
  27414. See
  27415. @uref{https://jcorporation.github.io/myMPD/scripting/#lua-standard-libraries}.
  27416. @item @code{uri} (type: maybe-string)
  27417. Override URI to myMPD. See
  27418. @uref{https://github.com/jcorporation/myMPD/issues/950}.
  27419. @item @code{script-acl} (default: @code{(mympd-ip-acl (allow '("127.0.0.1")))}) (type: maybe-mympd-ip-acl)
  27420. ACL to access the myMPD script backend.
  27421. @item @code{ssl?} (default: @code{#f}) (type: boolean)
  27422. SSL/TLS support.
  27423. @item @code{ssl-port} (default: @code{443}) (type: maybe-port)
  27424. Port to listen for HTTPS.
  27425. @item @code{ssl-cert} (type: maybe-string)
  27426. Path to PEM encoded X.509 SSL/TLS certificate (public key).
  27427. @item @code{ssl-key} (type: maybe-string)
  27428. Path to PEM encoded SSL/TLS private key.
  27429. @item @code{pin-hash} (type: maybe-string)
  27430. SHA-256 hashed pin used by myMPD to control settings access by prompting
  27431. a pin from the user.
  27432. @item @code{save-caches?} (type: maybe-boolean)
  27433. Whether to preserve caches between service restarts.
  27434. @end table
  27435. @end deftp
  27436. @c %end of fragment
  27437. @c %start of fragment
  27438. @deftp {Data Type} mympd-ip-acl
  27439. Available @code{mympd-ip-acl} fields are:
  27440. @table @asis
  27441. @item @code{allow} (default: @code{'()}) (type: list-of-strings)
  27442. Allowed IP addresses.
  27443. @item @code{deny} (default: @code{'()}) (type: list-of-strings)
  27444. Disallowed IP addresses.
  27445. @end table
  27446. @end deftp
  27447. @c %end of fragment
  27448. @node Virtualization Services
  27449. @subsection Virtualization Services
  27450. The @code{(gnu services virtualization)} module provides services for
  27451. the libvirt and virtlog daemons, as well as other virtualization-related
  27452. services.
  27453. @subsubheading Libvirt daemon
  27454. @code{libvirtd} is the server side daemon component of the libvirt
  27455. virtualization management system. This daemon runs on host servers
  27456. and performs required management tasks for virtualized guests.
  27457. @defvar libvirt-service-type
  27458. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  27459. Its value must be a @code{libvirt-configuration}.
  27460. @lisp
  27461. (service libvirt-service-type
  27462. (libvirt-configuration
  27463. (unix-sock-group "libvirt")
  27464. (tls-port "16555")))
  27465. @end lisp
  27466. @end defvar
  27467. @c Auto-generated with (generate-libvirt-documentation)
  27468. Available @code{libvirt-configuration} fields are:
  27469. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  27470. Libvirt package.
  27471. @end deftypevr
  27472. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  27473. Flag listening for secure TLS connections on the public TCP/IP port.
  27474. You must set @code{listen} for this to have any effect.
  27475. It is necessary to setup a CA and issue server certificates before using
  27476. this capability.
  27477. Defaults to @samp{#t}.
  27478. @end deftypevr
  27479. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  27480. Listen for unencrypted TCP connections on the public TCP/IP port. You must
  27481. set @code{listen} for this to have any effect.
  27482. Using the TCP socket requires SASL authentication by default. Only SASL
  27483. mechanisms which support data encryption are allowed. This is
  27484. DIGEST_MD5 and GSSAPI (Kerberos5).
  27485. Defaults to @samp{#f}.
  27486. @end deftypevr
  27487. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  27488. Port for accepting secure TLS connections. This can be a port number,
  27489. or service name.
  27490. Defaults to @samp{"16514"}.
  27491. @end deftypevr
  27492. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  27493. Port for accepting insecure TCP connections. This can be a port number,
  27494. or service name.
  27495. Defaults to @samp{"16509"}.
  27496. @end deftypevr
  27497. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  27498. IP address or hostname used for client connections.
  27499. Defaults to @samp{"0.0.0.0"}.
  27500. @end deftypevr
  27501. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  27502. Flag toggling mDNS advertisement of the libvirt service.
  27503. Alternatively can disable for all services on a host by stopping the
  27504. Avahi daemon.
  27505. Defaults to @samp{#f}.
  27506. @end deftypevr
  27507. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  27508. Default mDNS advertisement name. This must be unique on the immediate
  27509. broadcast network.
  27510. Defaults to @samp{"Virtualization Host <hostname>"}.
  27511. @end deftypevr
  27512. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  27513. UNIX domain socket group ownership. This can be used to allow a
  27514. 'trusted' set of users access to management capabilities without
  27515. becoming root.
  27516. Defaults to @samp{"root"}.
  27517. @end deftypevr
  27518. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  27519. UNIX socket permissions for the R/O socket. This is used for monitoring
  27520. VM status only.
  27521. Defaults to @samp{"0777"}.
  27522. @end deftypevr
  27523. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  27524. UNIX socket permissions for the R/W socket. Default allows only root.
  27525. If PolicyKit is enabled on the socket, the default will change to allow
  27526. everyone (eg, 0777)
  27527. Defaults to @samp{"0770"}.
  27528. @end deftypevr
  27529. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  27530. UNIX socket permissions for the admin socket. Default allows only owner
  27531. (root), do not change it unless you are sure to whom you are exposing
  27532. the access to.
  27533. Defaults to @samp{"0777"}.
  27534. @end deftypevr
  27535. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  27536. The directory in which sockets will be found/created.
  27537. Defaults to @samp{"/var/run/libvirt"}.
  27538. @end deftypevr
  27539. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  27540. Authentication scheme for UNIX read-only sockets. By default socket
  27541. permissions allow anyone to connect
  27542. Defaults to @samp{"polkit"}.
  27543. @end deftypevr
  27544. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  27545. Authentication scheme for UNIX read-write sockets. By default socket
  27546. permissions only allow root. If PolicyKit support was compiled into
  27547. libvirt, the default will be to use 'polkit' auth.
  27548. Defaults to @samp{"polkit"}.
  27549. @end deftypevr
  27550. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  27551. Authentication scheme for TCP sockets. If you don't enable SASL, then
  27552. all TCP traffic is cleartext. Don't do this outside of a dev/test
  27553. scenario.
  27554. Defaults to @samp{"sasl"}.
  27555. @end deftypevr
  27556. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  27557. Authentication scheme for TLS sockets. TLS sockets already have
  27558. encryption provided by the TLS layer, and limited authentication is done
  27559. by certificates.
  27560. It is possible to make use of any SASL authentication mechanism as well,
  27561. by using 'sasl' for this option
  27562. Defaults to @samp{"none"}.
  27563. @end deftypevr
  27564. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  27565. API access control scheme.
  27566. By default an authenticated user is allowed access to all APIs. Access
  27567. drivers can place restrictions on this.
  27568. Defaults to @samp{'()}.
  27569. @end deftypevr
  27570. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  27571. Server key file path. If set to an empty string, then no private key is
  27572. loaded.
  27573. Defaults to @samp{""}.
  27574. @end deftypevr
  27575. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  27576. Server key file path. If set to an empty string, then no certificate is
  27577. loaded.
  27578. Defaults to @samp{""}.
  27579. @end deftypevr
  27580. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  27581. Server key file path. If set to an empty string, then no CA certificate
  27582. is loaded.
  27583. Defaults to @samp{""}.
  27584. @end deftypevr
  27585. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  27586. Certificate revocation list path. If set to an empty string, then no
  27587. CRL is loaded.
  27588. Defaults to @samp{""}.
  27589. @end deftypevr
  27590. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  27591. Disable verification of our own server certificates.
  27592. When libvirtd starts it performs some sanity checks against its own
  27593. certificates.
  27594. Defaults to @samp{#f}.
  27595. @end deftypevr
  27596. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  27597. Disable verification of client certificates.
  27598. Client certificate verification is the primary authentication mechanism.
  27599. Any client which does not present a certificate signed by the CA will be
  27600. rejected.
  27601. Defaults to @samp{#f}.
  27602. @end deftypevr
  27603. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  27604. Whitelist of allowed x509 Distinguished Name.
  27605. Defaults to @samp{'()}.
  27606. @end deftypevr
  27607. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  27608. Whitelist of allowed SASL usernames. The format for username depends on
  27609. the SASL authentication mechanism.
  27610. Defaults to @samp{'()}.
  27611. @end deftypevr
  27612. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  27613. Override the compile time default TLS priority string. The default is
  27614. usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
  27615. is desired for libvirt to deviate from the global default settings.
  27616. Defaults to @samp{"NORMAL"}.
  27617. @end deftypevr
  27618. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  27619. Maximum number of concurrent client connections to allow over all
  27620. sockets combined.
  27621. Defaults to @samp{5000}.
  27622. @end deftypevr
  27623. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  27624. Maximum length of queue of connections waiting to be accepted by the
  27625. daemon. Note, that some protocols supporting retransmission may obey
  27626. this so that a later reattempt at connection succeeds.
  27627. Defaults to @samp{1000}.
  27628. @end deftypevr
  27629. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  27630. Maximum length of queue of accepted but not yet authenticated clients.
  27631. Set this to zero to turn this feature off
  27632. Defaults to @samp{20}.
  27633. @end deftypevr
  27634. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  27635. Number of workers to start up initially.
  27636. Defaults to @samp{5}.
  27637. @end deftypevr
  27638. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  27639. Maximum number of worker threads.
  27640. If the number of active clients exceeds @code{min-workers}, then more
  27641. threads are spawned, up to max_workers limit. Typically you'd want
  27642. max_workers to equal maximum number of clients allowed.
  27643. Defaults to @samp{20}.
  27644. @end deftypevr
  27645. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  27646. Number of priority workers. If all workers from above pool are stuck,
  27647. some calls marked as high priority (notably domainDestroy) can be
  27648. executed in this pool.
  27649. Defaults to @samp{5}.
  27650. @end deftypevr
  27651. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  27652. Total global limit on concurrent RPC calls.
  27653. Defaults to @samp{20}.
  27654. @end deftypevr
  27655. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  27656. Limit on concurrent requests from a single client connection. To avoid
  27657. one client monopolizing the server this should be a small fraction of
  27658. the global max_requests and max_workers parameter.
  27659. Defaults to @samp{5}.
  27660. @end deftypevr
  27661. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  27662. Same as @code{min-workers} but for the admin interface.
  27663. Defaults to @samp{1}.
  27664. @end deftypevr
  27665. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  27666. Same as @code{max-workers} but for the admin interface.
  27667. Defaults to @samp{5}.
  27668. @end deftypevr
  27669. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  27670. Same as @code{max-clients} but for the admin interface.
  27671. Defaults to @samp{5}.
  27672. @end deftypevr
  27673. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  27674. Same as @code{max-queued-clients} but for the admin interface.
  27675. Defaults to @samp{5}.
  27676. @end deftypevr
  27677. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  27678. Same as @code{max-client-requests} but for the admin interface.
  27679. Defaults to @samp{5}.
  27680. @end deftypevr
  27681. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  27682. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  27683. Defaults to @samp{3}.
  27684. @end deftypevr
  27685. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  27686. Logging filters.
  27687. A filter allows to select a different logging level for a given category
  27688. of logs. The format for a filter is one of:
  27689. @itemize @bullet
  27690. @item
  27691. x:name
  27692. @item
  27693. x:+name
  27694. @end itemize
  27695. where @code{name} is a string which is matched against the category
  27696. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  27697. file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
  27698. name in the filter can be a substring of the full category name, in
  27699. order to match multiple similar categories), the optional @samp{"+"}
  27700. prefix tells libvirt to log stack trace for each message matching name,
  27701. and @code{x} is the minimal level where matching messages should be
  27702. logged:
  27703. @itemize @bullet
  27704. @item
  27705. 1: DEBUG
  27706. @item
  27707. 2: INFO
  27708. @item
  27709. 3: WARNING
  27710. @item
  27711. 4: ERROR
  27712. @end itemize
  27713. Multiple filters can be defined in a single filters statement, they just
  27714. need to be separated by spaces.
  27715. Defaults to @samp{"3:remote 4:event"}.
  27716. @end deftypevr
  27717. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  27718. Logging outputs.
  27719. An output is one of the places to save logging information. The format
  27720. for an output can be:
  27721. @table @code
  27722. @item x:stderr
  27723. output goes to stderr
  27724. @item x:syslog:name
  27725. use syslog for the output and use the given name as the ident
  27726. @item x:file:file_path
  27727. output to a file, with the given filepath
  27728. @item x:journald
  27729. output to journald logging system
  27730. @end table
  27731. In all case the x prefix is the minimal level, acting as a filter
  27732. @itemize @bullet
  27733. @item
  27734. 1: DEBUG
  27735. @item
  27736. 2: INFO
  27737. @item
  27738. 3: WARNING
  27739. @item
  27740. 4: ERROR
  27741. @end itemize
  27742. Multiple outputs can be defined, they just need to be separated by
  27743. spaces.
  27744. Defaults to @samp{"3:stderr"}.
  27745. @end deftypevr
  27746. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  27747. Allows usage of the auditing subsystem to be altered
  27748. @itemize @bullet
  27749. @item
  27750. 0: disable all auditing
  27751. @item
  27752. 1: enable auditing, only if enabled on host
  27753. @item
  27754. 2: enable auditing, and exit if disabled on host.
  27755. @end itemize
  27756. Defaults to @samp{1}.
  27757. @end deftypevr
  27758. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  27759. Send audit messages via libvirt logging infrastructure.
  27760. Defaults to @samp{#f}.
  27761. @end deftypevr
  27762. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  27763. Host UUID@. UUID must not have all digits be the same.
  27764. Defaults to @samp{""}.
  27765. @end deftypevr
  27766. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  27767. Source to read host UUID.
  27768. @itemize @bullet
  27769. @item
  27770. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  27771. @item
  27772. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  27773. @end itemize
  27774. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  27775. be generated.
  27776. Defaults to @samp{"smbios"}.
  27777. @end deftypevr
  27778. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  27779. A keepalive message is sent to a client after @code{keepalive_interval}
  27780. seconds of inactivity to check if the client is still responding. If
  27781. set to -1, libvirtd will never send keepalive requests; however clients
  27782. can still send them and the daemon will send responses.
  27783. Defaults to @samp{5}.
  27784. @end deftypevr
  27785. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  27786. Maximum number of keepalive messages that are allowed to be sent to the
  27787. client without getting any response before the connection is considered
  27788. broken.
  27789. In other words, the connection is automatically closed approximately
  27790. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  27791. the last message received from the client. When @code{keepalive-count}
  27792. is set to 0, connections will be automatically closed after
  27793. @code{keepalive-interval} seconds of inactivity without sending any
  27794. keepalive messages.
  27795. Defaults to @samp{5}.
  27796. @end deftypevr
  27797. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  27798. Same as above but for admin interface.
  27799. Defaults to @samp{5}.
  27800. @end deftypevr
  27801. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  27802. Same as above but for admin interface.
  27803. Defaults to @samp{5}.
  27804. @end deftypevr
  27805. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  27806. Timeout for Open vSwitch calls.
  27807. The @code{ovs-vsctl} utility is used for the configuration and its
  27808. timeout option is set by default to 5 seconds to avoid potential
  27809. infinite waits blocking libvirt.
  27810. Defaults to @samp{5}.
  27811. @end deftypevr
  27812. @c %end of autogenerated docs
  27813. @subsubheading Virtlog daemon
  27814. The virtlogd service is a server side daemon component of libvirt that is
  27815. used to manage logs from virtual machine consoles.
  27816. This daemon is not used directly by libvirt client applications, rather it
  27817. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  27818. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  27819. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  27820. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  27821. @defvar virtlog-service-type
  27822. This is the type of the virtlog daemon.
  27823. Its value must be a @code{virtlog-configuration}.
  27824. @lisp
  27825. (service virtlog-service-type
  27826. (virtlog-configuration
  27827. (max-clients 1000)))
  27828. @end lisp
  27829. @end defvar
  27830. @deftypevr {@code{libvirt} parameter} package libvirt
  27831. Libvirt package.
  27832. @end deftypevr
  27833. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  27834. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  27835. Defaults to @samp{3}.
  27836. @end deftypevr
  27837. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  27838. Logging filters.
  27839. A filter allows to select a different logging level for a given category
  27840. of logs The format for a filter is one of:
  27841. @itemize @bullet
  27842. @item
  27843. x:name
  27844. @item
  27845. x:+name
  27846. @end itemize
  27847. where @code{name} is a string which is matched against the category
  27848. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  27849. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  27850. be a substring of the full category name, in order to match multiple
  27851. similar categories), the optional "+" prefix tells libvirt to log stack
  27852. trace for each message matching name, and @code{x} is the minimal level
  27853. where matching messages should be logged:
  27854. @itemize @bullet
  27855. @item
  27856. 1: DEBUG
  27857. @item
  27858. 2: INFO
  27859. @item
  27860. 3: WARNING
  27861. @item
  27862. 4: ERROR
  27863. @end itemize
  27864. Multiple filters can be defined in a single filters statement, they just
  27865. need to be separated by spaces.
  27866. Defaults to @samp{"3:remote 4:event"}.
  27867. @end deftypevr
  27868. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  27869. Logging outputs.
  27870. An output is one of the places to save logging information The format
  27871. for an output can be:
  27872. @table @code
  27873. @item x:stderr
  27874. output goes to stderr
  27875. @item x:syslog:name
  27876. use syslog for the output and use the given name as the ident
  27877. @item x:file:file_path
  27878. output to a file, with the given filepath
  27879. @item x:journald
  27880. output to journald logging system
  27881. @end table
  27882. In all case the x prefix is the minimal level, acting as a filter
  27883. @itemize @bullet
  27884. @item
  27885. 1: DEBUG
  27886. @item
  27887. 2: INFO
  27888. @item
  27889. 3: WARNING
  27890. @item
  27891. 4: ERROR
  27892. @end itemize
  27893. Multiple outputs can be defined, they just need to be separated by
  27894. spaces.
  27895. Defaults to @samp{"3:stderr"}.
  27896. @end deftypevr
  27897. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  27898. Maximum number of concurrent client connections to allow over all
  27899. sockets combined.
  27900. Defaults to @samp{1024}.
  27901. @end deftypevr
  27902. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  27903. Maximum file size before rolling over.
  27904. Defaults to @samp{2MB}
  27905. @end deftypevr
  27906. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  27907. Maximum number of backup files to keep.
  27908. Defaults to @samp{3}
  27909. @end deftypevr
  27910. @anchor{transparent-emulation-qemu}
  27911. @subsubheading Transparent Emulation with QEMU
  27912. @cindex emulation
  27913. @cindex @code{binfmt_misc}
  27914. @code{qemu-binfmt-service-type} provides support for transparent
  27915. emulation of program binaries built for different architectures---e.g.,
  27916. it allows you to transparently execute an ARMv7 program on an x86_64
  27917. machine. It achieves this by combining the @uref{https://www.qemu.org,
  27918. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  27919. This feature only allows you to emulate GNU/Linux on a different
  27920. architecture, but see below for GNU/Hurd support.
  27921. @defvar qemu-binfmt-service-type
  27922. This is the type of the QEMU/binfmt service for transparent emulation.
  27923. Its value must be a @code{qemu-binfmt-configuration} object, which
  27924. specifies the QEMU package to use as well as the architecture we want to
  27925. emulated:
  27926. @lisp
  27927. (service qemu-binfmt-service-type
  27928. (qemu-binfmt-configuration
  27929. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  27930. @end lisp
  27931. In this example, we enable transparent emulation for the ARM and aarch64
  27932. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  27933. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  27934. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  27935. @end defvar
  27936. @deftp {Data Type} qemu-binfmt-configuration
  27937. This is the configuration for the @code{qemu-binfmt} service.
  27938. @table @asis
  27939. @item @code{platforms} (default: @code{'()})
  27940. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  27941. object} as returned by @code{lookup-qemu-platforms} (see below).
  27942. For example, let's suppose you're on an x86_64 machine and you have this
  27943. service:
  27944. @lisp
  27945. (service qemu-binfmt-service-type
  27946. (qemu-binfmt-configuration
  27947. (platforms (lookup-qemu-platforms "arm"))))
  27948. @end lisp
  27949. You can run:
  27950. @example
  27951. guix build -s armhf-linux inkscape
  27952. @end example
  27953. @noindent
  27954. and it will build Inkscape for ARMv7 @emph{as if it were a native
  27955. build}, transparently using QEMU to emulate the ARMv7 CPU@. Pretty handy
  27956. if you'd like to test a package build for an architecture you don't have
  27957. access to!
  27958. @item @code{qemu} (default: @code{qemu})
  27959. The QEMU package to use.
  27960. @end table
  27961. @end deftp
  27962. @deffn {Procedure} lookup-qemu-platforms platforms@dots{}
  27963. Return the list of QEMU platform objects corresponding to
  27964. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  27965. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  27966. @code{"mips64el"}, and so on.
  27967. @end deffn
  27968. @deffn {Procedure} qemu-platform? obj
  27969. Return true if @var{obj} is a platform object.
  27970. @end deffn
  27971. @deffn {Procedure} qemu-platform-name platform
  27972. Return the name of @var{platform}---a string such as @code{"arm"}.
  27973. @end deffn
  27974. @subsubheading QEMU Guest Agent
  27975. @cindex emulation
  27976. The QEMU guest agent provides control over the emulated system to the
  27977. host. The @code{qemu-guest-agent} service runs the agent on Guix
  27978. guests. To control the agent from the host, open a socket by invoking
  27979. QEMU with the following arguments:
  27980. @example
  27981. qemu-system-x86_64 \
  27982. -chardev socket,path=/tmp/qga.sock,server=on,wait=off,id=qga0 \
  27983. -device virtio-serial \
  27984. -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
  27985. ...
  27986. @end example
  27987. This creates a socket at @file{/tmp/qga.sock} on the host. Once the
  27988. guest agent is running, you can issue commands with @code{socat}:
  27989. @example
  27990. $ guix shell socat -- socat unix-connect:/tmp/qga.sock stdio
  27991. @{"execute": "guest-get-host-name"@}
  27992. @{"return": @{"host-name": "guix"@}@}
  27993. @end example
  27994. See @url{https://wiki.qemu.org/Features/GuestAgent,QEMU guest agent
  27995. documentation} for more options and commands.
  27996. @defvar qemu-guest-agent-service-type
  27997. Service type for the QEMU guest agent service.
  27998. @end defvar
  27999. @deftp {Data Type} qemu-guest-agent-configuration
  28000. Configuration for the @code{qemu-guest-agent} service.
  28001. @table @asis
  28002. @item @code{qemu} (default: @code{qemu-minimal})
  28003. The QEMU package to use.
  28004. @item @code{device} (default: @code{""})
  28005. File name of the device or socket the agent uses to communicate with the
  28006. host. If empty, QEMU uses a default file name.
  28007. @end table
  28008. @end deftp
  28009. @subsubheading The Hurd in a Virtual Machine
  28010. @cindex @code{hurd}
  28011. @cindex the Hurd
  28012. @cindex childhurd
  28013. Service @code{hurd-vm} provides support for running GNU/Hurd in a
  28014. virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
  28015. to be used on GNU/Linux and the given GNU/Hurd operating system
  28016. configuration is cross-compiled. The virtual machine is a Shepherd
  28017. service that can be referred to by the names @code{hurd-vm} and
  28018. @code{childhurd} and be controlled with commands such as:
  28019. @example
  28020. herd start hurd-vm
  28021. herd stop childhurd
  28022. @end example
  28023. When the service is running, you can view its console by connecting to
  28024. it with a VNC client, for example with:
  28025. @example
  28026. guix shell tigervnc-client -- vncviewer localhost:5900
  28027. @end example
  28028. The default configuration (see @code{hurd-vm-configuration} below)
  28029. spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
  28030. (the virtual machine emulator) redirects to port 10222 on the host.
  28031. Thus, you can connect over SSH to the childhurd with:
  28032. @example
  28033. ssh root@@localhost -p 10022
  28034. @end example
  28035. The childhurd is volatile and stateless: it starts with a fresh root
  28036. file system every time you restart it. By default though, all the files
  28037. under @file{/etc/childhurd} on the host are copied as is to the root
  28038. file system of the childhurd when it boots. This allows you to
  28039. initialize ``secrets'' inside the VM: SSH host keys, authorized
  28040. substitute keys, and so on---see the explanation of @code{secret-root}
  28041. below.
  28042. @defvar hurd-vm-service-type
  28043. This is the type of the Hurd in a Virtual Machine service. Its value
  28044. must be a @code{hurd-vm-configuration} object, which specifies the
  28045. operating system (@pxref{operating-system Reference}) and the disk size
  28046. for the Hurd Virtual Machine, the QEMU package to use as well as the
  28047. options for running it.
  28048. For example:
  28049. @lisp
  28050. (service hurd-vm-service-type
  28051. (hurd-vm-configuration
  28052. (disk-size (* 5000 (expt 2 20))) ;5G
  28053. (memory-size 1024))) ;1024MiB
  28054. @end lisp
  28055. would create a disk image big enough to build GNU@tie{}Hello, with some
  28056. extra memory.
  28057. @end defvar
  28058. @deftp {Data Type} hurd-vm-configuration
  28059. The data type representing the configuration for
  28060. @code{hurd-vm-service-type}.
  28061. @table @asis
  28062. @item @code{os} (default: @var{%hurd-vm-operating-system})
  28063. The operating system to instantiate. This default is bare-bones with a
  28064. permissive OpenSSH secure shell daemon listening on port 2222
  28065. (@pxref{Networking Services, @code{openssh-service-type}}).
  28066. @item @code{qemu} (default: @code{qemu-minimal})
  28067. The QEMU package to use.
  28068. @item @code{image} (default: @var{hurd-vm-disk-image})
  28069. The procedure used to build the disk-image built from this
  28070. configuration.
  28071. @item @code{disk-size} (default: @code{'guess})
  28072. The size of the disk image.
  28073. @item @code{memory-size} (default: @code{512})
  28074. The memory size of the Virtual Machine in mebibytes.
  28075. @item @code{options} (default: @code{'("--snapshot")})
  28076. The extra options for running QEMU.
  28077. @item @code{id} (default: @code{#f})
  28078. If set, a non-zero positive integer used to parameterize Childhurd
  28079. instances. It is appended to the service's name,
  28080. e.g. @code{childhurd1}.
  28081. @item @code{net-options} (default: @var{hurd-vm-net-options})
  28082. The procedure used to produce the list of QEMU networking options.
  28083. By default, it produces
  28084. @lisp
  28085. '("--device" "rtl8139,netdev=net0"
  28086. "--netdev" (string-append
  28087. "user,id=net0,"
  28088. "hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004,"
  28089. "hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222,"
  28090. "hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900"))
  28091. @end lisp
  28092. with forwarded ports:
  28093. @example
  28094. @var{secrets-port}: @code{(+ 11004 (* 1000 @var{ID}))}
  28095. @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
  28096. @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
  28097. @end example
  28098. @item @code{secret-root} (default: @file{/etc/childhurd})
  28099. The root directory with out-of-band secrets to be installed into the
  28100. childhurd once it runs. Childhurds are volatile which means that on
  28101. every startup, secrets such as the SSH host keys and Guix signing key
  28102. are recreated.
  28103. If the @file{/etc/childhurd} directory does not exist, the
  28104. @code{secret-service} running in the Childhurd will be sent an empty
  28105. list of secrets.
  28106. By default, the service automatically populates @file{/etc/childhurd}
  28107. with the following non-volatile secrets, unless they already exist:
  28108. @example
  28109. /etc/childhurd/etc/guix/acl
  28110. /etc/childhurd/etc/guix/signing-key.pub
  28111. /etc/childhurd/etc/guix/signing-key.sec
  28112. /etc/childhurd/etc/ssh/ssh_host_ed25519_key
  28113. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
  28114. /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
  28115. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
  28116. @end example
  28117. These files are automatically sent to the guest Hurd VM when it boots,
  28118. including permissions.
  28119. @cindex childhurd, offloading
  28120. @cindex Hurd, offloading
  28121. Having these files in place means that only a couple of things are
  28122. missing to allow the host to offload @code{i586-gnu} builds to the
  28123. childhurd:
  28124. @enumerate
  28125. @item
  28126. Authorizing the childhurd's key on the host so that the host accepts
  28127. build results coming from the childhurd, which can be done like so:
  28128. @example
  28129. guix archive --authorize < \
  28130. /etc/childhurd/etc/guix/signing-key.pub
  28131. @end example
  28132. @item
  28133. Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
  28134. Offload Setup}).
  28135. @end enumerate
  28136. We're working towards making that happen automatically---get in touch
  28137. with us at @email{guix-devel@@gnu.org} to discuss it!
  28138. @end table
  28139. @end deftp
  28140. Note that by default the VM image is volatile, i.e., once stopped the
  28141. contents are lost. If you want a stateful image instead, override the
  28142. configuration's @code{image} and @code{options} without
  28143. the @code{--snapshot} flag using something along these lines:
  28144. @lisp
  28145. (service hurd-vm-service-type
  28146. (hurd-vm-configuration
  28147. (image (const "/out/of/store/writable/hurd.img"))
  28148. (options '())))
  28149. @end lisp
  28150. @subsubheading Ganeti
  28151. @cindex ganeti
  28152. @quotation Note
  28153. This service is considered experimental. Configuration options may be changed
  28154. in a backwards-incompatible manner, and not all features have been thorougly
  28155. tested. Users of this service are encouraged to share their experience at
  28156. @email{guix-devel@@gnu.org}.
  28157. @end quotation
  28158. Ganeti is a virtual machine management system. It is designed to keep virtual
  28159. machines running on a cluster of servers even in the event of hardware failures,
  28160. and to make maintenance and recovery tasks easy. It consists of multiple
  28161. services which are described later in this section. In addition to the Ganeti
  28162. service, you will need the OpenSSH service (@pxref{Networking Services,
  28163. @code{openssh-service-type}}), and update the @file{/etc/hosts} file
  28164. (@pxref{Service Reference, @code{hosts-service-type}}) with the cluster name
  28165. and address (or use a DNS server).
  28166. All nodes participating in a Ganeti cluster should have the same Ganeti and
  28167. @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
  28168. cluster node that supports multiple storage backends, and installs the
  28169. @code{debootstrap} and @code{guix} @dfn{OS providers}:
  28170. @lisp
  28171. (use-package-modules virtualization)
  28172. (use-service-modules base ganeti networking ssh)
  28173. (operating-system
  28174. ;; @dots{}
  28175. (host-name "node1")
  28176. ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
  28177. ;; in order to use the "plain", "drbd" and "rbd" storage backends.
  28178. (packages (append (map specification->package
  28179. '("qemu" "lvm2" "drbd-utils" "ceph"
  28180. ;; Add the debootstrap and guix OS providers.
  28181. "ganeti-instance-guix" "ganeti-instance-debootstrap"))
  28182. %base-packages))
  28183. (services
  28184. (append (list (service static-networking-service-type
  28185. (list (static-networking
  28186. (addresses
  28187. (list (network-address
  28188. (device "eth0")
  28189. (value "192.168.1.201/24"))))
  28190. (routes
  28191. (list (network-route
  28192. (destination "default")
  28193. (gateway "192.168.1.254"))))
  28194. (name-servers '("192.168.1.252"
  28195. "192.168.1.253")))))
  28196. ;; Ganeti uses SSH to communicate between nodes.
  28197. (service openssh-service-type
  28198. (openssh-configuration
  28199. (permit-root-login 'prohibit-password)))
  28200. (simple-service 'ganeti-hosts-entries hosts-service-type
  28201. (list
  28202. (host "192.168.1.200" "ganeti.example.com")
  28203. (host "192.168.1.201" "node1.example.com"
  28204. '("node1"))
  28205. (host "192.168.1.202" "node2.example.com"
  28206. '("node2"))))
  28207. (service ganeti-service-type
  28208. (ganeti-configuration
  28209. ;; This list specifies allowed file system paths
  28210. ;; for storing virtual machine images.
  28211. (file-storage-paths '("/srv/ganeti/file-storage"))
  28212. ;; This variable configures a single "variant" for
  28213. ;; both Debootstrap and Guix that works with KVM.
  28214. (os %default-ganeti-os))))
  28215. %base-services)))
  28216. @end lisp
  28217. Users are advised to read the
  28218. @url{https://docs.ganeti.org/docs/ganeti/3.0/html/admin.html,Ganeti
  28219. administrators guide} to learn about the various cluster options and
  28220. day-to-day operations. There is also a
  28221. @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
  28222. describing how to configure and initialize a small cluster.
  28223. @defvar ganeti-service-type
  28224. This is a service type that includes all the various services that Ganeti
  28225. nodes should run.
  28226. Its value is a @code{ganeti-configuration} object that defines the package
  28227. to use for CLI operations, as well as configuration for the various daemons.
  28228. Allowed file storage paths and available guest operating systems are also
  28229. configured through this data type.
  28230. @end defvar
  28231. @deftp {Data Type} ganeti-configuration
  28232. The @code{ganeti} service takes the following configuration options:
  28233. @table @asis
  28234. @item @code{ganeti} (default: @code{ganeti})
  28235. The @code{ganeti} package to use. It will be installed to the system profile
  28236. and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
  28237. that the value specified here does not affect the other services as each refer
  28238. to a specific @code{ganeti} package (see below).
  28239. @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
  28240. @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
  28241. @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
  28242. @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
  28243. @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
  28244. @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
  28245. @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
  28246. @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
  28247. @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
  28248. @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
  28249. These options control the various daemons and cron jobs that are distributed
  28250. with Ganeti. The possible values for these are described in detail below.
  28251. To override a setting, you must use the configuration type for that service:
  28252. @lisp
  28253. (service ganeti-service-type
  28254. (ganeti-configuration
  28255. (rapi-configuration
  28256. (ganeti-rapi-configuration
  28257. (interface "eth1"))))
  28258. (watcher-configuration
  28259. (ganeti-watcher-configuration
  28260. (rapi-ip "10.0.0.1"))))
  28261. @end lisp
  28262. @item @code{file-storage-paths} (default: @code{'()})
  28263. List of allowed directories for file storage backend.
  28264. @item @code{hooks} (default: @code{#f})
  28265. When set, this should be a file-like object containing a directory with
  28266. @url{https://docs.ganeti.org/docs/ganeti/3.0/html/hooks.html,cluster execution hooks}.
  28267. @item @code{os} (default: @code{%default-ganeti-os})
  28268. List of @code{<ganeti-os>} records.
  28269. @end table
  28270. In essence @code{ganeti-service-type} is shorthand for declaring each service
  28271. individually:
  28272. @lisp
  28273. (service ganeti-noded-service-type)
  28274. (service ganeti-confd-service-type)
  28275. (service ganeti-wconfd-service-type)
  28276. (service ganeti-luxid-service-type)
  28277. (service ganeti-kvmd-service-type)
  28278. (service ganeti-mond-service-type)
  28279. (service ganeti-metad-service-type)
  28280. (service ganeti-watcher-service-type)
  28281. (service ganeti-cleaner-service-type)
  28282. @end lisp
  28283. Plus a service extension for @code{etc-service-type} that configures the file
  28284. storage backend and OS variants.
  28285. @end deftp
  28286. @deftp {Data Type} ganeti-os
  28287. This data type is suitable for passing to the @code{os} parameter of
  28288. @code{ganeti-configuration}. It takes the following parameters:
  28289. @table @asis
  28290. @item @code{name}
  28291. The name for this OS provider. It is only used to specify where the
  28292. configuration ends up. Setting it to ``debootstrap'' will create
  28293. @file{/etc/ganeti/instance-debootstrap}.
  28294. @item @code{extension} (default: @code{#f})
  28295. The file extension for variants of this OS type. For example @file{.conf}
  28296. or @file{.scm}. It will be appended to the variant file name if set.
  28297. @item @code{variants} (default: @code{'()})
  28298. This must be either a list of @code{ganeti-os-variant} objects for this OS,
  28299. or a ``file-like'' object (@pxref{G-Expressions, file-like objects})
  28300. representing the variants directory.
  28301. To use the Guix OS provider with variant definitions residing in a local
  28302. directory instead of declaring individual variants (see @var{guix-variants}
  28303. below), you can do:
  28304. @lisp
  28305. (ganeti-os
  28306. (name "guix")
  28307. (variants (local-file "ganeti-guix-variants"
  28308. #:recursive? #true)))
  28309. @end lisp
  28310. Note that you will need to maintain the @file{variants.list} file
  28311. (see @code{@url{https://docs.ganeti.org/docs/ganeti/3.0/man/ganeti-os-interface.html,
  28312. ganeti-os-interface(7)}})
  28313. manually in this case.
  28314. @end table
  28315. @end deftp
  28316. @deftp {Data Type} ganeti-os-variant
  28317. This is the data type for a Ganeti OS variant. It takes the following
  28318. parameters:
  28319. @table @asis
  28320. @item @code{name}
  28321. The name of this variant.
  28322. @item @code{configuration}
  28323. A configuration file for this variant.
  28324. @end table
  28325. @end deftp
  28326. @defvar %default-debootstrap-hooks
  28327. This variable contains hooks to configure networking and the GRUB bootloader.
  28328. @end defvar
  28329. @defvar %default-debootstrap-extra-pkgs
  28330. This variable contains a list of packages suitable for a fully-virtualized guest.
  28331. @end defvar
  28332. @deftp {Data Type} debootstrap-configuration
  28333. This data type creates configuration files suitable for the debootstrap OS provider.
  28334. @table @asis
  28335. @item @code{hooks} (default: @code{%default-debootstrap-hooks})
  28336. When not @code{#f}, this must be a G-expression that specifies a directory with
  28337. scripts that will run when the OS is installed. It can also be a list of
  28338. @code{(name . file-like)} pairs. For example:
  28339. @lisp
  28340. `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
  28341. @end lisp
  28342. That will create a directory with one executable named @code{99-hello-world}
  28343. and run it every time this variant is installed. If set to @code{#f}, hooks
  28344. in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
  28345. @item @code{proxy} (default: @code{#f})
  28346. Optional HTTP proxy to use.
  28347. @item @code{mirror} (default: @code{#f})
  28348. The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
  28349. The default varies depending on the distribution.
  28350. @item @code{arch} (default: @code{#f})
  28351. The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
  28352. on an AArch64 host. Default is to use the current system architecture.
  28353. @item @code{suite} (default: @code{"stable"})
  28354. When set, this must be a Debian distribution ``suite'' such as @code{buster}
  28355. or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
  28356. @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
  28357. List of extra packages that will get installed by dpkg in addition
  28358. to the minimal system.
  28359. @item @code{components} (default: @code{#f})
  28360. When set, must be a list of Debian repository ``components''. For example
  28361. @code{'("main" "contrib")}.
  28362. @item @code{generate-cache?} (default: @code{#t})
  28363. Whether to automatically cache the generated debootstrap archive.
  28364. @item @code{clean-cache} (default: @code{14})
  28365. Discard the cache after this amount of days. Use @code{#f} to never
  28366. clear the cache.
  28367. @item @code{partition-style} (default: @code{'msdos})
  28368. The type of partition to create. When set, it must be one of
  28369. @code{'msdos}, @code{'none} or a string.
  28370. @item @code{partition-alignment} (default: @code{2048})
  28371. Alignment of the partition in sectors.
  28372. @end table
  28373. @end deftp
  28374. @deffn {Procedure} debootstrap-variant name configuration
  28375. This is a helper procedure that creates a @code{ganeti-os-variant} record. It
  28376. takes two parameters: a name and a @code{debootstrap-configuration} object.
  28377. @end deffn
  28378. @deffn {Procedure} debootstrap-os variants@dots{}
  28379. This is a helper procedure that creates a @code{ganeti-os} record. It takes
  28380. a list of variants created with @code{debootstrap-variant}.
  28381. @end deffn
  28382. @deffn {Procedure} guix-variant name configuration
  28383. This is a helper procedure that creates a @code{ganeti-os-variant} record for
  28384. use with the Guix OS provider. It takes a name and a G-expression that returns
  28385. a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
  28386. Guix System configuration.
  28387. @end deffn
  28388. @deffn {Procedure} guix-os variants@dots{}
  28389. This is a helper procedure that creates a @code{ganeti-os} record. It
  28390. takes a list of variants produced by @code{guix-variant}.
  28391. @end deffn
  28392. @defvar %default-debootstrap-variants
  28393. This is a convenience variable to make the debootstrap provider work
  28394. ``out of the box'' without users having to declare variants manually. It
  28395. contains a single debootstrap variant with the default configuration:
  28396. @lisp
  28397. (list (debootstrap-variant
  28398. "default"
  28399. (debootstrap-configuration)))
  28400. @end lisp
  28401. @end defvar
  28402. @defvar %default-guix-variants
  28403. This is a convenience variable to make the Guix OS provider work without
  28404. additional configuration. It creates a virtual machine that has an SSH
  28405. server, a serial console, and authorizes the Ganeti hosts SSH keys.
  28406. @lisp
  28407. (list (guix-variant
  28408. "default"
  28409. (file-append ganeti-instance-guix
  28410. "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
  28411. @end lisp
  28412. @end defvar
  28413. Users can implement support for OS providers unbeknownst to Guix by extending
  28414. the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
  28415. For example:
  28416. @lisp
  28417. (ganeti-os
  28418. (name "custom")
  28419. (extension ".conf")
  28420. (variants
  28421. (list (ganeti-os-variant
  28422. (name "foo")
  28423. (configuration (plain-file "bar" "this is fine"))))))
  28424. @end lisp
  28425. That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
  28426. to a file in the store with contents @code{this is fine}. It also creates
  28427. @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
  28428. Obviously this may not work for all OS providers out there. If you find the
  28429. interface limiting, please reach out to @email{guix-devel@@gnu.org}.
  28430. The rest of this section documents the various services that are included by
  28431. @code{ganeti-service-type}.
  28432. @defvar ganeti-noded-service-type
  28433. @command{ganeti-noded} is the daemon responsible for node-specific functions
  28434. within the Ganeti system. The value of this service must be a
  28435. @code{ganeti-noded-configuration} object.
  28436. @end defvar
  28437. @deftp {Data Type} ganeti-noded-configuration
  28438. This is the configuration for the @code{ganeti-noded} service.
  28439. @table @asis
  28440. @item @code{ganeti} (default: @code{ganeti})
  28441. The @code{ganeti} package to use for this service.
  28442. @item @code{port} (default: @code{1811})
  28443. The TCP port on which the node daemon listens for network requests.
  28444. @item @code{address} (default: @code{"0.0.0.0"})
  28445. The network address that the daemon will bind to. The default address means
  28446. bind to all available addresses.
  28447. @item @code{interface} (default: @code{#f})
  28448. When this is set, it must be a specific network interface (e.g.@: @code{eth0})
  28449. that the daemon will bind to.
  28450. @item @code{max-clients} (default: @code{20})
  28451. This sets a limit on the maximum number of simultaneous client connections
  28452. that the daemon will handle. Connections above this count are accepted, but
  28453. no responses will be sent until enough connections have closed.
  28454. @item @code{ssl?} (default: @code{#t})
  28455. Whether to use SSL/TLS to encrypt network communications. The certificate
  28456. is automatically provisioned by the cluster and can be rotated with
  28457. @command{gnt-cluster renew-crypto}.
  28458. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  28459. This can be used to provide a specific encryption key for TLS communications.
  28460. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  28461. This can be used to provide a specific certificate for TLS communications.
  28462. @item @code{debug?} (default: @code{#f})
  28463. When true, the daemon performs additional logging for debugging purposes.
  28464. Note that this will leak encryption details to the log files, use with caution.
  28465. @end table
  28466. @end deftp
  28467. @defvar ganeti-confd-service-type
  28468. @command{ganeti-confd} answers queries related to the configuration of a
  28469. Ganeti cluster. The purpose of this daemon is to have a highly available
  28470. and fast way to query cluster configuration values. It is automatically
  28471. active on all @dfn{master candidates}. The value of this service must be a
  28472. @code{ganeti-confd-configuration} object.
  28473. @end defvar
  28474. @deftp {Data Type} ganeti-confd-configuration
  28475. This is the configuration for the @code{ganeti-confd} service.
  28476. @table @asis
  28477. @item @code{ganeti} (default: @code{ganeti})
  28478. The @code{ganeti} package to use for this service.
  28479. @item @code{port} (default: @code{1814})
  28480. The UDP port on which to listen for network requests.
  28481. @item @code{address} (default: @code{"0.0.0.0"})
  28482. Network address that the daemon will bind to.
  28483. @item @code{debug?} (default: @code{#f})
  28484. When true, the daemon performs additional logging for debugging purposes.
  28485. @end table
  28486. @end deftp
  28487. @defvar ganeti-wconfd-service-type
  28488. @command{ganeti-wconfd} is the daemon that has authoritative knowledge
  28489. about the cluster configuration and is the only entity that can accept
  28490. changes to it. All jobs that need to modify the configuration will do so
  28491. by sending appropriate requests to this daemon. It only runs on the
  28492. @dfn{master node} and will automatically disable itself on other nodes.
  28493. The value of this service must be a
  28494. @code{ganeti-wconfd-configuration} object.
  28495. @end defvar
  28496. @deftp {Data Type} ganeti-wconfd-configuration
  28497. This is the configuration for the @code{ganeti-wconfd} service.
  28498. @table @asis
  28499. @item @code{ganeti} (default: @code{ganeti})
  28500. The @code{ganeti} package to use for this service.
  28501. @item @code{no-voting?} (default: @code{#f})
  28502. The daemon will refuse to start if the majority of cluster nodes does not
  28503. agree that it is running on the master node. Set to @code{#t} to start
  28504. even if a quorum can not be reached (dangerous, use with caution).
  28505. @item @code{debug?} (default: @code{#f})
  28506. When true, the daemon performs additional logging for debugging purposes.
  28507. @end table
  28508. @end deftp
  28509. @defvar ganeti-luxid-service-type
  28510. @command{ganeti-luxid} is a daemon used to answer queries related to the
  28511. configuration and the current live state of a Ganeti cluster. Additionally,
  28512. it is the authoritative daemon for the Ganeti job queue. Jobs can be
  28513. submitted via this daemon and it schedules and starts them.
  28514. It takes a @code{ganeti-luxid-configuration} object.
  28515. @end defvar
  28516. @deftp {Data Type} ganeti-luxid-configuration
  28517. This is the configuration for the @code{ganeti-luxid} service.
  28518. @table @asis
  28519. @item @code{ganeti} (default: @code{ganeti})
  28520. The @code{ganeti} package to use for this service.
  28521. @item @code{no-voting?} (default: @code{#f})
  28522. The daemon will refuse to start if it cannot verify that the majority of
  28523. cluster nodes believes that it is running on the master node. Set to
  28524. @code{#t} to ignore such checks and start anyway (this can be dangerous).
  28525. @item @code{debug?} (default: @code{#f})
  28526. When true, the daemon performs additional logging for debugging purposes.
  28527. @end table
  28528. @end deftp
  28529. @defvar ganeti-rapi-service-type
  28530. @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
  28531. the master node and can be used to perform cluster actions programmatically
  28532. via a JSON-based RPC protocol.
  28533. Most query operations are allowed without authentication (unless
  28534. @var{require-authentication?} is set), whereas write operations require
  28535. explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
  28536. the @url{https://docs.ganeti.org/docs/ganeti/3.0/html/rapi.html, Ganeti Remote
  28537. API documentation} for more information.
  28538. The value of this service must be a @code{ganeti-rapi-configuration} object.
  28539. @end defvar
  28540. @deftp {Data Type} ganeti-rapi-configuration
  28541. This is the configuration for the @code{ganeti-rapi} service.
  28542. @table @asis
  28543. @item @code{ganeti} (default: @code{ganeti})
  28544. The @code{ganeti} package to use for this service.
  28545. @item @code{require-authentication?} (default: @code{#f})
  28546. Whether to require authentication even for read-only operations.
  28547. @item @code{port} (default: @code{5080})
  28548. The TCP port on which to listen to API requests.
  28549. @item @code{address} (default: @code{"0.0.0.0"})
  28550. The network address that the service will bind to. By default it listens
  28551. on all configured addresses.
  28552. @item @code{interface} (default: @code{#f})
  28553. When set, it must specify a specific network interface such as @code{eth0}
  28554. that the daemon will bind to.
  28555. @item @code{max-clients} (default: @code{20})
  28556. The maximum number of simultaneous client requests to handle. Further
  28557. connections are allowed, but no responses are sent until enough connections
  28558. have closed.
  28559. @item @code{ssl?} (default: @code{#t})
  28560. Whether to use SSL/TLS encryption on the RAPI port.
  28561. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  28562. This can be used to provide a specific encryption key for TLS communications.
  28563. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  28564. This can be used to provide a specific certificate for TLS communications.
  28565. @item @code{debug?} (default: @code{#f})
  28566. When true, the daemon performs additional logging for debugging purposes.
  28567. Note that this will leak encryption details to the log files, use with caution.
  28568. @end table
  28569. @end deftp
  28570. @defvar ganeti-kvmd-service-type
  28571. @command{ganeti-kvmd} is responsible for determining whether a given KVM
  28572. instance was shut down by an administrator or a user. Normally Ganeti will
  28573. restart an instance that was not stopped through Ganeti itself. If the
  28574. cluster option @code{user_shutdown} is true, this daemon monitors the
  28575. @code{QMP} socket provided by QEMU and listens for shutdown events, and
  28576. marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
  28577. it shuts down gracefully by itself.
  28578. It takes a @code{ganeti-kvmd-configuration} object.
  28579. @end defvar
  28580. @deftp {Data Type} ganeti-kvmd-configuration
  28581. @table @asis
  28582. @item @code{ganeti} (default: @code{ganeti})
  28583. The @code{ganeti} package to use for this service.
  28584. @item @code{debug?} (default: @code{#f})
  28585. When true, the daemon performs additional logging for debugging purposes.
  28586. @end table
  28587. @end deftp
  28588. @defvar ganeti-mond-service-type
  28589. @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
  28590. functionality. It is responsible for running data collectors and publish the
  28591. collected information through a HTTP interface.
  28592. It takes a @code{ganeti-mond-configuration} object.
  28593. @end defvar
  28594. @deftp {Data Type} ganeti-mond-configuration
  28595. @table @asis
  28596. @item @code{ganeti} (default: @code{ganeti})
  28597. The @code{ganeti} package to use for this service.
  28598. @item @code{port} (default: @code{1815})
  28599. The port on which the daemon will listen.
  28600. @item @code{address} (default: @code{"0.0.0.0"})
  28601. The network address that the daemon will bind to. By default it binds to all
  28602. available interfaces.
  28603. @item @code{debug?} (default: @code{#f})
  28604. When true, the daemon performs additional logging for debugging purposes.
  28605. @end table
  28606. @end deftp
  28607. @defvar ganeti-metad-service-type
  28608. @command{ganeti-metad} is an optional daemon that can be used to provide
  28609. information about the cluster to instances or OS install scripts.
  28610. It takes a @code{ganeti-metad-configuration} object.
  28611. @end defvar
  28612. @deftp {Data Type} ganeti-metad-configuration
  28613. @table @asis
  28614. @item @code{ganeti} (default: @code{ganeti})
  28615. The @code{ganeti} package to use for this service.
  28616. @item @code{port} (default: @code{80})
  28617. The port on which the daemon will listen.
  28618. @item @code{address} (default: @code{#f})
  28619. If set, the daemon will bind to this address only. If left unset, the behavior
  28620. depends on the cluster configuration.
  28621. @item @code{debug?} (default: @code{#f})
  28622. When true, the daemon performs additional logging for debugging purposes.
  28623. @end table
  28624. @end deftp
  28625. @defvar ganeti-watcher-service-type
  28626. @command{ganeti-watcher} is a script designed to run periodically and ensure
  28627. the health of a cluster. It will automatically restart instances that have
  28628. stopped without Ganeti's consent, and repairs DRBD links in case a node has
  28629. rebooted. It also archives old cluster jobs and restarts Ganeti daemons
  28630. that are not running. If the cluster parameter @code{ensure_node_health}
  28631. is set, the watcher will also shutdown instances and DRBD devices if the
  28632. node it is running on is declared offline by known master candidates.
  28633. It can be paused on all nodes with @command{gnt-cluster watcher pause}.
  28634. The service takes a @code{ganeti-watcher-configuration} object.
  28635. @end defvar
  28636. @deftp {Data Type} ganeti-watcher-configuration
  28637. @table @asis
  28638. @item @code{ganeti} (default: @code{ganeti})
  28639. The @code{ganeti} package to use for this service.
  28640. @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
  28641. How often to run the script. The default is every five minutes.
  28642. @item @code{rapi-ip} (default: @code{#f})
  28643. This option needs to be specified only if the RAPI daemon is configured to use
  28644. a particular interface or address. By default the cluster address is used.
  28645. @item @code{job-age} (default: @code{(* 6 3600)})
  28646. Archive cluster jobs older than this age, specified in seconds. The default
  28647. is 6 hours. This keeps @command{gnt-job list} manageable.
  28648. @item @code{verify-disks?} (default: @code{#t})
  28649. If this is @code{#f}, the watcher will not try to repair broken DRBD links
  28650. automatically. Administrators will need to use @command{gnt-cluster verify-disks}
  28651. manually instead.
  28652. @item @code{debug?} (default: @code{#f})
  28653. When @code{#t}, the script performs additional logging for debugging purposes.
  28654. @end table
  28655. @end deftp
  28656. @defvar ganeti-cleaner-service-type
  28657. @command{ganeti-cleaner} is a script designed to run periodically and remove
  28658. old files from the cluster. This service type controls two @dfn{cron jobs}:
  28659. one intended for the master node that permanently purges old cluster jobs,
  28660. and one intended for every node that removes expired X509 certificates, keys,
  28661. and outdated @command{ganeti-watcher} information. Like all Ganeti services,
  28662. it is safe to include even on non-master nodes as it will disable itself as
  28663. necessary.
  28664. It takes a @code{ganeti-cleaner-configuration} object.
  28665. @end defvar
  28666. @deftp {Data Type} ganeti-cleaner-configuration
  28667. @table @asis
  28668. @item @code{ganeti} (default: @code{ganeti})
  28669. The @code{ganeti} package to use for the @command{gnt-cleaner} command.
  28670. @item @code{master-schedule} (default: @code{"45 1 * * *"})
  28671. How often to run the master cleaning job. The default is once per day, at
  28672. 01:45:00.
  28673. @item @code{node-schedule} (default: @code{"45 2 * * *"})
  28674. How often to run the node cleaning job. The default is once per day, at
  28675. 02:45:00.
  28676. @end table
  28677. @end deftp
  28678. @node Version Control Services
  28679. @subsection Version Control Services
  28680. The @code{(gnu services version-control)} module provides a service to
  28681. allow remote access to local Git repositories. There are three options:
  28682. the @code{git-daemon-service-type}, which provides access to repositories via
  28683. the @code{git://} unsecured TCP-based protocol, extending the
  28684. @code{nginx} web server to proxy some requests to
  28685. @code{git-http-backend}, or providing a web interface with
  28686. @code{cgit-service-type}.
  28687. @defvar git-daemon-service-type
  28688. Type for a service that runs @command{git daemon}, a simple TCP server to
  28689. expose repositories over the Git protocol for anonymous access.
  28690. The value for this service type is a @code{<git-daemon-configuration>}
  28691. record, by default it allows read-only access to exported@footnote{By
  28692. creating the magic file @file{git-daemon-export-ok} in the repository
  28693. directory.} repositories under @file{/srv/git}.
  28694. @end defvar
  28695. @deftp {Data Type} git-daemon-configuration
  28696. Data type representing the configuration for @code{git-daemon-service-type}.
  28697. @table @asis
  28698. @item @code{package} (default: @code{git})
  28699. Package object of the Git distributed version control system.
  28700. @item @code{export-all?} (default: @code{#f})
  28701. Whether to allow access for all Git repositories, even if they do not
  28702. have the @file{git-daemon-export-ok} file.
  28703. @item @code{base-path} (default: @file{/srv/git})
  28704. Whether to remap all the path requests as relative to the given path.
  28705. If you run @command{git daemon} with @code{(base-path "/srv/git")} on
  28706. @samp{example.com}, then if you later try to pull
  28707. @indicateurl{git://example.com/hello.git}, git daemon will interpret the
  28708. path as @file{/srv/git/hello.git}.
  28709. @item @code{user-path} (default: @code{#f})
  28710. Whether to allow @code{~user} notation to be used in requests. When
  28711. specified with empty string, requests to
  28712. @indicateurl{git://host/~alice/foo} is taken as a request to access
  28713. @code{foo} repository in the home directory of user @code{alice}. If
  28714. @code{(user-path "@var{path}")} is specified, the same request is taken
  28715. as a request to access @file{@var{path}/foo} repository in the home
  28716. directory of user @code{alice}.
  28717. @item @code{listen} (default: @code{'()})
  28718. Whether to listen on specific IP addresses or hostnames, defaults to
  28719. all.
  28720. @item @code{port} (default: @code{#f})
  28721. Whether to listen on an alternative port, which defaults to 9418.
  28722. @item @code{whitelist} (default: @code{'()})
  28723. If not empty, only allow access to this list of directories.
  28724. @item @code{extra-options} (default: @code{'()})
  28725. Extra options that will be passed to @command{git daemon}.@footnote{Run
  28726. @command{man git-daemon} for more information.}
  28727. @end table
  28728. @end deftp
  28729. The @code{git://} protocol lacks authentication. When you pull from a
  28730. repository fetched via @code{git://}, you don't know whether the data you
  28731. receive was modified or is even coming from the specified host, and your
  28732. connection is subject to eavesdropping. It's better to use an authenticated
  28733. and encrypted transport, such as @code{https}. Although Git allows you
  28734. to serve repositories using unsophisticated file-based web servers,
  28735. there is a faster protocol implemented by the @code{git-http-backend}
  28736. program. This program is the back-end of a proper Git web service. It
  28737. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  28738. on running the necessary @code{fcgiwrap} daemon.
  28739. Guix has a separate configuration data type for serving Git repositories
  28740. over HTTP.
  28741. @deftp {Data Type} git-http-configuration
  28742. Data type representing the configuration for a future
  28743. @code{git-http-service-type}; can currently be used to configure Nginx
  28744. through @code{git-http-nginx-location-configuration}.
  28745. @table @asis
  28746. @item @code{package} (default: @var{git})
  28747. Package object of the Git distributed version control system.
  28748. @item @code{git-root} (default: @file{/srv/git})
  28749. Directory containing the Git repositories to expose to the world.
  28750. @item @code{export-all?} (default: @code{#f})
  28751. Whether to expose access for all Git repositories in @var{git-root},
  28752. even if they do not have the @file{git-daemon-export-ok} file.
  28753. @item @code{uri-path} (default: @samp{/git/})
  28754. Path prefix for Git access. With the default @samp{/git/} prefix, this
  28755. will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
  28756. @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  28757. with this prefix are not passed on to this Git instance.
  28758. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  28759. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  28760. Services}.
  28761. @end table
  28762. @end deftp
  28763. There is no @code{git-http-service-type}, currently; instead you can
  28764. create an @code{nginx-location-configuration} from a
  28765. @code{git-http-configuration} and then add that location to a web
  28766. server.
  28767. @deffn {Procedure} git-http-nginx-location-configuration @
  28768. [config=(git-http-configuration)]
  28769. Compute an @code{nginx-location-configuration} that corresponds to the
  28770. given Git http configuration. An example nginx service definition to
  28771. serve the default @file{/srv/git} over HTTPS might be:
  28772. @lisp
  28773. (service nginx-service-type
  28774. (nginx-configuration
  28775. (server-blocks
  28776. (list
  28777. (nginx-server-configuration
  28778. (listen '("443 ssl"))
  28779. (server-name "git.my-host.org")
  28780. (ssl-certificate
  28781. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  28782. (ssl-certificate-key
  28783. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  28784. (locations
  28785. (list
  28786. (git-http-nginx-location-configuration
  28787. (git-http-configuration (uri-path "/"))))))))))
  28788. @end lisp
  28789. This example assumes that you are using Let's Encrypt to get your TLS
  28790. certificate. @xref{Certificate Services}. The default @code{certbot}
  28791. service will redirect all HTTP traffic on @code{git.my-host.org} to
  28792. HTTPS@. You will also need to add an @code{fcgiwrap} proxy to your
  28793. system services. @xref{Web Services}.
  28794. @end deffn
  28795. @subsubheading Cgit Service
  28796. @cindex Cgit service
  28797. @cindex Git, web interface
  28798. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  28799. repositories written in C.
  28800. The following example will configure the service with default values.
  28801. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  28802. @lisp
  28803. (service cgit-service-type)
  28804. @end lisp
  28805. The @code{file-object} type designates either a file-like object
  28806. (@pxref{G-Expressions, file-like objects}) or a string.
  28807. @c %start of fragment
  28808. Available @code{cgit-configuration} fields are:
  28809. @deftypevr {@code{cgit-configuration} parameter} package package
  28810. The CGIT package.
  28811. @end deftypevr
  28812. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  28813. NGINX configuration.
  28814. @end deftypevr
  28815. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  28816. Specifies a command which will be invoked to format the content of about
  28817. pages (both top-level and for each repository).
  28818. Defaults to @samp{""}.
  28819. @end deftypevr
  28820. @deftypevr {@code{cgit-configuration} parameter} string agefile
  28821. Specifies a path, relative to each repository path, which can be used to
  28822. specify the date and time of the youngest commit in the repository.
  28823. Defaults to @samp{""}.
  28824. @end deftypevr
  28825. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  28826. Specifies a command that will be invoked for authenticating repository
  28827. access.
  28828. Defaults to @samp{""}.
  28829. @end deftypevr
  28830. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  28831. Flag which, when set to @samp{age}, enables date ordering in the branch
  28832. ref list, and when set @samp{name} enables ordering by branch name.
  28833. Defaults to @samp{"name"}.
  28834. @end deftypevr
  28835. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  28836. Path used to store the cgit cache entries.
  28837. Defaults to @samp{"/var/cache/cgit"}.
  28838. @end deftypevr
  28839. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  28840. Number which specifies the time-to-live, in minutes, for the cached
  28841. version of repository pages accessed with a fixed SHA1.
  28842. Defaults to @samp{-1}.
  28843. @end deftypevr
  28844. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  28845. Number which specifies the time-to-live, in minutes, for the cached
  28846. version of repository pages accessed without a fixed SHA1.
  28847. Defaults to @samp{5}.
  28848. @end deftypevr
  28849. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  28850. Number which specifies the time-to-live, in minutes, for the cached
  28851. version of the repository summary page.
  28852. Defaults to @samp{5}.
  28853. @end deftypevr
  28854. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  28855. Number which specifies the time-to-live, in minutes, for the cached
  28856. version of the repository index page.
  28857. Defaults to @samp{5}.
  28858. @end deftypevr
  28859. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  28860. Number which specifies the time-to-live, in minutes, for the result of
  28861. scanning a path for Git repositories.
  28862. Defaults to @samp{15}.
  28863. @end deftypevr
  28864. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  28865. Number which specifies the time-to-live, in minutes, for the cached
  28866. version of the repository about page.
  28867. Defaults to @samp{15}.
  28868. @end deftypevr
  28869. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  28870. Number which specifies the time-to-live, in minutes, for the cached
  28871. version of snapshots.
  28872. Defaults to @samp{5}.
  28873. @end deftypevr
  28874. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  28875. The maximum number of entries in the cgit cache. When set to @samp{0},
  28876. caching is disabled.
  28877. Defaults to @samp{0}.
  28878. @end deftypevr
  28879. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  28880. Sort items in the repo list case sensitively.
  28881. Defaults to @samp{#t}.
  28882. @end deftypevr
  28883. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  28884. List of common prefixes which, when combined with a repository URL,
  28885. generates valid clone URLs for the repository.
  28886. Defaults to @samp{'()}.
  28887. @end deftypevr
  28888. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  28889. List of @code{clone-url} templates.
  28890. Defaults to @samp{'()}.
  28891. @end deftypevr
  28892. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  28893. Command which will be invoked to format commit messages.
  28894. Defaults to @samp{""}.
  28895. @end deftypevr
  28896. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  28897. Flag which, when set to @samp{date}, enables strict date ordering in the
  28898. commit log, and when set to @samp{topo} enables strict topological
  28899. ordering.
  28900. Defaults to @samp{"git log"}.
  28901. @end deftypevr
  28902. @deftypevr {@code{cgit-configuration} parameter} file-object css
  28903. URL which specifies the css document to include in all cgit pages.
  28904. Defaults to @samp{"/share/cgit/cgit.css"}.
  28905. @end deftypevr
  28906. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  28907. Specifies a command which will be invoked to format names and email
  28908. address of committers, authors, and taggers, as represented in various
  28909. places throughout the cgit interface.
  28910. Defaults to @samp{""}.
  28911. @end deftypevr
  28912. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  28913. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  28914. fragment suitable for embedding in other HTML pages.
  28915. Defaults to @samp{#f}.
  28916. @end deftypevr
  28917. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  28918. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  28919. commit history graph to the left of the commit messages in the
  28920. repository log page.
  28921. Defaults to @samp{#f}.
  28922. @end deftypevr
  28923. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  28924. Flag which, when set to @samp{#t}, allows all filter settings to be
  28925. overridden in repository-specific cgitrc files.
  28926. Defaults to @samp{#f}.
  28927. @end deftypevr
  28928. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  28929. Flag which, when set to @samp{#t}, allows users to follow a file in the
  28930. log view.
  28931. Defaults to @samp{#f}.
  28932. @end deftypevr
  28933. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  28934. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  28935. clones.
  28936. Defaults to @samp{#t}.
  28937. @end deftypevr
  28938. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  28939. Flag which, when set to @samp{#t}, will make cgit generate extra links
  28940. "summary", "commit", "tree" for each repo in the repository index.
  28941. Defaults to @samp{#f}.
  28942. @end deftypevr
  28943. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  28944. Flag which, when set to @samp{#t}, will make cgit display the owner of
  28945. each repo in the repository index.
  28946. Defaults to @samp{#t}.
  28947. @end deftypevr
  28948. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  28949. Flag which, when set to @samp{#t}, will make cgit print the number of
  28950. modified files for each commit on the repository log page.
  28951. Defaults to @samp{#f}.
  28952. @end deftypevr
  28953. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  28954. Flag which, when set to @samp{#t}, will make cgit print the number of
  28955. added and removed lines for each commit on the repository log page.
  28956. Defaults to @samp{#f}.
  28957. @end deftypevr
  28958. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  28959. Flag which, when set to @code{#t}, will make cgit display remote
  28960. branches in the summary and refs views.
  28961. Defaults to @samp{#f}.
  28962. @end deftypevr
  28963. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  28964. Flag which, when set to @code{1}, will make cgit use the subject of the
  28965. parent commit as link text when generating links to parent commits in
  28966. commit view.
  28967. Defaults to @samp{#f}.
  28968. @end deftypevr
  28969. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  28970. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  28971. parent commit as link text when generating links to parent commits in
  28972. commit view.
  28973. Defaults to @samp{#f}.
  28974. @end deftypevr
  28975. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  28976. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  28977. links for plaintext blobs printed in the tree view.
  28978. Defaults to @samp{#t}.
  28979. @end deftypevr
  28980. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  28981. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  28982. set any repo specific settings.
  28983. Defaults to @samp{#f}.
  28984. @end deftypevr
  28985. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  28986. URL used as link to a shortcut icon for cgit.
  28987. Defaults to @samp{"/favicon.ico"}.
  28988. @end deftypevr
  28989. @deftypevr {@code{cgit-configuration} parameter} string footer
  28990. The content of the file specified with this option will be included
  28991. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  28992. "generated by..."@: message).
  28993. Defaults to @samp{""}.
  28994. @end deftypevr
  28995. @deftypevr {@code{cgit-configuration} parameter} string head-include
  28996. The content of the file specified with this option will be included
  28997. verbatim in the HTML HEAD section on all pages.
  28998. Defaults to @samp{""}.
  28999. @end deftypevr
  29000. @deftypevr {@code{cgit-configuration} parameter} string header
  29001. The content of the file specified with this option will be included
  29002. verbatim at the top of all pages.
  29003. Defaults to @samp{""}.
  29004. @end deftypevr
  29005. @deftypevr {@code{cgit-configuration} parameter} file-object include
  29006. Name of a configfile to include before the rest of the current config-
  29007. file is parsed.
  29008. Defaults to @samp{""}.
  29009. @end deftypevr
  29010. @deftypevr {@code{cgit-configuration} parameter} string index-header
  29011. The content of the file specified with this option will be included
  29012. verbatim above the repository index.
  29013. Defaults to @samp{""}.
  29014. @end deftypevr
  29015. @deftypevr {@code{cgit-configuration} parameter} string index-info
  29016. The content of the file specified with this option will be included
  29017. verbatim below the heading on the repository index page.
  29018. Defaults to @samp{""}.
  29019. @end deftypevr
  29020. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  29021. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  29022. in the servers timezone.
  29023. Defaults to @samp{#f}.
  29024. @end deftypevr
  29025. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  29026. URL which specifies the source of an image which will be used as a logo
  29027. on all cgit pages.
  29028. Defaults to @samp{"/share/cgit/cgit.png"}.
  29029. @end deftypevr
  29030. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  29031. URL loaded when clicking on the cgit logo image.
  29032. Defaults to @samp{""}.
  29033. @end deftypevr
  29034. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  29035. Command which will be invoked to format the Owner column of the main
  29036. page.
  29037. Defaults to @samp{""}.
  29038. @end deftypevr
  29039. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  29040. Number of items to display in atom feeds view.
  29041. Defaults to @samp{10}.
  29042. @end deftypevr
  29043. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  29044. Number of entries to list per page in "log" view.
  29045. Defaults to @samp{50}.
  29046. @end deftypevr
  29047. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  29048. Number of commit message characters to display in "log" view.
  29049. Defaults to @samp{80}.
  29050. @end deftypevr
  29051. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  29052. Specifies the number of entries to list per page on the repository index
  29053. page.
  29054. Defaults to @samp{50}.
  29055. @end deftypevr
  29056. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  29057. Specifies the maximum number of repo description characters to display
  29058. on the repository index page.
  29059. Defaults to @samp{80}.
  29060. @end deftypevr
  29061. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  29062. Specifies the maximum size of a blob to display HTML for in KBytes.
  29063. Defaults to @samp{0}.
  29064. @end deftypevr
  29065. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  29066. Maximum statistics period. Valid values are @samp{week},@samp{month},
  29067. @samp{quarter} and @samp{year}.
  29068. Defaults to @samp{""}.
  29069. @end deftypevr
  29070. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  29071. Mimetype for the specified filename extension.
  29072. Defaults to @samp{'((gif "image/gif") (html "text/html") (jpg
  29073. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  29074. "image/png") (svg "image/svg+xml"))}.
  29075. @end deftypevr
  29076. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  29077. Specifies the file to use for automatic mimetype lookup.
  29078. Defaults to @samp{""}.
  29079. @end deftypevr
  29080. @deftypevr {@code{cgit-configuration} parameter} string module-link
  29081. Text which will be used as the formatstring for a hyperlink when a
  29082. submodule is printed in a directory listing.
  29083. Defaults to @samp{""}.
  29084. @end deftypevr
  29085. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  29086. If set to the value @samp{#t} caching will be disabled.
  29087. Defaults to @samp{#f}.
  29088. @end deftypevr
  29089. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  29090. If set to @samp{#t} showing full author email addresses will be
  29091. disabled.
  29092. Defaults to @samp{#f}.
  29093. @end deftypevr
  29094. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  29095. Flag which, when set to @samp{#t}, will make cgit omit the standard
  29096. header on all pages.
  29097. Defaults to @samp{#f}.
  29098. @end deftypevr
  29099. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  29100. A list of subdirectories inside of @code{repository-directory}, relative
  29101. to it, that should loaded as Git repositories. An empty list means that
  29102. all subdirectories will be loaded.
  29103. Defaults to @samp{'()}.
  29104. @end deftypevr
  29105. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  29106. Text which will be used as default @code{repository-cgit-configuration}
  29107. @code{readme}.
  29108. Defaults to @samp{""}.
  29109. @end deftypevr
  29110. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  29111. If set to @code{#t} and @code{repository-directory} is enabled, if any
  29112. repositories are found with a suffix of @code{.git}, this suffix will be
  29113. removed for the URL and name.
  29114. Defaults to @samp{#f}.
  29115. @end deftypevr
  29116. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  29117. Maximum number of files to consider when detecting renames.
  29118. Defaults to @samp{-1}.
  29119. @end deftypevr
  29120. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  29121. The way in which repositories in each section are sorted.
  29122. Defaults to @samp{""}.
  29123. @end deftypevr
  29124. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  29125. Text used as content for the @code{robots} meta-tag.
  29126. Defaults to @samp{'("noindex" "nofollow")}.
  29127. @end deftypevr
  29128. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  29129. Text printed below the heading on the repository index page.
  29130. Defaults to @samp{"a fast webinterface for the git dscm"}.
  29131. @end deftypevr
  29132. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  29133. The content of the file specified with this option will be included
  29134. verbatim below the ``about'' link on the repository index page.
  29135. Defaults to @samp{""}.
  29136. @end deftypevr
  29137. @deftypevr {@code{cgit-configuration} parameter} string root-title
  29138. Text printed as heading on the repository index page.
  29139. Defaults to @samp{""}.
  29140. @end deftypevr
  29141. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  29142. If set to @samp{#t} and repository-directory is enabled,
  29143. repository-directory will recurse into directories whose name starts
  29144. with a period. Otherwise, repository-directory will stay away from such
  29145. directories, considered as ``hidden''. Note that this does not apply to
  29146. the @file{.git} directory in non-bare repos.
  29147. Defaults to @samp{#f}.
  29148. @end deftypevr
  29149. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  29150. Text which specifies the default set of snapshot formats that cgit
  29151. generates links for.
  29152. Defaults to @samp{'()}.
  29153. @end deftypevr
  29154. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  29155. Name of the directory to scan for repositories (represents
  29156. @code{scan-path}).
  29157. Defaults to @samp{"/srv/git"}.
  29158. @end deftypevr
  29159. @deftypevr {@code{cgit-configuration} parameter} string section
  29160. The name of the current repository section - all repositories defined
  29161. after this option will inherit the current section name.
  29162. Defaults to @samp{""}.
  29163. @end deftypevr
  29164. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  29165. Flag which, when set to @samp{1}, will sort the sections on the
  29166. repository listing by name.
  29167. Defaults to @samp{""}.
  29168. @end deftypevr
  29169. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  29170. A number which, if defined prior to repository-directory, specifies how
  29171. many path elements from each repo path to use as a default section name.
  29172. Defaults to @samp{0}.
  29173. @end deftypevr
  29174. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  29175. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  29176. default.
  29177. Defaults to @samp{#f}.
  29178. @end deftypevr
  29179. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  29180. Specifies a command which will be invoked to format plaintext blobs in
  29181. the tree view.
  29182. Defaults to @samp{""}.
  29183. @end deftypevr
  29184. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  29185. Specifies the number of branches to display in the repository ``summary''
  29186. view.
  29187. Defaults to @samp{10}.
  29188. @end deftypevr
  29189. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  29190. Specifies the number of log entries to display in the repository
  29191. ``summary'' view.
  29192. Defaults to @samp{10}.
  29193. @end deftypevr
  29194. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  29195. Specifies the number of tags to display in the repository ``summary''
  29196. view.
  29197. Defaults to @samp{10}.
  29198. @end deftypevr
  29199. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  29200. Filename which, if specified, needs to be present within the repository
  29201. for cgit to allow access to that repository.
  29202. Defaults to @samp{""}.
  29203. @end deftypevr
  29204. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  29205. URL which, if specified, will be used as root for all cgit links.
  29206. Defaults to @samp{"/"}.
  29207. @end deftypevr
  29208. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  29209. A list of @code{repository-cgit-configuration} records.
  29210. Defaults to @samp{'()}.
  29211. Available @code{repository-cgit-configuration} fields are:
  29212. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  29213. A mask of snapshot formats for this repo that cgit generates links for,
  29214. restricted by the global @code{snapshots} setting.
  29215. Defaults to @samp{'()}.
  29216. @end deftypevr
  29217. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  29218. Override the default @code{source-filter}.
  29219. Defaults to @samp{""}.
  29220. @end deftypevr
  29221. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  29222. The relative URL used to access the repository.
  29223. Defaults to @samp{""}.
  29224. @end deftypevr
  29225. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  29226. Override the default @code{about-filter}.
  29227. Defaults to @samp{""}.
  29228. @end deftypevr
  29229. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  29230. Flag which, when set to @samp{age}, enables date ordering in the branch
  29231. ref list, and when set to @samp{name} enables ordering by branch name.
  29232. Defaults to @samp{""}.
  29233. @end deftypevr
  29234. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  29235. A list of URLs which can be used to clone repo.
  29236. Defaults to @samp{'()}.
  29237. @end deftypevr
  29238. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  29239. Override the default @code{commit-filter}.
  29240. Defaults to @samp{""}.
  29241. @end deftypevr
  29242. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  29243. Flag which, when set to @samp{date}, enables strict date ordering in the
  29244. commit log, and when set to @samp{topo} enables strict topological
  29245. ordering.
  29246. Defaults to @samp{""}.
  29247. @end deftypevr
  29248. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  29249. The name of the default branch for this repository. If no such branch
  29250. exists in the repository, the first branch name (when sorted) is used as
  29251. default instead. By default branch pointed to by HEAD, or ``master'' if
  29252. there is no suitable HEAD.
  29253. Defaults to @samp{""}.
  29254. @end deftypevr
  29255. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  29256. The value to show as repository description.
  29257. Defaults to @samp{""}.
  29258. @end deftypevr
  29259. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  29260. The value to show as repository homepage.
  29261. Defaults to @samp{""}.
  29262. @end deftypevr
  29263. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  29264. Override the default @code{email-filter}.
  29265. Defaults to @samp{""}.
  29266. @end deftypevr
  29267. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  29268. A flag which can be used to disable the global setting
  29269. @code{enable-commit-graph?}.
  29270. Defaults to @samp{disabled}.
  29271. @end deftypevr
  29272. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  29273. A flag which can be used to disable the global setting
  29274. @code{enable-log-filecount?}.
  29275. Defaults to @samp{disabled}.
  29276. @end deftypevr
  29277. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  29278. A flag which can be used to disable the global setting
  29279. @code{enable-log-linecount?}.
  29280. Defaults to @samp{disabled}.
  29281. @end deftypevr
  29282. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  29283. Flag which, when set to @code{#t}, will make cgit display remote
  29284. branches in the summary and refs views.
  29285. Defaults to @samp{disabled}.
  29286. @end deftypevr
  29287. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  29288. A flag which can be used to override the global setting
  29289. @code{enable-subject-links?}.
  29290. Defaults to @samp{disabled}.
  29291. @end deftypevr
  29292. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  29293. A flag which can be used to override the global setting
  29294. @code{enable-html-serving?}.
  29295. Defaults to @samp{disabled}.
  29296. @end deftypevr
  29297. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  29298. Flag which, when set to @code{#t}, hides the repository from the
  29299. repository index.
  29300. Defaults to @samp{#f}.
  29301. @end deftypevr
  29302. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  29303. Flag which, when set to @samp{#t}, ignores the repository.
  29304. Defaults to @samp{#f}.
  29305. @end deftypevr
  29306. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  29307. URL which specifies the source of an image which will be used as a logo
  29308. on this repo’s pages.
  29309. Defaults to @samp{""}.
  29310. @end deftypevr
  29311. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  29312. URL loaded when clicking on the cgit logo image.
  29313. Defaults to @samp{""}.
  29314. @end deftypevr
  29315. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  29316. Override the default @code{owner-filter}.
  29317. Defaults to @samp{""}.
  29318. @end deftypevr
  29319. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  29320. Text which will be used as the formatstring for a hyperlink when a
  29321. submodule is printed in a directory listing. The arguments for the
  29322. formatstring are the path and SHA1 of the submodule commit.
  29323. Defaults to @samp{""}.
  29324. @end deftypevr
  29325. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  29326. Text which will be used as the formatstring for a hyperlink when a
  29327. submodule with the specified subdirectory path is printed in a directory
  29328. listing.
  29329. Defaults to @samp{'()}.
  29330. @end deftypevr
  29331. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  29332. Override the default maximum statistics period.
  29333. Defaults to @samp{""}.
  29334. @end deftypevr
  29335. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  29336. The value to show as repository name.
  29337. Defaults to @samp{""}.
  29338. @end deftypevr
  29339. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  29340. A value used to identify the owner of the repository.
  29341. Defaults to @samp{""}.
  29342. @end deftypevr
  29343. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  29344. An absolute path to the repository directory.
  29345. Defaults to @samp{""}.
  29346. @end deftypevr
  29347. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  29348. A path (relative to repo) which specifies a file to include verbatim as
  29349. the ``About'' page for this repo.
  29350. Defaults to @samp{""}.
  29351. @end deftypevr
  29352. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  29353. The name of the current repository section - all repositories defined
  29354. after this option will inherit the current section name.
  29355. Defaults to @samp{""}.
  29356. @end deftypevr
  29357. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  29358. Extra options will be appended to cgitrc file.
  29359. Defaults to @samp{'()}.
  29360. @end deftypevr
  29361. @end deftypevr
  29362. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  29363. Extra options will be appended to cgitrc file.
  29364. Defaults to @samp{'()}.
  29365. @end deftypevr
  29366. @c %end of fragment
  29367. However, it could be that you just want to get a @code{cgitrc} up and
  29368. running. In that case, you can pass an @code{opaque-cgit-configuration}
  29369. as a record to @code{cgit-service-type}. As its name indicates, an
  29370. opaque configuration does not have easy reflective capabilities.
  29371. Available @code{opaque-cgit-configuration} fields are:
  29372. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  29373. The cgit package.
  29374. @end deftypevr
  29375. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  29376. The contents of the @code{cgitrc}, as a string.
  29377. @end deftypevr
  29378. For example, if your @code{cgitrc} is just the empty string, you
  29379. could instantiate a cgit service like this:
  29380. @lisp
  29381. (service cgit-service-type
  29382. (opaque-cgit-configuration
  29383. (cgitrc "")))
  29384. @end lisp
  29385. @subsubheading Gitolite Service
  29386. @cindex Gitolite service
  29387. @cindex Git, hosting
  29388. @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  29389. repositories on a central server.
  29390. Gitolite can handle multiple repositories and users, and supports flexible
  29391. configuration of the permissions for the users on the repositories.
  29392. The following example will configure Gitolite using the default @code{git}
  29393. user, and the provided SSH public key.
  29394. @lisp
  29395. (service gitolite-service-type
  29396. (gitolite-configuration
  29397. (admin-pubkey (plain-file
  29398. "yourname.pub"
  29399. "ssh-rsa AAAA... guix@@example.com"))))
  29400. @end lisp
  29401. Gitolite is configured through a special admin repository which you can clone,
  29402. for example, if you setup Gitolite on @code{example.com}, you would run the
  29403. following command to clone the admin repository.
  29404. @example
  29405. git clone git@@example.com:gitolite-admin
  29406. @end example
  29407. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  29408. be inserted in to the @file{keydir} directory in the gitolite-admin
  29409. repository. If this results in a change in the repository, it will be
  29410. committed using the message ``gitolite setup by GNU Guix''.
  29411. @deftp {Data Type} gitolite-configuration
  29412. Data type representing the configuration for @code{gitolite-service-type}.
  29413. @table @asis
  29414. @item @code{package} (default: @var{gitolite})
  29415. Gitolite package to use. There are optional Gitolite dependencies that
  29416. are not included in the default package, such as Redis and git-annex.
  29417. These features can be made available by using the @code{make-gitolite}
  29418. procedure in the @code{(gnu packages version-control}) module to produce
  29419. a variant of Gitolite with the desired additional dependencies.
  29420. The following code returns a package in which the Redis and git-annex
  29421. programs can be invoked by Gitolite's scripts:
  29422. @example
  29423. (use-modules (gnu packages databases)
  29424. (gnu packages haskell-apps)
  29425. (gnu packages version-control))
  29426. (make-gitolite (list redis git-annex))
  29427. @end example
  29428. @item @code{user} (default: @var{git})
  29429. User to use for Gitolite. This will be user that you use when accessing
  29430. Gitolite over SSH.
  29431. @item @code{group} (default: @var{git})
  29432. Group to use for Gitolite.
  29433. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  29434. Directory in which to store the Gitolite configuration and repositories.
  29435. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  29436. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  29437. representing the configuration for Gitolite.
  29438. @item @code{admin-pubkey} (default: @var{#f})
  29439. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  29440. setup Gitolite. This will be inserted in to the @file{keydir} directory
  29441. within the gitolite-admin repository.
  29442. To specify the SSH key as a string, use the @code{plain-file} function.
  29443. @lisp
  29444. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  29445. @end lisp
  29446. @end table
  29447. @end deftp
  29448. @deftp {Data Type} gitolite-rc-file
  29449. Data type representing the Gitolite RC file.
  29450. @table @asis
  29451. @item @code{umask} (default: @code{#o0077})
  29452. This controls the permissions Gitolite sets on the repositories and their
  29453. contents.
  29454. A value like @code{#o0027} will give read access to the group used by Gitolite
  29455. (by default: @code{git}). This is necessary when using Gitolite with software
  29456. like cgit or gitweb.
  29457. @item @code{local-code} (default: @code{"$rc@{GL_ADMIN_BASE@}/local"})
  29458. Allows you to add your own non-core programs, or even override the
  29459. shipped ones with your own.
  29460. Please supply the FULL path to this variable. By default, directory
  29461. called "local" in your gitolite clone is used, providing the benefits of
  29462. versioning them as well as making changes to them without having to log
  29463. on to the server.
  29464. @item @code{unsafe-pattern} (default: @code{#f})
  29465. An optional Perl regular expression for catching unsafe configurations in
  29466. the configuration file. See
  29467. @uref{https://gitolite.com/gitolite/git-config.html#compensating-for-unsafe_patt,
  29468. Gitolite's documentation} for more information.
  29469. When the value is not @code{#f}, it should be a string containing a Perl
  29470. regular expression, such as @samp{"[`~#\$\&()|;<>]"}, which is the default
  29471. value used by gitolite. It rejects any special character in configuration
  29472. that might be interpreted by a shell, which is useful when sharing the
  29473. administration burden with other people that do not otherwise have shell
  29474. access on the server.
  29475. @item @code{git-config-keys} (default: @code{""})
  29476. Gitolite allows you to set git config values using the @samp{config}
  29477. keyword. This setting allows control over the config keys to accept.
  29478. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  29479. Set the role names allowed to be used by users running the perms command.
  29480. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  29481. This setting controls the commands and features to enable within Gitolite.
  29482. @end table
  29483. @end deftp
  29484. @subsubheading Gitile Service
  29485. @cindex Gitile service
  29486. @cindex Git, forge
  29487. @uref{https://git.lepiller.eu/gitile, Gitile} is a Git forge for viewing
  29488. public git repository contents from a web browser.
  29489. Gitile works best in collaboration with Gitolite, and will serve the public
  29490. repositories from Gitolite by default. The service should listen only on
  29491. a local port, and a webserver should be configured to serve static resources.
  29492. The gitile service provides an easy way to extend the Nginx service for
  29493. that purpose (@pxref{NGINX}).
  29494. The following example will configure Gitile to serve repositories from a
  29495. custom location, with some default messages for the home page and the
  29496. footers.
  29497. @lisp
  29498. (service gitile-service-type
  29499. (gitile-configuration
  29500. (repositories "/srv/git")
  29501. (base-git-url "https://myweb.site/git")
  29502. (index-title "My git repositories")
  29503. (intro '((p "This is all my public work!")))
  29504. (footer '((p "This is the end")))
  29505. (nginx-server-block
  29506. (nginx-server-configuration
  29507. (ssl-certificate
  29508. "/etc/letsencrypt/live/myweb.site/fullchain.pem")
  29509. (ssl-certificate-key
  29510. "/etc/letsencrypt/live/myweb.site/privkey.pem")
  29511. (listen '("443 ssl http2" "[::]:443 ssl http2"))
  29512. (locations
  29513. (list
  29514. ;; Allow for https anonymous fetch on /git/ urls.
  29515. (git-http-nginx-location-configuration
  29516. (git-http-configuration
  29517. (uri-path "/git/")
  29518. (git-root "/var/lib/gitolite/repositories")))))))))
  29519. @end lisp
  29520. In addition to the configuration record, you should configure your git
  29521. repositories to contain some optional information. First, your public
  29522. repositories need to contain the @file{git-daemon-export-ok} magic file
  29523. that allows Git to export the repository. Gitile uses the presence of this
  29524. file to detect public repositories it should make accessible. To do so with
  29525. Gitolite for instance, modify your @file{conf/gitolite.conf} to include
  29526. this in the repositories you want to make public:
  29527. @example
  29528. repo foo
  29529. R = daemon
  29530. @end example
  29531. In addition, Gitile can read the repository configuration to display more
  29532. information on the repository. Gitile uses the gitweb namespace for its
  29533. configuration. As an example, you can use the following in your
  29534. @file{conf/gitolite.conf}:
  29535. @example
  29536. repo foo
  29537. R = daemon
  29538. desc = A long description, optionally with <i>HTML</i>, shown on the index page
  29539. config gitweb.name = The Foo Project
  29540. config gitweb.synopsis = A short description, shown on the main page of the project
  29541. @end example
  29542. Do not forget to commit and push these changes once you are satisfied. You
  29543. may need to change your gitolite configuration to allow the previous
  29544. configuration options to be set. One way to do that is to add the
  29545. following service definition:
  29546. @lisp
  29547. (service gitolite-service-type
  29548. (gitolite-configuration
  29549. (admin-pubkey (local-file "key.pub"))
  29550. (rc-file
  29551. (gitolite-rc-file
  29552. (umask #o0027)
  29553. ;; Allow to set any configuration key
  29554. (git-config-keys ".*")
  29555. ;; Allow any text as a valid configuration value
  29556. (unsafe-patt "^$")))))
  29557. @end lisp
  29558. @deftp {Data Type} gitile-configuration
  29559. Data type representing the configuration for @code{gitile-service-type}.
  29560. @table @asis
  29561. @item @code{package} (default: @var{gitile})
  29562. Gitile package to use.
  29563. @item @code{host} (default: @code{"localhost"})
  29564. The host on which gitile is listening.
  29565. @item @code{port} (default: @code{8080})
  29566. The port on which gitile is listening.
  29567. @item @code{database} (default: @code{"/var/lib/gitile/gitile-db.sql"})
  29568. The location of the database.
  29569. @item @code{repositories} (default: @code{"/var/lib/gitolite/repositories"})
  29570. The location of the repositories. Note that only public repositories will
  29571. be shown by Gitile. To make a repository public, add an empty
  29572. @file{git-daemon-export-ok} file at the root of that repository.
  29573. @item @code{base-git-url}
  29574. The base git url that will be used to show clone commands.
  29575. @item @code{index-title} (default: @code{"Index"})
  29576. The page title for the index page that lists all the available repositories.
  29577. @item @code{intro} (default: @code{'()})
  29578. The intro content, as a list of sxml expressions. This is shown above the list
  29579. of repositories, on the index page.
  29580. @item @code{footer} (default: @code{'()})
  29581. The footer content, as a list of sxml expressions. This is shown on every
  29582. page served by Gitile.
  29583. @item @code{nginx-server-block}
  29584. An nginx server block that will be extended and used as a reverse proxy by
  29585. Gitile to serve its pages, and as a normal web server to serve its assets.
  29586. You can use this block to add more custom URLs to your domain, such as a
  29587. @code{/git/} URL for anonymous clones, or serving any other files you would
  29588. like to serve.
  29589. @end table
  29590. @end deftp
  29591. @node Game Services
  29592. @subsection Game Services
  29593. @subsubheading Joycond service
  29594. @cindex joycond
  29595. The joycond service allows the pairing of Nintendo joycon game
  29596. controllers over Bluetooth. (@pxref{Desktop Services} for setting up
  29597. Bluetooth.)
  29598. @deftp {Data Type} joycond-configuration
  29599. Data type representing the configuration of @command{joycond}.
  29600. @table @asis
  29601. @item @code{package} (default: @code{joycond})
  29602. The joycond package to use.
  29603. @end table
  29604. @end deftp
  29605. @defvar joycond-service-type
  29606. Service type for the joycond service.
  29607. @end defvar
  29608. @subsubheading The Battle for Wesnoth Service
  29609. @cindex wesnothd
  29610. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  29611. based tactical strategy game, with several single player campaigns, and
  29612. multiplayer games (both networked and local).
  29613. @defvar wesnothd-service-type
  29614. Service type for the wesnothd service. Its value must be a
  29615. @code{wesnothd-configuration} object. To run wesnothd in the default
  29616. configuration, instantiate it as:
  29617. @lisp
  29618. (service wesnothd-service-type)
  29619. @end lisp
  29620. @end defvar
  29621. @deftp {Data Type} wesnothd-configuration
  29622. Data type representing the configuration of @command{wesnothd}.
  29623. @table @asis
  29624. @item @code{package} (default: @code{wesnoth-server})
  29625. The wesnoth server package to use.
  29626. @item @code{port} (default: @code{15000})
  29627. The port to bind the server to.
  29628. @end table
  29629. @end deftp
  29630. @node PAM Mount Service
  29631. @subsection PAM Mount Service
  29632. @cindex pam-mount
  29633. The @code{(gnu services pam-mount)} module provides a service allowing
  29634. users to mount volumes when they log in. It should be able to mount any
  29635. volume format supported by the system.
  29636. @defvar pam-mount-service-type
  29637. Service type for PAM Mount support.
  29638. @end defvar
  29639. @deftp {Data Type} pam-mount-configuration
  29640. Data type representing the configuration of PAM Mount.
  29641. It takes the following parameters:
  29642. @table @asis
  29643. @item @code{rules}
  29644. The configuration rules that will be used to generate
  29645. @file{/etc/security/pam_mount.conf.xml}.
  29646. The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
  29647. Guile Reference Manual}), and the default ones don't mount anything for
  29648. anyone at login:
  29649. @lisp
  29650. `((debug (@@ (enable "0")))
  29651. (mntoptions (@@ (allow ,(string-join
  29652. '("nosuid" "nodev" "loop"
  29653. "encryption" "fsck" "nonempty"
  29654. "allow_root" "allow_other")
  29655. ","))))
  29656. (mntoptions (@@ (require "nosuid,nodev")))
  29657. (logout (@@ (wait "0")
  29658. (hup "0")
  29659. (term "no")
  29660. (kill "no")))
  29661. (mkmountpoint (@@ (enable "1")
  29662. (remove "true"))))
  29663. @end lisp
  29664. Some @code{volume} elements must be added to automatically mount volumes
  29665. at login. Here's an example allowing the user @code{alice} to mount her
  29666. encrypted @env{HOME} directory and allowing the user @code{bob} to mount
  29667. the partition where he stores his data:
  29668. @lisp
  29669. (define pam-mount-rules
  29670. `((debug (@@ (enable "0")))
  29671. (volume (@@ (user "alice")
  29672. (fstype "crypt")
  29673. (path "/dev/sda2")
  29674. (mountpoint "/home/alice")))
  29675. (volume (@@ (user "bob")
  29676. (fstype "auto")
  29677. (path "/dev/sdb3")
  29678. (mountpoint "/home/bob/data")
  29679. (options "defaults,autodefrag,compress")))
  29680. (mntoptions (@@ (allow ,(string-join
  29681. '("nosuid" "nodev" "loop"
  29682. "encryption" "fsck" "nonempty"
  29683. "allow_root" "allow_other")
  29684. ","))))
  29685. (mntoptions (@@ (require "nosuid,nodev")))
  29686. (logout (@@ (wait "0")
  29687. (hup "0")
  29688. (term "no")
  29689. (kill "no")))
  29690. (mkmountpoint (@@ (enable "1")
  29691. (remove "true")))))
  29692. (service pam-mount-service-type
  29693. (pam-mount-configuration
  29694. (rules pam-mount-rules)))
  29695. @end lisp
  29696. The complete list of possible options can be found in the man page for
  29697. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
  29698. @end table
  29699. @end deftp
  29700. @subheading PAM Mount Volume Service
  29701. @cindex pam volume mounting
  29702. PAM mount volumes are automatically mounted at login by the PAM login
  29703. service according to a set of per-volume rules. Because they are
  29704. mounted by PAM the password entered during login may be used directly to
  29705. mount authenticated volumes, such as @code{cifs}, using the same
  29706. credentials.
  29707. These volumes will be added in addition to any volumes directly
  29708. specified in @code{pam-mount-rules}.
  29709. Here is an example of a rule which will mount a remote CIFS share from
  29710. @file{//remote-server/share} into a sub-directory of @file{/shares}
  29711. named after the user logging in:
  29712. @lisp
  29713. (simple-service 'pam-mount-remote-share pam-mount-volume-service-type
  29714. (list (pam-mount-volume
  29715. (secondary-group "users")
  29716. (file-system-type "cifs")
  29717. (server "remote-server")
  29718. (file-name "share")
  29719. (mount-point "/shares/%(USER)")
  29720. (options "nosuid,nodev,seal,cifsacl"))))
  29721. @end lisp
  29722. @deftp {Data Type} pam-mount-volume-service-type
  29723. Configuration for a single volume to be mounted. Any fields not
  29724. specified will be omitted from the run-time PAM configuration. See
  29725. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html,
  29726. the man page} for the default values when unspecified.
  29727. @table @asis
  29728. @item @code{user-name} (type: maybe-string)
  29729. Mount the volume for the given user.
  29730. @item @code{user-id} (type: maybe-integer-or-range)
  29731. Mount the volume for the user with this ID. This field may also be
  29732. specified as a pair of @code{(start . end)} indicating a range of user
  29733. IDs for whom to mount the volume.
  29734. @item @code{primary-group} (type: maybe-string)
  29735. Mount the volume for users with this primary group name.
  29736. @item @code{group-id} (type: maybe-integer-or-range)
  29737. Mount the volume for the users with this primary group ID. This field
  29738. may also be specified as a cons cell of @code{(start . end)} indicating
  29739. a range of group ids for whom to mount the volume.
  29740. @item @code{secondary-group} (type: maybe-string)
  29741. Mount the volume for users who are members of this group as either a
  29742. primary or secondary group.
  29743. @item @code{file-system-type} (type: maybe-string)
  29744. The file system type for the volume being mounted (e.g., @code{cifs})
  29745. @item @code{no-mount-as-root?} (type: maybe-boolean)
  29746. Whether or not to mount the volume with root privileges. This is
  29747. normally disabled, but may be enabled for mounts of type @code{fuse}, or
  29748. other user-level mounts.
  29749. @item @code{server} (type: maybe-string)
  29750. The name of the remote server to mount the volume from, when necessary.
  29751. @item @code{file-name} (type: maybe-string)
  29752. The location of the volume, either local or remote, depending on the
  29753. @code{file-system-type}.
  29754. @item @code{mount-point} (type: maybe-string)
  29755. Where to mount the volume in the local file-system. This may be set to
  29756. @file{~} to indicate the home directory of the user logging in. If this
  29757. field is omitted then @file{/etc/fstab} is consulted for the mount
  29758. destination.
  29759. @item @code{options} (type: maybe-string)
  29760. The options to be passed as-is to the underlying mount program.
  29761. @item @code{ssh?} (type: maybe-boolean)
  29762. Enable this option to pass the login password to SSH for use with mounts
  29763. involving SSH (e.g., @code{sshfs}).
  29764. @item @code{cipher} (type: maybe-string)
  29765. Cryptsetup cipher name for the volume. To be used with the @code{crypt}
  29766. @code{file-system-type}.
  29767. @item @code{file-system-key-cipher} (type: maybe-string)
  29768. Cipher name used by the target volume.
  29769. @item @code{file-system-key-hash} (type: maybe-string)
  29770. SSL hash name used by the target volume.
  29771. @item @code{file-system-key-file-name} (type: maybe-string)
  29772. File name of the file system key for the target volume.
  29773. @end table
  29774. @end deftp
  29775. @node Guix Services
  29776. @subsection Guix Services
  29777. @subsubheading Build Farm Front-End (BFFE)
  29778. The @uref{https://git.cbaines.net/guix/bffe/,Build Farm Front-End}
  29779. assists with building Guix packages in bulk. It's responsible for
  29780. submitting builds and displaying the status of the build farm.
  29781. @defvar bffe-service-type
  29782. Service type for the Build Farm Front-End. Its value must be a
  29783. @code{bffe-configuration} object.
  29784. @end defvar
  29785. @deftp {Data Type} bffe-configuration
  29786. Data type representing the configuration of the Build Farm Front-End.
  29787. @table @asis
  29788. @item @code{package} (default: @code{bffe})
  29789. The Build Farm Front-End package to use.
  29790. @item @code{user} (default: @code{"bffe"})
  29791. The system user to run the service as.
  29792. @item @code{group} (default: @code{"bffe"})
  29793. The system group to run the service as.
  29794. @item @code{arguments}
  29795. A list of arguments to the Build Farm Front-End. These are passed to
  29796. the @code{run-bffe-service} procedure when starting the service.
  29797. For example, the following value directs the Build Farm Front-End to
  29798. submit builds for derivations available from @code{data.guix.gnu.org} to
  29799. the Build Coordinator instance assumed to be running on the same
  29800. machine.
  29801. @example
  29802. (list
  29803. #:build
  29804. (list
  29805. (build-from-guix-data-service
  29806. (data-service-url "https://data.guix.gnu.org")
  29807. (build-coordinator-url "http://127.0.0.1:8746")
  29808. (branches '("master"))
  29809. (systems '("x86_64-linux" "i686-linux"))
  29810. (systems-and-targets
  29811. (map (lambda (target)
  29812. (cons "x86_64-linux" target))
  29813. '("aarch64-linux-gnu"
  29814. "i586-pc-gnu")))
  29815. (build-priority (const 0))))
  29816. #:web-server-args
  29817. '(#:event-source "https://example.com"
  29818. #:controller-args
  29819. (#:title "example.com build farm")))
  29820. @end example
  29821. @item @code{extra-environment-variables} (default: @var{'()})
  29822. Extra environment variables to set via the shepherd service.
  29823. @end table
  29824. @end deftp
  29825. @subsubheading Guix Build Coordinator
  29826. The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
  29827. Coordinator} aids in distributing derivation builds among machines
  29828. running an @dfn{agent}. The build daemon is still used to build the
  29829. derivations, but the Guix Build Coordinator manages allocating builds
  29830. and working with the results.
  29831. The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
  29832. more connected @dfn{agent} processes. The coordinator process handles
  29833. clients submitting builds, and allocating builds to agents. The agent
  29834. processes talk to a build daemon to actually perform the builds, then
  29835. send the results back to the coordinator.
  29836. There is a script to run the coordinator component of the Guix Build
  29837. Coordinator, but the Guix service uses a custom Guile script instead, to
  29838. provide better integration with G-expressions used in the configuration.
  29839. @defvar guix-build-coordinator-service-type
  29840. Service type for the Guix Build Coordinator. Its value must be a
  29841. @code{guix-build-coordinator-configuration} object.
  29842. @end defvar
  29843. @deftp {Data Type} guix-build-coordinator-configuration
  29844. Data type representing the configuration of the Guix Build Coordinator.
  29845. @table @asis
  29846. @item @code{package} (default: @code{guix-build-coordinator})
  29847. The Guix Build Coordinator package to use.
  29848. @item @code{user} (default: @code{"guix-build-coordinator"})
  29849. The system user to run the service as.
  29850. @item @code{group} (default: @code{"guix-build-coordinator"})
  29851. The system group to run the service as.
  29852. @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
  29853. The URI to use for the database.
  29854. @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
  29855. The URI describing how to listen to requests from agent processes.
  29856. @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
  29857. The URI describing how to listen to requests from clients. The client
  29858. API allows submitting builds and currently isn't authenticated, so take
  29859. care when configuring this value.
  29860. @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
  29861. A G-expression for the allocation strategy to be used. This is a
  29862. procedure that takes the datastore as an argument and populates the
  29863. allocation plan in the database.
  29864. @item @code{hooks} (default: @var{'()})
  29865. An association list of hooks. These provide a way to execute arbitrary
  29866. code upon certain events, like a build result being processed.
  29867. @item @code{parallel-hooks} (default: @var{'()})
  29868. Hooks can be configured to run in parallel. This parameter is an
  29869. association list of hooks to do in parallel, where the key is the symbol
  29870. for the hook and the value is the number of threads to run.
  29871. @item @code{guile} (default: @code{guile-3.0-latest})
  29872. The Guile package with which to run the Guix Build Coordinator.
  29873. @item @code{extra-environment-variables} (default: @var{'()})
  29874. Extra environment variables to set via the shepherd service.
  29875. @end table
  29876. @end deftp
  29877. @defvar guix-build-coordinator-agent-service-type
  29878. Service type for a Guix Build Coordinator agent. Its value must be a
  29879. @code{guix-build-coordinator-agent-configuration} object.
  29880. @end defvar
  29881. @deftp {Data Type} guix-build-coordinator-agent-configuration
  29882. Data type representing the configuration a Guix Build Coordinator agent.
  29883. @table @asis
  29884. @item @code{package} (default: @code{guix-build-coordinator/agent-only})
  29885. The Guix Build Coordinator package to use.
  29886. @item @code{user} (default: @code{"guix-build-coordinator-agent"})
  29887. The system user to run the service as.
  29888. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  29889. The URI to use when connecting to the coordinator.
  29890. @item @code{authentication}
  29891. Record describing how this agent should authenticate with the
  29892. coordinator. Possible record types are described below.
  29893. @item @code{systems} (default: @code{#f})
  29894. The systems for which this agent should fetch builds. The agent process
  29895. will use the current system it's running on as the default.
  29896. @item @code{max-parallel-builds} (default: @code{1})
  29897. The number of builds to perform in parallel.
  29898. @item @code{max-parallel-uploads} (default: @code{1})
  29899. The number of uploads to perform in parallel.
  29900. @item @code{max-allocated-builds} (default: @code{#f})
  29901. The maximum number of builds this agent can be allocated.
  29902. @item @code{max-1min-load-average} (default: @code{#f})
  29903. Load average value to look at when considering starting new builds, if
  29904. the 1 minute load average exceeds this value, the agent will wait before
  29905. starting new builds.
  29906. This will be unspecified if the value is @code{#f}, and the agent will
  29907. use the number of cores reported by the system as the max 1 minute load
  29908. average.
  29909. @item @code{derivation-substitute-urls} (default: @code{#f})
  29910. URLs from which to attempt to fetch substitutes for derivations, if the
  29911. derivations aren't already available.
  29912. @item @code{non-derivation-substitute-urls} (default: @code{#f})
  29913. URLs from which to attempt to fetch substitutes for build inputs, if the
  29914. input store items aren't already available.
  29915. @end table
  29916. @end deftp
  29917. @deftp {Data Type} guix-build-coordinator-agent-password-auth
  29918. Data type representing an agent authenticating with a coordinator via a
  29919. UUID and password.
  29920. @table @asis
  29921. @item @code{uuid}
  29922. The UUID of the agent. This should be generated by the coordinator
  29923. process, stored in the coordinator database, and used by the intended
  29924. agent.
  29925. @item @code{password}
  29926. The password to use when connecting to the coordinator.
  29927. @end table
  29928. @end deftp
  29929. @deftp {Data Type} guix-build-coordinator-agent-password-file-auth
  29930. Data type representing an agent authenticating with a coordinator via a
  29931. UUID and password read from a file.
  29932. @table @asis
  29933. @item @code{uuid}
  29934. The UUID of the agent. This should be generated by the coordinator
  29935. process, stored in the coordinator database, and used by the intended
  29936. agent.
  29937. @item @code{password-file}
  29938. A file containing the password to use when connecting to the
  29939. coordinator.
  29940. @end table
  29941. @end deftp
  29942. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth
  29943. Data type representing an agent authenticating with a coordinator via a
  29944. dynamic auth token and agent name.
  29945. @table @asis
  29946. @item @code{agent-name}
  29947. Name of an agent, this is used to match up to an existing entry in the
  29948. database if there is one. When no existing entry is found, a new entry
  29949. is automatically added.
  29950. @item @code{token}
  29951. Dynamic auth token, this is created and stored in the coordinator
  29952. database, and is used by the agent to authenticate.
  29953. @end table
  29954. @end deftp
  29955. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth-with-file
  29956. Data type representing an agent authenticating with a coordinator via a
  29957. dynamic auth token read from a file and agent name.
  29958. @table @asis
  29959. @item @code{agent-name}
  29960. Name of an agent, this is used to match up to an existing entry in the
  29961. database if there is one. When no existing entry is found, a new entry
  29962. is automatically added.
  29963. @item @code{token-file}
  29964. File containing the dynamic auth token, this is created and stored in
  29965. the coordinator database, and is used by the agent to authenticate.
  29966. @end table
  29967. @end deftp
  29968. The Guix Build Coordinator package contains a script to query an
  29969. instance of the Guix Data Service for derivations to build, and then
  29970. submit builds for those derivations to the coordinator. The service
  29971. type below assists in running this script. This is an additional tool
  29972. that may be useful when building derivations contained within an
  29973. instance of the Guix Data Service.
  29974. @defvar guix-build-coordinator-queue-builds-service-type
  29975. Service type for the
  29976. guix-build-coordinator-queue-builds-from-guix-data-service script. Its
  29977. value must be a @code{guix-build-coordinator-queue-builds-configuration}
  29978. object.
  29979. @end defvar
  29980. @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
  29981. Data type representing the options to the queue builds from guix data
  29982. service script.
  29983. @table @asis
  29984. @item @code{package} (default: @code{guix-build-coordinator})
  29985. The Guix Build Coordinator package to use.
  29986. @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
  29987. The system user to run the service as.
  29988. @item @code{coordinator} (default: @code{"http://localhost:8746"})
  29989. The URI to use when connecting to the coordinator.
  29990. @item @code{systems} (default: @code{#f})
  29991. The systems for which to fetch derivations to build.
  29992. @item @code{systems-and-targets} (default: @code{#f})
  29993. An association list of system and target pairs for which to fetch
  29994. derivations to build.
  29995. @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
  29996. The Guix Data Service instance from which to query to find out about
  29997. derivations to build.
  29998. @item @code{guix-data-service-build-server-id} (default: @code{#f})
  29999. The Guix Data Service build server ID corresponding to the builds being
  30000. submitted. Providing this speeds up the submitting of builds as
  30001. derivations that have already been submitted can be skipped before
  30002. asking the coordinator to build them.
  30003. @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
  30004. A file to record which commits have been processed, to avoid needlessly
  30005. processing them again if the service is restarted.
  30006. @end table
  30007. @end deftp
  30008. @subsubheading Guix Data Service
  30009. The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
  30010. and provides data about GNU Guix. This includes information about
  30011. packages, derivations and lint warnings.
  30012. The data is stored in a PostgreSQL database, and available through a web
  30013. interface.
  30014. @defvar guix-data-service-type
  30015. Service type for the Guix Data Service. Its value must be a
  30016. @code{guix-data-service-configuration} object. The service optionally
  30017. extends the getmail service, as the guix-commits mailing list is used to
  30018. find out about changes in the Guix git repository.
  30019. @end defvar
  30020. @deftp {Data Type} guix-data-service-configuration
  30021. Data type representing the configuration of the Guix Data Service.
  30022. @table @asis
  30023. @item @code{package} (default: @code{guix-data-service})
  30024. The Guix Data Service package to use.
  30025. @item @code{user} (default: @code{"guix-data-service"})
  30026. The system user to run the service as.
  30027. @item @code{group} (default: @code{"guix-data-service"})
  30028. The system group to run the service as.
  30029. @item @code{port} (default: @code{8765})
  30030. The port to bind the web service to.
  30031. @item @code{host} (default: @code{"127.0.0.1"})
  30032. The host to bind the web service to.
  30033. @item @code{getmail-idle-mailboxes} (default: @code{#f})
  30034. If set, this is the list of mailboxes that the getmail service will be
  30035. configured to listen to.
  30036. @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
  30037. If set, this is the @code{getmail-retriever-configuration} object with
  30038. which to configure getmail to fetch mail from the guix-commits mailing
  30039. list.
  30040. @item @code{extra-options} (default: @var{'()})
  30041. Extra command line options for @code{guix-data-service}.
  30042. @item @code{extra-process-jobs-options} (default: @var{'()})
  30043. Extra command line options for @code{guix-data-service-process-jobs}.
  30044. @end table
  30045. @end deftp
  30046. @subsubheading Nar Herder
  30047. The @uref{https://git.cbaines.net/guix/nar-herder/about/,Nar Herder} is
  30048. a utility for managing a collection of nars.
  30049. @defvar nar-herder-type
  30050. Service type for the Guix Data Service. Its value must be a
  30051. @code{nar-herder-configuration} object. The service optionally
  30052. extends the getmail service, as the guix-commits mailing list is used to
  30053. find out about changes in the Guix git repository.
  30054. @end defvar
  30055. @deftp {Data Type} nar-herder-configuration
  30056. Data type representing the configuration of the Guix Data Service.
  30057. @table @asis
  30058. @item @code{package} (default: @code{nar-herder})
  30059. The Nar Herder package to use.
  30060. @item @code{user} (default: @code{"nar-herder"})
  30061. The system user to run the service as.
  30062. @item @code{group} (default: @code{"nar-herder"})
  30063. The system group to run the service as.
  30064. @item @code{port} (default: @code{8734})
  30065. The port to bind the server to.
  30066. @item @code{host} (default: @code{"127.0.0.1"})
  30067. The host to bind the server to.
  30068. @item @code{mirror} (default: @code{#f})
  30069. Optional URL of the other Nar Herder instance which should be mirrored.
  30070. This means that this Nar Herder instance will download it's database,
  30071. and keep it up to date.
  30072. @item @code{database} (default: @code{"/var/lib/nar-herder/nar_herder.db"})
  30073. Location for the database. If this Nar Herder instance is mirroring
  30074. another, the database will be downloaded if it doesn't exist. If this
  30075. Nar Herder instance isn't mirroring another, an empty database will be
  30076. created.
  30077. @item @code{database-dump} (default: @code{"/var/lib/nar-herder/nar_herder_dump.db"})
  30078. Location of the database dump. This is created and regularly updated by
  30079. taking a copy of the database. This is the version of the database that
  30080. is available to download.
  30081. @item @code{storage} (default: @code{#f})
  30082. Optional location in which to store nars.
  30083. @item @code{storage-limit} (default: @code{"none"})
  30084. Limit in bytes for the nars stored in the storage location. This can
  30085. also be set to ``none'' so that there is no limit.
  30086. When the storage location exceeds this size, nars are removed according
  30087. to the nar removal criteria.
  30088. @item @code{storage-nar-removal-criteria} (default: @code{'()})
  30089. Criteria used to remove nars from the storage location. These are used
  30090. in conjunction with the storage limit.
  30091. When the storage location exceeds the storage limit size, nars will be
  30092. checked against the nar removal criteria and if any of the criteria
  30093. match, they will be removed. This will continue until the storage
  30094. location is below the storage limit size.
  30095. Each criteria is specified by a string, then an equals sign, then
  30096. another string. Currently, only one criteria is supported, checking if a
  30097. nar is stored on another Nar Herder instance.
  30098. @item @code{ttl} (default: @code{#f})
  30099. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  30100. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  30101. days, @code{1m} means 1 month, and so on.
  30102. This allows the user's Guix to keep substitute information in cache for
  30103. @var{ttl}.
  30104. @item @code{negative-ttl} (default: @code{#f})
  30105. Similarly produce @code{Cache-Control} HTTP headers to advertise the
  30106. time-to-live (TTL) of @emph{negative} lookups---missing store items, for
  30107. which the HTTP 404 code is returned. By default, no negative TTL is
  30108. advertised.
  30109. @item @code{log-level} (default: @code{'DEBUG})
  30110. Log level to use, specify a log level like @code{'INFO} to stop logging
  30111. individual requests.
  30112. @item @code{cached-compressions} (default: @code{'()})
  30113. Activate generating cached nars with different compression details from
  30114. the stored nars. This is a list of
  30115. nar-herder-cached-compression-configuration records.
  30116. @item @code{min-uses} (default: @code{3})
  30117. When cached-compressions are enabled, generate cached nars when at least
  30118. this number of requests are made for a nar.
  30119. @item @code{workers} (default: @code{2})
  30120. Number of cached nars to generate at a time.
  30121. @item @code{nar-source} (default: @code{#f})
  30122. Location to fetch nars from when computing cached compressions. By
  30123. default, the storage location will be used.
  30124. @item @code{extra-environment-variables} (default: @code{'()})
  30125. Extra environment variables to set via the shepherd service.
  30126. @end table
  30127. @end deftp
  30128. @deftp {Data Type} nar-herder-cached-compression-configuration
  30129. Data type representing the cached compression configuration.
  30130. @table @asis
  30131. @item @code{type}
  30132. Type of compression to use, e.g. @code{'zstd}.
  30133. @item @code{workers} (default: @code{#f})
  30134. Level of the compression to use.
  30135. @item @code{directory} (default: @code{#f})
  30136. Location to store the cached nars. If unspecified, they will be stored
  30137. in /var/cache/nar-herder/nar/TYPE.
  30138. @item @code{directory-max-size} (default: @code{#f})
  30139. Maximum size in bytes of the directory.
  30140. @end table
  30141. @end deftp
  30142. @node Linux Services
  30143. @subsection Linux Services
  30144. @cindex oom
  30145. @cindex out of memory killer
  30146. @cindex earlyoom
  30147. @cindex early out of memory daemon
  30148. @subsubheading Early OOM Service
  30149. @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
  30150. Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
  30151. space and provides a more responsive and configurable alternative to the
  30152. in-kernel OOM killer. It is useful to prevent the system from becoming
  30153. unresponsive when it runs out of memory.
  30154. @defvar earlyoom-service-type
  30155. The service type for running @command{earlyoom}, the Early OOM daemon.
  30156. Its value must be a @code{earlyoom-configuration} object, described
  30157. below. The service can be instantiated in its default configuration
  30158. with:
  30159. @lisp
  30160. (service earlyoom-service-type)
  30161. @end lisp
  30162. @end defvar
  30163. @deftp {Data Type} earlyoom-configuration
  30164. This is the configuration record for the @code{earlyoom-service-type}.
  30165. @table @asis
  30166. @item @code{earlyoom} (default: @var{earlyoom})
  30167. The Earlyoom package to use.
  30168. @item @code{minimum-available-memory} (default: @code{10})
  30169. The threshold for the minimum @emph{available} memory, in percentages.
  30170. @item @code{minimum-free-swap} (default: @code{10})
  30171. The threshold for the minimum free swap memory, in percentages.
  30172. @item @code{prefer-regexp} (default: @code{#f})
  30173. A regular expression (as a string) to match the names of the processes
  30174. that should be preferably killed.
  30175. @item @code{avoid-regexp} (default: @code{#f})
  30176. A regular expression (as a string) to match the names of the processes
  30177. that should @emph{not} be killed.
  30178. @item @code{memory-report-interval} (default: @code{0})
  30179. The interval in seconds at which a memory report is printed. It is
  30180. disabled by default.
  30181. @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
  30182. A boolean indicating whether the positive adjustments set in
  30183. @file{/proc/*/oom_score_adj} should be ignored.
  30184. @item @code{show-debug-messages?} (default: @code{#f})
  30185. A boolean indicating whether debug messages should be printed. The logs
  30186. are saved at @file{/var/log/earlyoom.log}.
  30187. @item @code{send-notification-command} (default: @code{#f})
  30188. This can be used to provide a custom command used for sending
  30189. notifications.
  30190. @end table
  30191. @end deftp
  30192. @subsubheading fstrim Service
  30193. @cindex fstrim service
  30194. @cindex solid state drives, periodic trim
  30195. @cindex solid state drives, trim
  30196. The command @command{fstrim} can be used to discard (or @dfn{trim})
  30197. unused blocks on a mounted file system.
  30198. @c This was copied from the fstrim manpage, with some Texinfo touch-ups.
  30199. @quotation Warning
  30200. Running @command{fstrim} frequently, or even using
  30201. @command{mount -o discard}, might negatively affect the lifetime of
  30202. poor-quality SSD devices. For most desktop and server systems a
  30203. sufficient trimming frequency is once a week. Note that not all devices
  30204. support a queued trim, so each trim command incurs a performance penalty
  30205. on whatever else might be trying to use the disk at the time.
  30206. @end quotation
  30207. @defvar fstrim-service-type
  30208. Type for a service that periodically runs @command{fstrim}, whose value must
  30209. be an @code{<fstrim-configuration>} object. The service can be instantiated
  30210. in its default configuration with:
  30211. @lisp
  30212. (service fstrim-service-type)
  30213. @end lisp
  30214. @end defvar
  30215. @c %start of fragment
  30216. @deftp {Data Type} fstrim-configuration
  30217. Available @code{fstrim-configuration} fields are:
  30218. @table @asis
  30219. @item @code{package} (default: @code{util-linux}) (type: file-like)
  30220. The package providing the @command{fstrim} command.
  30221. @item @code{schedule} (default: @code{"0 0 * * 0"}) (type: mcron-time)
  30222. Schedule for launching @command{fstrim}. This can be a procedure, a
  30223. list or a string. For additional information, see @ref{Guile
  30224. Syntax,,Job specification,mcron,the mcron manual}. By default this is
  30225. set to run weekly on Sunday at 00:00.
  30226. @item @code{listed-in} (default: @code{'("/etc/fstab" "/proc/self/mountinfo")}) (type: maybe-list-of-strings)
  30227. List of files in fstab or kernel mountinfo format. All missing or empty
  30228. files are silently ignored. The evaluation of the list @emph{stops}
  30229. after the first non-empty file. File systems with
  30230. @code{X-fstrim.notrim} mount option in fstab are skipped.
  30231. @item @code{verbose?} (default: @code{#t}) (type: boolean)
  30232. Verbose execution.
  30233. @item @code{quiet-unsupported?} (default: @code{#t}) (type: boolean)
  30234. Suppress error messages if trim operation (ioctl) is unsupported.
  30235. @item @code{extra-arguments} (type: maybe-list-of-strings)
  30236. Extra options to append to @command{fstrim} (run @samp{man fstrim} for
  30237. more information).
  30238. @end table
  30239. @end deftp
  30240. @c %end of fragment
  30241. @cindex modprobe
  30242. @cindex kernel module loader
  30243. @subsubheading Kernel Module Loader Service
  30244. The kernel module loader service allows one to load loadable kernel
  30245. modules at boot. This is especially useful for modules that don't
  30246. autoload and need to be manually loaded, as is the case with
  30247. @code{ddcci}.
  30248. @defvar kernel-module-loader-service-type
  30249. The service type for loading loadable kernel modules at boot with
  30250. @command{modprobe}. Its value must be a list of strings representing
  30251. module names. For example loading the drivers provided by
  30252. @code{ddcci-driver-linux}, in debugging mode by passing some module
  30253. parameters, can be done as follow:
  30254. @lisp
  30255. (use-modules (gnu) (gnu services))
  30256. (use-package-modules linux)
  30257. (use-service-modules linux)
  30258. (define ddcci-config
  30259. (plain-file "ddcci.conf"
  30260. "options ddcci dyndbg delay=120"))
  30261. (operating-system
  30262. ...
  30263. (services (cons* (service kernel-module-loader-service-type
  30264. '("ddcci" "ddcci_backlight"))
  30265. (simple-service 'ddcci-config etc-service-type
  30266. (list `("modprobe.d/ddcci.conf"
  30267. ,ddcci-config)))
  30268. %base-services))
  30269. (kernel-loadable-modules (list ddcci-driver-linux)))
  30270. @end lisp
  30271. @end defvar
  30272. @subsubheading Cachefilesd Service
  30273. @cindex cachefilesd
  30274. @cindex fscache, file system caching (Linux)
  30275. The Cachefilesd service starts a daemon that caches network file system
  30276. data locally. It is especially useful for NFS and AFS shares, where it
  30277. reduces latencies for repeated access when reading files.
  30278. The daemon can be configured as follows:
  30279. @lisp
  30280. (service cachefilesd-service-type
  30281. (cachefilesd-configuration
  30282. (cache-directory "/var/cache/fscache")))
  30283. @end lisp
  30284. @defvar cachefilesd-service-type
  30285. The service type for starting @command{cachefilesd}. The value for this
  30286. service type is a @code{cachefilesd-configuration}, whose only required
  30287. field is @var{cache-directory}.
  30288. @end defvar
  30289. @c %start of fragment
  30290. @deftp {Data Type} cachefilesd-configuration
  30291. Available @code{cachefilesd-configuration} fields are:
  30292. @table @asis
  30293. @item @code{cachefilesd} (default: @code{cachefilesd}) (type: file-like)
  30294. The cachefilesd package to use.
  30295. @item @code{debug-output?} (default: @code{#f}) (type: boolean)
  30296. Print debugging output to stderr.
  30297. @item @code{use-syslog?} (default: @code{#t}) (type: boolean)
  30298. Log to syslog facility instead of stdout.
  30299. @item @code{scan?} (default: @code{#t}) (type: boolean)
  30300. Scan for cachable objects.
  30301. @item @code{cache-directory} (type: maybe-string)
  30302. Location of the cache directory.
  30303. @item @code{cache-name} (default: @code{"CacheFiles"}) (type: maybe-string)
  30304. Name of cache (keep unique).
  30305. @item @code{security-context} (type: maybe-string)
  30306. SELinux security context.
  30307. @item @code{pause-culling-for-block-percentage} (default: @code{7}) (type: maybe-non-negative-integer)
  30308. Pause culling when available blocks exceed this percentage.
  30309. @item @code{pause-culling-for-file-percentage} (default: @code{7}) (type: maybe-non-negative-integer)
  30310. Pause culling when available files exceed this percentage.
  30311. @item @code{resume-culling-for-block-percentage} (default: @code{5}) (type: maybe-non-negative-integer)
  30312. Start culling when available blocks drop below this percentage.
  30313. @item @code{resume-culling-for-file-percentage} (default: @code{5}) (type: maybe-non-negative-integer)
  30314. Start culling when available files drop below this percentage.
  30315. @item @code{pause-caching-for-block-percentage} (default: @code{1}) (type: maybe-non-negative-integer)
  30316. Pause further allocations when available blocks drop below this
  30317. percentage.
  30318. @item @code{pause-caching-for-file-percentage} (default: @code{1}) (type: maybe-non-negative-integer)
  30319. Pause further allocations when available files drop below this
  30320. percentage.
  30321. @item @code{log2-table-size} (default: @code{12}) (type: maybe-non-negative-integer)
  30322. Size of tables holding cullable objects in logarithm of base 2.
  30323. @item @code{cull?} (default: @code{#t}) (type: boolean)
  30324. Create free space by culling (consumes system load).
  30325. @item @code{trace-function-entry-in-kernel-module?} (default: @code{#f}) (type: boolean)
  30326. Trace function entry in the kernel module (for debugging).
  30327. @item @code{trace-function-exit-in-kernel-module?} (default: @code{#f}) (type: boolean)
  30328. Trace function exit in the kernel module (for debugging).
  30329. @item @code{trace-internal-checkpoints-in-kernel-module?} (default: @code{#f}) (type: boolean)
  30330. Trace internal checkpoints in the kernel module (for debugging).
  30331. @end table
  30332. @end deftp
  30333. @c %end of fragment
  30334. @cindex rasdaemon
  30335. @cindex Platform Reliability, Availability and Serviceability daemon
  30336. @subsubheading Rasdaemon Service
  30337. The Rasdaemon service provides a daemon which monitors platform
  30338. @acronym{RAS, Reliability@comma{} Availability@comma{} and Serviceability} reports from
  30339. Linux kernel trace events, logging them to syslogd.
  30340. Reliability, Availability and Serviceability is a concept used on servers meant
  30341. to measure their robustness.
  30342. @strong{Relability} is the probability that a system will produce correct
  30343. outputs:
  30344. @itemize @bullet
  30345. @item Generally measured as Mean Time Between Failures (MTBF), and
  30346. @item Enhanced by features that help to avoid, detect and repair hardware
  30347. faults
  30348. @end itemize
  30349. @strong{Availability} is the probability that a system is operational at a
  30350. given time:
  30351. @itemize @bullet
  30352. @item Generally measured as a percentage of downtime per a period of time, and
  30353. @item Often uses mechanisms to detect and correct hardware faults in runtime.
  30354. @end itemize
  30355. @strong{Serviceability} is the simplicity and speed with which a system can be
  30356. repaired or maintained:
  30357. @itemize @bullet
  30358. @item Generally measured on Mean Time Between Repair (MTBR).
  30359. @end itemize
  30360. Among the monitoring measures, the most usual ones include:
  30361. @itemize @bullet
  30362. @item CPU – detect errors at instruction execution and at L1/L2/L3 caches;
  30363. @item Memory – add error correction logic (ECC) to detect and correct errors;
  30364. @item I/O – add CRC checksums for transferred data;
  30365. @item Storage – RAID, journal file systems, checksums, Self-Monitoring,
  30366. Analysis and Reporting Technology (SMART).
  30367. @end itemize
  30368. By monitoring the number of occurrences of error detections, it is possible to
  30369. identify if the probability of hardware errors is increasing, and, on such
  30370. case, do a preventive maintenance to replace a degraded component while those
  30371. errors are correctable.
  30372. For detailed information about the types of error events gathered and how to
  30373. make sense of them, see the kernel administrator's guide at
  30374. @url{https://www.kernel.org/doc/html/latest/admin-guide/ras.html}.
  30375. @defvar rasdaemon-service-type
  30376. Service type for the @command{rasdaemon} service. It accepts a
  30377. @code{rasdaemon-configuration} object. Instantiating like
  30378. @lisp
  30379. (service rasdaemon-service-type)
  30380. @end lisp
  30381. will load with a default configuration, which monitors all events and logs to
  30382. syslogd.
  30383. @end defvar
  30384. @deftp {Data Type} rasdaemon-configuration
  30385. The data type representing the configuration of @command{rasdaemon}.
  30386. @table @asis
  30387. @item @code{record?} (default: @code{#f})
  30388. A boolean indicating whether to record the events in an SQLite database. This
  30389. provides a more structured access to the information contained in the log file.
  30390. The database location is hard-coded to @file{/var/lib/rasdaemon/ras-mc_event.db}.
  30391. @end table
  30392. @end deftp
  30393. @cindex zram
  30394. @cindex compressed swap
  30395. @cindex Compressed RAM-based block devices
  30396. @subsubheading Zram Device Service
  30397. The Zram device service provides a compressed swap device in system
  30398. memory. The Linux Kernel documentation has more information about
  30399. @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
  30400. devices.
  30401. @defvar zram-device-service-type
  30402. This service creates the zram block device, formats it as swap and
  30403. enables it as a swap device. The service's value is a
  30404. @code{zram-device-configuration} record.
  30405. @deftp {Data Type} zram-device-configuration
  30406. This is the data type representing the configuration for the zram-device
  30407. service.
  30408. @table @asis
  30409. @item @code{size} (default @code{"1G"})
  30410. This is the amount of space you wish to provide for the zram device. It
  30411. accepts a string and can be a number of bytes or use a suffix, eg.:
  30412. @code{"512M"} or @code{1024000}.
  30413. @item @code{compression-algorithm} (default @code{'lzo})
  30414. This is the compression algorithm you wish to use. It is difficult to
  30415. list all the possible compression options, but common ones supported by
  30416. Guix's Linux Libre Kernel include @code{'lzo}, @code{'lz4} and @code{'zstd}.
  30417. @item @code{memory-limit} (default @code{0})
  30418. This is the maximum amount of memory which the zram device can use.
  30419. Setting it to '0' disables the limit. While it is generally expected
  30420. that compression will be 2:1, it is possible that uncompressable data
  30421. can be written to swap and this is a method to limit how much memory can
  30422. be used. It accepts a string and can be a number of bytes or use a
  30423. suffix, eg.: @code{"2G"}.
  30424. @item @code{priority} (default @code{#f})
  30425. This is the priority of the swap device created from the zram device.
  30426. @xref{Swap Space} for a description of swap priorities. You might want
  30427. to set a specific priority for the zram device, otherwise it could end
  30428. up not being used much for the reasons described there.
  30429. @end table
  30430. @end deftp
  30431. @end defvar
  30432. @node Hurd Services
  30433. @subsection Hurd Services
  30434. @defvar hurd-console-service-type
  30435. This service starts the fancy @code{VGA} console client on the Hurd.
  30436. The service's value is a @code{hurd-console-configuration} record.
  30437. @end defvar
  30438. @deftp {Data Type} hurd-console-configuration
  30439. This is the data type representing the configuration for the
  30440. hurd-console-service.
  30441. @table @asis
  30442. @item @code{hurd} (default: @var{hurd})
  30443. The Hurd package to use.
  30444. @end table
  30445. @end deftp
  30446. @defvar hurd-getty-service-type
  30447. This service starts a tty using the Hurd @code{getty} program.
  30448. The service's value is a @code{hurd-getty-configuration} record.
  30449. @end defvar
  30450. @deftp {Data Type} hurd-getty-configuration
  30451. This is the data type representing the configuration for the
  30452. hurd-getty-service.
  30453. @table @asis
  30454. @item @code{hurd} (default: @var{hurd})
  30455. The Hurd package to use.
  30456. @item @code{tty}
  30457. The name of the console this Getty runs on---e.g., @code{"tty1"}.
  30458. @item @code{baud-rate} (default: @code{38400})
  30459. An integer specifying the baud rate of the tty.
  30460. @end table
  30461. @end deftp
  30462. @node Miscellaneous Services
  30463. @subsection Miscellaneous Services
  30464. @cindex fingerprint
  30465. @subsubheading Fingerprint Service
  30466. The @code{(gnu services authentication)} module provides a DBus service to
  30467. read and identify fingerprints via a fingerprint sensor.
  30468. @defvar fprintd-service-type
  30469. The service type for @command{fprintd}, which provides the fingerprint
  30470. reading capability.
  30471. @lisp
  30472. (service fprintd-service-type)
  30473. @end lisp
  30474. @end defvar
  30475. @cindex sysctl
  30476. @subsubheading System Control Service
  30477. The @code{(gnu services sysctl)} provides a service to configure kernel
  30478. parameters at boot.
  30479. @defvar sysctl-service-type
  30480. The service type for @command{sysctl}, which modifies kernel parameters
  30481. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  30482. instantiated as:
  30483. @lisp
  30484. (service sysctl-service-type
  30485. (sysctl-configuration
  30486. (settings '(("net.ipv4.ip_forward" . "1")))))
  30487. @end lisp
  30488. Since @code{sysctl-service-type} is used in the default lists of
  30489. services, @code{%base-services} and @code{%desktop-services}, you can
  30490. use @code{modify-services} to change its configuration and add the
  30491. kernel parameters that you want (@pxref{Service Reference,
  30492. @code{modify-services}}).
  30493. @lisp
  30494. (modify-services %base-services
  30495. (sysctl-service-type config =>
  30496. (sysctl-configuration
  30497. (settings (append '(("net.ipv4.ip_forward" . "1"))
  30498. %default-sysctl-settings)))))
  30499. @end lisp
  30500. @end defvar
  30501. @deftp {Data Type} sysctl-configuration
  30502. The data type representing the configuration of @command{sysctl}.
  30503. @table @asis
  30504. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  30505. The @command{sysctl} executable to use.
  30506. @item @code{settings} (default: @code{%default-sysctl-settings})
  30507. An association list specifies kernel parameters and their values.
  30508. @end table
  30509. @end deftp
  30510. @defvar %default-sysctl-settings
  30511. An association list specifying the default @command{sysctl} parameters
  30512. on Guix System.
  30513. @end defvar
  30514. @cindex pcscd
  30515. @subsubheading PC/SC Smart Card Daemon Service
  30516. The @code{(gnu services security-token)} module provides the following service
  30517. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  30518. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  30519. manager that coordinates communications with smart card readers, smart cards
  30520. and cryptographic tokens that are connected to the system.
  30521. @defvar pcscd-service-type
  30522. Service type for the @command{pcscd} service. Its value must be a
  30523. @code{pcscd-configuration} object. To run pcscd in the default
  30524. configuration, instantiate it as:
  30525. @lisp
  30526. (service pcscd-service-type)
  30527. @end lisp
  30528. @end defvar
  30529. @deftp {Data Type} pcscd-configuration
  30530. The data type representing the configuration of @command{pcscd}.
  30531. @table @asis
  30532. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  30533. The pcsc-lite package that provides pcscd.
  30534. @item @code{usb-drivers} (default: @code{(list ccid)})
  30535. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  30536. under @file{pcsc/drivers} in the store directory of the package.
  30537. @end table
  30538. @end deftp
  30539. @cindex LIRC
  30540. @subsubheading LIRC Service
  30541. The @code{(gnu services lirc)} module provides the following service.
  30542. @defvar lirc-service-type
  30543. Type for a service that runs @url{http://www.lirc.org, LIRC}, a daemon
  30544. that decodes infrared signals from remote controls.
  30545. The value for this service is a @code{<lirc-configuration>} object.
  30546. @end defvar
  30547. @deftp {Data Type} lirc-configuration
  30548. Data type representing the configuration of @command{lircd}.
  30549. @table @asis
  30550. @item @code{lirc} (default: @code{lirc}) (type: file-like)
  30551. Package object for @command{lirc}.
  30552. @item @code{device} (default: @code{#f}) (type: string)
  30553. @itemx @code{driver} (default: @code{#f}) (type: string)
  30554. @itemx @code{config-file} (default: @code{#f}) (type: string-or-file-like)
  30555. TODO. See @command{lircd} manual for details.
  30556. @item @code{extra-options} (default: @code{'()}) (type: list-of-string)
  30557. Additional command-line options to pass to @command{lircd}.
  30558. @end table
  30559. @end deftp
  30560. @c TODO: Document <lirc-configuration>, preferably by refactoring this to use
  30561. @c define-configuration and generating documentation from it.
  30562. @cindex SPICE
  30563. @subsubheading SPICE Service
  30564. The @code{(gnu services spice)} module provides the following service.
  30565. @defvar spice-vdagent-service-type
  30566. Type of the service that runs @url{https://www.spice-space.org, VDAGENT},
  30567. a daemon that enables sharing the clipboard with a vm and setting the
  30568. guest display resolution when the graphical console window resizes.
  30569. @end defvar
  30570. @deftp {Data Type} spice-vdagent-configuration
  30571. Data type representing the configuration of
  30572. @code{spice-vdagent-service-type}.
  30573. @table @asis
  30574. @item @code{spice-vdagent} (default: @code{spice-vdagent}) (type: file-like)
  30575. Package object for VDAGENT.
  30576. @end table
  30577. @end deftp
  30578. @cindex inputattach
  30579. @subsubheading inputattach Service
  30580. @cindex tablet input, for Xorg
  30581. @cindex touchscreen input, for Xorg
  30582. The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
  30583. use input devices such as Wacom tablets, touchscreens, or joysticks with the
  30584. Xorg display server.
  30585. @defvar inputattach-service-type
  30586. Type of a service that runs @command{inputattach} on a device and
  30587. dispatches events from it.
  30588. @end defvar
  30589. @deftp {Data Type} inputattach-configuration
  30590. @table @asis
  30591. @item @code{device-type} (default: @code{"wacom"})
  30592. The type of device to connect to. Run @command{inputattach --help}, from the
  30593. @code{inputattach} package, to see the list of supported device types.
  30594. @item @code{device} (default: @code{"/dev/ttyS0"})
  30595. The device file to connect to the device.
  30596. @item @code{baud-rate} (default: @code{#f})
  30597. Baud rate to use for the serial connection.
  30598. Should be a number or @code{#f}.
  30599. @item @code{log-file} (default: @code{#f})
  30600. If true, this must be the name of a file to log messages to.
  30601. @end table
  30602. @end deftp
  30603. @subsubheading Dictionary Service
  30604. @cindex dictionary
  30605. The @code{(gnu services dict)} module provides the following service:
  30606. @defvar dicod-service-type
  30607. This is the type of the service that runs the @command{dicod} daemon, an
  30608. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  30609. You can add @command{open localhost} to your @file{~/.dico} file to make
  30610. @code{localhost} the default server for @command{dico} client
  30611. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  30612. @quotation Note
  30613. This service is also available for Guix Home, where it runs directly
  30614. with your user privileges (@pxref{Miscellaneous Home Services,
  30615. @code{home-dicod-service-type}}).
  30616. @end quotation
  30617. @end defvar
  30618. @deftp {Data Type} dicod-configuration
  30619. Data type representing the configuration of dicod.
  30620. @table @asis
  30621. @item @code{dico} (default: @var{dico})
  30622. Package object of the GNU Dico dictionary server.
  30623. @item @code{interfaces} (default: @var{'("localhost")})
  30624. This is the list of IP addresses and ports and possibly socket file
  30625. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  30626. dico, GNU Dico Manual}).
  30627. @item @code{handlers} (default: @var{'()})
  30628. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  30629. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  30630. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  30631. @end table
  30632. @end deftp
  30633. @deftp {Data Type} dicod-handler
  30634. Data type representing a dictionary handler (module instance).
  30635. @table @asis
  30636. @item @code{name}
  30637. Name of the handler (module instance).
  30638. @item @code{module} (default: @var{#f})
  30639. Name of the dicod module of the handler (instance). If it is @code{#f},
  30640. the module has the same name as the handler.
  30641. (@pxref{Modules,,, dico, GNU Dico Manual}).
  30642. @item @code{options}
  30643. List of strings or gexps representing the arguments for the module handler
  30644. @end table
  30645. @end deftp
  30646. @deftp {Data Type} dicod-database
  30647. Data type representing a dictionary database.
  30648. @table @asis
  30649. @item @code{name}
  30650. Name of the database, will be used in DICT commands.
  30651. @item @code{handler}
  30652. Name of the dicod handler (module instance) used by this database
  30653. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  30654. @item @code{complex?} (default: @var{#f})
  30655. Whether the database configuration complex. The complex configuration
  30656. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  30657. @item @code{options}
  30658. List of strings or gexps representing the arguments for the database
  30659. (@pxref{Databases,,, dico, GNU Dico Manual}).
  30660. @end table
  30661. @end deftp
  30662. @defvar %dicod-database:gcide
  30663. A @code{<dicod-database>} object serving the GNU Collaborative International
  30664. Dictionary of English using the @code{gcide} package.
  30665. @end defvar
  30666. The following is an example @code{dicod-service-type} configuration.
  30667. @lisp
  30668. (service dicod-service-type
  30669. (dicod-configuration
  30670. (handlers (list
  30671. (dicod-handler
  30672. (name "wordnet")
  30673. (module "wordnet")
  30674. (options
  30675. (list #~(string-append "wnhome=" #$wordnet))))))
  30676. (databases (list
  30677. (dicod-database
  30678. (name "wordnet")
  30679. (complex? #t)
  30680. (handler "wordnet"))
  30681. %dicod-database:gcide))))
  30682. @end lisp
  30683. @cindex Docker
  30684. @subsubheading Docker Service
  30685. The @code{(gnu services docker)} module provides the following services.
  30686. @defvar docker-service-type
  30687. This is the type of the service that runs @url{https://www.docker.com,Docker},
  30688. a daemon that can execute application bundles (sometimes referred to as
  30689. ``containers'') in isolated environments.
  30690. @end defvar
  30691. @deftp {Data Type} docker-configuration
  30692. This is the data type representing the configuration of Docker and Containerd.
  30693. @table @asis
  30694. @item @code{docker} (default: @code{docker})
  30695. The Docker daemon package to use.
  30696. @item @code{docker-cli} (default: @code{docker-cli})
  30697. The Docker client package to use.
  30698. @item @code{containerd} (default: @var{containerd})
  30699. The Containerd package to use.
  30700. @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
  30701. The Docker user-land networking proxy package to use.
  30702. @item @code{enable-proxy?} (default @code{#t})
  30703. Enable or disable the use of the Docker user-land networking proxy.
  30704. @item @code{debug?} (default @code{#f})
  30705. Enable or disable debug output.
  30706. @item @code{enable-iptables?} (default @code{#t})
  30707. Enable or disable the addition of iptables rules.
  30708. @item @code{environment-variables} (default: @code{'()})
  30709. List of environment variables to set for @command{dockerd}.
  30710. This must be a list of strings where each string has the form
  30711. @samp{@var{key}=@var{value}} as in this example:
  30712. @lisp
  30713. (list "LANGUAGE=eo:ca:eu"
  30714. "TMPDIR=/tmp/dockerd")
  30715. @end lisp
  30716. @end table
  30717. @end deftp
  30718. @cindex Singularity, container service
  30719. @defvar singularity-service-type
  30720. This is the type of the service that allows you to run
  30721. @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
  30722. create and run application bundles (aka. ``containers''). The value for this
  30723. service is the Singularity package to use.
  30724. The service does not install a daemon; instead, it installs helper programs as
  30725. setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
  30726. @command{singularity run} and similar commands.
  30727. @end defvar
  30728. @cindex Audit
  30729. @subsubheading Auditd Service
  30730. The @code{(gnu services auditd)} module provides the following service.
  30731. @defvar auditd-service-type
  30732. This is the type of the service that runs
  30733. @url{https://people.redhat.com/sgrubb/audit/,auditd},
  30734. a daemon that tracks security-relevant information on your system.
  30735. Examples of things that can be tracked:
  30736. @enumerate
  30737. @item
  30738. File accesses
  30739. @item
  30740. System calls
  30741. @item
  30742. Invoked commands
  30743. @item
  30744. Failed login attempts
  30745. @item
  30746. Firewall filtering
  30747. @item
  30748. Network access
  30749. @end enumerate
  30750. @command{auditctl} from the @code{audit} package can be used in order
  30751. to add or remove events to be tracked (until the next reboot).
  30752. In order to permanently track events, put the command line arguments
  30753. of auditctl into a file called @code{audit.rules} in the configuration
  30754. directory (see below).
  30755. @command{aureport} from the @code{audit} package can be used in order
  30756. to view a report of all recorded events.
  30757. The audit daemon by default logs into the file
  30758. @file{/var/log/audit.log}.
  30759. @end defvar
  30760. @deftp {Data Type} auditd-configuration
  30761. This is the data type representing the configuration of auditd.
  30762. @table @asis
  30763. @item @code{audit} (default: @code{audit})
  30764. The audit package to use.
  30765. @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
  30766. The directory containing the configuration file for the audit package, which
  30767. must be named @code{auditd.conf}, and optionally some audit rules to
  30768. instantiate on startup.
  30769. @end table
  30770. @end deftp
  30771. @cindex rshiny
  30772. @subsubheading R-Shiny service
  30773. The @code{(gnu services science)} module provides the following service.
  30774. @defvar rshiny-service-type
  30775. This is a type of service which is used to run a webapp created with
  30776. @code{r-shiny}. This service sets the @env{R_LIBS_USER} environment
  30777. variable and runs the provided script to call @code{runApp}.
  30778. @deftp {Data Type} rshiny-configuration
  30779. This is the data type representing the configuration of rshiny.
  30780. @table @asis
  30781. @item @code{package} (default: @code{r-shiny})
  30782. The package to use.
  30783. @item @code{binary} (default @code{"rshiny"})
  30784. The name of the binary or shell script located at @code{package/bin/} to
  30785. run when the service is run.
  30786. The common way to create this file is as follows:
  30787. @lisp
  30788. @dots{}
  30789. (let* ((out (assoc-ref %outputs "out"))
  30790. (targetdir (string-append out "/share/" ,name))
  30791. (app (string-append out "/bin/" ,name))
  30792. (Rbin (search-input-file %build-inputs "/bin/Rscript")))
  30793. ;; @dots{}
  30794. (mkdir-p (string-append out "/bin"))
  30795. (call-with-output-file app
  30796. (lambda (port)
  30797. (format port
  30798. "#!~a
  30799. library(shiny)
  30800. setwd(\"~a\")
  30801. runApp(launch.browser=0, port=4202)~%\n"
  30802. Rbin targetdir))))
  30803. @end lisp
  30804. @end table
  30805. @end deftp
  30806. @end defvar
  30807. @cindex Nix
  30808. @subsubheading Nix service
  30809. The @code{(gnu services nix)} module provides the following service.
  30810. @defvar nix-service-type
  30811. This is the type of the service that runs build daemon of the
  30812. @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
  30813. how to use it:
  30814. @lisp
  30815. (use-modules (gnu))
  30816. (use-service-modules nix)
  30817. (use-package-modules package-management)
  30818. (operating-system
  30819. ;; @dots{}
  30820. (packages (append (list nix)
  30821. %base-packages))
  30822. (services (append (list (service nix-service-type))
  30823. %base-services)))
  30824. @end lisp
  30825. After @command{guix system reconfigure} configure Nix for your user:
  30826. @itemize
  30827. @item Add a Nix channel and update it. See
  30828. @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
  30829. @item Create a symlink to your profile and activate Nix profile:
  30830. @end itemize
  30831. @example
  30832. $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
  30833. $ source /run/current-system/profile/etc/profile.d/nix.sh
  30834. @end example
  30835. @end defvar
  30836. @deftp {Data Type} nix-configuration
  30837. This data type represents the configuration of the Nix daemon.
  30838. @table @asis
  30839. @item @code{nix} (default: @code{nix})
  30840. The Nix package to use.
  30841. @item @code{sandbox} (default: @code{#t})
  30842. Specifies whether builds are sandboxed by default.
  30843. @item @code{build-directory} (default: @code{"/tmp"})
  30844. The directory where build directory are stored during builds.
  30845. This is useful to change if, for example, the default location does not
  30846. have enough space to hold build trees for big packages.
  30847. This is similar to setting the @env{TMPDIR} environment variable for
  30848. @command{guix-daemon}. @ref{Build Environment Setup, @env{TMPDIR}},
  30849. for more info.
  30850. @item @code{build-sandbox-items} (default: @code{'()})
  30851. This is a list of strings or objects appended to the
  30852. @code{build-sandbox-items} field of the configuration file.
  30853. @item @code{extra-config} (default: @code{'()})
  30854. This is a list of strings or objects appended to the configuration file.
  30855. It is used to pass extra text to be added verbatim to the configuration
  30856. file.
  30857. @item @code{extra-options} (default: @code{'()})
  30858. Extra command line options for @code{nix-service-type}.
  30859. @end table
  30860. @end deftp
  30861. @cindex Fail2Ban
  30862. @subsubheading Fail2Ban service
  30863. @uref{http://www.fail2ban.org/, @code{fail2ban}} scans log files
  30864. (e.g. @code{/var/log/apache/error_log}) and bans IP addresses that show
  30865. malicious signs -- repeated password failures, attempts to make use of
  30866. exploits, etc.
  30867. @code{fail2ban-service-type} service type is provided by the @code{(gnu
  30868. services security)} module.
  30869. This service type runs the @code{fail2ban} daemon. It can be configured
  30870. in various ways, which are:
  30871. @table @asis
  30872. @item Basic configuration
  30873. The basic parameters of the Fail2Ban service can be configured via its
  30874. @code{fail2ban} configuration, which is documented below.
  30875. @item User-specified jail extensions
  30876. The @code{fail2ban-jail-service} function can be used to add new
  30877. Fail2Ban jails.
  30878. @item Shepherd extension mechanism
  30879. Service developers can extend the @code{fail2ban-service-type} service
  30880. type itself via the usual service extension mechanism.
  30881. @end table
  30882. @defvar fail2ban-service-type
  30883. This is the type of the service that runs @code{fail2ban} daemon. Below
  30884. is an example of a basic, explicit configuration:
  30885. @lisp
  30886. (append
  30887. (list
  30888. (service fail2ban-service-type
  30889. (fail2ban-configuration
  30890. (extra-jails
  30891. (list
  30892. (fail2ban-jail-configuration
  30893. (name "sshd")
  30894. (enabled? #t))))))
  30895. ;; There is no implicit dependency on an actual SSH
  30896. ;; service, so you need to provide one.
  30897. (service openssh-service-type))
  30898. %base-services)
  30899. @end lisp
  30900. @end defvar
  30901. @deffn {Procedure} fail2ban-jail-service svc-type jail
  30902. Extend @var{svc-type}, a @code{<service-type>} object with @var{jail}, a
  30903. @code{fail2ban-jail-configuration} object.
  30904. For example:
  30905. @lisp
  30906. (append
  30907. (list
  30908. (service
  30909. ;; The 'fail2ban-jail-service' procedure can extend any service type
  30910. ;; with a fail2ban jail. This removes the requirement to explicitly
  30911. ;; extend services with fail2ban-service-type.
  30912. (fail2ban-jail-service
  30913. openssh-service-type
  30914. (fail2ban-jail-configuration
  30915. (name "sshd")
  30916. (enabled? #t)))
  30917. (openssh-configuration ...))))
  30918. @end lisp
  30919. @end deffn
  30920. Below is the reference for the different @code{jail-service-type}
  30921. configuration records.
  30922. @c The documentation is to be auto-generated via
  30923. @c 'generate-documentation'. See at the bottom of (gnu services
  30924. @c security).
  30925. @deftp {Data Type} fail2ban-configuration
  30926. Available @code{fail2ban-configuration} fields are:
  30927. @table @asis
  30928. @item @code{fail2ban} (default: @code{fail2ban}) (type: package)
  30929. The @code{fail2ban} package to use. It is used for both binaries and as
  30930. base default configuration that is to be extended with
  30931. @code{<fail2ban-jail-configuration>} objects.
  30932. @item @code{run-directory} (default: @code{"/var/run/fail2ban"}) (type: string)
  30933. The state directory for the @code{fail2ban} daemon.
  30934. @item @code{jails} (default: @code{'()}) (type: list-of-fail2ban-jail-configurations)
  30935. Instances of @code{<fail2ban-jail-configuration>} collected from
  30936. extensions.
  30937. @item @code{extra-jails} (default: @code{'()}) (type: list-of-fail2ban-jail-configurations)
  30938. Instances of @code{<fail2ban-jail-configuration>} explicitly provided.
  30939. @item @code{extra-content} (default: @code{'()}) (type: text-config)
  30940. Extra raw content to add to the end of the @file{jail.local} file,
  30941. provided as a list of file-like objects.
  30942. @end table
  30943. @end deftp
  30944. @deftp {Data Type} fail2ban-ignore-cache-configuration
  30945. Available @code{fail2ban-ignore-cache-configuration} fields are:
  30946. @table @asis
  30947. @item @code{key} (type: string)
  30948. Cache key.
  30949. @item @code{max-count} (type: integer)
  30950. Cache size.
  30951. @item @code{max-time} (type: integer)
  30952. Cache time.
  30953. @end table
  30954. @end deftp
  30955. @deftp {Data Type} fail2ban-jail-action-configuration
  30956. Available @code{fail2ban-jail-action-configuration} fields are:
  30957. @table @asis
  30958. @item @code{name} (type: string)
  30959. Action name.
  30960. @item @code{arguments} (default: @code{'()}) (type: list-of-arguments)
  30961. Action arguments.
  30962. @end table
  30963. @end deftp
  30964. @deftp {Data Type} fail2ban-jail-configuration
  30965. Available @code{fail2ban-jail-configuration} fields are:
  30966. @table @asis
  30967. @item @code{name} (type: string)
  30968. Required name of this jail configuration.
  30969. @item @code{enabled?} (default: @code{#t}) (type: boolean)
  30970. Whether this jail is enabled.
  30971. @item @code{backend} (type: maybe-symbol)
  30972. Backend to use to detect changes in the @code{log-path}. The default is
  30973. 'auto. To consult the defaults of the jail configuration, refer to the
  30974. @file{/etc/fail2ban/jail.conf} file of the @code{fail2ban} package.
  30975. @item @code{max-retry} (type: maybe-integer)
  30976. The number of failures before a host get banned (e.g. @code{(max-retry
  30977. 5)}).
  30978. @item @code{max-matches} (type: maybe-integer)
  30979. The number of matches stored in ticket (resolvable via tag
  30980. @code{<matches>}) in action.
  30981. @item @code{find-time} (type: maybe-string)
  30982. The time window during which the maximum retry count must be reached for
  30983. an IP address to be banned. A host is banned if it has generated
  30984. @code{max-retry} during the last @code{find-time} seconds (e.g.
  30985. @code{(find-time "10m")}). It can be provided in seconds or using
  30986. Fail2Ban's "time abbreviation format", as described in @command{man 5
  30987. jail.conf}.
  30988. @item @code{ban-time} (type: maybe-string)
  30989. The duration, in seconds or time abbreviated format, that a ban should
  30990. last. (e.g. @code{(ban-time "10m")}).
  30991. @item @code{ban-time-increment?} (type: maybe-boolean)
  30992. Whether to consider past bans to compute increases to the default ban
  30993. time of a specific IP address.
  30994. @item @code{ban-time-factor} (type: maybe-string)
  30995. The coefficient to use to compute an exponentially growing ban time.
  30996. @item @code{ban-time-formula} (type: maybe-string)
  30997. This is the formula used to calculate the next value of a ban time.
  30998. @item @code{ban-time-multipliers} (type: maybe-string)
  30999. Used to calculate next value of ban time instead of formula.
  31000. @item @code{ban-time-max-time} (type: maybe-string)
  31001. The maximum number of seconds a ban should last.
  31002. @item @code{ban-time-rnd-time} (type: maybe-string)
  31003. The maximum number of seconds a randomized ban time should last. This
  31004. can be useful to stop ``clever'' botnets calculating the exact time an
  31005. IP address can be unbanned again.
  31006. @item @code{ban-time-overall-jails?} (type: maybe-boolean)
  31007. When true, it specifies the search of an IP address in the database
  31008. should be made across all jails. Otherwise, only the current jail of
  31009. the ban IP address is considered.
  31010. @item @code{ignore-self?} (type: maybe-boolean)
  31011. Never ban the local machine's own IP address.
  31012. @item @code{ignore-ip} (default: @code{'()}) (type: list-of-strings)
  31013. A list of IP addresses, CIDR masks or DNS hosts to ignore.
  31014. @code{fail2ban} will not ban a host which matches an address in this
  31015. list.
  31016. @item @code{ignore-cache} (type: maybe-fail2ban-ignore-cache-configuration)
  31017. Provide cache parameters for the ignore failure check.
  31018. @item @code{filter} (type: maybe-fail2ban-jail-filter-configuration)
  31019. The filter to use by the jail, specified via a
  31020. @code{<fail2ban-jail-filter-configuration>} object. By default, jails
  31021. have names matching their filter name.
  31022. @item @code{log-time-zone} (type: maybe-string)
  31023. The default time zone for log lines that do not have one.
  31024. @item @code{log-encoding} (type: maybe-symbol)
  31025. The encoding of the log files handled by the jail. Possible values are:
  31026. @code{'ascii}, @code{'utf-8} and @code{'auto}.
  31027. @item @code{log-path} (default: @code{'()}) (type: list-of-strings)
  31028. The file names of the log files to be monitored.
  31029. @item @code{action} (default: @code{'()}) (type: list-of-fail2ban-jail-actions)
  31030. A list of @code{<fail2ban-jail-action-configuration>}.
  31031. @item @code{extra-content} (default: @code{'()}) (type: text-config)
  31032. Extra content for the jail configuration, provided as a list of file-like
  31033. objects.
  31034. @end table
  31035. @end deftp
  31036. @deftp {Data Type} fail2ban-jail-filter-configuration
  31037. Available @code{fail2ban-jail-filter-configuration} fields are:
  31038. @table @asis
  31039. @item @code{name} (type: string)
  31040. Filter to use.
  31041. @item @code{mode} (type: maybe-string)
  31042. Mode for filter.
  31043. @end table
  31044. @end deftp
  31045. @c End of auto-generated fail2ban documentation.
  31046. @node Setuid Programs
  31047. @section Setuid Programs
  31048. @cindex setuid programs
  31049. @cindex setgid programs
  31050. Some programs need to run with elevated privileges, even when they are
  31051. launched by unprivileged users. A notorious example is the
  31052. @command{passwd} program, which users can run to change their
  31053. password, and which needs to access the @file{/etc/passwd} and
  31054. @file{/etc/shadow} files---something normally restricted to root, for
  31055. obvious security reasons. To address that, @command{passwd} should be
  31056. @dfn{setuid-root}, meaning that it always runs with root privileges
  31057. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  31058. for more info about the setuid mechanism).
  31059. The store itself @emph{cannot} contain setuid programs: that would be a
  31060. security issue since any user on the system can write derivations that
  31061. populate the store (@pxref{The Store}). Thus, a different mechanism is
  31062. used: instead of changing the setuid or setgid bits directly on files that
  31063. are in the store, we let the system administrator @emph{declare} which
  31064. programs should be entrusted with these additional privileges.
  31065. The @code{setuid-programs} field of an @code{operating-system}
  31066. declaration contains a list of @code{<setuid-program>} denoting the
  31067. names of programs to have a setuid or setgid bit set (@pxref{Using the
  31068. Configuration System}). For instance, the @command{mount.nfs} program,
  31069. which is part of the nfs-utils package, with a setuid root can be
  31070. designated like this:
  31071. @lisp
  31072. (setuid-program
  31073. (program (file-append nfs-utils "/sbin/mount.nfs")))
  31074. @end lisp
  31075. And then, to make @command{mount.nfs} setuid on your system, add the
  31076. previous example to your operating system declaration by appending it to
  31077. @code{%setuid-programs} like this:
  31078. @lisp
  31079. (operating-system
  31080. ;; Some fields omitted...
  31081. (setuid-programs
  31082. (append (list (setuid-program
  31083. (program (file-append nfs-utils "/sbin/mount.nfs"))))
  31084. %setuid-programs)))
  31085. @end lisp
  31086. @deftp {Data Type} setuid-program
  31087. This data type represents a program with a setuid or setgid bit set.
  31088. @table @asis
  31089. @item @code{program}
  31090. A file-like object having its setuid and/or setgid bit set.
  31091. @item @code{setuid?} (default: @code{#t})
  31092. Whether to set user setuid bit.
  31093. @item @code{setgid?} (default: @code{#f})
  31094. Whether to set group setgid bit.
  31095. @item @code{user} (default: @code{0})
  31096. UID (integer) or user name (string) for the user owner of the program,
  31097. defaults to root.
  31098. @item @code{group} (default: @code{0})
  31099. GID (integer) group name (string) for the group owner of the program,
  31100. defaults to root.
  31101. @end table
  31102. @end deftp
  31103. A default set of setuid programs is defined by the
  31104. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  31105. @defvar %setuid-programs
  31106. A list of @code{<setuid-program>} denoting common programs that are
  31107. setuid-root.
  31108. The list includes commands such as @command{passwd}, @command{ping},
  31109. @command{su}, and @command{sudo}.
  31110. @end defvar
  31111. Under the hood, the actual setuid programs are created in the
  31112. @file{/run/setuid-programs} directory at system activation time. The
  31113. files in this directory refer to the ``real'' binaries, which are in the
  31114. store.
  31115. @node X.509 Certificates
  31116. @section X.509 Certificates
  31117. @cindex HTTPS, certificates
  31118. @cindex X.509 certificates
  31119. @cindex TLS
  31120. Web servers available over HTTPS (that is, HTTP over the transport-layer
  31121. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  31122. that the client can then use to @emph{authenticate} the server. To do
  31123. that, clients verify that the server's certificate is signed by a
  31124. so-called @dfn{certificate authority} (CA). But to verify the CA's
  31125. signature, clients must have first acquired the CA's certificate.
  31126. Web browsers such as GNU@tie{}IceCat include their own set of CA
  31127. certificates, such that they are able to verify CA signatures
  31128. out-of-the-box.
  31129. However, most other programs that can talk HTTPS---@command{wget},
  31130. @command{git}, @command{w3m}, etc.---need to be told where CA
  31131. certificates can be found.
  31132. @cindex @code{nss-certs}
  31133. For users of Guix System, this is done by adding a package that
  31134. provides certificates to the @code{packages} field of the
  31135. @code{operating-system} declaration (@pxref{operating-system
  31136. Reference}). Guix includes one such package, @code{nss-certs}, which
  31137. is a set of CA certificates provided as part of Mozilla's Network
  31138. Security Services.
  31139. Note that it is @emph{not} part of @code{%base-packages}, so you need to
  31140. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  31141. most applications and libraries look for certificates by default, points
  31142. to the certificates installed globally.
  31143. Unprivileged users, including users of Guix on a foreign distro,
  31144. can also install their own certificate package in
  31145. their profile. A number of environment variables need to be defined so
  31146. that applications and libraries know where to find them. Namely, the
  31147. OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
  31148. variables. Some applications add their own environment variables; for
  31149. instance, the Git version control system honors the certificate bundle
  31150. pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
  31151. would typically run something like:
  31152. @example
  31153. guix install nss-certs
  31154. export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  31155. export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  31156. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  31157. @end example
  31158. As another example, R requires the @env{CURL_CA_BUNDLE} environment
  31159. variable to point to a certificate bundle, so you would have to run
  31160. something like this:
  31161. @example
  31162. guix install nss-certs
  31163. export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  31164. @end example
  31165. For other applications you may want to look up the required environment
  31166. variable in the relevant documentation.
  31167. @node Name Service Switch
  31168. @section Name Service Switch
  31169. @cindex name service switch
  31170. @cindex NSS
  31171. The @code{(gnu system nss)} module provides bindings to the
  31172. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  31173. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  31174. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  31175. extended with new ``name'' lookup methods for system databases, which
  31176. includes host names, service names, user accounts, and more (@pxref{Name
  31177. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  31178. C Library Reference Manual}).
  31179. The NSS configuration specifies, for each system database, which lookup
  31180. method is to be used, and how the various methods are chained
  31181. together---for instance, under which circumstances NSS should try the
  31182. next method in the list. The NSS configuration is given in the
  31183. @code{name-service-switch} field of @code{operating-system} declarations
  31184. (@pxref{operating-system Reference, @code{name-service-switch}}).
  31185. @cindex nss-mdns
  31186. @cindex .local, host name lookup
  31187. As an example, the declaration below configures the NSS to use the
  31188. @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  31189. back-end}, which supports host name lookups over multicast DNS (mDNS)
  31190. for host names ending in @code{.local}:
  31191. @lisp
  31192. (name-service-switch
  31193. (hosts (list %files ;first, check /etc/hosts
  31194. ;; If the above did not succeed, try
  31195. ;; with 'mdns_minimal'.
  31196. (name-service
  31197. (name "mdns_minimal")
  31198. ;; 'mdns_minimal' is authoritative for
  31199. ;; '.local'. When it returns "not found",
  31200. ;; no need to try the next methods.
  31201. (reaction (lookup-specification
  31202. (not-found => return))))
  31203. ;; Then fall back to DNS.
  31204. (name-service
  31205. (name "dns"))
  31206. ;; Finally, try with the "full" 'mdns'.
  31207. (name-service
  31208. (name "mdns")))))
  31209. @end lisp
  31210. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  31211. contains this configuration, so you will not have to type it if all you
  31212. want is to have @code{.local} host lookup working.
  31213. Note that, in this case, in addition to setting the
  31214. @code{name-service-switch} of the @code{operating-system} declaration,
  31215. you also need to use @code{avahi-service-type} (@pxref{Networking Services,
  31216. @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
  31217. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  31218. to the name service cache daemon (@pxref{Base Services,
  31219. @code{nscd-service}}).
  31220. For convenience, the following variables provide typical NSS
  31221. configurations.
  31222. @defvar %default-nss
  31223. This is the default name service switch configuration, a
  31224. @code{name-service-switch} object.
  31225. @end defvar
  31226. @defvar %mdns-host-lookup-nss
  31227. This is the name service switch configuration with support for host name
  31228. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  31229. @end defvar
  31230. The reference for name service switch configuration is given below. It
  31231. is a direct mapping of the configuration file format of the C library , so
  31232. please refer to the C library manual for more information (@pxref{NSS
  31233. Configuration File,,, libc, The GNU C Library Reference Manual}).
  31234. Compared to the configuration file format of libc NSS, it has the advantage
  31235. not only of adding this warm parenthetic feel that we like, but also
  31236. static checks: you will know about syntax errors and typos as soon as you
  31237. run @command{guix system}.
  31238. @deftp {Data Type} name-service-switch
  31239. This is the data type representation the configuration of libc's name
  31240. service switch (NSS). Each field below represents one of the supported
  31241. system databases.
  31242. @table @code
  31243. @item aliases
  31244. @itemx ethers
  31245. @itemx group
  31246. @itemx gshadow
  31247. @itemx hosts
  31248. @itemx initgroups
  31249. @itemx netgroup
  31250. @itemx networks
  31251. @itemx password
  31252. @itemx public-key
  31253. @itemx rpc
  31254. @itemx services
  31255. @itemx shadow
  31256. The system databases handled by the NSS@. Each of these fields must be a
  31257. list of @code{<name-service>} objects (see below).
  31258. @end table
  31259. @end deftp
  31260. @deftp {Data Type} name-service
  31261. This is the data type representing an actual name service and the
  31262. associated lookup action.
  31263. @table @code
  31264. @item name
  31265. A string denoting the name service (@pxref{Services in the NSS
  31266. configuration,,, libc, The GNU C Library Reference Manual}).
  31267. Note that name services listed here must be visible to nscd. This is
  31268. achieved by passing the @code{#:name-services} argument to
  31269. @code{nscd-service} the list of packages providing the needed name
  31270. services (@pxref{Base Services, @code{nscd-service}}).
  31271. @item reaction
  31272. An action specified using the @code{lookup-specification} macro
  31273. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  31274. Reference Manual}). For example:
  31275. @lisp
  31276. (lookup-specification (unavailable => continue)
  31277. (success => return))
  31278. @end lisp
  31279. @end table
  31280. @end deftp
  31281. @node Initial RAM Disk
  31282. @section Initial RAM Disk
  31283. @cindex initrd
  31284. @cindex initial RAM disk
  31285. For bootstrapping purposes, the Linux-Libre kernel is passed an
  31286. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  31287. root file system as well as an initialization script. The latter is
  31288. responsible for mounting the real root file system, and for loading any
  31289. kernel modules that may be needed to achieve that.
  31290. The @code{initrd-modules} field of an @code{operating-system}
  31291. declaration allows you to specify Linux-libre kernel modules that must
  31292. be available in the initrd. In particular, this is where you would list
  31293. modules needed to actually drive the hard disk where your root partition
  31294. is---although the default value of @code{initrd-modules} should cover
  31295. most use cases. For example, assuming you need the @code{megaraid_sas}
  31296. module in addition to the default modules to be able to access your root
  31297. file system, you would write:
  31298. @lisp
  31299. (operating-system
  31300. ;; @dots{}
  31301. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  31302. @end lisp
  31303. @defvar %base-initrd-modules
  31304. This is the list of kernel modules included in the initrd by default.
  31305. @end defvar
  31306. Furthermore, if you need lower-level customization, the @code{initrd}
  31307. field of an @code{operating-system} declaration allows
  31308. you to specify which initrd you would like to use. The @code{(gnu
  31309. system linux-initrd)} module provides three ways to build an initrd: the
  31310. high-level @code{base-initrd} procedure and the low-level
  31311. @code{raw-initrd} and @code{expression->initrd} procedures.
  31312. The @code{base-initrd} procedure is intended to cover most common uses.
  31313. For example, if you want to add a bunch of kernel modules to be loaded
  31314. at boot time, you can define the @code{initrd} field of the operating
  31315. system declaration like this:
  31316. @lisp
  31317. (initrd (lambda (file-systems . rest)
  31318. ;; Create a standard initrd but set up networking
  31319. ;; with the parameters QEMU expects by default.
  31320. (apply base-initrd file-systems
  31321. #:qemu-networking? #t
  31322. rest)))
  31323. @end lisp
  31324. The @code{base-initrd} procedure also handles common use cases that
  31325. involves using the system as a QEMU guest, or as a ``live'' system with
  31326. volatile root file system.
  31327. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  31328. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  31329. such as trying to guess which kernel modules and packages should be included
  31330. to the initrd. An example use of @code{raw-initrd} is when a user has
  31331. a custom Linux kernel configuration and default kernel modules included by
  31332. @code{base-initrd} are not available.
  31333. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  31334. honors several options passed on the Linux kernel command line
  31335. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  31336. @code{-append} option of QEMU), notably:
  31337. @table @code
  31338. @item gnu.load=@var{boot}
  31339. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  31340. program, once it has mounted the root file system.
  31341. Guix uses this option to yield control to a boot program that runs the
  31342. service activation programs and then spawns the GNU@tie{}Shepherd, the
  31343. initialization system.
  31344. @item root=@var{root}
  31345. Mount @var{root} as the root file system. @var{root} can be a device
  31346. name like @code{/dev/sda1}, a file system label, or a file system UUID.
  31347. When unspecified, the device name from the root file system of the
  31348. operating system declaration is used.
  31349. @item rootfstype=@var{type}
  31350. Set the type of the root file system. It overrides the @code{type}
  31351. field of the root file system specified via the @code{operating-system}
  31352. declaration, if any.
  31353. @item rootflags=@var{options}
  31354. Set the mount @emph{options} of the root file system. It overrides the
  31355. @code{options} field of the root file system specified via the
  31356. @code{operating-system} declaration, if any.
  31357. @item fsck.mode=@var{mode}
  31358. Whether to check the @var{root} file system for errors before mounting
  31359. it. @var{mode} is one of @code{skip} (never check), @code{force} (always
  31360. check), or @code{auto} to respect the root @code{<file-system>} object's
  31361. @code{check?} setting (@pxref{File Systems}) and run a full scan only if
  31362. the file system was not cleanly shut down.
  31363. @code{auto} is the default if this option is not present or if @var{mode}
  31364. is not one of the above.
  31365. @item fsck.repair=@var{level}
  31366. The level of repairs to perform automatically if errors are found in the
  31367. @var{root} file system. @var{level} is one of @code{no} (do not write to
  31368. @var{root} at all if possible), @code{yes} (repair as much as possible),
  31369. or @code{preen} to repair problems considered safe to repair automatically.
  31370. @code{preen} is the default if this option is not present or if @var{level}
  31371. is not one of the above.
  31372. @item gnu.system=@var{system}
  31373. Have @file{/run/booted-system} and @file{/run/current-system} point to
  31374. @var{system}.
  31375. @item modprobe.blacklist=@var{modules}@dots{}
  31376. @cindex module, black-listing
  31377. @cindex black list, of kernel modules
  31378. Instruct the initial RAM disk as well as the @command{modprobe} command
  31379. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  31380. must be a comma-separated list of module names---e.g.,
  31381. @code{usbkbd,9pnet}.
  31382. @item gnu.repl
  31383. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  31384. tries to load kernel modules and to mount the root file system. Our
  31385. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  31386. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  31387. Manual}, for more information on Guile's REPL.
  31388. @end table
  31389. Now that you know all the features that initial RAM disks produced by
  31390. @code{base-initrd} and @code{raw-initrd} provide,
  31391. here is how to use it and customize it further.
  31392. @cindex initrd
  31393. @cindex initial RAM disk
  31394. @deffn {Procedure} raw-initrd file-systems @
  31395. [#:linux-modules '()] [#:pre-mount #t] [#:mapped-devices '()] @
  31396. [#:keyboard-layout #f] [#:helper-packages '()] @
  31397. [#:qemu-networking? #f] [#:volatile-root? #f]
  31398. Return a derivation that builds a raw initrd. @var{file-systems} is
  31399. a list of file systems to be mounted by the initrd, possibly in addition to
  31400. the root file system specified on the kernel command line via @option{root}.
  31401. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  31402. @var{mapped-devices} is a list of device mappings to realize before
  31403. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  31404. @var{pre-mount} is a G-expression to evaluate before realizing
  31405. @var{mapped-devices}.
  31406. @var{helper-packages} is a list of packages to be copied in the initrd.
  31407. It may
  31408. include @code{e2fsck/static} or other packages needed by the initrd to check
  31409. the root file system.
  31410. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  31411. the desired console keyboard layout. This is done before @var{mapped-devices}
  31412. are set up and before @var{file-systems} are mounted such that, should the
  31413. user need to enter a passphrase or use the REPL, this happens using the
  31414. intended keyboard layout.
  31415. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  31416. parameters. When @var{virtio?} is true, load additional modules so that the
  31417. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  31418. When @var{volatile-root?} is true, the root file system is writable but any changes
  31419. to it are lost.
  31420. @end deffn
  31421. @deffn {Procedure} base-initrd file-systems @
  31422. [#:mapped-devices '()] [#:keyboard-layout #f] @
  31423. [#:qemu-networking? #f] [#:volatile-root? #f] @
  31424. [#:linux-modules '()]
  31425. Return as a file-like object a generic initrd, with kernel
  31426. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  31427. mounted by the initrd, possibly in addition to the root file system specified
  31428. on the kernel command line via @option{root}. @var{mapped-devices} is a list of device
  31429. mappings to realize before @var{file-systems} are mounted.
  31430. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  31431. the desired console keyboard layout. This is done before @var{mapped-devices}
  31432. are set up and before @var{file-systems} are mounted such that, should the
  31433. user need to enter a passphrase or use the REPL, this happens using the
  31434. intended keyboard layout.
  31435. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  31436. The initrd is automatically populated with all the kernel modules necessary
  31437. for @var{file-systems} and for the given options. Additional kernel
  31438. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  31439. loaded at boot time in the order in which they appear.
  31440. @end deffn
  31441. Needless to say, the initrds we produce and use embed a
  31442. statically-linked Guile, and the initialization program is a Guile
  31443. program. That gives a lot of flexibility. The
  31444. @code{expression->initrd} procedure builds such an initrd, given the
  31445. program to run in that initrd.
  31446. @deffn {Procedure} expression->initrd exp @
  31447. [#:guile %guile-static-stripped] [#:name "guile-initrd"]
  31448. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  31449. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  31450. upon booting. All the derivations referenced by @var{exp} are
  31451. automatically copied to the initrd.
  31452. @end deffn
  31453. @node Bootloader Configuration
  31454. @section Bootloader Configuration
  31455. @cindex bootloader
  31456. @cindex boot loader
  31457. The operating system supports multiple bootloaders. The bootloader is
  31458. configured using @code{bootloader-configuration} declaration. All the
  31459. fields of this structure are bootloader agnostic except for one field,
  31460. @code{bootloader} that indicates the bootloader to be configured and
  31461. installed.
  31462. Some of the bootloaders do not honor every field of
  31463. @code{bootloader-configuration}. For instance, the extlinux
  31464. bootloader does not support themes and thus ignores the @code{theme}
  31465. field.
  31466. @deftp {Data Type} bootloader-configuration
  31467. The type of a bootloader configuration declaration.
  31468. @table @asis
  31469. @item @code{bootloader}
  31470. @cindex EFI, bootloader
  31471. @cindex UEFI, bootloader
  31472. @cindex BIOS, bootloader
  31473. The bootloader to use, as a @code{bootloader} object. For now
  31474. @code{grub-bootloader}, @code{grub-efi-bootloader},
  31475. @code{grub-efi-removable-bootloader}, @code{grub-efi-netboot-bootloader},
  31476. @code{grub-efi-netboot-removable-bootloader}, @code{extlinux-bootloader}
  31477. and @code{u-boot-bootloader} are supported.
  31478. @cindex ARM, bootloaders
  31479. @cindex AArch64, bootloaders
  31480. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  31481. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  31482. of bootloaders for a wide range of ARM and AArch64 systems, using the
  31483. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  31484. @vindex grub-bootloader
  31485. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  31486. in ``legacy'' BIOS mode.
  31487. @vindex grub-efi-bootloader
  31488. @code{grub-efi-bootloader} allows to boot on modern systems using the
  31489. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  31490. use if the installation image contains a @file{/sys/firmware/efi} directory
  31491. when you boot it on your system.
  31492. @vindex grub-efi-removable-bootloader
  31493. @code{grub-efi-removable-bootloader} allows you to boot your system from
  31494. removable media by writing the GRUB file to the UEFI-specification location of
  31495. @file{/EFI/BOOT/BOOTX64.efi} of the boot directory, usually @file{/boot/efi}.
  31496. This is also useful for some UEFI firmwares that ``forget'' their configuration
  31497. from their non-volatile storage. Like @code{grub-efi-bootloader}, this can only
  31498. be used if the @file{/sys/firmware/efi} directory is available.
  31499. @quotation Note
  31500. This @emph{will} overwrite the GRUB file from any other operating systems that
  31501. also place their GRUB file in the UEFI-specification location; making them
  31502. unbootable.
  31503. @end quotation
  31504. @vindex grub-efi-netboot-bootloader
  31505. @code{grub-efi-netboot-bootloader} allows you to boot your system over network
  31506. through TFTP@. In combination with an NFS root file system this allows you to
  31507. build a diskless Guix system.
  31508. The installation of the @code{grub-efi-netboot-bootloader} generates the
  31509. content of the TFTP root directory at @code{targets} (@pxref{Bootloader
  31510. Configuration, @code{targets}}) below the sub-directory @file{efi/Guix}, to be
  31511. served by a TFTP server. You may want to mount your TFTP server directories
  31512. onto the @code{targets} to move the required files to the TFTP server
  31513. automatically during installation.
  31514. If you plan to use an NFS root file system as well (actually if you mount the
  31515. store from an NFS share), then the TFTP server needs to serve the file
  31516. @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
  31517. image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
  31518. initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
  31519. files from the store will be accessed by GRUB through TFTP with their normal
  31520. store path, for example as
  31521. @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
  31522. Two symlinks are created to make this possible. For each target in the
  31523. @code{targets} field, the first symlink is
  31524. @samp{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
  31525. @file{../../../boot/grub/grub.cfg}, where @samp{target} may be
  31526. @file{/boot}. In this case the link is not leaving the served TFTP root
  31527. directory, but otherwise it does. The second link is
  31528. @samp{target}@file{/gnu/store} and points to @file{../gnu/store}. This
  31529. link is leaving the served TFTP root directory.
  31530. The assumption behind all this is that you have an NFS server exporting
  31531. the root file system for your Guix system, and additionally a TFTP
  31532. server exporting your @code{targets} directories—usually a single
  31533. @file{/boot}—from that same root file system for your Guix system. In
  31534. this constellation the symlinks will work.
  31535. For other constellations you will have to program your own bootloader
  31536. installer, which then takes care to make necessary files from the store
  31537. accessible through TFTP, for example by copying them into the TFTP root
  31538. directory for your @code{targets}.
  31539. It is important to note that symlinks pointing outside the TFTP root directory
  31540. may need to be allowed in the configuration of your TFTP server. Further the
  31541. store link exposes the whole store through TFTP@. Both points need to be
  31542. considered carefully for security aspects. It is advised to disable any TFTP
  31543. write access!
  31544. Please note, that this bootloader will not modify the ‘UEFI Boot Manager’ of
  31545. the system.
  31546. Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
  31547. NFS servers, you also need a properly configured DHCP server to make the booting
  31548. over netboot possible. For all this we can currently only recommend you to look
  31549. for instructions about @acronym{PXE, Preboot eXecution Environment}.
  31550. If a local EFI System Partition (ESP) or a similar partition with a FAT
  31551. file system is mounted in @code{targets}, then symlinks cannot be
  31552. created. In this case everything will be prepared for booting from
  31553. local storage, matching the behavior of @code{grub-efi-bootloader}, with
  31554. the difference that all GRUB binaries are copied to @code{targets},
  31555. necessary for booting over the network.
  31556. @vindex grub-efi-netboot-removable-bootloader
  31557. @code{grub-efi-netboot-removable-bootloader} is identical to
  31558. @code{grub-efi-netboot-bootloader} with the exception that the
  31559. sub-directory @file{efi/boot} will be used instead of @file{efi/Guix} to
  31560. comply with the UEFI specification for removable media.
  31561. @quotation Note
  31562. This @emph{will} overwrite the GRUB file from any other operating systems that
  31563. also place their GRUB file in the UEFI-specification location; making them
  31564. unbootable.
  31565. @end quotation
  31566. @item @code{targets}
  31567. This is a list of strings denoting the targets onto which to install the
  31568. bootloader.
  31569. The interpretation of targets depends on the bootloader in question.
  31570. For @code{grub-bootloader}, for example, they should be device names
  31571. understood by the bootloader @command{installer} command, such as
  31572. @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub,
  31573. GNU GRUB Manual}). For @code{grub-efi-bootloader} and
  31574. @code{grub-efi-removable-bootloader} they should be mount
  31575. points of the EFI file system, usually @file{/boot/efi}. For
  31576. @code{grub-efi-netboot-bootloader}, @code{targets} should be the mount
  31577. points corresponding to TFTP root directories served by your TFTP
  31578. server.
  31579. @item @code{menu-entries} (default: @code{'()})
  31580. A possibly empty list of @code{menu-entry} objects (see below), denoting
  31581. entries to appear in the bootloader menu, in addition to the current
  31582. system entry and the entry pointing to previous system generations.
  31583. @item @code{default-entry} (default: @code{0})
  31584. The index of the default boot menu entry. Index 0 is for the entry of the
  31585. current system.
  31586. @item @code{timeout} (default: @code{5})
  31587. The number of seconds to wait for keyboard input before booting. Set to
  31588. 0 to boot immediately, and to -1 to wait indefinitely.
  31589. @cindex keyboard layout, for the bootloader
  31590. @item @code{keyboard-layout} (default: @code{#f})
  31591. If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
  31592. layout, usually US@tie{}English (``qwerty'').
  31593. Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
  31594. Layout}).
  31595. @quotation Note
  31596. This option is currently ignored by bootloaders other than @code{grub} and
  31597. @code{grub-efi}.
  31598. @end quotation
  31599. @item @code{theme} (default: @var{#f})
  31600. The bootloader theme object describing the theme to use. If no theme
  31601. is provided, some bootloaders might use a default theme, that's true
  31602. for GRUB.
  31603. @item @code{terminal-outputs} (default: @code{'(gfxterm)})
  31604. The output terminals used for the bootloader boot menu, as a list of
  31605. symbols. GRUB accepts the values: @code{console}, @code{serial},
  31606. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  31607. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  31608. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  31609. configuration,,, grub,GNU GRUB manual}).
  31610. @item @code{terminal-inputs} (default: @code{'()})
  31611. The input terminals used for the bootloader boot menu, as a list of
  31612. symbols. For GRUB, the default is the native platform terminal as
  31613. determined at run-time. GRUB accepts the values: @code{console},
  31614. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  31615. @code{usb_keyboard}. This field corresponds to the GRUB variable
  31616. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  31617. manual}).
  31618. @item @code{serial-unit} (default: @code{#f})
  31619. The serial unit used by the bootloader, as an integer from 0 to 3.
  31620. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  31621. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  31622. @item @code{serial-speed} (default: @code{#f})
  31623. The speed of the serial interface, as an integer. For GRUB, the
  31624. default value is chosen at run-time; currently GRUB chooses
  31625. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  31626. @item @code{device-tree-support?} (default: @code{#t})
  31627. Whether to support Linux @uref{https://en.wikipedia.org/wiki/Devicetree,
  31628. device tree} files loading.
  31629. This option in enabled by default. In some cases involving the
  31630. @code{u-boot} bootloader, where the device tree has already been loaded
  31631. in RAM, it can be handy to disable the option by setting it to
  31632. @code{#f}.
  31633. @end table
  31634. @end deftp
  31635. @cindex dual boot
  31636. @cindex boot menu
  31637. Should you want to list additional boot menu entries @i{via} the
  31638. @code{menu-entries} field above, you will need to create them with the
  31639. @code{menu-entry} form. For example, imagine you want to be able to
  31640. boot another distro (hard to imagine!), you can define a menu entry
  31641. along these lines:
  31642. @lisp
  31643. (menu-entry
  31644. (label "The Other Distro")
  31645. (linux "/boot/old/vmlinux-2.6.32")
  31646. (linux-arguments '("root=/dev/sda2"))
  31647. (initrd "/boot/old/initrd"))
  31648. @end lisp
  31649. Details below.
  31650. @deftp {Data Type} menu-entry
  31651. The type of an entry in the bootloader menu.
  31652. @table @asis
  31653. @item @code{label}
  31654. The label to show in the menu---e.g., @code{"GNU"}.
  31655. @item @code{linux} (default: @code{#f})
  31656. The Linux kernel image to boot, for example:
  31657. @lisp
  31658. (file-append linux-libre "/bzImage")
  31659. @end lisp
  31660. For GRUB, it is also possible to specify a device explicitly in the
  31661. file path using GRUB's device naming convention (@pxref{Naming
  31662. convention,,, grub, GNU GRUB manual}), for example:
  31663. @example
  31664. "(hd0,msdos1)/boot/vmlinuz"
  31665. @end example
  31666. If the device is specified explicitly as above, then the @code{device}
  31667. field is ignored entirely.
  31668. @item @code{linux-arguments} (default: @code{'()})
  31669. The list of extra Linux kernel command-line arguments---e.g.,
  31670. @code{'("console=ttyS0")}.
  31671. @item @code{initrd} (default: @code{#f})
  31672. A G-Expression or string denoting the file name of the initial RAM disk
  31673. to use (@pxref{G-Expressions}).
  31674. @item @code{device} (default: @code{#f})
  31675. The device where the kernel and initrd are to be found---i.e., for GRUB,
  31676. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  31677. This may be a file system label (a string), a file system UUID (a
  31678. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  31679. the bootloader will search the device containing the file specified by
  31680. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  31681. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  31682. @item @code{multiboot-kernel} (default: @code{#f})
  31683. The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
  31684. manual}). When this field is set, a Multiboot menu-entry is generated.
  31685. For example:
  31686. @lisp
  31687. (file-append mach "/boot/gnumach")
  31688. @end lisp
  31689. @item @code{multiboot-arguments} (default: @code{'()})
  31690. The list of extra command-line arguments for the multiboot-kernel.
  31691. For example, when running in QEMU it can be useful to use a text-based
  31692. console (use options @option{--nographic} @option{--serial mon:stdio}):
  31693. @lisp
  31694. '("console=com0")
  31695. @end lisp
  31696. To use the new and still experimental
  31697. @uref{https://darnassus.sceen.net/~hurd-web/rump_kernel/, rumpdisk
  31698. user-level disk driver} instead of GNU@tie{}Mach's in-kernel IDE driver,
  31699. set @code{kernel-arguments} to:
  31700. @lisp
  31701. '("noide")
  31702. @end lisp
  31703. Of course, these options can be combined:
  31704. @lisp
  31705. '("console=com0" "noide")
  31706. @end lisp
  31707. +@item @code{multiboot-modules} (default: @code{'()})
  31708. The list of commands for loading Multiboot modules. For example:
  31709. @lisp
  31710. (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
  31711. @dots{})
  31712. (list (file-append libc "/lib/ld.so.1") "exec"
  31713. @dots{}))
  31714. @end lisp
  31715. @item @code{chain-loader} (default: @code{#f})
  31716. A string that can be accepted by @code{grub}'s @code{chainloader}
  31717. directive. This has no effect if either @code{linux} or
  31718. @code{multiboot-kernel} fields are specified. The following is an
  31719. example of chainloading a different GNU/Linux system.
  31720. @lisp
  31721. (bootloader
  31722. (bootloader-configuration
  31723. ;; @dots{}
  31724. (menu-entries
  31725. (list
  31726. (menu-entry
  31727. (label "GNU/Linux")
  31728. (device (uuid "1C31-A17C" 'fat))
  31729. (chain-loader "/EFI/GNULinux/grubx64.efi"))))))
  31730. @end lisp
  31731. @end table
  31732. @end deftp
  31733. @cindex HDPI
  31734. @cindex HiDPI
  31735. @cindex resolution
  31736. @c FIXME: Write documentation once it's stable.
  31737. For now only GRUB has theme support. GRUB themes are created using
  31738. the @code{grub-theme} form, which is not fully documented yet.
  31739. @deftp {Data Type} grub-theme
  31740. Data type representing the configuration of the GRUB theme.
  31741. @table @asis
  31742. @item @code{gfxmode} (default: @code{'("auto")})
  31743. The GRUB @code{gfxmode} to set (a list of screen resolution strings,
  31744. @pxref{gfxmode,,, grub, GNU GRUB manual}).
  31745. @end table
  31746. @end deftp
  31747. @deffn {Procedure} grub-theme
  31748. Return the default GRUB theme used by the operating system if no
  31749. @code{theme} field is specified in @code{bootloader-configuration}
  31750. record.
  31751. It comes with a fancy background image displaying the GNU and Guix
  31752. logos.
  31753. @end deffn
  31754. For example, to override the default resolution, you may use something
  31755. like
  31756. @lisp
  31757. (bootloader
  31758. (bootloader-configuration
  31759. ;; @dots{}
  31760. (theme (grub-theme
  31761. (inherit (grub-theme))
  31762. (gfxmode '("1024x786x32" "auto"))))))
  31763. @end lisp
  31764. @node Invoking guix system
  31765. @section Invoking @command{guix system}
  31766. @cindex @command{guix system}
  31767. Once you have written an operating system declaration as seen in the
  31768. previous section, it can be @dfn{instantiated} using the @command{guix
  31769. system} command. The synopsis is:
  31770. @example
  31771. guix system @var{options}@dots{} @var{action} @var{file}
  31772. @end example
  31773. @var{file} must be the name of a file containing an
  31774. @code{operating-system} declaration. @var{action} specifies how the
  31775. operating system is instantiated. Currently the following values are
  31776. supported:
  31777. @table @code
  31778. @item search
  31779. Display available service type definitions that match the given regular
  31780. expressions, sorted by relevance:
  31781. @cindex HDPI
  31782. @cindex HiDPI
  31783. @cindex resolution
  31784. @example
  31785. $ guix system search console
  31786. name: console-fonts
  31787. location: gnu/services/base.scm:806:2
  31788. extends: shepherd-root
  31789. description: Install the given fonts on the specified ttys (fonts are per
  31790. + virtual console on GNU/Linux). The value of this service is a list of
  31791. + tty/font pairs. The font can be the name of a font provided by the `kbd'
  31792. + package or any valid argument to `setfont', as in this example:
  31793. +
  31794. + '(("tty1" . "LatGrkCyr-8x16")
  31795. + ("tty2" . (file-append
  31796. + font-tamzen
  31797. + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  31798. + ("tty3" . (file-append
  31799. + font-terminus
  31800. + "/share/consolefonts/ter-132n"))) ; for HDPI
  31801. relevance: 9
  31802. name: mingetty
  31803. location: gnu/services/base.scm:1190:2
  31804. extends: shepherd-root
  31805. description: Provide console login using the `mingetty' program.
  31806. relevance: 2
  31807. name: login
  31808. location: gnu/services/base.scm:860:2
  31809. extends: pam
  31810. description: Provide a console log-in service as specified by its
  31811. + configuration value, a `login-configuration' object.
  31812. relevance: 2
  31813. @dots{}
  31814. @end example
  31815. As for @command{guix package --search}, the result is written in
  31816. @code{recutils} format, which makes it easy to filter the output
  31817. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  31818. @cindex service type definition, editing
  31819. @cindex editing, service type definition
  31820. @item edit
  31821. Edit or view the definition of the given service types.
  31822. For example, the command below opens your editor, as specified by the
  31823. @env{EDITOR} environment variable, on the definition of the
  31824. @code{openssh} service type:
  31825. @example
  31826. guix system edit openssh
  31827. @end example
  31828. @item reconfigure
  31829. Build the operating system described in @var{file}, activate it, and
  31830. switch to it@footnote{This action (and the related actions
  31831. @code{switch-generation} and @code{roll-back}) are usable only on
  31832. systems already running Guix System.}.
  31833. @quotation Note
  31834. @c The paragraph below refers to the problem discussed at
  31835. @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  31836. It is highly recommended to run @command{guix pull} once before you run
  31837. @command{guix system reconfigure} for the first time (@pxref{Invoking
  31838. guix pull}). Failing to do that you would see an older version of Guix
  31839. once @command{reconfigure} has completed.
  31840. @end quotation
  31841. This effects all the configuration specified in @var{file}: user
  31842. accounts, system services, global package list, setuid programs, etc.
  31843. The command starts system services specified in @var{file} that are not
  31844. currently running; if a service is currently running this command will
  31845. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  31846. @code{herd stop X} or @code{herd restart X}).
  31847. This command creates a new generation whose number is one greater than
  31848. the current generation (as reported by @command{guix system
  31849. list-generations}). If that generation already exists, it will be
  31850. overwritten. This behavior mirrors that of @command{guix package}
  31851. (@pxref{Invoking guix package}).
  31852. It also adds a bootloader menu entry for the new OS configuration,
  31853. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  31854. entries for older configurations to a submenu, allowing you to choose
  31855. an older system generation at boot time should you need it.
  31856. @cindex provenance tracking, of the operating system
  31857. Upon completion, the new system is deployed under
  31858. @file{/run/current-system}. This directory contains @dfn{provenance
  31859. meta-data}: the list of channels in use (@pxref{Channels}) and
  31860. @var{file} itself, when available. You can view it by running:
  31861. @example
  31862. guix system describe
  31863. @end example
  31864. This information is useful should you later want to inspect how this
  31865. particular generation was built. In fact, assuming @var{file} is
  31866. self-contained, you can later rebuild generation @var{n} of your
  31867. operating system with:
  31868. @example
  31869. guix time-machine \
  31870. -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
  31871. system reconfigure \
  31872. /var/guix/profiles/system-@var{n}-link/configuration.scm
  31873. @end example
  31874. You can think of it as some sort of built-in version control! Your
  31875. system is not just a binary artifact: @emph{it carries its own source}.
  31876. @xref{Service Reference, @code{provenance-service-type}}, for more
  31877. information on provenance tracking.
  31878. By default, @command{reconfigure} @emph{prevents you from downgrading
  31879. your system}, which could (re)introduce security vulnerabilities and
  31880. also cause problems with ``stateful'' services such as database
  31881. management systems. You can override that behavior by passing
  31882. @option{--allow-downgrades}.
  31883. @item switch-generation
  31884. @cindex generations
  31885. Switch to an existing system generation. This action atomically
  31886. switches the system profile to the specified system generation. It
  31887. also rearranges the system's existing bootloader menu entries. It
  31888. makes the menu entry for the specified system generation the default,
  31889. and it moves the entries for the other generations to a submenu, if
  31890. supported by the bootloader being used. The next time the system
  31891. boots, it will use the specified system generation.
  31892. The bootloader itself is not being reinstalled when using this
  31893. command. Thus, the installed bootloader is used with an updated
  31894. configuration file.
  31895. The target generation can be specified explicitly by its generation
  31896. number. For example, the following invocation would switch to system
  31897. generation 7:
  31898. @example
  31899. guix system switch-generation 7
  31900. @end example
  31901. The target generation can also be specified relative to the current
  31902. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  31903. ``3 generations ahead of the current generation,'' and @code{-1} means
  31904. ``1 generation prior to the current generation.'' When specifying a
  31905. negative value such as @code{-1}, you must precede it with @code{--} to
  31906. prevent it from being parsed as an option. For example:
  31907. @example
  31908. guix system switch-generation -- -1
  31909. @end example
  31910. Currently, the effect of invoking this action is @emph{only} to switch
  31911. the system profile to an existing generation and rearrange the
  31912. bootloader menu entries. To actually start using the target system
  31913. generation, you must reboot after running this action. In the future,
  31914. it will be updated to do the same things as @command{reconfigure},
  31915. like activating and deactivating services.
  31916. This action will fail if the specified generation does not exist.
  31917. @item roll-back
  31918. @cindex rolling back
  31919. Switch to the preceding system generation. The next time the system
  31920. boots, it will use the preceding system generation. This is the inverse
  31921. of @command{reconfigure}, and it is exactly the same as invoking
  31922. @command{switch-generation} with an argument of @code{-1}.
  31923. Currently, as with @command{switch-generation}, you must reboot after
  31924. running this action to actually start using the preceding system
  31925. generation.
  31926. @item delete-generations
  31927. @cindex deleting system generations
  31928. @cindex saving space
  31929. Delete system generations, making them candidates for garbage collection
  31930. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  31931. collector'').
  31932. This works in the same way as @samp{guix package --delete-generations}
  31933. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  31934. arguments, all system generations but the current one are deleted:
  31935. @example
  31936. guix system delete-generations
  31937. @end example
  31938. You can also select the generations you want to delete. The example below
  31939. deletes all the system generations that are more than two months old:
  31940. @example
  31941. guix system delete-generations 2m
  31942. @end example
  31943. Running this command automatically reinstalls the bootloader with an updated
  31944. list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
  31945. longer lists the generations that have been deleted.
  31946. @item build
  31947. Build the derivation of the operating system, which includes all the
  31948. configuration files and programs needed to boot and run the system.
  31949. This action does not actually install anything.
  31950. @item init
  31951. Populate the given directory with all the files necessary to run the
  31952. operating system specified in @var{file}. This is useful for first-time
  31953. installations of Guix System. For instance:
  31954. @example
  31955. guix system init my-os-config.scm /mnt
  31956. @end example
  31957. copies to @file{/mnt} all the store items required by the configuration
  31958. specified in @file{my-os-config.scm}. This includes configuration
  31959. files, packages, and so on. It also creates other essential files
  31960. needed for the system to operate correctly---e.g., the @file{/etc},
  31961. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  31962. This command also installs bootloader on the targets specified in
  31963. @file{my-os-config}, unless the @option{--no-bootloader} option was
  31964. passed.
  31965. @item vm
  31966. @cindex virtual machine
  31967. @cindex VM
  31968. @anchor{guix system vm}
  31969. Build a virtual machine (VM) that contains the operating system declared
  31970. in @var{file}, and return a script to run that VM.
  31971. @quotation Note
  31972. The @code{vm} action and others below
  31973. can use KVM support in the Linux-libre kernel. Specifically, if the
  31974. machine has hardware virtualization support, the corresponding
  31975. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  31976. must exist and be readable and writable by the user and by the
  31977. build users of the daemon (@pxref{Build Environment Setup}).
  31978. @end quotation
  31979. Arguments given to the script are passed to QEMU as in the example
  31980. below, which enables networking and requests 1@tie{}GiB of RAM for the
  31981. emulated machine:
  31982. @example
  31983. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -nic user,model=virtio-net-pci
  31984. @end example
  31985. It's possible to combine the two steps into one:
  31986. @example
  31987. $ $(guix system vm my-config.scm) -m 1024 -smp 2 -nic user,model=virtio-net-pci
  31988. @end example
  31989. The VM shares its store with the host system.
  31990. By default, the root file system of the VM is mounted volatile; the
  31991. @option{--persistent} option can be provided to make it persistent
  31992. instead. In that case, the VM disk-image file will be copied from the
  31993. store to the @env{TMPDIR} directory to make it writable.
  31994. Additional file systems can be shared between the host and the VM using
  31995. the @option{--share} and @option{--expose} command-line options: the former
  31996. specifies a directory to be shared with write access, while the latter
  31997. provides read-only access to the shared directory.
  31998. The example below creates a VM in which the user's home directory is
  31999. accessible read-only, and where the @file{/exchange} directory is a
  32000. read-write mapping of @file{$HOME/tmp} on the host:
  32001. @example
  32002. guix system vm my-config.scm \
  32003. --expose=$HOME --share=$HOME/tmp=/exchange
  32004. @end example
  32005. On GNU/Linux, the default is to boot directly to the kernel; this has
  32006. the advantage of requiring only a very tiny root disk image since the
  32007. store of the host can then be mounted.
  32008. The @option{--full-boot} option forces a complete boot sequence, starting
  32009. with the bootloader. This requires more disk space since a root image
  32010. containing at least the kernel, initrd, and bootloader data files must
  32011. be created.
  32012. The @option{--image-size} option can be used to specify the size of the
  32013. image.
  32014. The @option{--no-graphic} option will instruct @command{guix system} to
  32015. spawn a headless VM that will use the invoking tty for IO. Among other
  32016. things, this enables copy-pasting, and scrollback. Use the @kbd{ctrl-a}
  32017. prefix to issue QEMU commands; e.g. @kbd{ctrl-a h} prints a help,
  32018. @kbd{ctrl-a x} quits the VM, and @kbd{ctrl-a c} switches between the
  32019. QEMU monitor and the VM.
  32020. @cindex System images, creation in various formats
  32021. @cindex Creating system images in various formats
  32022. @item image
  32023. @cindex image, creating disk images
  32024. The @code{image} command can produce various image types. The image
  32025. type can be selected using the @option{--image-type} option. It
  32026. defaults to @code{mbr-raw}. When its value is @code{iso9660}, the
  32027. @option{--label} option can be used to specify a volume ID with
  32028. @code{image}. By default, the root file system of a disk image is
  32029. mounted non-volatile; the @option{--volatile} option can be provided to
  32030. make it volatile instead. When using @code{image}, the bootloader
  32031. installed on the generated image is taken from the provided
  32032. @code{operating-system} definition. The following example demonstrates
  32033. how to generate an image that uses the @code{grub-efi-bootloader}
  32034. bootloader and boot it with QEMU:
  32035. @example
  32036. image=$(guix system image --image-type=qcow2 \
  32037. gnu/system/examples/lightweight-desktop.tmpl)
  32038. cp $image /tmp/my-image.qcow2
  32039. chmod +w /tmp/my-image.qcow2
  32040. qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
  32041. -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
  32042. @end example
  32043. When using the @code{mbr-raw} image type, a raw disk image is produced;
  32044. it can be copied as is to a USB stick, for instance. Assuming
  32045. @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
  32046. the image to it using the following command:
  32047. @example
  32048. # dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress
  32049. @end example
  32050. The @code{--list-image-types} command lists all the available image
  32051. types.
  32052. @cindex creating virtual machine images
  32053. When using the @code{qcow2} image type, the returned image is in qcow2
  32054. format, which the QEMU emulator can efficiently use. @xref{Running Guix
  32055. in a VM}, for more information on how to run the image in a virtual
  32056. machine. The @code{grub-bootloader} bootloader is always used
  32057. independently of what is declared in the @code{operating-system} file
  32058. passed as argument. This is to make it easier to work with QEMU, which
  32059. uses the SeaBIOS BIOS by default, expecting a bootloader to be installed
  32060. in the Master Boot Record (MBR).
  32061. @cindex docker-image, creating docker images
  32062. When using the @code{docker} image type, a Docker image is produced.
  32063. Guix builds the image from scratch, not from a pre-existing Docker base
  32064. image. As a result, it contains @emph{exactly} what you define in the
  32065. operating system configuration file. You can then load the image and
  32066. launch a Docker container using commands like the following:
  32067. @example
  32068. image_id="$(docker load < guix-system-docker-image.tar.gz)"
  32069. container_id="$(docker create $image_id)"
  32070. docker start $container_id
  32071. @end example
  32072. This command starts a new Docker container from the specified image. It
  32073. will boot the Guix system in the usual manner, which means it will
  32074. start any services you have defined in the operating system
  32075. configuration. You can get an interactive shell running in the container
  32076. using @command{docker exec}:
  32077. @example
  32078. docker exec -ti $container_id /run/current-system/profile/bin/bash --login
  32079. @end example
  32080. Depending on what you run in the Docker container, it
  32081. may be necessary to give the container additional permissions. For
  32082. example, if you intend to build software using Guix inside of the Docker
  32083. container, you may need to pass the @option{--privileged} option to
  32084. @code{docker create}.
  32085. Last, the @option{--network} option applies to @command{guix system
  32086. docker-image}: it produces an image where network is supposedly shared
  32087. with the host, and thus without services like nscd or NetworkManager.
  32088. @item container
  32089. Return a script to run the operating system declared in @var{file}
  32090. within a container. Containers are a set of lightweight isolation
  32091. mechanisms provided by the kernel Linux-libre. Containers are
  32092. substantially less resource-demanding than full virtual machines since
  32093. the kernel, shared objects, and other resources can be shared with the
  32094. host system; this also means they provide thinner isolation.
  32095. Currently, the script must be run as root in order to support more than
  32096. a single user and group. The container shares its store with the host
  32097. system.
  32098. As with the @code{vm} action (@pxref{guix system vm}), additional file
  32099. systems to be shared between the host and container can be specified
  32100. using the @option{--share} and @option{--expose} options:
  32101. @example
  32102. guix system container my-config.scm \
  32103. --expose=$HOME --share=$HOME/tmp=/exchange
  32104. @end example
  32105. The @option{--share} and @option{--expose} options can also be passed to
  32106. the generated script to bind-mount additional directories into the
  32107. container.
  32108. @quotation Note
  32109. This option requires Linux-libre 3.19 or newer.
  32110. @end quotation
  32111. @end table
  32112. @var{options} can contain any of the common build options (@pxref{Common
  32113. Build Options}). In addition, @var{options} can contain one of the
  32114. following:
  32115. @table @option
  32116. @item --expression=@var{expr}
  32117. @itemx -e @var{expr}
  32118. Consider the operating-system @var{expr} evaluates to.
  32119. This is an alternative to specifying a file which evaluates to an
  32120. operating system.
  32121. This is used to generate the Guix system installer @pxref{Building the
  32122. Installation Image}).
  32123. @item --system=@var{system}
  32124. @itemx -s @var{system}
  32125. Attempt to build for @var{system} instead of the host system type.
  32126. This works as per @command{guix build} (@pxref{Invoking guix build}).
  32127. @item --target=@var{triplet}
  32128. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  32129. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  32130. configuration triplets,, autoconf, Autoconf}).
  32131. @item --derivation
  32132. @itemx -d
  32133. Return the derivation file name of the given operating system without
  32134. building anything.
  32135. @cindex provenance tracking, of the operating system
  32136. @item --save-provenance
  32137. As discussed above, @command{guix system init} and @command{guix system
  32138. reconfigure} always save provenance information @i{via} a dedicated
  32139. service (@pxref{Service Reference, @code{provenance-service-type}}).
  32140. However, other commands don't do that by default. If you wish to, say,
  32141. create a virtual machine image that contains provenance information, you
  32142. can run:
  32143. @example
  32144. guix system image -t qcow2 --save-provenance config.scm
  32145. @end example
  32146. That way, the resulting image will effectively ``embed its own source''
  32147. in the form of meta-data in @file{/run/current-system}. With that
  32148. information, one can rebuild the image to make sure it really contains
  32149. what it pretends to contain; or they could use that to derive a variant
  32150. of the image.
  32151. @item --image-type=@var{type}
  32152. @itemx -t @var{type}
  32153. For the @code{image} action, create an image with given @var{type}.
  32154. When this option is omitted, @command{guix system} uses the
  32155. @code{mbr-raw} image type.
  32156. @cindex ISO-9660 format
  32157. @cindex CD image format
  32158. @cindex DVD image format
  32159. @option{--image-type=iso9660} produces an ISO-9660 image, suitable
  32160. for burning on CDs and DVDs.
  32161. @item --image-size=@var{size}
  32162. For the @code{image} action, create an image of the given @var{size}.
  32163. @var{size} may be a number of bytes, or it may include a unit as a
  32164. suffix (@pxref{Block size, size specifications,, coreutils, GNU
  32165. Coreutils}).
  32166. When this option is omitted, @command{guix system} computes an estimate
  32167. of the image size as a function of the size of the system declared in
  32168. @var{file}.
  32169. @item --network
  32170. @itemx -N
  32171. For the @code{container} action, allow containers to access the host network,
  32172. that is, do not create a network namespace.
  32173. @item --root=@var{file}
  32174. @itemx -r @var{file}
  32175. Make @var{file} a symlink to the result, and register it as a garbage
  32176. collector root.
  32177. @item --skip-checks
  32178. Skip pre-installation safety checks.
  32179. By default, @command{guix system init} and @command{guix system
  32180. reconfigure} perform safety checks: they make sure the file systems that
  32181. appear in the @code{operating-system} declaration actually exist
  32182. (@pxref{File Systems}), and that any Linux kernel modules that may be
  32183. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  32184. RAM Disk}). Passing this option skips these tests altogether.
  32185. @item --allow-downgrades
  32186. Instruct @command{guix system reconfigure} to allow system downgrades.
  32187. By default, @command{reconfigure} prevents you from downgrading your
  32188. system. It achieves that by comparing the provenance info of your
  32189. system (shown by @command{guix system describe}) with that of your
  32190. @command{guix} command (shown by @command{guix describe}). If the
  32191. commits for @command{guix} are not descendants of those used for your
  32192. system, @command{guix system reconfigure} errors out. Passing
  32193. @option{--allow-downgrades} allows you to bypass these checks.
  32194. @quotation Note
  32195. Make sure you understand its security implications before using
  32196. @option{--allow-downgrades}.
  32197. @end quotation
  32198. @cindex on-error
  32199. @cindex on-error strategy
  32200. @cindex error strategy
  32201. @item --on-error=@var{strategy}
  32202. Apply @var{strategy} when an error occurs when reading @var{file}.
  32203. @var{strategy} may be one of the following:
  32204. @table @code
  32205. @item nothing-special
  32206. Report the error concisely and exit. This is the default strategy.
  32207. @item backtrace
  32208. Likewise, but also display a backtrace.
  32209. @item debug
  32210. Report the error and enter Guile's debugger. From there, you can run
  32211. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  32212. display local variable values, and more generally inspect the state of the
  32213. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  32214. a list of available debugging commands.
  32215. @end table
  32216. @end table
  32217. Once you have built, configured, re-configured, and re-re-configured
  32218. your Guix installation, you may find it useful to list the operating
  32219. system generations available on disk---and that you can choose from the
  32220. bootloader boot menu:
  32221. @table @code
  32222. @item describe
  32223. Describe the running system generation: its file name, the kernel and
  32224. bootloader used, etc., as well as provenance information when available.
  32225. The @code{--list-installed} flag is available, with the same
  32226. syntax that is used in @command{guix package --list-installed}
  32227. (@pxref{Invoking guix package}). When the flag is used,
  32228. the description will include a list of packages that are currently
  32229. installed in the system profile, with optional filtering based on a
  32230. regular expression.
  32231. @quotation Note
  32232. The @emph{running} system generation---referred to by
  32233. @file{/run/current-system}---is not necessarily the @emph{current}
  32234. system generation---referred to by @file{/var/guix/profiles/system}: it
  32235. differs when, for instance, you chose from the bootloader menu to boot
  32236. an older generation.
  32237. It can also differ from the @emph{booted} system generation---referred
  32238. to by @file{/run/booted-system}---for instance because you reconfigured
  32239. the system in the meantime.
  32240. @end quotation
  32241. @item list-generations
  32242. List a summary of each generation of the operating system available on
  32243. disk, in a human-readable way. This is similar to the
  32244. @option{--list-generations} option of @command{guix package}
  32245. (@pxref{Invoking guix package}).
  32246. Optionally, one can specify a pattern, with the same syntax that is used
  32247. in @command{guix package --list-generations}, to restrict the list of
  32248. generations displayed. For instance, the following command displays
  32249. generations that are up to 10 days old:
  32250. @example
  32251. $ guix system list-generations 10d
  32252. @end example
  32253. The @code{--list-installed} flag may also be specified, with the same
  32254. syntax that is used in @command{guix package --list-installed}. This
  32255. may be helpful if trying to determine when a package was added to the
  32256. system.
  32257. @end table
  32258. The @command{guix system} command has even more to offer! The following
  32259. sub-commands allow you to visualize how your system services relate to
  32260. each other:
  32261. @anchor{system-extension-graph}
  32262. @table @code
  32263. @item extension-graph
  32264. Emit to standard output the @dfn{service
  32265. extension graph} of the operating system defined in @var{file}
  32266. (@pxref{Service Composition}, for more information on service
  32267. extensions). By default the output is in Dot/Graphviz format, but you
  32268. can choose a different format with @option{--graph-backend}, as with
  32269. @command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}):
  32270. The command:
  32271. @example
  32272. $ guix system extension-graph @var{file} | xdot -
  32273. @end example
  32274. shows the extension relations among services.
  32275. @quotation Note
  32276. The @command{dot} program is provided by the @code{graphviz} package.
  32277. @end quotation
  32278. @anchor{system-shepherd-graph}
  32279. @item shepherd-graph
  32280. Emit to standard output the @dfn{dependency
  32281. graph} of shepherd services of the operating system defined in
  32282. @var{file}. @xref{Shepherd Services}, for more information and for an
  32283. example graph.
  32284. Again, the default output format is Dot/Graphviz, but you can pass
  32285. @option{--graph-backend} to select a different one.
  32286. @end table
  32287. @node Invoking guix deploy
  32288. @section Invoking @command{guix deploy}
  32289. @cindex @command{guix deploy}
  32290. We've already seen @code{operating-system} declarations used to manage a
  32291. machine's configuration locally. Suppose you need to configure multiple
  32292. machines, though---perhaps you're managing a service on the web that's
  32293. comprised of several servers. @command{guix deploy} enables you to use those
  32294. same @code{operating-system} declarations to manage multiple remote hosts at
  32295. once as a logical ``deployment''.
  32296. @quotation Note
  32297. The functionality described in this section is still under development
  32298. and is subject to change. Get in touch with us on
  32299. @email{guix-devel@@gnu.org}!
  32300. @end quotation
  32301. @example
  32302. guix deploy @var{file}
  32303. @end example
  32304. Such an invocation will deploy the machines that the code within @var{file}
  32305. evaluates to. As an example, @var{file} might contain a definition like this:
  32306. @lisp
  32307. ;; This is a Guix deployment of a "bare bones" setup, with
  32308. ;; no X11 display server, to a machine with an SSH daemon
  32309. ;; listening on localhost:2222. A configuration such as this
  32310. ;; may be appropriate for virtual machine with ports
  32311. ;; forwarded to the host's loopback interface.
  32312. (use-service-modules networking ssh)
  32313. (use-package-modules bootloaders)
  32314. (define %system
  32315. (operating-system
  32316. (host-name "gnu-deployed")
  32317. (timezone "Etc/UTC")
  32318. (bootloader (bootloader-configuration
  32319. (bootloader grub-bootloader)
  32320. (targets '("/dev/vda"))
  32321. (terminal-outputs '(console))))
  32322. (file-systems (cons (file-system
  32323. (mount-point "/")
  32324. (device "/dev/vda1")
  32325. (type "ext4"))
  32326. %base-file-systems))
  32327. (services
  32328. (append (list (service dhcp-client-service-type)
  32329. (service openssh-service-type
  32330. (openssh-configuration
  32331. (permit-root-login #t)
  32332. (allow-empty-passwords? #t))))
  32333. %base-services))))
  32334. (list (machine
  32335. (operating-system %system)
  32336. (environment managed-host-environment-type)
  32337. (configuration (machine-ssh-configuration
  32338. (host-name "localhost")
  32339. (system "x86_64-linux")
  32340. (user "alice")
  32341. (identity "./id_rsa")
  32342. (port 2222)))))
  32343. @end lisp
  32344. The file should evaluate to a list of @var{machine} objects. This example,
  32345. upon being deployed, will create a new generation on the remote system
  32346. realizing the @code{operating-system} declaration @code{%system}.
  32347. @code{environment} and @code{configuration} specify how the machine should be
  32348. provisioned---that is, how the computing resources should be created and
  32349. managed. The above example does not create any resources, as a
  32350. @code{'managed-host} is a machine that is already running the Guix system and
  32351. available over the network. This is a particularly simple case; a more
  32352. complex deployment may involve, for example, starting virtual machines through
  32353. a Virtual Private Server (VPS) provider. In such a case, a different
  32354. @var{environment} type would be used.
  32355. Do note that you first need to generate a key pair on the coordinator machine
  32356. to allow the daemon to export signed archives of files from the store
  32357. (@pxref{Invoking guix archive}), though this step is automatic on Guix
  32358. System:
  32359. @example
  32360. # guix archive --generate-key
  32361. @end example
  32362. @noindent
  32363. Each target machine must authorize the key of the master machine so that it
  32364. accepts store items it receives from the coordinator:
  32365. @example
  32366. # guix archive --authorize < coordinator-public-key.txt
  32367. @end example
  32368. @code{user}, in this example, specifies the name of the user account to log in
  32369. as to perform the deployment. Its default value is @code{root}, but root
  32370. login over SSH may be forbidden in some cases. To work around this,
  32371. @command{guix deploy} can log in as an unprivileged user and employ
  32372. @code{sudo} to escalate privileges. This will only work if @code{sudo} is
  32373. currently installed on the remote and can be invoked non-interactively as
  32374. @code{user}. That is, the line in @code{sudoers} granting @code{user} the
  32375. ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
  32376. be accomplished with the following operating system configuration snippet:
  32377. @lisp
  32378. (use-modules ...
  32379. (gnu system)) ;for %sudoers-specification
  32380. (define %user "username")
  32381. (operating-system
  32382. ...
  32383. (sudoers-file
  32384. (plain-file "sudoers"
  32385. (string-append (plain-file-content %sudoers-specification)
  32386. (format #f "~a ALL = NOPASSWD: ALL~%"
  32387. %user)))))
  32388. @end lisp
  32389. For more information regarding the format of the @file{sudoers} file,
  32390. consult @command{man sudoers}.
  32391. Once you've deployed a system on a set of machines, you may find it
  32392. useful to run a command on all of them. The @option{--execute} or
  32393. @option{-x} option lets you do that; the example below runs
  32394. @command{uname -a} on all the machines listed in the deployment file:
  32395. @example
  32396. guix deploy @var{file} -x -- uname -a
  32397. @end example
  32398. One thing you may often need to do after deployment is restart specific
  32399. services on all the machines, which you can do like so:
  32400. @example
  32401. guix deploy @var{file} -x -- herd restart @var{service}
  32402. @end example
  32403. The @command{guix deploy -x} command returns zero if and only if the
  32404. command succeeded on all the machines.
  32405. @c FIXME/TODO: Separate the API doc from the CLI doc.
  32406. Below are the data types you need to know about when writing a
  32407. deployment file.
  32408. @deftp {Data Type} machine
  32409. This is the data type representing a single machine in a heterogeneous Guix
  32410. deployment.
  32411. @table @asis
  32412. @item @code{operating-system}
  32413. The object of the operating system configuration to deploy.
  32414. @item @code{environment}
  32415. An @code{environment-type} describing how the machine should be provisioned.
  32416. @item @code{configuration} (default: @code{#f})
  32417. An object describing the configuration for the machine's @code{environment}.
  32418. If the @code{environment} has a default configuration, @code{#f} may be used.
  32419. If @code{#f} is used for an environment with no default configuration,
  32420. however, an error will be thrown.
  32421. @end table
  32422. @end deftp
  32423. @deftp {Data Type} machine-ssh-configuration
  32424. This is the data type representing the SSH client parameters for a machine
  32425. with an @code{environment} of @code{managed-host-environment-type}.
  32426. @table @asis
  32427. @item @code{host-name}
  32428. @item @code{build-locally?} (default: @code{#t})
  32429. If false, system derivations will be built on the machine being deployed to.
  32430. @item @code{system}
  32431. The system type describing the architecture of the machine being deployed
  32432. to---e.g., @code{"x86_64-linux"}.
  32433. @item @code{authorize?} (default: @code{#t})
  32434. If true, the coordinator's signing key will be added to the remote's ACL
  32435. keyring.
  32436. @item @code{port} (default: @code{22})
  32437. @item @code{user} (default: @code{"root"})
  32438. @item @code{identity} (default: @code{#f})
  32439. If specified, the path to the SSH private key to use to authenticate with the
  32440. remote host.
  32441. @item @code{host-key} (default: @code{#f})
  32442. This should be the SSH host key of the machine, which looks like this:
  32443. @example
  32444. ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
  32445. @end example
  32446. When @code{host-key} is @code{#f}, the server is authenticated against
  32447. the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
  32448. client does.
  32449. @item @code{allow-downgrades?} (default: @code{#f})
  32450. Whether to allow potential downgrades.
  32451. Like @command{guix system reconfigure}, @command{guix deploy} compares
  32452. the channel commits currently deployed on the remote host (as returned
  32453. by @command{guix system describe}) to those currently in use (as
  32454. returned by @command{guix describe}) to determine whether commits
  32455. currently in use are descendants of those deployed. When this is not
  32456. the case and @code{allow-downgrades?} is false, it raises an error.
  32457. This ensures you do not accidentally downgrade remote machines.
  32458. @item @code{safety-checks?} (default: @code{#t})
  32459. Whether to perform ``safety checks'' before deployment. This includes
  32460. verifying that devices and file systems referred to in the operating
  32461. system configuration actually exist on the target machine, and making
  32462. sure that Linux modules required to access storage devices at boot time
  32463. are listed in the @code{initrd-modules} field of the operating system.
  32464. These safety checks ensure that you do not inadvertently deploy a system
  32465. that would fail to boot. Be careful before turning them off!
  32466. @end table
  32467. @end deftp
  32468. @deftp {Data Type} digital-ocean-configuration
  32469. This is the data type describing the Droplet that should be created for a
  32470. machine with an @code{environment} of @code{digital-ocean-environment-type}.
  32471. @table @asis
  32472. @item @code{ssh-key}
  32473. The path to the SSH private key to use to authenticate with the remote
  32474. host. In the future, this field may not exist.
  32475. @item @code{tags}
  32476. A list of string ``tags'' that uniquely identify the machine. Must be given
  32477. such that no two machines in the deployment have the same set of tags.
  32478. @item @code{region}
  32479. A Digital Ocean region slug, such as @code{"nyc3"}.
  32480. @item @code{size}
  32481. A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
  32482. @item @code{enable-ipv6?}
  32483. Whether or not the droplet should be created with IPv6 networking.
  32484. @end table
  32485. @end deftp
  32486. @node Running Guix in a VM
  32487. @section Running Guix in a Virtual Machine
  32488. @cindex virtual machine
  32489. To run Guix in a virtual machine (VM), one can use the pre-built Guix VM
  32490. image distributed at
  32491. @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.qcow2}.
  32492. This image is a compressed image in QCOW format. You can pass it to an
  32493. emulator such as @uref{https://qemu.org/, QEMU} (see below for details).
  32494. This image boots the Xfce graphical environment and it contains some
  32495. commonly used tools. You can install more software in the image by running
  32496. @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
  32497. also reconfigure the system based on its initial configuration file available
  32498. as @file{/run/current-system/configuration.scm} (@pxref{Using the
  32499. Configuration System}).
  32500. Instead of using this pre-built image, one can also build their own
  32501. image using @command{guix system image} (@pxref{Invoking guix system}).
  32502. @cindex QEMU
  32503. If you built your own image, you must copy it out of the store
  32504. (@pxref{The Store}) and give yourself permission to write to the copy
  32505. before you can use it. When invoking QEMU, you must choose a system
  32506. emulator that is suitable for your hardware platform. Here is a minimal
  32507. QEMU invocation that will boot the result of @command{guix system
  32508. image -t qcow2} on x86_64 hardware:
  32509. @example
  32510. $ qemu-system-x86_64 \
  32511. -nic user,model=virtio-net-pci \
  32512. -enable-kvm -m 2048 \
  32513. -device virtio-blk,drive=myhd \
  32514. -drive if=none,file=guix-system-vm-image-@value{VERSION}.x86_64-linux.qcow2,id=myhd
  32515. @end example
  32516. Here is what each of these options means:
  32517. @table @code
  32518. @item qemu-system-x86_64
  32519. This specifies the hardware platform to emulate. This should match the
  32520. host.
  32521. @item -nic user,model=virtio-net-pci
  32522. Enable the unprivileged user-mode network stack. The guest OS can
  32523. access the host but not vice versa. This is the simplest way to get the
  32524. guest OS online. @code{model} specifies which network device to emulate:
  32525. @code{virtio-net-pci} is a special device made for virtualized operating
  32526. systems and recommended for most uses. Assuming your hardware platform is
  32527. x86_64, you can get a list of available NIC models by running
  32528. @command{qemu-system-x86_64 -nic model=help}.
  32529. @item -enable-kvm
  32530. If your system has hardware virtualization extensions, enabling the
  32531. virtual machine support (KVM) of the Linux kernel will make things run
  32532. faster.
  32533. @c To run Xfce + 'guix pull', we need at least 1G of RAM.
  32534. @item -m 2048
  32535. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  32536. which may be insufficient for some operations.
  32537. @item -device virtio-blk,drive=myhd
  32538. Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
  32539. ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
  32540. better performance than if it were emulating a complete disk drive. See the
  32541. QEMU and KVM documentation for more info.
  32542. @item -drive if=none,file=/tmp/qemu-image,id=myhd
  32543. Use our QCOW image, the
  32544. @file{guix-system-vm-image-@value{VERSION}.x86_64-linux.qcow2} file, as
  32545. the backing store of the ``myhd'' drive.
  32546. @end table
  32547. The default @command{run-vm.sh} script that is returned by an invocation of
  32548. @command{guix system vm} does not add a @command{-nic user} flag by default.
  32549. To get network access from within the vm add the @code{(dhcp-client-service)}
  32550. to your system definition and start the VM using
  32551. @command{$(guix system vm config.scm) -nic user}. An important caveat of using
  32552. @command{-nic user} for networking is that @command{ping} will not work, because
  32553. it uses the ICMP protocol. You'll have to use a different command to check for
  32554. network connectivity, for example @command{guix download}.
  32555. @subsection Connecting Through SSH
  32556. @cindex SSH
  32557. @cindex SSH server
  32558. To enable SSH inside a VM you need to add an SSH server like
  32559. @code{openssh-service-type} to your VM (@pxref{Networking Services,
  32560. @code{openssh-service-type}}). In addition you need to forward the SSH port,
  32561. 22 by default, to the host. You can do this with
  32562. @example
  32563. $(guix system vm config.scm) -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  32564. @end example
  32565. To connect to the VM you can run
  32566. @example
  32567. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 localhost
  32568. @end example
  32569. The @command{-p} tells @command{ssh} the port you want to connect to.
  32570. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  32571. every time you modify your @command{config.scm} file and the
  32572. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  32573. connection to an unknown host every time you connect.
  32574. @quotation Note
  32575. If you find the above @samp{hostfwd} example not to be working (e.g.,
  32576. your SSH client hangs attempting to connect to the mapped port of your
  32577. VM), make sure that your Guix System VM has networking support, such as
  32578. by using the @code{dhcp-client-service-type} service type.
  32579. @end quotation
  32580. @subsection Using @command{virt-viewer} with Spice
  32581. As an alternative to the default @command{qemu} graphical client you can
  32582. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  32583. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  32584. @command{qemu}. See previous section for further information on how to do this.
  32585. Spice also allows you to do some nice stuff like share your clipboard with your
  32586. VM@. To enable that you'll also have to pass the following flags to @command{qemu}:
  32587. @example
  32588. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  32589. -chardev spicevmc,name=vdagent,id=vdagent
  32590. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,\
  32591. name=com.redhat.spice.0
  32592. @end example
  32593. You'll also need to add the @code{(spice-vdagent-service)} to your
  32594. system definition (@pxref{Miscellaneous Services, Spice service}).
  32595. @node Defining Services
  32596. @section Defining Services
  32597. The previous sections show the available services and how one can combine
  32598. them in an @code{operating-system} declaration. But how do we define
  32599. them in the first place? And what is a service anyway?
  32600. @menu
  32601. * Service Composition:: The model for composing services.
  32602. * Service Types and Services:: Types and services.
  32603. * Service Reference:: API reference.
  32604. * Shepherd Services:: A particular type of service.
  32605. * Complex Configurations:: Defining bindings for complex configurations.
  32606. @end menu
  32607. @node Service Composition
  32608. @subsection Service Composition
  32609. @cindex services
  32610. @cindex daemons
  32611. Here we define a @dfn{service} as, broadly, something that extends the
  32612. functionality of the operating system. Often a service is a process---a
  32613. @dfn{daemon}---started when the system boots: a secure shell server, a
  32614. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  32615. whose execution can be triggered by another daemon---e.g., an FTP server
  32616. started by @command{inetd} or a D-Bus service activated by
  32617. @command{dbus-daemon}. Occasionally, a service does not map to a
  32618. daemon. For instance, the ``account'' service collects user accounts
  32619. and makes sure they exist when the system runs; the ``udev'' service
  32620. collects device management rules and makes them available to the eudev
  32621. daemon; the @file{/etc} service populates the @file{/etc} directory
  32622. of the system.
  32623. @cindex service extensions
  32624. Guix system services are connected by @dfn{extensions}. For instance, the
  32625. secure shell service @emph{extends} the Shepherd---the
  32626. initialization system, running as PID@tie{}1---by giving it the command
  32627. lines to start and stop the secure shell daemon (@pxref{Networking
  32628. Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
  32629. service by passing it its @file{.service} specification, and extends the
  32630. udev service by passing it device management rules (@pxref{Desktop
  32631. Services, @code{upower-service}}); the Guix daemon service extends the
  32632. Shepherd by passing it the command lines to start and stop the daemon,
  32633. and extends the account service by passing it a list of required build
  32634. user accounts (@pxref{Base Services}).
  32635. All in all, services and their ``extends'' relations form a directed
  32636. acyclic graph (DAG). If we represent services as boxes and extensions
  32637. as arrows, a typical system might provide something like this:
  32638. @image{images/service-graph,,5in,Typical service extension graph.}
  32639. @cindex system service
  32640. At the bottom, we see the @dfn{system service}, which produces the
  32641. directory containing everything to run and boot the system, as returned
  32642. by the @command{guix system build} command. @xref{Service Reference},
  32643. to learn about the other service types shown here.
  32644. @xref{system-extension-graph, the @command{guix system extension-graph}
  32645. command}, for information on how to generate this representation for a
  32646. particular operating system definition.
  32647. @cindex service types
  32648. Technically, developers can define @dfn{service types} to express these
  32649. relations. There can be any number of services of a given type on the
  32650. system---for instance, a system running two instances of the GNU secure
  32651. shell server (lsh) has two instances of @code{lsh-service-type}, with
  32652. different parameters.
  32653. The following section describes the programming interface for service
  32654. types and services.
  32655. @node Service Types and Services
  32656. @subsection Service Types and Services
  32657. A @dfn{service type} is a node in the DAG described above. Let us start
  32658. with a simple example, the service type for the Guix build daemon
  32659. (@pxref{Invoking guix-daemon}):
  32660. @lisp
  32661. (define guix-service-type
  32662. (service-type
  32663. (name 'guix)
  32664. (extensions
  32665. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  32666. (service-extension account-service-type guix-accounts)
  32667. (service-extension activation-service-type guix-activation)))
  32668. (default-value (guix-configuration))))
  32669. @end lisp
  32670. @noindent
  32671. It defines three things:
  32672. @enumerate
  32673. @item
  32674. A name, whose sole purpose is to make inspection and debugging easier.
  32675. @item
  32676. A list of @dfn{service extensions}, where each extension designates the
  32677. target service type and a procedure that, given the parameters of the
  32678. service, returns a list of objects to extend the service of that type.
  32679. Every service type has at least one service extension. The only
  32680. exception is the @dfn{boot service type}, which is the ultimate service.
  32681. @item
  32682. Optionally, a default value for instances of this type.
  32683. @end enumerate
  32684. In this example, @code{guix-service-type} extends three services:
  32685. @table @code
  32686. @item shepherd-root-service-type
  32687. The @code{guix-shepherd-service} procedure defines how the Shepherd
  32688. service is extended. Namely, it returns a @code{<shepherd-service>}
  32689. object that defines how @command{guix-daemon} is started and stopped
  32690. (@pxref{Shepherd Services}).
  32691. @item account-service-type
  32692. This extension for this service is computed by @code{guix-accounts},
  32693. which returns a list of @code{user-group} and @code{user-account}
  32694. objects representing the build user accounts (@pxref{Invoking
  32695. guix-daemon}).
  32696. @item activation-service-type
  32697. Here @code{guix-activation} is a procedure that returns a gexp, which is
  32698. a code snippet to run at ``activation time''---e.g., when the service is
  32699. booted.
  32700. @end table
  32701. A service of this type is instantiated like this:
  32702. @lisp
  32703. (service guix-service-type
  32704. (guix-configuration
  32705. (build-accounts 5)
  32706. (extra-options '("--gc-keep-derivations"))))
  32707. @end lisp
  32708. The second argument to the @code{service} form is a value representing
  32709. the parameters of this specific service instance.
  32710. @xref{guix-configuration-type, @code{guix-configuration}}, for
  32711. information about the @code{guix-configuration} data type. When the
  32712. value is omitted, the default value specified by
  32713. @code{guix-service-type} is used:
  32714. @lisp
  32715. (service guix-service-type)
  32716. @end lisp
  32717. @code{guix-service-type} is quite simple because it extends other
  32718. services but is not extensible itself.
  32719. @c @subsubsubsection Extensible Service Types
  32720. The service type for an @emph{extensible} service looks like this:
  32721. @lisp
  32722. (define udev-service-type
  32723. (service-type (name 'udev)
  32724. (extensions
  32725. (list (service-extension shepherd-root-service-type
  32726. udev-shepherd-service)))
  32727. (compose concatenate) ;concatenate the list of rules
  32728. (extend (lambda (config rules)
  32729. (udev-configuration
  32730. (inherit config)
  32731. (rules (append (udev-configuration-rules config)
  32732. rules)))))))
  32733. @end lisp
  32734. This is the service type for the
  32735. @uref{https://github.com/eudev-project/eudev, eudev device
  32736. management daemon}. Compared to the previous example, in addition to an
  32737. extension of @code{shepherd-root-service-type}, we see two new fields:
  32738. @table @code
  32739. @item compose
  32740. This is the procedure to @dfn{compose} the list of extensions to
  32741. services of this type.
  32742. Services can extend the udev service by passing it lists of rules; we
  32743. compose those extensions simply by concatenating them.
  32744. @item extend
  32745. This procedure defines how the value of the service is @dfn{extended} with
  32746. the composition of the extensions.
  32747. Udev extensions are composed into a list of rules, but the udev service
  32748. value is itself a @code{<udev-configuration>} record. So here, we
  32749. extend that record by appending the list of rules it contains to the
  32750. list of contributed rules.
  32751. @item description
  32752. This is a string giving an overview of the service type. The string can
  32753. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  32754. @command{guix system search} command searches these strings and displays
  32755. them (@pxref{Invoking guix system}).
  32756. @end table
  32757. There can be only one instance of an extensible service type such as
  32758. @code{udev-service-type}. If there were more, the
  32759. @code{service-extension} specifications would be ambiguous.
  32760. Still here? The next section provides a reference of the programming
  32761. interface for services.
  32762. @node Service Reference
  32763. @subsection Service Reference
  32764. We have seen an overview of service types (@pxref{Service Types and
  32765. Services}). This section provides a reference on how to manipulate
  32766. services and service types. This interface is provided by the
  32767. @code{(gnu services)} module.
  32768. @deffn {Procedure} service type [value]
  32769. Return a new service of @var{type}, a @code{<service-type>} object (see
  32770. below). @var{value} can be any object; it represents the parameters of
  32771. this particular service instance.
  32772. When @var{value} is omitted, the default value specified by @var{type}
  32773. is used; if @var{type} does not specify a default value, an error is
  32774. raised.
  32775. For instance, this:
  32776. @lisp
  32777. (service openssh-service-type)
  32778. @end lisp
  32779. @noindent
  32780. is equivalent to this:
  32781. @lisp
  32782. (service openssh-service-type
  32783. (openssh-configuration))
  32784. @end lisp
  32785. In both cases the result is an instance of @code{openssh-service-type}
  32786. with the default configuration.
  32787. @end deffn
  32788. @deffn {Procedure} service? obj
  32789. Return true if @var{obj} is a service.
  32790. @end deffn
  32791. @deffn {Procedure} service-kind service
  32792. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  32793. @end deffn
  32794. @deffn {Procedure} service-value service
  32795. Return the value associated with @var{service}. It represents its
  32796. parameters.
  32797. @end deffn
  32798. Here is an example of how a service is created and manipulated:
  32799. @lisp
  32800. (define s
  32801. (service nginx-service-type
  32802. (nginx-configuration
  32803. (nginx nginx)
  32804. (log-directory log-directory)
  32805. (run-directory run-directory)
  32806. (file config-file))))
  32807. (service? s)
  32808. @result{} #t
  32809. (eq? (service-kind s) nginx-service-type)
  32810. @result{} #t
  32811. @end lisp
  32812. The @code{modify-services} form provides a handy way to change the
  32813. parameters of some of the services of a list such as
  32814. @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  32815. evaluates to a list of services. Of course, you could always use
  32816. standard list combinators such as @code{map} and @code{fold} to do that
  32817. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  32818. @code{modify-services} simply provides a more concise form for this
  32819. common pattern.
  32820. @defspec modify-services services @
  32821. (type variable => body) @dots{}
  32822. Modify the services listed in @var{services} according to the given
  32823. clauses. Each clause has the form:
  32824. @example
  32825. (@var{type} @var{variable} => @var{body})
  32826. @end example
  32827. where @var{type} is a service type---e.g.,
  32828. @code{guix-service-type}---and @var{variable} is an identifier that is
  32829. bound within the @var{body} to the service parameters---e.g., a
  32830. @code{guix-configuration} instance---of the original service of that
  32831. @var{type}.
  32832. The @var{body} should evaluate to the new service parameters, which will
  32833. be used to configure the new service. This new service will replace the
  32834. original in the resulting list. Because a service's service parameters
  32835. are created using @code{define-record-type*}, you can write a succinct
  32836. @var{body} that evaluates to the new service parameters by using the
  32837. @code{inherit} feature that @code{define-record-type*} provides.
  32838. Clauses can also have the following form:
  32839. @lisp
  32840. (delete @var{type})
  32841. @end lisp
  32842. Such a clause removes all services of the given @var{type} from
  32843. @var{services}.
  32844. @xref{Using the Configuration System}, for example usage.
  32845. @end defspec
  32846. Next comes the programming interface for service types. This is
  32847. something you want to know when writing new service definitions, but not
  32848. necessarily when simply looking for ways to customize your
  32849. @code{operating-system} declaration.
  32850. @deftp {Data Type} service-type
  32851. @cindex service type
  32852. This is the representation of a @dfn{service type} (@pxref{Service Types
  32853. and Services}).
  32854. @table @asis
  32855. @item @code{name}
  32856. This is a symbol, used only to simplify inspection and debugging.
  32857. @item @code{extensions}
  32858. A non-empty list of @code{<service-extension>} objects (see below).
  32859. @item @code{compose} (default: @code{#f})
  32860. If this is @code{#f}, then the service type denotes services that cannot
  32861. be extended---i.e., services that do not receive ``values'' from other
  32862. services.
  32863. Otherwise, it must be a one-argument procedure. The procedure is called
  32864. by @code{fold-services} and is passed a list of values collected from
  32865. extensions. It may return any single value.
  32866. @item @code{extend} (default: @code{#f})
  32867. If this is @code{#f}, services of this type cannot be extended.
  32868. Otherwise, it must be a two-argument procedure: @code{fold-services}
  32869. calls it, passing it the initial value of the service as the first
  32870. argument and the result of applying @code{compose} to the extension
  32871. values as the second argument. It must return a value that is a valid
  32872. parameter value for the service instance.
  32873. @item @code{description}
  32874. This is a string, possibly using Texinfo markup, describing in a couple
  32875. of sentences what the service is about. This string allows users to
  32876. find about the service through @command{guix system search}
  32877. (@pxref{Invoking guix system}).
  32878. @item @code{default-value} (default: @code{&no-default-value})
  32879. The default value associated for instances of this service type. This
  32880. allows users to use the @code{service} form without its second argument:
  32881. @lisp
  32882. (service @var{type})
  32883. @end lisp
  32884. The returned service in this case has the default value specified by
  32885. @var{type}.
  32886. @end table
  32887. @xref{Service Types and Services}, for examples.
  32888. @end deftp
  32889. @deffn {Procedure} service-extension target-type compute
  32890. Return a new extension for services of type @var{target-type}.
  32891. @var{compute} must be a one-argument procedure: @code{fold-services}
  32892. calls it, passing it the value associated with the service that provides
  32893. the extension; it must return a valid value for the target service.
  32894. @end deffn
  32895. @deffn {Procedure} service-extension? obj
  32896. Return true if @var{obj} is a service extension.
  32897. @end deffn
  32898. Occasionally, you might want to simply extend an existing service. This
  32899. involves creating a new service type and specifying the extension of
  32900. interest, which can be verbose; the @code{simple-service} procedure
  32901. provides a shorthand for this.
  32902. @deffn {Procedure} simple-service name target value
  32903. Return a service that extends @var{target} with @var{value}. This works
  32904. by creating a singleton service type @var{name}, of which the returned
  32905. service is an instance.
  32906. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  32907. an additional job:
  32908. @lisp
  32909. (simple-service 'my-mcron-job mcron-service-type
  32910. #~(job '(next-hour (3)) "guix gc -F 2G"))
  32911. @end lisp
  32912. @end deffn
  32913. At the core of the service abstraction lies the @code{fold-services}
  32914. procedure, which is responsible for ``compiling'' a list of services
  32915. down to a single directory that contains everything needed to boot and
  32916. run the system---the directory shown by the @command{guix system build}
  32917. command (@pxref{Invoking guix system}). In essence, it propagates
  32918. service extensions down the service graph, updating each node parameters
  32919. on the way, until it reaches the root node.
  32920. @deffn {Procedure} fold-services services [#:target-type system-service-type]
  32921. Fold @var{services} by propagating their extensions down to the root of
  32922. type @var{target-type}; return the root service adjusted accordingly.
  32923. @end deffn
  32924. Lastly, the @code{(gnu services)} module also defines several essential
  32925. service types, some of which are listed below.
  32926. @defvar system-service-type
  32927. This is the root of the service graph. It produces the system directory
  32928. as returned by the @command{guix system build} command.
  32929. @end defvar
  32930. @defvar boot-service-type
  32931. The type of the ``boot service'', which produces the @dfn{boot script}.
  32932. The boot script is what the initial RAM disk runs when booting.
  32933. @end defvar
  32934. @defvar etc-service-type
  32935. The type of the @file{/etc} service. This service is used to create
  32936. files under @file{/etc} and can be extended by
  32937. passing it name/file tuples such as:
  32938. @lisp
  32939. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  32940. @end lisp
  32941. In this example, the effect would be to add an @file{/etc/issue} file
  32942. pointing to the given file.
  32943. @end defvar
  32944. @defvar setuid-program-service-type
  32945. Type for the ``setuid-program service''. This service collects lists of
  32946. executable file names, passed as gexps, and adds them to the set of
  32947. setuid and setgid programs on the system (@pxref{Setuid Programs}).
  32948. @end defvar
  32949. @defvar profile-service-type
  32950. Type of the service that populates the @dfn{system profile}---i.e., the
  32951. programs under @file{/run/current-system/profile}. Other services can
  32952. extend it by passing it lists of packages to add to the system profile.
  32953. @end defvar
  32954. @cindex provenance tracking, of the operating system
  32955. @anchor{provenance-service-type}
  32956. @defvar provenance-service-type
  32957. This is the type of the service that records @dfn{provenance meta-data}
  32958. in the system itself. It creates several files under
  32959. @file{/run/current-system}:
  32960. @table @file
  32961. @item channels.scm
  32962. This is a ``channel file'' that can be passed to @command{guix pull -C}
  32963. or @command{guix time-machine -C}, and which describes the channels used
  32964. to build the system, if that information was available
  32965. (@pxref{Channels}).
  32966. @item configuration.scm
  32967. This is the file that was passed as the value for this
  32968. @code{provenance-service-type} service. By default, @command{guix
  32969. system reconfigure} automatically passes the OS configuration file it
  32970. received on the command line.
  32971. @item provenance
  32972. This contains the same information as the two other files but in a
  32973. format that is more readily processable.
  32974. @end table
  32975. In general, these two pieces of information (channels and configuration
  32976. file) are enough to reproduce the operating system ``from source''.
  32977. @quotation Caveats
  32978. This information is necessary to rebuild your operating system, but it
  32979. is not always sufficient. In particular, @file{configuration.scm}
  32980. itself is insufficient if it is not self-contained---if it refers to
  32981. external Guile modules or to extra files. If you want
  32982. @file{configuration.scm} to be self-contained, we recommend that modules
  32983. or files it refers to be part of a channel.
  32984. Besides, provenance meta-data is ``silent'' in the sense that it does
  32985. not change the bits contained in your system, @emph{except for the
  32986. meta-data bits themselves}. Two different OS configurations or sets of
  32987. channels can lead to the same system, bit-for-bit; when
  32988. @code{provenance-service-type} is used, these two systems will have
  32989. different meta-data and thus different store file names, which makes
  32990. comparison less trivial.
  32991. @end quotation
  32992. This service is automatically added to your operating system
  32993. configuration when you use @command{guix system reconfigure},
  32994. @command{guix system init}, or @command{guix deploy}.
  32995. @end defvar
  32996. @defvar linux-loadable-module-service-type
  32997. Type of the service that collects lists of packages containing
  32998. kernel-loadable modules, and adds them to the set of kernel-loadable
  32999. modules.
  33000. This service type is intended to be extended by other service types,
  33001. such as below:
  33002. @lisp
  33003. (simple-service 'installing-module
  33004. linux-loadable-module-service-type
  33005. (list module-to-install-1
  33006. module-to-install-2))
  33007. @end lisp
  33008. This does not actually load modules at bootup, only adds it to the
  33009. kernel profile so that it @emph{can} be loaded by other means.
  33010. @end defvar
  33011. @node Shepherd Services
  33012. @subsection Shepherd Services
  33013. @cindex shepherd services
  33014. @cindex PID 1
  33015. @cindex init system
  33016. The @code{(gnu services shepherd)} module provides a way to define
  33017. services managed by the GNU@tie{}Shepherd, which is the
  33018. initialization system---the first process that is started when the
  33019. system boots, also known as PID@tie{}1
  33020. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  33021. Services in the Shepherd can depend on each other. For instance, the
  33022. SSH daemon may need to be started after the syslog daemon has been
  33023. started, which in turn can only happen once all the file systems have
  33024. been mounted. The simple operating system defined earlier (@pxref{Using
  33025. the Configuration System}) results in a service graph like this:
  33026. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  33027. You can actually generate such a graph for any operating system
  33028. definition using the @command{guix system shepherd-graph} command
  33029. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  33030. The @code{%shepherd-root-service} is a service object representing
  33031. PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
  33032. by passing it lists of @code{<shepherd-service>} objects.
  33033. @deftp {Data Type} shepherd-service
  33034. The data type representing a service managed by the Shepherd.
  33035. @table @asis
  33036. @item @code{provision}
  33037. This is a list of symbols denoting what the service provides.
  33038. These are the names that may be passed to @command{herd start},
  33039. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  33040. shepherd, The GNU Shepherd Manual}). @xref{Defining Services,,,
  33041. shepherd, The GNU Shepherd Manual}, for details.
  33042. @item @code{requirement} (default: @code{'()})
  33043. List of symbols denoting the Shepherd services this one depends on.
  33044. @cindex one-shot services, for the Shepherd
  33045. @item @code{one-shot?} (default: @code{#f})
  33046. Whether this service is @dfn{one-shot}. One-shot services stop immediately
  33047. after their @code{start} action has completed. @xref{Slots of services,,,
  33048. shepherd, The GNU Shepherd Manual}, for more info.
  33049. @item @code{respawn?} (default: @code{#t})
  33050. Whether to restart the service when it stops, for instance when the
  33051. underlying process dies.
  33052. @item @code{start}
  33053. @itemx @code{stop} (default: @code{#~(const #f)})
  33054. The @code{start} and @code{stop} fields refer to the Shepherd's
  33055. facilities to start and stop processes (@pxref{Service De- and
  33056. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  33057. G-expressions that get expanded in the Shepherd configuration file
  33058. (@pxref{G-Expressions}).
  33059. @item @code{actions} (default: @code{'()})
  33060. @cindex actions, of Shepherd services
  33061. This is a list of @code{shepherd-action} objects (see below) defining
  33062. @dfn{actions} supported by the service, in addition to the standard
  33063. @code{start} and @code{stop} actions. Actions listed here become available as
  33064. @command{herd} sub-commands:
  33065. @example
  33066. herd @var{action} @var{service} [@var{arguments}@dots{}]
  33067. @end example
  33068. @item @code{auto-start?} (default: @code{#t})
  33069. Whether this service should be started automatically by the Shepherd. If it
  33070. is @code{#f} the service has to be started manually with @code{herd start}.
  33071. @item @code{documentation}
  33072. A documentation string, as shown when running:
  33073. @example
  33074. herd doc @var{service-name}
  33075. @end example
  33076. where @var{service-name} is one of the symbols in @code{provision}
  33077. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  33078. @item @code{modules} (default: @code{%default-modules})
  33079. This is the list of modules that must be in scope when @code{start} and
  33080. @code{stop} are evaluated.
  33081. @end table
  33082. @end deftp
  33083. The example below defines a Shepherd service that spawns
  33084. @command{syslogd}, the system logger from the GNU Networking Utilities
  33085. (@pxref{syslogd invocation, @command{syslogd},, inetutils, GNU
  33086. Inetutils}):
  33087. @example
  33088. (let ((config (plain-file "syslogd.conf" "@dots{}")))
  33089. (shepherd-service
  33090. (documentation "Run the syslog daemon (syslogd).")
  33091. (provision '(syslogd))
  33092. (requirement '(user-processes))
  33093. (start #~(make-forkexec-constructor
  33094. (list #$(file-append inetutils "/libexec/syslogd")
  33095. "--rcfile" #$config)
  33096. #:pid-file "/var/run/syslog.pid"))
  33097. (stop #~(make-kill-destructor))))
  33098. @end example
  33099. Key elements in this example are the @code{start} and @code{stop}
  33100. fields: they are @dfn{staged} code snippets that use the
  33101. @code{make-forkexec-constructor} procedure provided by the Shepherd and
  33102. its dual, @code{make-kill-destructor} (@pxref{Service De- and
  33103. Constructors,,, shepherd, The GNU Shepherd Manual}). The @code{start}
  33104. field will have @command{shepherd} spawn @command{syslogd} with the
  33105. given option; note that we pass @code{config} after @option{--rcfile},
  33106. which is a configuration file declared above (contents of this file are
  33107. omitted). Likewise, the @code{stop} field tells how this service is to
  33108. be stopped; in this case, it is stopped by making the @code{kill} system
  33109. call on its PID@. Code staging is achieved using G-expressions:
  33110. @code{#~} stages code, while @code{#$} ``escapes'' back to host code
  33111. (@pxref{G-Expressions}).
  33112. @deftp {Data Type} shepherd-action
  33113. This is the data type that defines additional actions implemented by a
  33114. Shepherd service (see above).
  33115. @table @code
  33116. @item name
  33117. Symbol naming the action.
  33118. @item documentation
  33119. This is a documentation string for the action. It can be viewed by running:
  33120. @example
  33121. herd doc @var{service} action @var{action}
  33122. @end example
  33123. @item procedure
  33124. This should be a gexp that evaluates to a procedure of at least one argument,
  33125. which is the ``running value'' of the service (@pxref{Slots of services,,,
  33126. shepherd, The GNU Shepherd Manual}).
  33127. @end table
  33128. The following example defines an action called @code{say-hello} that kindly
  33129. greets the user:
  33130. @lisp
  33131. (shepherd-action
  33132. (name 'say-hello)
  33133. (documentation "Say hi!")
  33134. (procedure #~(lambda (running . args)
  33135. (format #t "Hello, friend! arguments: ~s\n"
  33136. args)
  33137. #t)))
  33138. @end lisp
  33139. Assuming this action is added to the @code{example} service, then you can do:
  33140. @example
  33141. # herd say-hello example
  33142. Hello, friend! arguments: ()
  33143. # herd say-hello example a b c
  33144. Hello, friend! arguments: ("a" "b" "c")
  33145. @end example
  33146. This, as you can see, is a fairly sophisticated way to say hello.
  33147. @xref{Defining Services,,, shepherd, The GNU Shepherd Manual}, for more
  33148. info on actions.
  33149. @end deftp
  33150. @cindex configuration file, of Shepherd services
  33151. @deffn {Procedure} shepherd-configuration-action
  33152. Return a @code{configuration} action to display @var{file}, which should
  33153. be the name of the service's configuration file.
  33154. It can be useful to equip services with that action. For example, the
  33155. service for the Tor anonymous router (@pxref{Networking Services,
  33156. @code{tor-service-type}}) is defined roughly like this:
  33157. @lisp
  33158. (let ((torrc (plain-file "torrc" @dots{})))
  33159. (shepherd-service
  33160. (provision '(tor))
  33161. (requirement '(user-processes loopback syslogd))
  33162. (start #~(make-forkexec-constructor
  33163. (list #$(file-append tor "/bin/tor") "-f" #$torrc)
  33164. #:user "tor" #:group "tor"))
  33165. (stop #~(make-kill-destructor))
  33166. (actions (list (shepherd-configuration-action torrc)))
  33167. (documentation "Run the Tor anonymous network overlay.")))
  33168. @end lisp
  33169. Thanks to this action, administrators can inspect the configuration file
  33170. passed to @command{tor} with this shell command:
  33171. @example
  33172. cat $(herd configuration tor)
  33173. @end example
  33174. This can come in as a handy debugging tool!
  33175. @end deffn
  33176. @defvar shepherd-root-service-type
  33177. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  33178. This is the service type that extensions target when they want to create
  33179. shepherd services (@pxref{Service Types and Services}, for an example).
  33180. Each extension must pass a list of @code{<shepherd-service>}. Its
  33181. value must be a @code{shepherd-configuration}, as described below.
  33182. @end defvar
  33183. @deftp {Data Type} shepherd-configuration
  33184. This data type represents the Shepherd's configuration.
  33185. @table @code
  33186. @item shepherd (default: @code{shepherd})
  33187. The Shepherd package to use.
  33188. @item services (default: @code{'()})
  33189. A list of @code{<shepherd-service>} to start.
  33190. You should probably use the service extension
  33191. mechanism instead (@pxref{Shepherd Services}).
  33192. @end table
  33193. @end deftp
  33194. The following example specifies the Shepherd package for the operating
  33195. system:
  33196. @lisp
  33197. (operating-system
  33198. ;; ...
  33199. (services (append (list openssh-service-type))
  33200. ;; ...
  33201. %desktop-services)
  33202. ;; ...
  33203. ;; Use own Shepherd package.
  33204. (essential-services
  33205. (modify-services (operating-system-default-essential-services
  33206. this-operating-system)
  33207. (shepherd-root-service-type config => (shepherd-configuration
  33208. (inherit config)
  33209. (shepherd my-shepherd))))))
  33210. @end lisp
  33211. @defvar %shepherd-root-service
  33212. This service represents PID@tie{}1.
  33213. @end defvar
  33214. @node Complex Configurations
  33215. @subsection Complex Configurations
  33216. @cindex complex configurations
  33217. Some programs might have rather complex configuration files or formats,
  33218. and to make it easier to create Scheme bindings for these configuration
  33219. files, you can use the utilities defined in the @code{(gnu services
  33220. configuration)} module.
  33221. The main utility is the @code{define-configuration} macro, which you
  33222. will use to define a Scheme record type (@pxref{Record Overview,,,
  33223. guile, GNU Guile Reference Manual}). The Scheme record will be
  33224. serialized to a configuration file by using @dfn{serializers}, which are
  33225. procedures that take some kind of Scheme value and returns a
  33226. G-expression (@pxref{G-Expressions}), which should, once serialized to
  33227. the disk, return a string. More details are listed below.
  33228. @defmac define-configuration name clause1 clause2 @dots{}
  33229. Create a record type named @code{@var{name}} that contains the
  33230. fields found in the clauses.
  33231. A clause can have one of the following forms:
  33232. @example
  33233. (@var{field-name}
  33234. (@var{type} @var{default-value})
  33235. @var{documentation})
  33236. (@var{field-name}
  33237. (@var{type} @var{default-value})
  33238. @var{documentation}
  33239. (serializer @var{serializer}))
  33240. (@var{field-name}
  33241. (@var{type})
  33242. @var{documentation})
  33243. (@var{field-name}
  33244. (@var{type})
  33245. @var{documentation}
  33246. (serializer @var{serializer}))
  33247. (@var{field-name}
  33248. (@var{type})
  33249. @var{documentation}
  33250. (sanitizer @var{sanitizer})
  33251. (@var{field-name}
  33252. (@var{type})
  33253. @var{documentation}
  33254. (sanitizer @var{sanitizer})
  33255. (serializer @var{serializer}))
  33256. @end example
  33257. @var{field-name} is an identifier that denotes the name of the field in
  33258. the generated record.
  33259. @var{type} is the type of the value corresponding to @var{field-name};
  33260. since Guile is untyped, a predicate
  33261. procedure---@code{@var{type}?}---will be called on the value
  33262. corresponding to the field to ensure that the value is of the correct
  33263. type. This means that if say, @var{type} is @code{package}, then a
  33264. procedure named @code{package?} will be applied on the value to make
  33265. sure that it is indeed a @code{<package>} object.
  33266. @var{default-value} is the default value corresponding to the field; if
  33267. none is specified, the user is forced to provide a value when creating
  33268. an object of the record type.
  33269. @c XXX: Should these be full sentences or are they allow to be very
  33270. @c short like package synopses?
  33271. @var{documentation} is a string formatted with Texinfo syntax which
  33272. should provide a description of what setting this field does.
  33273. @var{sanitizer} is a procedure which takes one argument,
  33274. a user-supplied value, and returns a ``sanitized'' value for the field.
  33275. If no sanitizer is specified, a default sanitizer is used, which raises
  33276. an error if the value is not of type @var{type}.
  33277. An example of a sanitizer for a field that accepts both strings and
  33278. symbols looks like this:
  33279. @lisp
  33280. (define (sanitize-foo value)
  33281. (cond ((string? value) value)
  33282. ((symbol? value) (symbol->string value))
  33283. (else (error "bad value"))))
  33284. @end lisp
  33285. @var{serializer} is the name of a procedure which takes two arguments,
  33286. the first is the name of the field, and the second is the value
  33287. corresponding to the field. The procedure should return a string or
  33288. G-expression (@pxref{G-Expressions}) that represents the content that
  33289. will be serialized to the configuration file. If none is specified, a
  33290. procedure of the name @code{serialize-@var{type}} will be used.
  33291. A simple serializer procedure could look like this:
  33292. @lisp
  33293. (define (serialize-boolean field-name value)
  33294. (let ((value (if value "true" "false")))
  33295. #~(string-append #$field-name #$value)))
  33296. @end lisp
  33297. In some cases multiple different configuration records might be defined
  33298. in the same file, but their serializers for the same type might have to
  33299. be different, because they have different configuration formats. For
  33300. example, the @code{serialize-boolean} procedure for the Getmail service
  33301. would have to be different from the one for the Transmission service. To
  33302. make it easier to deal with this situation, one can specify a serializer
  33303. prefix by using the @code{prefix} literal in the
  33304. @code{define-configuration} form. This means that one doesn't have to
  33305. manually specify a custom @var{serializer} for every field.
  33306. @lisp
  33307. (define (foo-serialize-string field-name value)
  33308. @dots{})
  33309. (define (bar-serialize-string field-name value)
  33310. @dots{})
  33311. (define-configuration foo-configuration
  33312. (label
  33313. (string)
  33314. "The name of label.")
  33315. (prefix foo-))
  33316. (define-configuration bar-configuration
  33317. (ip-address
  33318. (string)
  33319. "The IPv4 address for this device.")
  33320. (prefix bar-))
  33321. @end lisp
  33322. However, in some cases you might not want to serialize any of the values
  33323. of the record, to do this, you can use the @code{no-serialization}
  33324. literal. There is also the @code{define-configuration/no-serialization}
  33325. macro which is a shorthand of this.
  33326. @lisp
  33327. ;; Nothing will be serialized to disk.
  33328. (define-configuration foo-configuration
  33329. (field
  33330. (string "test")
  33331. "Some documentation.")
  33332. (no-serialization))
  33333. ;; The same thing as above.
  33334. (define-configuration/no-serialization bar-configuration
  33335. (field
  33336. (string "test")
  33337. "Some documentation."))
  33338. @end lisp
  33339. @end defmac
  33340. @defmac define-maybe type
  33341. Sometimes a field should not be serialized if the user doesn’t specify a
  33342. value. To achieve this, you can use the @code{define-maybe} macro to
  33343. define a ``maybe type''; if the value of a maybe type is left unset, or
  33344. is set to the @code{%unset-value} value, then it will not be serialized.
  33345. When defining a ``maybe type'', the corresponding serializer for the
  33346. regular type will be used by default. For example, a field of type
  33347. @code{maybe-string} will be serialized using the @code{serialize-string}
  33348. procedure by default, you can of course change this by specifying a
  33349. custom serializer procedure. Likewise, the type of the value would have
  33350. to be a string, or left unspecified.
  33351. @lisp
  33352. (define-maybe string)
  33353. (define (serialize-string field-name value)
  33354. @dots{})
  33355. (define-configuration baz-configuration
  33356. (name
  33357. ;; If set to a string, the `serialize-string' procedure will be used
  33358. ;; to serialize the string. Otherwise this field is not serialized.
  33359. maybe-string
  33360. "The name of this module."))
  33361. @end lisp
  33362. Like with @code{define-configuration}, one can set a prefix for the
  33363. serializer name by using the @code{prefix} literal.
  33364. @lisp
  33365. (define-maybe integer
  33366. (prefix baz-))
  33367. (define (baz-serialize-integer field-name value)
  33368. @dots{})
  33369. @end lisp
  33370. There is also the @code{no-serialization} literal, which when set means
  33371. that no serializer will be defined for the ``maybe type'', regardless of
  33372. whether its value is set or not.
  33373. @code{define-maybe/no-serialization} is a shorthand for specifying the
  33374. @code{no-serialization} literal.
  33375. @lisp
  33376. (define-maybe/no-serialization symbol)
  33377. (define-configuration/no-serialization test-configuration
  33378. (mode
  33379. maybe-symbol
  33380. "Docstring."))
  33381. @end lisp
  33382. @end defmac
  33383. @deffn {Procedure} maybe-value-set? value
  33384. Predicate to check whether a user explicitly specified the value of a
  33385. maybe field.
  33386. @end deffn
  33387. @deffn {Procedure} serialize-configuration configuration fields
  33388. Return a G-expression that contains the values corresponding to the
  33389. @var{fields} of @var{configuration}, a record that has been generated by
  33390. @code{define-configuration}. The G-expression can then be serialized to
  33391. disk by using something like @code{mixed-text-file}.
  33392. @end deffn
  33393. @deffn {Procedure} empty-serializer field-name value
  33394. A serializer that just returns an empty string. The
  33395. @code{serialize-package} procedure is an alias for this.
  33396. @end deffn
  33397. Once you have defined a configuration record, you will most likely also
  33398. want to document it so that other people know to use it. To help with
  33399. that, there are two procedures, both of which are documented below.
  33400. @deffn {Procedure} generate-documentation documentation documentation-name
  33401. Generate a Texinfo fragment from the docstrings in @var{documentation},
  33402. a list of @code{(@var{label} @var{fields} @var{sub-documentation} ...)}.
  33403. @var{label} should be a symbol and should be the name of the
  33404. configuration record. @var{fields} should be a list of all the fields
  33405. available for the configuration record.
  33406. @var{sub-documentation} is a @code{(@var{field-name}
  33407. @var{configuration-name})} tuple. @var{field-name} is the name of the
  33408. field which takes another configuration record as its value, and
  33409. @var{configuration-name} is the name of that configuration record.
  33410. @var{sub-documentation} is only needed if there are nested configuration
  33411. records. For example, the @code{getmail-configuration} record
  33412. (@pxref{Mail Services}) accepts a @code{getmail-configuration-file}
  33413. record in one of its @code{rcfile} field, therefore documentation for
  33414. @code{getmail-configuration-file} is nested in
  33415. @code{getmail-configuration}.
  33416. @lisp
  33417. (generate-documentation
  33418. `((getmail-configuration ,getmail-configuration-fields
  33419. (rcfile getmail-configuration-file))
  33420. @dots{})
  33421. 'getmail-configuration)
  33422. @end lisp
  33423. @var{documentation-name} should be a symbol and should be the name of
  33424. the configuration record.
  33425. @end deffn
  33426. @deffn {Procedure} configuration->documentation configuration-symbol
  33427. Take @var{configuration-symbol}, the symbol corresponding to the name
  33428. used when defining a configuration record with
  33429. @code{define-configuration}, and print the Texinfo documentation of its
  33430. fields. This is useful if there aren’t any nested configuration records
  33431. since it only prints the documentation for the top-level fields.
  33432. @end deffn
  33433. As of right now, there is no automated way to generate documentation for
  33434. configuration records and put them in the manual. Instead, every
  33435. time you make a change to the docstrings of a configuration record, you
  33436. have to manually call @code{generate-documentation} or
  33437. @code{configuration->documentation}, and paste the output into the
  33438. @file{doc/guix.texi} file.
  33439. @c TODO: Actually test this
  33440. Below is an example of a record type created using
  33441. @code{define-configuration} and friends.
  33442. @lisp
  33443. (use-modules (gnu services)
  33444. (guix gexp)
  33445. (gnu services configuration)
  33446. (srfi srfi-26)
  33447. (srfi srfi-1))
  33448. ;; Turn field names, which are Scheme symbols into strings
  33449. (define (uglify-field-name field-name)
  33450. (let ((str (symbol->string field-name)))
  33451. ;; field? -> is-field
  33452. (if (string-suffix? "?" str)
  33453. (string-append "is-" (string-drop-right str 1))
  33454. str)))
  33455. (define (serialize-string field-name value)
  33456. #~(string-append #$(uglify-field-name field-name) " = " #$value "\n"))
  33457. (define (serialize-integer field-name value)
  33458. (serialize-string field-name (number->string value)))
  33459. (define (serialize-boolean field-name value)
  33460. (serialize-string field-name (if value "true" "false")))
  33461. (define (serialize-contact-name field-name value)
  33462. #~(string-append "\n[" #$value "]\n"))
  33463. (define (list-of-contact-configurations? lst)
  33464. (every contact-configuration? lst))
  33465. (define (serialize-list-of-contact-configurations field-name value)
  33466. #~(string-append #$@@(map (cut serialize-configuration <>
  33467. contact-configuration-fields)
  33468. value)))
  33469. (define (serialize-contacts-list-configuration configuration)
  33470. (mixed-text-file
  33471. "contactrc"
  33472. #~(string-append "[Owner]\n"
  33473. #$(serialize-configuration
  33474. configuration contacts-list-configuration-fields))))
  33475. (define-maybe integer)
  33476. (define-maybe string)
  33477. (define-configuration contact-configuration
  33478. (name
  33479. (string)
  33480. "The name of the contact."
  33481. serialize-contact-name)
  33482. (phone-number
  33483. maybe-integer
  33484. "The person's phone number.")
  33485. (email
  33486. maybe-string
  33487. "The person's email address.")
  33488. (married?
  33489. (boolean)
  33490. "Whether the person is married."))
  33491. (define-configuration contacts-list-configuration
  33492. (name
  33493. (string)
  33494. "The name of the owner of this contact list.")
  33495. (email
  33496. (string)
  33497. "The owner's email address.")
  33498. (contacts
  33499. (list-of-contact-configurations '())
  33500. "A list of @@code@{contact-configuation@} records which contain
  33501. information about all your contacts."))
  33502. @end lisp
  33503. A contacts list configuration could then be created like this:
  33504. @lisp
  33505. (define my-contacts
  33506. (contacts-list-configuration
  33507. (name "Alice")
  33508. (email "alice@@example.org")
  33509. (contacts
  33510. (list (contact-configuration
  33511. (name "Bob")
  33512. (phone-number 1234)
  33513. (email "bob@@gnu.org")
  33514. (married? #f))
  33515. (contact-configuration
  33516. (name "Charlie")
  33517. (phone-number 0000)
  33518. (married? #t))))))
  33519. @end lisp
  33520. After serializing the configuration to disk, the resulting file would
  33521. look like this:
  33522. @example
  33523. [owner]
  33524. name = Alice
  33525. email = alice@@example.org
  33526. [Bob]
  33527. phone-number = 1234
  33528. email = bob@@gnu.org
  33529. is-married = false
  33530. [Charlie]
  33531. phone-number = 0
  33532. is-married = true
  33533. @end example
  33534. @node Home Configuration
  33535. @chapter Home Configuration
  33536. @cindex home configuration
  33537. Guix supports declarative configuration of @dfn{home environments} by
  33538. utilizing the configuration mechanism described in the previous chapter
  33539. (@pxref{Defining Services}), but for user's dotfiles and packages. It
  33540. works both on Guix System and foreign distros and allows users to
  33541. declare all the packages and services that should be installed and
  33542. configured for the user. Once a user has written a file containing
  33543. @code{home-environment} record, such a configuration can be
  33544. @dfn{instantiated} by an unprivileged user with the @command{guix home}
  33545. command (@pxref{Invoking guix home}).
  33546. @c Maybe later, it will be possible to make home configuration a part of
  33547. @c system configuration to make everything managed by guix system.
  33548. @quotation Note
  33549. The functionality described in this section is still under development
  33550. and is subject to change. Get in touch with us on
  33551. @email{guix-devel@@gnu.org}!
  33552. @end quotation
  33553. The user's home environment usually consists of three basic parts:
  33554. software, configuration, and state. Software in mainstream distros are
  33555. usually installed system-wide, but with GNU Guix most software packages
  33556. can be installed on a per-user basis without needing root privileges,
  33557. and are thus considered part of the user’s @dfn{home environment}.
  33558. Packages on their own are not very useful in many cases, because often they
  33559. require some additional configuration, usually config files that reside
  33560. in @env{XDG_CONFIG_HOME} (@file{~/.config} by default) or other
  33561. directories. Everything else can be considered state, like media files,
  33562. application databases, and logs.
  33563. Using Guix for managing home environments provides a number of
  33564. advantages:
  33565. @itemize
  33566. @item All software can be configured in one language (Guile Scheme),
  33567. this gives users the ability to share values between configurations of
  33568. different programs.
  33569. @item A well-defined home environment is self-contained and can be
  33570. created in a declarative and reproducible way---there is no need to grab
  33571. external binaries or manually edit some configuration file.
  33572. @item After every @command{guix home reconfigure} invocation, a new home
  33573. environment generation will be created. This means that users can
  33574. rollback to a previous home environment generation so they don’t have to
  33575. worry about breaking their configuration.
  33576. @item It is possible to manage stateful data with Guix Home, this
  33577. includes the ability to automatically clone Git repositories on the
  33578. initial setup of the machine, and periodically running commands like
  33579. @command{rsync} to sync data with another host. This functionality is
  33580. still in an experimental stage, though.
  33581. @end itemize
  33582. @menu
  33583. * Declaring the Home Environment:: Customizing your Home.
  33584. * Configuring the Shell:: Enabling home environment.
  33585. * Home Services:: Specifying home services.
  33586. * Invoking guix home:: Instantiating a home configuration.
  33587. @end menu
  33588. @node Declaring the Home Environment
  33589. @section Declaring the Home Environment
  33590. The home environment is configured by providing a
  33591. @code{home-environment} declaration in a file that can be passed to the
  33592. @command{guix home} command (@pxref{Invoking guix home}). The easiest
  33593. way to get started is by generating an initial configuration with
  33594. @command{guix home import}:
  33595. @example
  33596. guix home import ~/src/guix-config
  33597. @end example
  33598. The @command{guix home import} command reads some of the ``dot files''
  33599. such as @file{~/.bashrc} found in your home directory and copies them to
  33600. the given directory, @file{~/src/guix-config} in this case; it also
  33601. reads the contents of your profile, @file{~/.guix-profile}, and, based
  33602. on that, it populates @file{~/src/guix-config/home-configuration.scm}
  33603. with a Home configuration that resembles your current configuration.
  33604. A simple setup can include Bash and a custom text configuration, like in
  33605. the example below. Don't be afraid to declare home environment parts,
  33606. which overlaps with your current dot files: before installing any
  33607. configuration files, Guix Home will back up existing config files to a
  33608. separate place in the home directory.
  33609. @quotation Note
  33610. It is highly recommended that you manage your shell or shells with Guix
  33611. Home, because it will make sure that all the necessary scripts are
  33612. sourced by the shell configuration file. Otherwise you will need to do
  33613. it manually. (@pxref{Configuring the Shell}).
  33614. @end quotation
  33615. @findex home-environment
  33616. @lisp
  33617. @include he-config-bare-bones.scm
  33618. @end lisp
  33619. The @code{packages} field should be self-explanatory, it will install
  33620. the list of packages into the user's profile. The most important field
  33621. is @code{services}, it contains a list of @dfn{home services}, which are
  33622. the basic building blocks of a home environment.
  33623. There is no daemon (at least not necessarily) related to a home service,
  33624. a home service is just an element that is used to declare part of home
  33625. environment and extend other parts of it. The extension mechanism
  33626. discussed in the previous chapter (@pxref{Defining Services}) should not
  33627. be confused with Shepherd services (@pxref{Shepherd Services}). Using this extension
  33628. mechanism and some Scheme code that glues things together gives the user
  33629. the freedom to declare their own, very custom, home environments.
  33630. @cindex container, for @command{guix home}
  33631. Once the configuration looks good, you can first test it in a throw-away
  33632. ``container'':
  33633. @example
  33634. guix home container config.scm
  33635. @end example
  33636. The command above spawns a shell where your home environment is running.
  33637. The shell runs in a container, meaning it's isolated from the rest of
  33638. the system, so it's a good way to try out your configuration---you can
  33639. see if configuration bits are missing or misbehaving, if daemons get
  33640. started, and so on. Once you exit that shell, you're back to the prompt
  33641. of your original shell ``in the real world''.
  33642. Once you have a configuration file that suits your needs, you can
  33643. reconfigure your home by running:
  33644. @example
  33645. guix home reconfigure config.scm
  33646. @end example
  33647. This ``builds'' your home environment and creates @file{~/.guix-home}
  33648. pointing to it. Voilà!
  33649. @quotation Note
  33650. Make sure the operating system has elogind, systemd, or a similar
  33651. mechanism to create the XDG run-time directory and has the
  33652. @env{XDG_RUNTIME_DIR} variable set. Failing that, the
  33653. @file{on-first-login} script will not execute anything, and processes
  33654. like user Shepherd and its descendants will not start.
  33655. @end quotation
  33656. @node Configuring the Shell
  33657. @section Configuring the Shell
  33658. This section is safe to skip if your shell or shells are managed by
  33659. Guix Home. Otherwise, read it carefully.
  33660. There are a few scripts that must be evaluated by a login shell to
  33661. activate the home environment. The shell startup files only read by
  33662. login shells often have @code{profile} suffix. For more information
  33663. about login shells see @ref{Invoking Bash,,, bash, The GNU Bash
  33664. Reference Manual} and see @ref{Bash Startup Files,,, bash, The GNU Bash
  33665. Reference Manual}.
  33666. The first script that needs to be sourced is @file{setup-environment},
  33667. which sets all the necessary environment variables (including variables
  33668. declared by the user) and the second one is @file{on-first-login}, which
  33669. starts Shepherd for the current user and performs actions declared by
  33670. other home services that extends
  33671. @code{home-run-on-first-login-service-type}.
  33672. Guix Home will always create @file{~/.profile}, which contains the
  33673. following lines:
  33674. @example
  33675. HOME_ENVIRONMENT=$HOME/.guix-home
  33676. . $HOME_ENVIRONMENT/setup-environment
  33677. $HOME_ENVIRONMENT/on-first-login
  33678. @end example
  33679. This makes POSIX compliant login shells activate the home environment.
  33680. However, in most cases this file won't be read by most modern shells,
  33681. because they are run in non POSIX mode by default and have their own
  33682. @file{*profile} startup files. For example Bash will prefer
  33683. @file{~/.bash_profile} in case it exists and only if it doesn't will it
  33684. fallback to @file{~/.profile}. Zsh (if no additional options are
  33685. specified) will ignore @file{~/.profile}, even if @file{~/.zprofile}
  33686. doesn't exist.
  33687. To make your shell respect @file{~/.profile}, add @code{. ~/.profile} or
  33688. @code{source ~/.profile} to the startup file for the login shell. In
  33689. case of Bash, it is @file{~/.bash_profile}, and in case of Zsh, it is
  33690. @file{~/.zprofile}.
  33691. @quotation Note
  33692. This step is only required if your shell is @emph{not} managed by Guix Home.
  33693. Otherwise, everything will be done automatically.
  33694. @end quotation
  33695. @node Home Services
  33696. @section Home Services
  33697. @cindex home services
  33698. A @dfn{home service} is not necessarily something that has a daemon and
  33699. is managed by Shepherd (@pxref{Jump Start,,, shepherd, The GNU Shepherd
  33700. Manual}), in most cases it doesn't. It's a simple building block of the
  33701. home environment, often declaring a set of packages to be installed in
  33702. the home environment profile, a set of config files to be symlinked into
  33703. @env{XDG_CONFIG_HOME} (@file{~/.config} by default), and environment
  33704. variables to be set by a login shell.
  33705. There is a service extension mechanism (@pxref{Service Composition})
  33706. which allows home services to extend other home services and utilize
  33707. capabilities they provide; for example: declare mcron jobs
  33708. (@pxref{Top,,, mcron, GNU@tie{}Mcron}) by extending @ref{Mcron Home
  33709. Service}; declare daemons by extending @ref{Shepherd Home Service}; add
  33710. commands, which will be invoked on by the Bash by extending
  33711. @ref{Shells Home Services, @code{home-bash-service-type}}.
  33712. A good way to discover available home services is using the
  33713. @command{guix home search} command (@pxref{Invoking guix home}). After
  33714. the required home services are found, include its module with the
  33715. @code{use-modules} form (@pxref{use-modules,, Using Guile Modules,
  33716. guile, The GNU Guile Reference Manual}), or the @code{#:use-modules}
  33717. directive (@pxref{define-module,, Creating Guile Modules, guile, The GNU
  33718. Guile Reference Manual}) and declare a home service using the
  33719. @code{service} function, or extend a service type by declaring a new
  33720. service with the @code{simple-service} procedure from @code{(gnu
  33721. services)}.
  33722. @menu
  33723. * Essential Home Services:: Environment variables, packages, on-* scripts.
  33724. * Shells: Shells Home Services. POSIX shells, Bash, Zsh.
  33725. * Mcron: Mcron Home Service. Scheduled User's Job Execution.
  33726. * Power Management: Power Management Home Services. Services for battery power.
  33727. * Shepherd: Shepherd Home Service. Managing User's Daemons.
  33728. * SSH: Secure Shell. Setting up the secure shell client.
  33729. * GPG: GNU Privacy Guard. Setting up GPG and related tools.
  33730. * Desktop: Desktop Home Services. Services for graphical environments.
  33731. * Guix: Guix Home Services. Services for Guix.
  33732. * Fonts: Fonts Home Services. Services for managing User's fonts.
  33733. * Sound: Sound Home Services. Dealing with audio.
  33734. * Mail: Mail Home Services. Services for managing mail.
  33735. * Messaging: Messaging Home Services. Services for managing messaging.
  33736. * Media: Media Home Services. Services for managing media.
  33737. * Networking: Networking Home Services. Networking services.
  33738. * Miscellaneous: Miscellaneous Home Services. More services.
  33739. @end menu
  33740. @c In addition to that Home Services can provide
  33741. @node Essential Home Services
  33742. @subsection Essential Home Services
  33743. There are a few essential home services defined in
  33744. @code{(gnu home services)}, they are mostly for internal use and are
  33745. required to build a home environment, but some of them will be useful
  33746. for the end user.
  33747. @cindex environment variables
  33748. @defvar home-environment-variables-service-type
  33749. The service of this type will be instantiated by every home environment
  33750. automatically by default, there is no need to define it, but someone may
  33751. want to extend it with a list of pairs to set some environment
  33752. variables.
  33753. @lisp
  33754. (list ("ENV_VAR1" . "value1")
  33755. ("ENV_VAR2" . "value2"))
  33756. @end lisp
  33757. The easiest way to extend a service type, without defining a new service
  33758. type is to use the @code{simple-service} helper from @code{(gnu
  33759. services)}.
  33760. @findex literal-string
  33761. @lisp
  33762. (simple-service 'some-useful-env-vars-service
  33763. home-environment-variables-service-type
  33764. `(("LESSHISTFILE" . "$XDG_CACHE_HOME/.lesshst")
  33765. ("SHELL" . ,(file-append zsh "/bin/zsh"))
  33766. ("USELESS_VAR" . #f)
  33767. ("_JAVA_AWT_WM_NONREPARENTING" . #t)
  33768. ("LITERAL_VALUE" . ,(literal-string "$@{abc@}"))))
  33769. @end lisp
  33770. If you include such a service in you home environment definition, it
  33771. will add the following content to the @file{setup-environment} script
  33772. (which is expected to be sourced by the login shell):
  33773. @example
  33774. export LESSHISTFILE="$XDG_CACHE_HOME/.lesshst"
  33775. export SHELL="/gnu/store/2hsg15n644f0glrcbkb1kqknmmqdar03-zsh-5.8/bin/zsh"
  33776. export _JAVA_AWT_WM_NONREPARENTING
  33777. export LITERAL_VALUE='$@{abc@}'
  33778. @end example
  33779. Notice that @code{literal-string} above lets us declare that a value is
  33780. to be interpreted as a @dfn{literal string}, meaning that ``special
  33781. characters'' such as the dollar sign will not be interpreted by the
  33782. shell.
  33783. @quotation Note
  33784. Make sure that module @code{(gnu packages shells)} is imported with
  33785. @code{use-modules} or any other way, this namespace contains the
  33786. definition of the @code{zsh} package, which is used in the example
  33787. above.
  33788. @end quotation
  33789. The association list (@pxref{Association Lists, alists, Association
  33790. Lists, guile, The GNU Guile Reference manual}) is a data structure
  33791. containing key-value pairs, for
  33792. @code{home-environment-variables-service-type} the key is always a
  33793. string, the value can be a string, string-valued gexp
  33794. (@pxref{G-Expressions}), file-like object (@pxref{G-Expressions,
  33795. file-like object}) or boolean. For gexps, the variable will be set to
  33796. the value of the gexp; for file-like objects, it will be set to the path
  33797. of the file in the store (@pxref{The Store}); for @code{#t}, it will
  33798. export the variable without any value; and for @code{#f}, it will omit
  33799. variable.
  33800. @end defvar
  33801. @defvar home-profile-service-type
  33802. The service of this type will be instantiated by every home environment
  33803. automatically, there is no need to define it, but you may want to extend
  33804. it with a list of packages if you want to install additional packages
  33805. into your profile. Other services, which need to make some programs
  33806. available to the user will also extend this service type.
  33807. The extension value is just a list of packages:
  33808. @lisp
  33809. (list htop vim emacs)
  33810. @end lisp
  33811. The same approach as @code{simple-service} (@pxref{Service Reference,
  33812. simple-service}) for @code{home-environment-variables-service-type} can
  33813. be used here, too. Make sure that modules containing the specified
  33814. packages are imported with @code{use-modules}. To find a package or
  33815. information about its module use @command{guix search} (@pxref{Invoking
  33816. guix package}). Alternatively, @code{specification->package} can be
  33817. used to get the package record from string without importing related
  33818. module.
  33819. @end defvar
  33820. There are few more essential services, but users are not expected to
  33821. extend them.
  33822. @defvar home-service-type
  33823. The root of home services DAG, it generates a folder, which later will be
  33824. symlinked to @file{~/.guix-home}, it contains configurations,
  33825. profile with binaries and libraries, and some necessary scripts to glue
  33826. things together.
  33827. @end defvar
  33828. @defvar home-run-on-first-login-service-type
  33829. The service of this type generates a Guile script, which is expected to
  33830. be executed by the login shell. It is only executed if the special flag
  33831. file inside @env{XDG_RUNTIME_DIR} hasn't been created, this prevents
  33832. redundant executions of the script if multiple login shells are spawned.
  33833. It can be extended with a gexp. However, to autostart an application,
  33834. users @emph{should not} use this service, in most cases it's better to extend
  33835. @code{home-shepherd-service-type} with a Shepherd service
  33836. (@pxref{Shepherd Services}), or extend the shell's startup file with
  33837. the required command using the appropriate service type.
  33838. @end defvar
  33839. @defvar home-files-service-type
  33840. The service of this type allows to specify a list of files, which will
  33841. go to @file{~/.guix-home/files}, usually this directory contains
  33842. configuration files (to be more precise it contains symlinks to files in
  33843. @file{/gnu/store}), which should be placed in @file{$XDG_CONFIG_DIR} or
  33844. in rare cases in @file{$HOME}. It accepts extension values in the
  33845. following format:
  33846. @lisp
  33847. `((".sway/config" ,sway-file-like-object)
  33848. (".tmux.conf" ,(local-file "./tmux.conf")))
  33849. @end lisp
  33850. Each nested list contains two values: a subdirectory and file-like
  33851. object. After building a home environment @file{~/.guix-home/files}
  33852. will be populated with appropriate content and all nested directories will
  33853. be created accordingly, however, those files won't go any further until
  33854. some other service will do it. By default a
  33855. @code{home-symlink-manager-service-type}, which creates necessary
  33856. symlinks in home folder to files from @file{~/.guix-home/files} and
  33857. backs up already existing, but clashing configs and other things, is a
  33858. part of essential home services (enabled by default), but it's possible
  33859. to use alternative services to implement more advanced use cases like
  33860. read-only home. Feel free to experiment and share your results.
  33861. @end defvar
  33862. @defvar home-xdg-configuration-files-service-type
  33863. The service is very similar to @code{home-files-service-type} (and
  33864. actually extends it), but used for defining files, which will go to
  33865. @file{~/.guix-home/files/.config}, which will be symlinked to
  33866. @file{$XDG_CONFIG_DIR} by @code{home-symlink-manager-service-type} (for
  33867. example) during activation. It accepts extension values in the
  33868. following format:
  33869. @lisp
  33870. `(("sway/config" ,sway-file-like-object)
  33871. ;; -> ~/.guix-home/files/.config/sway/config
  33872. ;; -> $XDG_CONFIG_DIR/sway/config (by symlink-manager)
  33873. ("tmux/tmux.conf" ,(local-file "./tmux.conf")))
  33874. @end lisp
  33875. @end defvar
  33876. @defvar home-activation-service-type
  33877. The service of this type generates a guile script, which runs on every
  33878. @command{guix home reconfigure} invocation or any other action, which
  33879. leads to the activation of the home environment.
  33880. @end defvar
  33881. @defvar home-symlink-manager-service-type
  33882. The service of this type generates a guile script, which will be
  33883. executed during activation of home environment, and do a few following
  33884. steps:
  33885. @enumerate
  33886. @item
  33887. Reads the content of @file{files/} directory of current and pending home
  33888. environments.
  33889. @item
  33890. Cleans up all symlinks created by symlink-manager on previous
  33891. activation. Also, sub-directories, which become empty also will be
  33892. cleaned up.
  33893. @item
  33894. Creates new symlinks the following way: It looks @file{files/} directory
  33895. (usually defined with @code{home-files-service-type},
  33896. @code{home-xdg-configuration-files-service-type} and maybe some others),
  33897. takes the files from @file{files/.config/} subdirectory and put
  33898. respective links in @env{XDG_CONFIG_DIR}. For example symlink for
  33899. @file{files/.config/sway/config} will end up in
  33900. @file{$XDG_CONFIG_DIR/sway/config}. The rest files in @file{files/}
  33901. outside of @file{files/.config/} subdirectory will be treated slightly
  33902. different: symlink will just go to @file{$HOME}.
  33903. @file{files/.some-program/config} will end up in
  33904. @file{$HOME/.some-program/config}.
  33905. @item
  33906. If some sub-directories are missing, they will be created.
  33907. @item
  33908. If there is a clashing files on the way, they will be backed up.
  33909. @end enumerate
  33910. symlink-manager is a part of essential home services and is enabled and
  33911. used by default.
  33912. @end defvar
  33913. @node Shells Home Services
  33914. @subsection Shells
  33915. @cindex shell
  33916. @cindex login shell
  33917. @cindex interactive shell
  33918. @cindex bash
  33919. @cindex zsh
  33920. Shells play a quite important role in the environment initialization
  33921. process, you can configure them manually as described in section
  33922. @ref{Configuring the Shell}, but the recommended way is to use home services
  33923. listed below. It's both easier and more reliable.
  33924. Each home environment instantiates
  33925. @code{home-shell-profile-service-type}, which creates a
  33926. @file{~/.profile} startup file for all POSIX-compatible shells. This
  33927. file contains all the necessary steps to properly initialize the
  33928. environment, but many modern shells like Bash or Zsh prefer their own
  33929. startup files, that's why the respective home services
  33930. (@code{home-bash-service-type} and @code{home-zsh-service-type}) ensure
  33931. that @file{~/.profile} is sourced by @file{~/.bash_profile} and
  33932. @file{~/.zprofile}, respectively.
  33933. @subsubheading Shell Profile Service
  33934. @deftp {Data Type} home-shell-profile-configuration
  33935. Available @code{home-shell-profile-configuration} fields are:
  33936. @table @asis
  33937. @item @code{profile} (default: @code{'()}) (type: text-config)
  33938. @code{home-shell-profile} is instantiated automatically by
  33939. @code{home-environment}, DO NOT create this service manually, it can
  33940. only be extended. @code{profile} is a list of file-like objects, which
  33941. will go to @file{~/.profile}. By default @file{~/.profile} contains the
  33942. initialization code which must be evaluated by the login shell to make
  33943. home-environment's profile available to the user, but other commands can
  33944. be added to the file if it is really necessary. In most cases shell's
  33945. configuration files are preferred places for user's customizations.
  33946. Extend home-shell-profile service only if you really know what you do.
  33947. @end table
  33948. @end deftp
  33949. @subsubheading Bash Home Service
  33950. @anchor{home-bash-configuration}
  33951. @deftp {Data Type} home-bash-configuration
  33952. Available @code{home-bash-configuration} fields are:
  33953. @table @asis
  33954. @item @code{package} (default: @code{bash}) (type: package)
  33955. The Bash package to use.
  33956. @item @code{guix-defaults?} (default: @code{#t}) (type: boolean)
  33957. Add sane defaults like reading @file{/etc/bashrc} and coloring the output of
  33958. @command{ls} to the top of the @file{.bashrc} file.
  33959. @item @code{environment-variables} (default: @code{'()}) (type: alist)
  33960. Association list of environment variables to set for the Bash session. The
  33961. rules for the @code{home-environment-variables-service-type} apply
  33962. here (@pxref{Essential Home Services}). The contents of this field will be
  33963. added after the contents of the @code{bash-profile} field.
  33964. @item @code{aliases} (default: @code{'()}) (type: alist)
  33965. Association list of aliases to set for the Bash session. The aliases
  33966. will be defined after the contents of the @code{bashrc} field has been
  33967. put in the @file{.bashrc} file. The alias will automatically be quoted,
  33968. so something like this:
  33969. @lisp
  33970. '(("ls" . "ls -alF"))
  33971. @end lisp
  33972. turns into
  33973. @example
  33974. alias ls="ls -alF"
  33975. @end example
  33976. @item @code{bash-profile} (default: @code{'()}) (type: text-config)
  33977. List of file-like objects, which will be added to @file{.bash_profile}.
  33978. Used for executing user's commands at start of login shell (In most
  33979. cases the shell started on tty just after login). @file{.bash_login}
  33980. won't be ever read, because @file{.bash_profile} always present.
  33981. @item @code{bashrc} (default: @code{'()}) (type: text-config)
  33982. List of file-like objects, which will be added to @file{.bashrc}. Used
  33983. for executing user's commands at start of interactive shell (The shell
  33984. for interactive usage started by typing @code{bash} or by terminal app
  33985. or any other program).
  33986. @item @code{bash-logout} (default: @code{'()}) (type: text-config)
  33987. List of file-like objects, which will be added to @file{.bash_logout}.
  33988. Used for executing user's commands at the exit of login shell. It won't
  33989. be read in some cases (if the shell terminates by exec'ing another
  33990. process for example).
  33991. @end table
  33992. @end deftp
  33993. You can extend the Bash service by using the @code{home-bash-extension}
  33994. configuration record, whose fields must mirror that of
  33995. @code{home-bash-configuration} (@pxref{home-bash-configuration}). The
  33996. contents of the extensions will be added to the end of the corresponding
  33997. Bash configuration files (@pxref{Bash Startup Files,,, bash, The GNU
  33998. Bash Reference Manual}.
  33999. For example, here is how you would define a service that extends the
  34000. Bash service such that @file{~/.bash_profile} defines an additional
  34001. environment variable, @env{PS1}:
  34002. @lisp
  34003. (define bash-fancy-prompt-service
  34004. (simple-service 'bash-fancy-prompt
  34005. home-bash-service-type
  34006. (home-bash-extension
  34007. (environment-variables
  34008. '(("PS1" . "\\u \\wλ "))))))
  34009. @end lisp
  34010. You would then add @code{bash-fancy-prompt-service} to the list in the
  34011. @code{services} field of your @code{home-environment}. The reference of
  34012. @code{home-bash-extension} follows.
  34013. @deftp {Data Type} home-bash-extension
  34014. Available @code{home-bash-extension} fields are:
  34015. @table @asis
  34016. @item @code{environment-variables} (default: @code{'()}) (type: alist)
  34017. Additional environment variables to set. These will be combined with the
  34018. environment variables from other extensions and the base service to form one
  34019. coherent block of environment variables.
  34020. @item @code{aliases} (default: @code{'()}) (type: alist)
  34021. Additional aliases to set. These will be combined with the aliases from
  34022. other extensions and the base service.
  34023. @item @code{bash-profile} (default: @code{'()}) (type: text-config)
  34024. Additional text blocks to add to @file{.bash_profile}, which will be combined
  34025. with text blocks from other extensions and the base service.
  34026. @item @code{bashrc} (default: @code{'()}) (type: text-config)
  34027. Additional text blocks to add to @file{.bashrc}, which will be combined
  34028. with text blocks from other extensions and the base service.
  34029. @item @code{bash-logout} (default: @code{'()}) (type: text-config)
  34030. Additional text blocks to add to @file{.bash_logout}, which will be combined
  34031. with text blocks from other extensions and the base service.
  34032. @end table
  34033. @end deftp
  34034. @subsubheading Zsh Home Service
  34035. @deftp {Data Type} home-zsh-configuration
  34036. Available @code{home-zsh-configuration} fields are:
  34037. @table @asis
  34038. @item @code{package} (default: @code{zsh}) (type: package)
  34039. The Zsh package to use.
  34040. @item @code{xdg-flavor?} (default: @code{#t}) (type: boolean)
  34041. Place all the configs to @file{$XDG_CONFIG_HOME/zsh}. Makes
  34042. @file{~/.zshenv} to set @env{ZDOTDIR} to @file{$XDG_CONFIG_HOME/zsh}.
  34043. Shell startup process will continue with
  34044. @file{$XDG_CONFIG_HOME/zsh/.zshenv}.
  34045. @item @code{environment-variables} (default: @code{'()}) (type: alist)
  34046. Association list of environment variables to set for the Zsh session.
  34047. @item @code{zshenv} (default: @code{'()}) (type: text-config)
  34048. List of file-like objects, which will be added to @file{.zshenv}. Used
  34049. for setting user's shell environment variables. Must not contain
  34050. commands assuming the presence of tty or producing output. Will be read
  34051. always. Will be read before any other file in @env{ZDOTDIR}.
  34052. @item @code{zprofile} (default: @code{'()}) (type: text-config)
  34053. List of file-like objects, which will be added to @file{.zprofile}. Used
  34054. for executing user's commands at start of login shell (In most cases the
  34055. shell started on tty just after login). Will be read before
  34056. @file{.zlogin}.
  34057. @item @code{zshrc} (default: @code{'()}) (type: text-config)
  34058. List of file-like objects, which will be added to @file{.zshrc}. Used
  34059. for executing user's commands at start of interactive shell (The shell
  34060. for interactive usage started by typing @code{zsh} or by terminal app or
  34061. any other program).
  34062. @item @code{zlogin} (default: @code{'()}) (type: text-config)
  34063. List of file-like objects, which will be added to @file{.zlogin}. Used
  34064. for executing user's commands at the end of starting process of login
  34065. shell.
  34066. @item @code{zlogout} (default: @code{'()}) (type: text-config)
  34067. List of file-like objects, which will be added to @file{.zlogout}. Used
  34068. for executing user's commands at the exit of login shell. It won't be
  34069. read in some cases (if the shell terminates by exec'ing another process
  34070. for example).
  34071. @end table
  34072. @end deftp
  34073. @subsubheading Inputrc Profile Service
  34074. @cindex inputrc
  34075. @cindex readline
  34076. The @uref{https://tiswww.cwru.edu/php/chet/readline/rltop.html, GNU
  34077. Readline package} includes Emacs and vi editing modes, with the ability
  34078. to customize the configuration with settings in the @file{~/.inputrc}
  34079. file. With the @code{gnu home services shells} module, you can setup
  34080. your readline configuration in a predictable manner, as shown below.
  34081. For more information about configuring an @file{~/.inputrc} file,
  34082. @pxref{Readline Init File,,, readline, GNU Readline}.
  34083. @defvar home-inputrc-service-type
  34084. This is the service to setup various @file{.inputrc} configurations. The
  34085. settings in @file{.inputrc} are read by all programs which are linked
  34086. with GNU Readline.
  34087. Here is an example of a service and its configuration that you could add
  34088. to the @code{services} field of your @code{home-environment}:
  34089. @lisp
  34090. (service home-inputrc-service-type
  34091. (home-inputrc-configuration
  34092. (key-bindings
  34093. `(("Control-l" . "clear-screen")))
  34094. (variables
  34095. `(("bell-style" . "visible")
  34096. ("colored-completion-prefix" . #t)
  34097. ("editing-mode" . "vi")
  34098. ("show-mode-in-prompt" . #t)))
  34099. (conditional-constructs
  34100. `(("$if mode=vi" .
  34101. ,(home-inputrc-configuration
  34102. (variables
  34103. `(("colored-stats" . #t)
  34104. ("enable-bracketed-paste" . #t)))))
  34105. ("$else" .
  34106. ,(home-inputrc-configuration
  34107. (variables
  34108. `(("show-all-if-ambiguous" . #t)))))
  34109. ("endif" . #t)
  34110. ("$include" . "/etc/inputrc")
  34111. ("$include" . ,(file-append
  34112. (specification->package "readline")
  34113. "/etc/inputrc"))))))
  34114. @end lisp
  34115. The example above starts with a combination of @code{key-bindings} and
  34116. @code{variables}. The @code{conditional-constructs} show how it is
  34117. possible to add conditionals and includes. In the example above
  34118. @code{colored-stats} is only enabled if the editing mode is @code{vi}
  34119. style, and it also reads any additional configuration located in
  34120. @file{/etc/inputrc} or in @file{/gnu/store/@dots{}-readline/etc/inputrc}.
  34121. The value associated with a @code{home-inputrc-service-type} instance
  34122. must be a @code{home-inputrc-configuration} record, as described below.
  34123. @end defvar
  34124. @anchor{home-inputrc-configuration}
  34125. @deftp {Data Type} home-inputrc-configuration
  34126. Available @code{home-inputrc-configuration} fields are:
  34127. @table @asis
  34128. @item @code{key-bindings} (default: @code{'()}) (type: alist)
  34129. Association list of readline key bindings to be added to the
  34130. @file{~/.inputrc} file.
  34131. @lisp
  34132. '((\"Control-l\" . \"clear-screen\"))
  34133. @end lisp
  34134. turns into
  34135. @example
  34136. Control-l: clear-screen
  34137. @end example
  34138. @item @code{variables} (default: @code{'()}) (type: alist)
  34139. Association list of readline variables to set.
  34140. @lisp
  34141. '((\"bell-style\" . \"visible\")
  34142. (\"colored-completion-prefix\" . #t))
  34143. @end lisp
  34144. turns into
  34145. @example
  34146. set bell-style visible
  34147. set colored-completion-prefix on
  34148. @end example
  34149. @item @code{conditional-constructs} (default: @code{'()}) (type: alist)
  34150. Association list of conditionals to add to the initialization file. This
  34151. includes @command{$if}, @command{else}, @command{endif} and @command{include}
  34152. and they receive a value of another @command{home-inputrc-configuration}.
  34153. @lisp
  34154. (conditional-constructs
  34155. `((\"$if mode=vi\" .
  34156. ,(home-inputrc-configuration
  34157. (variables
  34158. `((\"show-mode-in-prompt\" . #t)))))
  34159. (\"$else\" .
  34160. ,(home-inputrc-configuration
  34161. (key-bindings
  34162. `((\"Control-l\" . \"clear-screen\")))))
  34163. (\"$endif\" . #t)))
  34164. @end lisp
  34165. turns into
  34166. @example
  34167. $if mode=vi
  34168. set show-mode-in-prompt on
  34169. $else
  34170. Control-l: clear-screen
  34171. $endif
  34172. @end example
  34173. @item @code{extra-content} (default: @code{""}) (type: text-config)
  34174. Extra content appended as-is to the configuration file. Run @command{man
  34175. readline} for more information about all the configuration options.
  34176. @end table
  34177. @end deftp
  34178. @node Mcron Home Service
  34179. @subsection Scheduled User's Job Execution
  34180. @cindex cron
  34181. @cindex mcron
  34182. @cindex scheduling jobs
  34183. The @code{(gnu home services mcron)} module provides an interface to
  34184. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  34185. mcron, GNU@tie{}mcron}). The information about system's mcron is
  34186. applicable here (@pxref{Scheduled Job Execution}), the only difference
  34187. for home services is that they have to be declared in a
  34188. @code{home-environment} record instead of an @code{operating-system}
  34189. record.
  34190. @defvar home-mcron-service-type
  34191. This is the type of the @code{mcron} home service, whose value is a
  34192. @code{home-mcron-configuration} object. It allows to manage scheduled
  34193. tasks.
  34194. This service type can be the target of a service extension that provides
  34195. additional job specifications (@pxref{Service Composition}). In other
  34196. words, it is possible to define services that provide additional mcron
  34197. jobs to run.
  34198. @end defvar
  34199. @deftp {Data Type} home-mcron-configuration
  34200. Available @code{home-mcron-configuration} fields are:
  34201. @c Auto-generated with (gnu home services mcron)'s
  34202. @c generate-documentation procedure.
  34203. @c %start of fragment
  34204. @table @asis
  34205. @item @code{mcron} (default: @code{mcron}) (type: file-like)
  34206. The mcron package to use.
  34207. @item @code{jobs} (default: @code{'()}) (type: list-of-gexps)
  34208. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  34209. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  34210. specifications,, mcron,GNU@tie{}mcron}).
  34211. @item @code{log?} (default: @code{#t}) (type: boolean)
  34212. Log messages to standard output.
  34213. @item @code{log-format} (default: @code{"~1@@*~a ~a: ~a~%"}) (type: string)
  34214. @code{(ice-9 format)} format string for log messages. The default value
  34215. produces messages like "@samp{@var{pid} @var{name}: @var{message}"}
  34216. (@pxref{Invoking mcron, Invoking,, mcron,GNU@tie{}mcron}). Each message
  34217. is also prefixed by a timestamp by GNU Shepherd.
  34218. @end table
  34219. @end deftp
  34220. @c %end of fragment
  34221. @node Power Management Home Services
  34222. @subsection Power Management Home Services
  34223. @cindex power management
  34224. The @code{(gnu home services pm)} module provides home services
  34225. pertaining to battery power.
  34226. @defvar home-batsignal-service-type
  34227. Service for @code{batsignal}, a program that monitors battery levels
  34228. and warns the user through desktop notifications when their battery
  34229. is getting low. You can also configure a command to be run when the
  34230. battery level passes a point deemed ``dangerous''. This service is
  34231. configured with the @code{home-batsignal-configuration} record.
  34232. @end defvar
  34233. @deftp {Data Type} home-batsignal-configuration
  34234. Data type representing the configuration for batsignal.
  34235. @table @asis
  34236. @item @code{warning-level} (default: @code{15})
  34237. The battery level to send a warning message at.
  34238. @item @code{warning-message} (default: @code{#f})
  34239. The message to send as a notification when the battery level reaches
  34240. the @code{warning-level}. Setting to @code{#f} uses the default
  34241. message.
  34242. @item @code{critical-level} (default: @code{5})
  34243. The battery level to send a critical message at.
  34244. @item @code{critical-message} (default: @code{#f})
  34245. The message to send as a notification when the battery level reaches
  34246. the @code{critical-level}. Setting to @code{#f} uses the default
  34247. message.
  34248. @item @code{danger-level} (default: @code{2})
  34249. The battery level to run the @code{danger-command} at.
  34250. @item @code{danger-command} (default: @code{#f})
  34251. The command to run when the battery level reaches the @code{danger-level}.
  34252. Setting to @code{#f} disables running the command entirely.
  34253. @item @code{full-level} (default: @code{#f})
  34254. The battery level to send a full message at. Setting to @code{#f}
  34255. disables sending the full message entirely.
  34256. @item @code{full-message} (default: @code{#f})
  34257. The message to send as a notification when the battery level reaches
  34258. the @code{full-level}. Setting to @code{#f} uses the default message.
  34259. @item @code{batteries} (default: @code{'()})
  34260. The batteries to monitor. Setting to @code{'()} tries to find batteries
  34261. automatically.
  34262. @item @code{poll-delay} (default: @code{60})
  34263. The time in seconds to wait before checking the batteries again.
  34264. @item @code{icon} (default: @code{#f})
  34265. A file-like object to use as the icon for battery notifications. Setting
  34266. to @code{#f} disables notification icons entirely.
  34267. @item @code{notifications?} (default: @code{#t})
  34268. Whether to send any notifications.
  34269. @item @code{notifications-expire?} (default: @code{#f})
  34270. Whether notifications sent expire after a time.
  34271. @item @code{notification-command} (default: @code{#f})
  34272. Command to use to send messages. Setting to @code{#f} sends a notification
  34273. through @code{libnotify}.
  34274. @item @code{ignore-missing?} (default: @code{#f})
  34275. Whether to ignore missing battery errors.
  34276. @end table
  34277. @end deftp
  34278. @node Shepherd Home Service
  34279. @subsection Managing User Daemons
  34280. @cindex shepherd services, for users
  34281. The @code{(gnu home services shepherd)} module supports the definitions
  34282. of per-user Shepherd services (@pxref{Introduction,,, shepherd, The GNU
  34283. Shepherd Manual}). You extend @code{home-shepherd-service-type} with
  34284. new services; Guix Home then takes care of starting the @code{shepherd}
  34285. daemon for you when you log in, which in turns starts the services you
  34286. asked for.
  34287. @defvar home-shepherd-service-type
  34288. The service type for the userland Shepherd, which allows one to manage
  34289. long-running processes or one-shot tasks. User's Shepherd is not an
  34290. init process (PID 1), but almost all other information described in
  34291. (@pxref{Shepherd Services}) is applicable here too.
  34292. This is the service type that extensions target when they want to create
  34293. shepherd services (@pxref{Service Types and Services}, for an example).
  34294. Each extension must pass a list of @code{<shepherd-service>}. Its
  34295. value must be a @code{home-shepherd-configuration}, as described below.
  34296. @end defvar
  34297. @deftp {Data Type} home-shepherd-configuration
  34298. This data type represents the Shepherd's configuration.
  34299. @table @code
  34300. @item shepherd (default: @code{shepherd})
  34301. The Shepherd package to use.
  34302. @item auto-start? (default: @code{#t})
  34303. Whether or not to start Shepherd on first login.
  34304. @item services (default: @code{'()})
  34305. A list of @code{<shepherd-service>} to start.
  34306. You should probably use the service extension
  34307. mechanism instead (@pxref{Shepherd Services}).
  34308. @end table
  34309. @end deftp
  34310. @node Secure Shell
  34311. @subsection Secure Shell
  34312. @cindex secure shell client, configuration
  34313. @cindex SSH client, configuration
  34314. The @uref{https://www.openssh.com, OpenSSH package} includes a client,
  34315. the @command{ssh} command, that allows you to connect to remote machines
  34316. using the @acronym{SSH, secure shell} protocol. With the @code{(gnu
  34317. home services ssh)} module, you can set up OpenSSH so that it works in a
  34318. predictable fashion, almost independently of state on the local machine.
  34319. To do that, you instantiate @code{home-openssh-service-type} in your
  34320. Home configuration, as explained below.
  34321. @defvar home-openssh-service-type
  34322. This is the type of the service to set up the OpenSSH client. It takes
  34323. care of several things:
  34324. @itemize
  34325. @item
  34326. providing a @file{~/.ssh/config} file based on your configuration so
  34327. that @command{ssh} knows about hosts you regularly connect to and their
  34328. associated parameters;
  34329. @item
  34330. providing a @file{~/.ssh/authorized_keys}, which lists public keys that
  34331. the local SSH server, @command{sshd}, may accept to connect to this user
  34332. account;
  34333. @item
  34334. optionally providing a @file{~/.ssh/known_hosts} file so that @file{ssh}
  34335. can authenticate hosts you connect to.
  34336. @end itemize
  34337. Here is an example of a service and its configuration that you could add
  34338. to the @code{services} field of your @code{home-environment}:
  34339. @lisp
  34340. (service home-openssh-service-type
  34341. (home-openssh-configuration
  34342. (hosts
  34343. (list (openssh-host (name "ci.guix.gnu.org")
  34344. (user "charlie"))
  34345. (openssh-host (name "chbouib")
  34346. (host-name "chbouib.example.org")
  34347. (user "supercharlie")
  34348. (port 10022))))
  34349. (authorized-keys (list (local-file "alice.pub")))))
  34350. @end lisp
  34351. The example above lists two hosts and their parameters. For instance,
  34352. running @command{ssh chbouib} will automatically connect to
  34353. @code{chbouib.example.org} on port 10022, logging in as user
  34354. @samp{supercharlie}. Further, it marks the public key in
  34355. @file{alice.pub} as authorized for incoming connections.
  34356. The value associated with a @code{home-openssh-service-type} instance
  34357. must be a @code{home-openssh-configuration} record, as describe below.
  34358. @end defvar
  34359. @deftp {Data Type} home-openssh-configuration
  34360. This is the datatype representing the OpenSSH client and server
  34361. configuration in one's home environment. It contains the following
  34362. fields:
  34363. @table @asis
  34364. @item @code{hosts} (default: @code{'()})
  34365. A list of @code{openssh-host} records specifying host names and
  34366. associated connection parameters (see below). This host list goes into
  34367. @file{~/.ssh/config}, which @command{ssh} reads at startup.
  34368. @item @code{known-hosts} (default: @code{*unspecified*})
  34369. This must be either:
  34370. @itemize
  34371. @item
  34372. @code{*unspecified*}, in which case @code{home-openssh-service-type}
  34373. leaves it up to @command{ssh} and to the user to maintain the list of
  34374. known hosts at @file{~/.ssh/known_hosts}, or
  34375. @item
  34376. a list of file-like objects, in which case those are concatenated and
  34377. emitted as @file{~/.ssh/known_hosts}.
  34378. @end itemize
  34379. The @file{~/.ssh/known_hosts} contains a list of host name/host key
  34380. pairs that allow @command{ssh} to authenticate hosts you connect to and
  34381. to detect possible impersonation attacks. By default, @command{ssh}
  34382. updates it in a @dfn{TOFU, trust-on-first-use} fashion, meaning that it
  34383. records the host's key in that file the first time you connect to it.
  34384. This behavior is preserved when @code{known-hosts} is set to
  34385. @code{*unspecified*}.
  34386. If you instead provide a list of host keys upfront in the
  34387. @code{known-hosts} field, your configuration becomes self-contained and
  34388. stateless: it can be replicated elsewhere or at another point in time.
  34389. Preparing this list can be relatively tedious though, which is why
  34390. @code{*unspecified*} is kept as a default.
  34391. @item @code{authorized-keys} (default: @code{#false})
  34392. The default @code{#false} value means: Leave any
  34393. @file{~/.ssh/authorized_keys} file alone. Otherwise, this must be a
  34394. list of file-like objects, each of which containing an SSH public key
  34395. that should be authorized to connect to this machine.
  34396. Concretely, these files are concatenated and made available as
  34397. @file{~/.ssh/authorized_keys}. If an OpenSSH server, @command{sshd}, is
  34398. running on this machine, then it @emph{may} take this file into account:
  34399. this is what @command{sshd} does by default, but be aware that it can
  34400. also be configured to ignore it.
  34401. @item @code{add-keys-to-agent} (default: @code{``no''})
  34402. This string specifies whether keys should be automatically added to a
  34403. running ssh-agent. If this option is set to @code{``yes''} and a key is
  34404. loaded from a file, the key and its passphrase are added to the agent
  34405. with the default lifetime, as if by @code{ssh-add}. If this option is
  34406. set to @code{``ask''}, @code{ssh} will require confirmation. If this
  34407. option is set to @code{``confirm''}, each use of the key must be
  34408. confirmed. If this option is set to @code{``no''}, no keys are added to
  34409. the agent. Alternately, this option may be specified as a time interval
  34410. to specify the key's lifetime in @code{ssh-agent}, after which it will
  34411. automatically be removed. The argument must be @code{``no''},
  34412. @code{``yes''}, @code{``confirm''} (optionally followed by a time
  34413. interval), @code{``ask''} or a time interval.
  34414. @end table
  34415. @end deftp
  34416. @c %start of fragment
  34417. @deftp {Data Type} openssh-host
  34418. Available @code{openssh-host} fields are:
  34419. @table @asis
  34420. @item @code{name} (type: string)
  34421. Name of this host declaration. A @code{openssh-host} must define only
  34422. @code{name} or @code{match-criteria}. Use host-name @code{\"*\"} for
  34423. top-level options.
  34424. @item @code{host-name} (type: maybe-string)
  34425. Host name---e.g., @code{"foo.example.org"} or @code{"192.168.1.2"}.
  34426. @item @code{match-criteria} (type: maybe-match-criteria)
  34427. When specified, this string denotes the set of hosts to which the entry
  34428. applies, superseding the @code{host-name} field. Its first element must be
  34429. all or one of @code{ssh-match-keywords}. The rest of the elements are
  34430. arguments for the keyword, or other criteria. A @code{openssh-host} must
  34431. define only @code{name} or @code{match-criteria}. Other host configuration
  34432. options will apply to all hosts matching @code{match-criteria}.
  34433. @item @code{address-family} (type: maybe-address-family)
  34434. Address family to use when connecting to this host: one of
  34435. @code{AF_INET} (for IPv4 only), @code{AF_INET6} (for IPv6 only).
  34436. Additionally, the field can be left unset to allow any address family.
  34437. @item @code{identity-file} (type: maybe-string)
  34438. The identity file to use---e.g., @code{"/home/charlie/.ssh/id_ed25519"}.
  34439. @item @code{port} (type: maybe-natural-number)
  34440. TCP port number to connect to.
  34441. @item @code{user} (type: maybe-string)
  34442. User name on the remote host.
  34443. @item @code{forward-x11?} (type: maybe-boolean)
  34444. Whether to forward remote client connections to the local X11 graphical
  34445. display.
  34446. @item @code{forward-x11-trusted?} (type: maybe-boolean)
  34447. Whether remote X11 clients have full access to the original X11
  34448. graphical display.
  34449. @item @code{forward-agent?} (type: maybe-boolean)
  34450. Whether the authentication agent (if any) is forwarded to the remote
  34451. machine.
  34452. @item @code{compression?} (type: maybe-boolean)
  34453. Whether to compress data in transit.
  34454. @item @code{proxy} (type: maybe-proxy-command-or-jump-list)
  34455. The command to use to connect to the server or a list of SSH hosts to
  34456. jump through before connecting to the server. The field may be set to either a
  34457. @code{proxy-command} or a list of @code{proxy-jump} records.
  34458. As an example, a @code{proxy-command} to connect via an HTTP proxy at 192.0.2.0
  34459. would be constructed with: @code{(proxy-command "nc -X connect -x
  34460. 192.0.2.0:8080 %h %p")}.
  34461. @deftp {Data Type} proxy-jump
  34462. Available @code{proxy-jump} fields are:
  34463. @table @asis
  34464. @item @code{user} (type: maybe-string)
  34465. User name on the remote host.
  34466. @item @code{host-name} (type: string)
  34467. Host name---e.g., @code{foo.example.org} or @code{192.168.1.2}.
  34468. @item @code{port} (type: maybe-natural-number)
  34469. TCP port number to connect to.
  34470. @end table
  34471. @end deftp
  34472. @item @code{host-key-algorithms} (type: maybe-string-list)
  34473. The list of accepted host key algorithms---e.g.,
  34474. @code{'("ssh-ed25519")}.
  34475. @item @code{accepted-key-types} (type: maybe-string-list)
  34476. The list of accepted user public key types.
  34477. @item @code{extra-content} (default: @code{""}) (type: raw-configuration-string)
  34478. Extra content appended as-is to this @code{Host} block in
  34479. @file{~/.ssh/config}.
  34480. @end table
  34481. @end deftp
  34482. @cindex Parcimonie, Home service
  34483. The @code{parcimonie} service runs a daemon that slowly refreshes a GnuPG
  34484. public key from a keyserver. It refreshes one key at a time; between every
  34485. key update parcimonie sleeps a random amount of time, long enough for the
  34486. previously used Tor circuit to expire. This process is meant to make it hard
  34487. for an attacker to correlate the multiple key update.
  34488. As an example, here is how you would configure @code{parcimonie} to refresh the
  34489. keys in your GnuPG keyring, as well as those keyrings created by Guix, such as
  34490. when running @code{guix import}:
  34491. @lisp
  34492. (service home-parcimonie-service-type
  34493. (home-parcimonie-configuration
  34494. (refresh-guix-keyrings? #t)))
  34495. @end lisp
  34496. This assumes that the Tor anonymous routing daemon is already running on your
  34497. system. On Guix System, this can be achieved by setting up
  34498. @code{tor-service-type} (@pxref{Networking Services, @code{tor-service-type}}).
  34499. The service reference is given below.
  34500. @defvar parcimonie-service-type
  34501. This is the service type for @command{parcimonie}
  34502. (@uref{https://salsa.debian.org/intrigeri/parcimonie, Parcimonie's web site}).
  34503. Its value must be a @code{home-parcimonie-configuration}, as shown below.
  34504. @end defvar
  34505. @c %start of fragment
  34506. @deftp {Data Table} home-parcimonie-configuration
  34507. Available @code{home-parcimonie-configuration} fields are:
  34508. @table @asis
  34509. @item @code{parcimonie} (default: @code{parcimonie}) (type: file-like)
  34510. The parcimonie package to use.
  34511. @item @code{verbose?} (default: @code{#f}) (type: boolean)
  34512. Whether to have more verbose logging from the service.
  34513. @item @code{gnupg-already-torified?} (default: @code{#f}) (type: boolean)
  34514. Whether GnuPG is already configured to pass all traffic through
  34515. @uref{https://torproject.org, Tor}.
  34516. @item @code{refresh-guix-keyrings?} (default: @code{#f}) (type: boolean)
  34517. Guix creates a few keyrings in the @var{$XDG_CONFIG_DIR}, such as when running
  34518. @code{guix import} (@pxref{Invoking guix import}). Setting this to @code{#t}
  34519. will also refresh any keyrings which Guix has created.
  34520. @item @code{extra-content} (default: @code{#f}) (type: raw-configuration-string)
  34521. Raw content to add to the parcimonie command.
  34522. @end table
  34523. @end deftp
  34524. @c %end of fragment
  34525. @cindex ssh-agent
  34526. The @uref{https://www.openssh.com, OpenSSH package} includes a daemon,
  34527. the @command{ssh-agent} command, that manages keys to connect to remote
  34528. machines using the @acronym{SSH, secure shell} protocol. With the
  34529. @code{(gnu home services ssh)} service, you can configure the
  34530. OpenSSH ssh-agent to run upon login. @xref{GNU Privacy Guard,
  34531. @code{home-gpg-agent-service-type}}, for an alternative to OpenSSH's
  34532. @command{ssh-agent}.
  34533. Here is an example of a service and its configuration that you could add
  34534. to the @code{services} field of your @code{home-environment}:
  34535. @lisp
  34536. (service home-ssh-agent-service-type
  34537. (home-ssh-agent-configuration
  34538. (extra-options '("-t" "1h30m"))))
  34539. @end lisp
  34540. @defvar home-ssh-agent-service-type
  34541. This is the type of the @code{ssh-agent} home service, whose value is a
  34542. @code{home-ssh-agent-configuration} object.
  34543. @end defvar
  34544. @deftp {Data Type} home-ssh-agent-configuration
  34545. Available @code{home-ssh-agent-configuration} fields are:
  34546. @table @asis
  34547. @item @code{openssh} (default: @code{openssh}) (type: file-like)
  34548. The OpenSSH package to use.
  34549. @item @code{socket-directory} (default: @code{@env{XDG_RUNTIME_DIR}/ssh-agent"}) (type: gexp)
  34550. The directory to write the ssh-agent's @file{socket} file.
  34551. @item @code{extra-options} (default: @code{'()})
  34552. Extra options will be passed to @command{ssh-agent}, please run
  34553. @command{man ssh-agent} for more information.
  34554. @end table
  34555. @end deftp
  34556. @node GNU Privacy Guard
  34557. @subsection GNU Privacy Guard
  34558. @cindex GNU Privacy Guard, Home service
  34559. @cindex GPG, Home service
  34560. The @code{(gnu home services gnupg)} modules provides services that help
  34561. you set up the GNU Privacy Guard, also known as GnuPG or GPG, in your
  34562. home environment.
  34563. @cindex gpg-agent, Home service
  34564. @cindex SSH agent, with gpg-agent
  34565. The @code{gpg-agent} service configures and sets up GPG's agent, the
  34566. program that is responsible for managing OpenPGP private keys and,
  34567. optionally, OpenSSH (secure shell) private keys (@pxref{Invoking
  34568. GPG-AGENT,,, gnupg, Using the GNU Privacy Guard}).
  34569. As an example, here is how you would configure @code{gpg-agent} with SSH
  34570. support such that it uses the Emacs-based Pinentry interface when
  34571. prompting for a passphrase:
  34572. @lisp
  34573. (service home-gpg-agent-service-type
  34574. (home-gpg-agent-configuration
  34575. (pinentry-program
  34576. (file-append pinentry-emacs "/bin/pinentry-emacs"))
  34577. (ssh-support? #t)))
  34578. @end lisp
  34579. The service reference is given below.
  34580. @defvar home-gpg-agent-service-type
  34581. This is the service type for @command{gpg-agent} (@pxref{Invoking
  34582. GPG-AGENT,,, gnupg, Using the GNU Privacy Guard}). Its value must be a
  34583. @code{home-gpg-agent-configuration}, as shown below.
  34584. @end defvar
  34585. @c %start of fragment
  34586. @deftp {Data Type} home-gpg-agent-configuration
  34587. Available @code{home-gpg-agent-configuration} fields are:
  34588. @table @asis
  34589. @item @code{gnupg} (default: @code{gnupg}) (type: file-like)
  34590. The GnuPG package to use.
  34591. @item @code{pinentry-program} (type: file-like)
  34592. Pinentry program to use. Pinentry is a small user interface that
  34593. @command{gpg-agent} delegates to anytime it needs user input for a
  34594. passphrase or @acronym{PIN,personal identification number}
  34595. (@pxref{Top,,, pinentry,Using the PIN-Entry}).
  34596. @item @code{ssh-support?} (default: @code{#f}) (type: boolean)
  34597. Whether to enable @acronym{SSH,secure shell} support. When true,
  34598. @command{gpg-agent} acts as a drop-in replacement for OpenSSH's
  34599. @command{ssh-agent} program, taking care of OpenSSH secret keys and
  34600. directing passphrase requests to the chosen Pinentry program.
  34601. @item @code{default-cache-ttl} (default: @code{600}) (type: integer)
  34602. Time a cache entry is valid, in seconds.
  34603. @item @code{max-cache-ttl} (default: @code{7200}) (type: integer)
  34604. Maximum time a cache entry is valid, in seconds. After this time a
  34605. cache entry will be expired even if it has been accessed recently.
  34606. @item @code{default-cache-ttl-ssh} (default: @code{1800}) (type: integer)
  34607. Time a cache entry for SSH keys is valid, in seconds.
  34608. @item @code{max-cache-ttl-ssh} (default: @code{7200}) (type: integer)
  34609. Maximum time a cache entry for SSH keys is valid, in seconds.
  34610. @item @code{extra-content} (default: @code{""}) (type: raw-configuration-string)
  34611. Raw content to add to the end of @file{~/.gnupg/gpg-agent.conf}.
  34612. @end table
  34613. @end deftp
  34614. @c %end of fragment
  34615. @node Desktop Home Services
  34616. @subsection Desktop Home Services
  34617. The @code{(gnu home services desktop)} module provides services that you
  34618. may find useful on ``desktop'' systems running a graphical user
  34619. environment such as Xorg.
  34620. @defvar home-redshift-service-type
  34621. This is the service type for @uref{https://github.com/jonls/redshift,
  34622. Redshift}, a program that adjusts the display color temperature
  34623. according to the time of day. Its associated value must be a
  34624. @code{home-redshift-configuration} record, as shown below.
  34625. A typical configuration, where we manually specify the latitude and
  34626. longitude, might look like this:
  34627. @lisp
  34628. (service home-redshift-service-type
  34629. (home-redshift-configuration
  34630. (location-provider 'manual)
  34631. (latitude 35.81) ;northern hemisphere
  34632. (longitude -0.80))) ;west of Greenwich
  34633. @end lisp
  34634. @end defvar
  34635. @deftp {Data Type} home-redshift-configuration
  34636. Available @code{home-redshift-configuration} fields are:
  34637. @table @asis
  34638. @item @code{redshift} (default: @code{redshift}) (type: file-like)
  34639. Redshift package to use.
  34640. @item @code{location-provider} (default: @code{geoclue2}) (type: symbol)
  34641. Geolocation provider---@code{'manual} or @code{'geoclue2}. In the
  34642. former case, you must also specify the @code{latitude} and
  34643. @code{longitude} fields so Redshift can determine daytime at your place.
  34644. In the latter case, the Geoclue system service must be running; it will
  34645. be queried for location information.
  34646. @item @code{adjustment-method} (default: @code{randr}) (type: symbol)
  34647. Color adjustment method.
  34648. @item @code{daytime-temperature} (default: @code{6500}) (type: integer)
  34649. Daytime color temperature (kelvins).
  34650. @item @code{nighttime-temperature} (default: @code{4500}) (type: integer)
  34651. Nighttime color temperature (kelvins).
  34652. @item @code{daytime-brightness} (type: maybe-inexact-number)
  34653. Daytime screen brightness, between 0.1 and 1.0, or left unspecified.
  34654. @item @code{nighttime-brightness} (type: maybe-inexact-number)
  34655. Nighttime screen brightness, between 0.1 and 1.0, or left unspecified.
  34656. @item @code{latitude} (type: maybe-inexact-number)
  34657. Latitude, when @code{location-provider} is @code{'manual}.
  34658. @item @code{longitude} (type: maybe-inexact-number)
  34659. Longitude, when @code{location-provider} is @code{'manual}.
  34660. @item @code{dawn-time} (type: maybe-string)
  34661. Custom time for the transition from night to day in the
  34662. morning---@code{"HH:MM"} format. When specified, solar elevation is not
  34663. used to determine the daytime/nighttime period.
  34664. @item @code{dusk-time} (type: maybe-string)
  34665. Likewise, custom time for the transition from day to night in the
  34666. evening.
  34667. @item @code{extra-content} (default: @code{""}) (type: raw-configuration-string)
  34668. Extra content appended as-is to the Redshift configuration file. Run
  34669. @command{man redshift} for more information about the configuration file
  34670. format.
  34671. @end table
  34672. @end deftp
  34673. @defvar home-dbus-service-type
  34674. This is the service type for running a session-specific D-Bus, for
  34675. unprivileged applications that require D-Bus to be running.
  34676. @end defvar
  34677. @deftp {Data Type} home-dbus-configuration
  34678. The configuration record for @code{home-dbus-service-type}.
  34679. @table @asis
  34680. @item @code{dbus} (default: @code{dbus})
  34681. The package providing the @code{/bin/dbus-daemon} command.
  34682. @end table
  34683. @end deftp
  34684. @defvar home-unclutter-service-type
  34685. This is the service type for Unclutter, a program that runs on the
  34686. background of an X11 session and detects when the X pointer hasn't moved
  34687. for a specified idle timeout, after which it hides the cursor so that
  34688. you can focus on the text underneath. Its associated value must be a
  34689. @code{home-unclutter-configuration} record, as shown below.
  34690. A typical configuration, where we manually specify the idle timeout (in
  34691. seconds), might look like this:
  34692. @lisp
  34693. (service home-unclutter-service-type
  34694. (home-unclutter-configuration
  34695. (idle-timeout 2)))
  34696. @end lisp
  34697. @end defvar
  34698. @deftp {Data Type} home-unclutter-configuration
  34699. The configuration record for @code{home-unclutter-service-type}.
  34700. @table @asis
  34701. @item @code{unclutter} (default: @code{unclutter}) (type: file-like)
  34702. Unclutter package to use.
  34703. @item @code{idle-timeout} (default: @code{5}) (type: integer)
  34704. A timeout in seconds after which to hide cursor.
  34705. @end table
  34706. @end deftp
  34707. @defvar home-xmodmap-service-type
  34708. This is the service type for the
  34709. @uref{https://gitlab.freedesktop.org/xorg/app/xmodmap,xmodmap} utility
  34710. to modify keymaps and pointer button mappings under the Xorg display
  34711. server. Its associated value must be a
  34712. @code{home-xmodmap-configuration} record, as shown below.
  34713. The @code{key-map} field takes a list of objects, each of which is
  34714. either a @dfn{statement} (a string) or an @dfn{assignment} (a pair of
  34715. strings). As an example, the snippet below swaps around the
  34716. @kbd{Caps_Lock} and the @kbd{Control_L} keys, by first removing the
  34717. keysyms (on the right-hand side) from the corresponding modifier maps
  34718. (on the left-hand side), re-assigning them by swapping each other out,
  34719. and finally adding back the keysyms to the modifier maps.
  34720. @lisp
  34721. (service home-xmodmap-service-type
  34722. (home-xmodmap-configuration
  34723. (key-map '(("remove Lock" . "Caps_Lock")
  34724. ("remove Control" . "Control_L")
  34725. ("keysym Control_L" . "Caps_Lock")
  34726. ("keysym Caps_Lock" . "Control_L")
  34727. ("add Lock" . "Caps_Lock")
  34728. ("add Control" . "Control_L")))))
  34729. @end lisp
  34730. @end defvar
  34731. @deftp {Data Type} home-xmodmap-configuration
  34732. The configuration record for @code{home-xmodmap-service-type}. Its
  34733. available fields are:
  34734. @table @asis
  34735. @item @code{xmodmap} (default: @code{xmodmap}) (type: file-like)
  34736. The @code{xmodmap} package to use.
  34737. @item @code{key-map} (default: @code{'()}) (type: list)
  34738. The list of expressions to be read by @code{xmodmap} on service startup.
  34739. @end table
  34740. @end deftp
  34741. @node Guix Home Services
  34742. @subsection Guix Home Services
  34743. The @code{(gnu home services guix)} module provides services for
  34744. user-specific Guix configuration.
  34745. @defvar home-channels-service-type
  34746. This is the service type for managing
  34747. @file{$XDG_CONFIG_HOME/guix/channels.scm}, the file that controls the
  34748. channels received on @command{guix pull} (@pxref{Channels}). Its
  34749. associated value is a list of @code{channel} records, defined in the
  34750. @code{(guix channels)} module.
  34751. Generally, it is better to extend this service than to directly
  34752. configure it, as its default value is the default guix channel(s)
  34753. defined by @code{%default-channels}. If you configure this service
  34754. directly, be sure to include a guix channel. @xref{Specifying
  34755. Additional Channels} and @ref{Using a Custom Guix Channel} for more
  34756. details.
  34757. A typical extension for adding a channel might look like this:
  34758. @lisp
  34759. (simple-service 'variant-packages-service
  34760. home-channels-service-type
  34761. (list
  34762. (channel
  34763. (name 'variant-packages)
  34764. (url "https://example.org/variant-packages.git"))))
  34765. @end lisp
  34766. @end defvar
  34767. @node Fonts Home Services
  34768. @subsection Fonts Home Services
  34769. The @code{(gnu home services fontutils)} module provides services for
  34770. user-specific Fontconfig setup. The
  34771. @uref{https://www.freedesktop.org/wiki/Software/fontconfig,Fontconfig}
  34772. library is used by many applications to access fonts on the system.
  34773. @defvar home-fontconfig-service-type
  34774. This is the service type for generating configurations for Fontconfig.
  34775. Its associated value is a list of either strings (or gexps) pointing to
  34776. fonts locations, or SXML (@pxref{SXML,,, guile, GNU Guile Reference
  34777. Manual}) fragments to be converted into XML and put inside the main
  34778. @code{fontconfig} node.
  34779. Generally, it is better to extend this service than to directly
  34780. configure it, as its default value is the default Guix Home's profile
  34781. font installation path (@file{~/.guix-home/profile/share/fonts}). If
  34782. you configure this service directly, be sure to include the above
  34783. directory.
  34784. Here's how you'd extend it to include fonts installed with the Nix
  34785. package manager, and to prefer your favourite monospace font:
  34786. @lisp
  34787. (simple-service 'additional-fonts-service
  34788. home-fontconfig-service-type
  34789. (list "~/.nix-profile/share/fonts"
  34790. '(alias
  34791. (family "monospace")
  34792. (prefer
  34793. (family "Liberation Mono")))))
  34794. @end lisp
  34795. @end defvar
  34796. @node Sound Home Services
  34797. @subsection Sound Home Services
  34798. The @code{(gnu home services sound)} module provides services related to
  34799. sound support.
  34800. @cindex PulseAudio, home service
  34801. @cindex RTP, for PulseAudio
  34802. The following services dynamically reconfigure the
  34803. @uref{https://pulseaudio.org,PulseAudio sound server}: they let you
  34804. toggle broadcast of audio output over the network using the
  34805. @acronym{RTP, real-time transport protocol} and, correspondingly,
  34806. playback of sound received over RTP. Once
  34807. @code{home-pulseaudio-rtp-sink-service-type} is among your home
  34808. services, you can start broadcasting audio output by running this
  34809. command:
  34810. @example
  34811. herd start pulseaudio-rtp-sink
  34812. @end example
  34813. You can then run a PulseAudio-capable mixer, such as @code{pavucontrol}
  34814. or @code{pulsemixer} (both from the same-named package) to control which
  34815. audio stream(s) should be sent to the RTP ``sink''.
  34816. By default, audio is broadcasted to a multicast address: any device on
  34817. the @acronym{LAN, local area network} receives it and may play it.
  34818. Using multicast in this way puts a lot of pressure on the network and
  34819. degrades its performance, so you may instead prefer sending to
  34820. specifically one device. The first way to do that is by specifying the
  34821. IP address of the target device when starting the service:
  34822. @example
  34823. herd start pulseaudio-rtp-sink 192.168.1.42
  34824. @end example
  34825. The other option is to specify this IP address as the one to use by
  34826. default in your home environment configuration:
  34827. @lisp
  34828. (service home-pulseaudio-rtp-sink-service-type
  34829. "192.168.1.42")
  34830. @end lisp
  34831. On the device where you intend to receive and play the RTP stream, you
  34832. can use @code{home-pulseaudio-rtp-source-service-type}, like so:
  34833. @lisp
  34834. (service home-pulseaudio-rtp-source-service-type)
  34835. @end lisp
  34836. This will then let you start the receiving module for PulseAudio:
  34837. @example
  34838. herd start pulseaudio-rtp-source
  34839. @end example
  34840. Again, by default it will listen on the multicast address. If, instead,
  34841. you'd like it to listen for direct incoming connections, you can do that
  34842. by running:
  34843. @lisp
  34844. (service home-pulseaudio-rtp-source-service-type
  34845. "0.0.0.0")
  34846. @end lisp
  34847. The reference of these services is given below.
  34848. @defvar home-pulseaudio-rtp-sink-service-type
  34849. @defvarx home-pulseaudio-rtp-source-service-type
  34850. This is the type of the service to send, respectively receive, audio
  34851. streams over @acronym{RTP, real-time transport protocol}.
  34852. The value associated with this service is the IP address (a string)
  34853. where to send, respectively receive, the audio stream. By default,
  34854. audio is sent/received on multicast address
  34855. @code{%pulseaudio-rtp-multicast-address}.
  34856. This service defines one Shepherd service: @code{pulseaudio-rtp-sink},
  34857. respectively @code{pulseaudio-rtp-source}. The service is not started
  34858. by default, so you have to explicitly start it when you want to turn it
  34859. on, as in this example:
  34860. @example
  34861. herd start pulseaudio-rtp-sink
  34862. @end example
  34863. Stopping the Shepherd service turns off broadcasting.
  34864. @end defvar
  34865. @defvar %pulseaudio-rtp-multicast-address
  34866. This is the multicast address used by default by the two services above.
  34867. @end defvar
  34868. @node Mail Home Services
  34869. @subsection Mail Home Services
  34870. The @code{(gnu home services mail)} module provides services that help
  34871. you set up the tools to work with emails in your home environment.
  34872. @cindex msmtp
  34873. @uref{https://marlam.de/msmtp, MSMTP} is a @acronym{SMTP, Simple Mail
  34874. Transfer Protocol} client. It sends mail to a predefined SMTP server
  34875. that takes care of proper delivery.
  34876. The service reference is given below.
  34877. @defvar home-msmtp-service-type
  34878. This is the service type for @command{msmtp}. Its value must be a
  34879. @code{home-msmtp-configuration}, as shown below. It provides the
  34880. @file{~/.config/msmtp/config} file.
  34881. As an example, here is how you would configure @code{msmtp} for a single
  34882. account:
  34883. @lisp
  34884. (service home-msmtp-service-type
  34885. (home-msmtp-configuration
  34886. (accounts
  34887. (list
  34888. (msmtp-account
  34889. (name "alice")
  34890. (configuration
  34891. (msmtp-configuration
  34892. (host "mail.example.org")
  34893. (port 587)
  34894. (user "alice")
  34895. (password-eval "pass Mail/alice"))))))))
  34896. @end lisp
  34897. @end defvar
  34898. @c %start of fragment
  34899. @deftp {Data Type} home-msmtp-configuration
  34900. Available @code{home-msmtp-configuration} fields are:
  34901. @table @asis
  34902. @item @code{defaults} (type: msmtp-configuration)
  34903. The configuration that will be set as default for all accounts.
  34904. @item @code{accounts} (default: @code{'()}) (type: list-of-msmtp-accounts)
  34905. A list of @code{msmtp-account} records which contain information about
  34906. all your accounts.
  34907. @item @code{default-account} (type: maybe-string)
  34908. Set the default account.
  34909. @item @code{extra-content} (default: @code{""}) (type: string)
  34910. Extra content appended as-is to the configuration file. Run
  34911. @command{man msmtp} for more information about the configuration file
  34912. format.
  34913. @end table
  34914. @end deftp
  34915. @c %end of fragment
  34916. @c %start of fragment
  34917. @deftp {Data Type} msmtp-account
  34918. Available @code{msmtp-account} fields are:
  34919. @table @asis
  34920. @item @code{name} (type: string)
  34921. The unique name of the account.
  34922. @item @code{configuration} (type: msmtp-configuration)
  34923. The configuration for this given account.
  34924. @end table
  34925. @end deftp
  34926. @c %end of fragment
  34927. @c %start of fragment
  34928. @deftp {Data Type} msmtp-configuration
  34929. Available @code{msmtp-configuration} fields are:
  34930. @table @asis
  34931. @item @code{auth?} (type: maybe-boolean)
  34932. Enable or disable authentication.
  34933. @item @code{tls?} (type: maybe-boolean)
  34934. Enable or disable TLS (also known as SSL) for secured connections.
  34935. @item @code{tls-starttls?} (type: maybe-boolean)
  34936. Choose the TLS variant: start TLS from within the session (‘on’,
  34937. default), or tunnel the session through TLS (‘off’).
  34938. @item @code{tls-trust-file} (type: maybe-string)
  34939. Activate server certificate verification using a list of trusted
  34940. Certification Authorities (CAs).
  34941. @item @code{log-file} (type: maybe-string)
  34942. Enable logging to the specified file. An empty argument disables
  34943. logging. The file name ‘-’ directs the log information to standard
  34944. output.
  34945. @item @code{host} (type: maybe-string)
  34946. The SMTP server to send the mail to.
  34947. @item @code{port} (type: maybe-integer)
  34948. The port that the SMTP server listens on. The default is 25 ("smtp"),
  34949. unless TLS without STARTTLS is used, in which case it is 465 ("smtps").
  34950. @item @code{user} (type: maybe-string)
  34951. Set the user name for authentication.
  34952. @item @code{from} (type: maybe-string)
  34953. Set the envelope-from address.
  34954. @item @code{password-eval} (type: maybe-string)
  34955. Set the password for authentication to the output (stdout) of the
  34956. command cmd.
  34957. @item @code{extra-content} (default: @code{""}) (type: string)
  34958. Extra content appended as-is to the configuration block. Run
  34959. @command{man msmtp} for more information about the configuration file
  34960. format.
  34961. @end table
  34962. @end deftp
  34963. @c %end of fragment
  34964. @node Messaging Home Services
  34965. @subsection Messaging Home Services
  34966. @cindex znc
  34967. The @uref{https://znc.in, ZNC bouncer} can be run as a daemon to manage
  34968. your IRC presence. With the @code{(gnu home services messaging)} service, you
  34969. can configure ZNC to run upon login.
  34970. You will have to provide a @file{~/.znc/configs/znc.conf} separately.
  34971. Here is an example of a service and its configuration that you could add
  34972. to the @code{services} field of your @code{home-environment}:
  34973. @lisp
  34974. (service home-znc-service-type)
  34975. @end lisp
  34976. @defvar home-znc-service-type
  34977. This is the type of the ZNC home service, whose value is a
  34978. @code{home-znc-configuration} object.
  34979. @end defvar
  34980. @deftp {Data Type} home-znc-configuration
  34981. Available @code{home-znc-configuration} fields are:
  34982. @table @asis
  34983. @item @code{znc} (default: @code{znc}) (type: file-like)
  34984. The ZNC package to use.
  34985. @item @code{extra-options} (default: @code{'()})
  34986. Extra options will be passed to @command{znc}, please run @command{man
  34987. znc} for more information.
  34988. @end table
  34989. @end deftp
  34990. @node Media Home Services
  34991. @subsection Media Home Services
  34992. @cindex kodi
  34993. The @uref{https://kodi.tv, Kodi media center} can be run as a daemon on
  34994. a media server. With the @code{(gnu home services kodi)} service, you
  34995. can configure Kodi to run upon login.
  34996. Here is an example of a service and its configuration that you could add
  34997. to the @code{services} field of your @code{home-environment}:
  34998. @lisp
  34999. (service home-kodi-service-type
  35000. (home-kodi-configuration
  35001. (extra-options '("--settings="<settings-file>"))))
  35002. @end lisp
  35003. @defvar home-kodi-service-type
  35004. This is the type of the Kodi home service, whose value is a
  35005. @code{home-kodi-configuration} object.
  35006. @end defvar
  35007. @deftp {Data Type} home-kodi-configuration
  35008. Available @code{home-kodi-configuration} fields are:
  35009. @table @asis
  35010. @item @code{kodi} (default: @code{kodi}) (type: file-like)
  35011. The Kodi package to use.
  35012. @item @code{extra-options} (default: @code{'()})
  35013. Extra options will be passed to @command{kodi}, please run @command{man
  35014. kodi} for more information.
  35015. @end table
  35016. @end deftp
  35017. @node Networking Home Services
  35018. @subsection Networking Home Services
  35019. This section lists services somewhat networking-related that you may use
  35020. with Guix Home.
  35021. @cindex Syncthing, file synchronization service
  35022. @cindex backup service, Syncthing
  35023. The @code{(gnu home services syncthing)} module provides a service to
  35024. set up the @uref{Syncthing, https://syncthing.net} continuous file
  35025. backup service.
  35026. @defvar home-syncthing-service-type
  35027. This is the service type for the @command{syncthing} daemon; it is the
  35028. Home counterpart of the @code{syncthing-service-type} system service
  35029. (@pxref{Networking Services, @code{syncthing-service-type}}). The value
  35030. for this service type is a @command{syncthing-configuration}.
  35031. Here is how you would set it up with the default configuration:
  35032. @lisp
  35033. (service home-syncthing-service-type)
  35034. @end lisp
  35035. For a custom configuration, wrap you @code{syncthing-configuration} in
  35036. @code{for-home}, as in this example:
  35037. @lisp
  35038. (service home-syncthing-service-type
  35039. (for-home
  35040. (syncthing-configuration (logflags 5))))
  35041. @end lisp
  35042. For details about @code{syncthing-configuration}, check out the
  35043. documentation of the system service (@pxref{Networking Services,
  35044. @code{syncthing-service-type}}).
  35045. @end defvar
  35046. @node Miscellaneous Home Services
  35047. @subsection Miscellaneous Home Services
  35048. This section lists Home services that lack a better place.
  35049. @subsubheading Dictionary Service
  35050. @cindex dictionary service, for Home
  35051. The @code{(gnu home services dict)} module provides the following service:
  35052. @defvar home-dicod-service-type
  35053. This is the type of the service that runs the @command{dicod} daemon, an
  35054. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  35055. You can add @command{open localhost} to your @file{~/.dico} file to make
  35056. @code{localhost} the default server for @command{dico} client
  35057. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  35058. @end defvar
  35059. This service is a direct mapping of the @code{dicod-service-type} system
  35060. service (@pxref{Miscellaneous Services, Dictionary Service}). You can
  35061. use it like this:
  35062. @lisp
  35063. (service home-dicod-service-type)
  35064. @end lisp
  35065. You may specify a custom configuration by providing a
  35066. @code{dicod-configuration} record, exactly like for
  35067. @code{dicod-service-type}, but wrapping it in @code{for-home}:
  35068. @lisp
  35069. (service home-dicod-service-type
  35070. (for-home
  35071. (dicod-configuration @dots{})))
  35072. @end lisp
  35073. @node Invoking guix home
  35074. @section Invoking @command{guix home}
  35075. @cindex @command{guix home}
  35076. Once you have written a home environment declaration (@pxref{Declaring
  35077. the Home Environment,,,,}, it can be @dfn{instantiated} using the
  35078. @command{guix home} command. The synopsis is:
  35079. @example
  35080. guix home @var{options}@dots{} @var{action} @var{file}
  35081. @end example
  35082. @var{file} must be the name of a file containing a
  35083. @code{home-environment} declaration. @var{action} specifies how the
  35084. home environment is instantiated, but there are few auxiliary actions
  35085. which don't instantiate it. Currently the following values are
  35086. supported:
  35087. @table @code
  35088. @item search
  35089. Display available home service type definitions that match the given
  35090. regular expressions, sorted by relevance:
  35091. @cindex shell
  35092. @cindex shell-profile
  35093. @cindex bash
  35094. @cindex zsh
  35095. @example
  35096. $ guix home search shell
  35097. name: home-shell-profile
  35098. location: gnu/home/services/shells.scm:100:2
  35099. extends: home-files
  35100. description: Create `~/.profile', which is used for environment initialization of POSIX compliant login shells.
  35101. + This service type can be extended with a list of file-like objects.
  35102. relevance: 6
  35103. name: home-fish
  35104. location: gnu/home/services/shells.scm:640:2
  35105. extends: home-files home-profile
  35106. description: Install and configure Fish, the friendly interactive shell.
  35107. relevance: 3
  35108. name: home-zsh
  35109. location: gnu/home/services/shells.scm:290:2
  35110. extends: home-files home-profile
  35111. description: Install and configure Zsh.
  35112. relevance: 1
  35113. name: home-bash
  35114. location: gnu/home/services/shells.scm:508:2
  35115. extends: home-files home-profile
  35116. description: Install and configure GNU Bash.
  35117. relevance: 1
  35118. @dots{}
  35119. @end example
  35120. As for @command{guix search}, the result is written in
  35121. @code{recutils} format, which makes it easy to filter the output
  35122. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  35123. @cindex container, for @command{guix home}
  35124. @item container
  35125. Spawn a shell in an isolated environment---a
  35126. @dfn{container}---containing your home as specified by @var{file}.
  35127. For example, this is how you would start an interactive shell in a
  35128. container with your home:
  35129. @example
  35130. guix home container config.scm
  35131. @end example
  35132. This is a throw-away container where you can lightheartedly fiddle with
  35133. files; any changes made within the container, any process started---all
  35134. this disappears as soon as you exit that shell.
  35135. As with @command{guix shell}, several options control that container:
  35136. @table @option
  35137. @item --network
  35138. @itemx -N
  35139. Enable networking within the container (it is disabled by default).
  35140. @item --expose=@var{source}[=@var{target}]
  35141. @itemx --share=@var{source}[=@var{target}]
  35142. As with @command{guix shell}, make directory @var{source} of the host
  35143. system available as @var{target} inside the container---read-only if you
  35144. pass @option{--expose}, and writable if you pass @option{--share}
  35145. (@pxref{Invoking guix shell, @option{--expose} and @option{--share}}).
  35146. @end table
  35147. Additionally, you can run a command in that container, instead of
  35148. spawning an interactive shell. For instance, here is how you would
  35149. check which Shepherd services are started in a throw-away home
  35150. container:
  35151. @example
  35152. guix home container config.scm -- herd status
  35153. @end example
  35154. The command to run in the container must come after @code{--} (double
  35155. hyphen).
  35156. @cindex service type definition, editing
  35157. @cindex editing, service type definition
  35158. @item edit
  35159. Edit or view the definition of the given Home service types.
  35160. For example, the command below opens your editor, as specified by the
  35161. @env{EDITOR} environment variable, on the definition of the
  35162. @code{home-mcron} service type:
  35163. @example
  35164. guix home edit home-mcron
  35165. @end example
  35166. @item reconfigure
  35167. Build the home environment described in @var{file}, and switch to it.
  35168. Switching means that the activation script will be evaluated and (in
  35169. basic scenario) symlinks to configuration files generated from
  35170. @code{home-environment} declaration will be created in @file{~}. If the
  35171. file with the same path already exists in home folder it will be moved
  35172. to @file{~/@var{timestamp}-guix-home-legacy-configs-backup}, where @var{timestamp}
  35173. is a current UNIX epoch time.
  35174. @quotation Note
  35175. It is highly recommended to run @command{guix pull} once before you run
  35176. @command{guix home reconfigure} for the first time (@pxref{Invoking guix
  35177. pull}).
  35178. @end quotation
  35179. This effects all the configuration specified in @var{file}. The command
  35180. starts Shepherd services specified in @var{file} that are not currently
  35181. running; if a service is currently running, this command will arrange
  35182. for it to be upgraded the next time it is stopped (e.g.@: by @code{herd
  35183. stop @var{service}} or @code{herd restart @var{service}}).
  35184. This command creates a new generation whose number is one greater than
  35185. the current generation (as reported by @command{guix home
  35186. list-generations}). If that generation already exists, it will be
  35187. overwritten. This behavior mirrors that of @command{guix package}
  35188. (@pxref{Invoking guix package}).
  35189. @cindex provenance tracking, of the home environment
  35190. Upon completion, the new home is deployed under @file{~/.guix-home}.
  35191. This directory contains @dfn{provenance meta-data}: the list of channels
  35192. in use (@pxref{Channels}) and @var{file} itself, when available. You
  35193. can view the provenance information by running:
  35194. @example
  35195. guix home describe
  35196. @end example
  35197. This information is useful should you later want to inspect how this
  35198. particular generation was built. In fact, assuming @var{file} is
  35199. self-contained, you can later rebuild generation @var{n} of your
  35200. home environment with:
  35201. @example
  35202. guix time-machine \
  35203. -C /var/guix/profiles/per-user/@var{USER}/guix-home-@var{n}-link/channels.scm -- \
  35204. home reconfigure \
  35205. /var/guix/profiles/per-user/@var{USER}/guix-home-@var{n}-link/configuration.scm
  35206. @end example
  35207. You can think of it as some sort of built-in version control! Your
  35208. home is not just a binary artifact: @emph{it carries its own source}.
  35209. @c @xref{Service Reference, @code{provenance-service-type}}, for more
  35210. @c information on provenance tracking.
  35211. @c @footnote{This action (and the related actions
  35212. @c @code{switch-generation} and @code{roll-back}) are usable after the
  35213. @c home environment is initialized.}.
  35214. @item switch-generation
  35215. @cindex home generations
  35216. Switch to an existing home generation. This action atomically switches
  35217. the home profile to the specified home generation.
  35218. The target generation can be specified explicitly by its generation
  35219. number. For example, the following invocation would switch to home
  35220. generation 7:
  35221. @example
  35222. guix home switch-generation 7
  35223. @end example
  35224. The target generation can also be specified relative to the current
  35225. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  35226. ``3 generations ahead of the current generation,'' and @code{-1} means
  35227. ``1 generation prior to the current generation.'' When specifying a
  35228. negative value such as @code{-1}, you must precede it with @code{--} to
  35229. prevent it from being parsed as an option. For example:
  35230. @example
  35231. guix home switch-generation -- -1
  35232. @end example
  35233. This action will fail if the specified generation does not exist.
  35234. @item roll-back
  35235. @cindex rolling back
  35236. Switch to the preceding home generation. This is the inverse
  35237. of @command{reconfigure}, and it is exactly the same as invoking
  35238. @command{switch-generation} with an argument of @code{-1}.
  35239. @item delete-generations
  35240. @cindex deleting home generations
  35241. @cindex saving space
  35242. Delete home generations, making them candidates for garbage collection
  35243. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  35244. collector'').
  35245. This works in the same way as @samp{guix package --delete-generations}
  35246. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  35247. arguments, all home generations but the current one are deleted:
  35248. @example
  35249. guix home delete-generations
  35250. @end example
  35251. You can also select the generations you want to delete. The example below
  35252. deletes all the home generations that are more than two months old:
  35253. @example
  35254. guix home delete-generations 2m
  35255. @end example
  35256. @item build
  35257. Build the derivation of the home environment, which includes all the
  35258. configuration files and programs needed. This action does not actually
  35259. install anything.
  35260. @item describe
  35261. Describe the current home generation: its file name, as well as
  35262. provenance information when available.
  35263. To show installed packages in the current home generation's profile, the
  35264. @code{--list-installed} flag is provided, with the same syntax that is
  35265. used in @command{guix package --list-installed} (@pxref{Invoking guix
  35266. package}). For instance, the following command shows a table of all the
  35267. packages with ``emacs'' in their name that are installed in the current
  35268. home generation's profile:
  35269. @example
  35270. guix home describe --list-installed=emacs
  35271. @end example
  35272. @item list-generations
  35273. List a summary of each generation of the home environment available on
  35274. disk, in a human-readable way. This is similar to the
  35275. @option{--list-generations} option of @command{guix package}
  35276. (@pxref{Invoking guix package}).
  35277. Optionally, one can specify a pattern, with the same syntax that is used
  35278. in @command{guix package --list-generations}, to restrict the list of
  35279. generations displayed. For instance, the following command displays
  35280. generations that are up to 10 days old:
  35281. @example
  35282. guix home list-generations 10d
  35283. @end example
  35284. The @code{--list-installed} flag may also be specified, with the same
  35285. syntax that is used in @command{guix home describe}. This may be
  35286. helpful if trying to determine when a package was added to the home
  35287. profile.
  35288. @item import
  35289. Generate a @dfn{home environment} from the packages in the default
  35290. profile and configuration files found in the user's home directory. The
  35291. configuration files will be copied to the specified directory, and a
  35292. @file{home-configuration.scm} will be populated with the home
  35293. environment. Note that not every home service that exists is supported
  35294. (@pxref{Home Services}).
  35295. @example
  35296. $ guix home import ~/guix-config
  35297. guix home: '/home/alice/guix-config' populated with all the Home configuration files
  35298. @end example
  35299. @end table
  35300. And there's more! @command{guix home} also provides the following
  35301. sub-commands to visualize how the services of your home environment
  35302. relate to one another:
  35303. @table @code
  35304. @cindex service extension graph, of a home environment
  35305. @item extension-graph
  35306. Emit to standard output the @dfn{service extension graph} of the home
  35307. environment defined in @var{file} (@pxref{Service Composition}, for more
  35308. information on service extensions). By default the output is in
  35309. Dot/Graphviz format, but you can choose a different format with
  35310. @option{--graph-backend}, as with @command{guix graph} (@pxref{Invoking
  35311. guix graph, @option{--backend}}):
  35312. The command:
  35313. @example
  35314. guix home extension-graph @var{file} | xdot -
  35315. @end example
  35316. shows the extension relations among services.
  35317. @cindex Shepherd dependency graph, for a home environment
  35318. @item shepherd-graph
  35319. Emit to standard output the @dfn{dependency graph} of shepherd services
  35320. of the home environment defined in @var{file}. @xref{Shepherd
  35321. Services}, for more information and for an example graph.
  35322. Again, the default output format is Dot/Graphviz, but you can pass
  35323. @option{--graph-backend} to select a different one.
  35324. @end table
  35325. @var{options} can contain any of the common build options (@pxref{Common
  35326. Build Options}). In addition, @var{options} can contain one of the
  35327. following:
  35328. @table @option
  35329. @item --expression=@var{expr}
  35330. @itemx -e @var{expr}
  35331. Consider the home-environment @var{expr} evaluates to.
  35332. This is an alternative to specifying a file which evaluates to a home
  35333. environment.
  35334. @item --allow-downgrades
  35335. Instruct @command{guix home reconfigure} to allow system downgrades.
  35336. Just like @command{guix system}, @command{guix home reconfigure}, by
  35337. default, prevents you from downgrading your home to older or unrelated
  35338. revisions compared to the channel revisions that were used to deploy
  35339. it---those shown by @command{guix home describe}. Using
  35340. @option{--allow-downgrades} allows you to bypass that check, at the risk
  35341. of downgrading your home---be careful!
  35342. @end table
  35343. @node Documentation
  35344. @chapter Documentation
  35345. @cindex documentation, searching for
  35346. @cindex searching for documentation
  35347. @cindex Info, documentation format
  35348. @cindex man pages
  35349. @cindex manual pages
  35350. In most cases packages installed with Guix come with documentation.
  35351. There are two main documentation formats: ``Info'', a browsable
  35352. hypertext format used for GNU software, and ``manual pages'' (or ``man
  35353. pages''), the linear documentation format traditionally found on Unix.
  35354. Info manuals are accessed with the @command{info} command or with Emacs,
  35355. and man pages are accessed using @command{man}.
  35356. You can look for documentation of software installed on your system by
  35357. keyword. For example, the following command searches for information
  35358. about ``TLS'' in Info manuals:
  35359. @example
  35360. $ info -k TLS
  35361. "(emacs)Network Security" -- STARTTLS
  35362. "(emacs)Network Security" -- TLS
  35363. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  35364. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  35365. @dots{}
  35366. @end example
  35367. @noindent
  35368. The command below searches for the same keyword in man
  35369. pages@footnote{The database searched by @command{man -k} is only created
  35370. in profiles that contain the @code{man-db} package.}:
  35371. @example
  35372. $ man -k TLS
  35373. SSL (7) - OpenSSL SSL/TLS library
  35374. certtool (1) - GnuTLS certificate tool
  35375. @dots {}
  35376. @end example
  35377. These searches are purely local to your computer so you have the
  35378. guarantee that documentation you find corresponds to what you have
  35379. actually installed, you can access it off-line, and your privacy is
  35380. respected.
  35381. Once you have these results, you can view the relevant documentation by
  35382. running, say:
  35383. @example
  35384. $ info "(gnutls)Core TLS API"
  35385. @end example
  35386. @noindent
  35387. or:
  35388. @example
  35389. $ man certtool
  35390. @end example
  35391. Info manuals contain sections and indices as well as hyperlinks like
  35392. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  35393. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  35394. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  35395. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  35396. Introduction}, for an introduction to Info navigation.
  35397. @node Platforms
  35398. @chapter Platforms
  35399. The packages and systems built by Guix are intended, like most computer
  35400. programs, to run on a CPU with a specific instruction set, and under a
  35401. specific operating system. Those programs are often also targeting a
  35402. specific kernel and system library. Those constraints are captured by
  35403. Guix in @code{platform} records.
  35404. @menu
  35405. * platform Reference:: Detail of platform declarations.
  35406. * Supported Platforms:: Description of the supported platforms.
  35407. @end menu
  35408. @node platform Reference
  35409. @section @code{platform} Reference
  35410. The @code{platform} data type describes a @dfn{platform}: an
  35411. @acronym{ISA, instruction set architecture}, combined with an operating
  35412. system and possibly additional system-wide settings such as the
  35413. @acronym{ABI, application binary interface}.
  35414. @deftp {Data Type} platform
  35415. This is the data type representing a platform.
  35416. @table @asis
  35417. @item @code{target}
  35418. This field specifies the platform's GNU triplet as a string
  35419. (@pxref{Specifying Target Triplets, GNU configuration triplets,,
  35420. autoconf, Autoconf}).
  35421. @item @code{system}
  35422. This string is the system type as it is known to Guix and passed,
  35423. for instance, to the @option{--system} option of most commands.
  35424. It usually has the form @code{"@var{cpu}-@var{kernel}"}, where
  35425. @var{cpu} is the target CPU and @var{kernel} the target operating
  35426. system kernel.
  35427. It can be for instance @code{"aarch64-linux"} or @code{"armhf-linux"}.
  35428. You will encounter system types when you perform native builds
  35429. (@pxref{Native Builds}).
  35430. @item @code{linux-architecture} (default: @code{#false})
  35431. This optional string field is only relevant if the kernel is Linux. In
  35432. that case, it corresponds to the ARCH variable used when building Linux,
  35433. @code{"mips"} for instance.
  35434. @item @code{glibc-dynamic-linker}
  35435. This field is the name of the GNU C Library dynamic linker for the
  35436. corresponding system, as a string. It can be
  35437. @code{"/lib/ld-linux-armhf.so.3"}.
  35438. @end table
  35439. @end deftp
  35440. @node Supported Platforms
  35441. @section Supported Platforms
  35442. The @code{(guix platforms @dots{})} modules export the following
  35443. variables, each of which is bound to a @code{platform} record.
  35444. @defvar armv7-linux
  35445. Platform targeting ARM v7 CPU running GNU/Linux.
  35446. @end defvar
  35447. @defvar aarch64-linux
  35448. Platform targeting ARM v8 CPU running GNU/Linux.
  35449. @end defvar
  35450. @defvar mips64-linux
  35451. Platform targeting MIPS little-endian 64-bit CPU running GNU/Linux.
  35452. @end defvar
  35453. @defvar powerpc-linux
  35454. Platform targeting PowerPC big-endian 32-bit CPU running GNU/Linux.
  35455. @end defvar
  35456. @defvar powerpc64le-linux
  35457. Platform targeting PowerPC little-endian 64-bit CPU running GNU/Linux.
  35458. @end defvar
  35459. @defvar riscv64-linux
  35460. Platform targeting RISC-V 64-bit CPU running GNU/Linux.
  35461. @end defvar
  35462. @defvar i686-linux
  35463. Platform targeting x86 CPU running GNU/Linux.
  35464. @end defvar
  35465. @defvar x86_64-linux
  35466. Platform targeting x86 64-bit CPU running GNU/Linux.
  35467. @end defvar
  35468. @defvar i686-mingw
  35469. Platform targeting x86 CPU running Windows, with run-time support from
  35470. MinGW.
  35471. @end defvar
  35472. @defvar x86_64-mingw
  35473. Platform targeting x86 64-bit CPU running Windows, with run-time support
  35474. from MinGW.
  35475. @end defvar
  35476. @defvar i586-gnu
  35477. Platform targeting x86 CPU running GNU/Hurd (also referred to as
  35478. ``GNU'').
  35479. @end defvar
  35480. @node System Images
  35481. @chapter Creating System Images
  35482. @cindex system images
  35483. When it comes to installing Guix System for the first time on a new
  35484. machine, you can basically proceed in three different ways. The first
  35485. one is to use an existing operating system on the machine to run the
  35486. @command{guix system init} command (@pxref{Invoking guix system}). The
  35487. second one, is to produce an installation image (@pxref{Building the
  35488. Installation Image}). This is a bootable system which role is to
  35489. eventually run @command{guix system init}. Finally, the third option
  35490. would be to produce an image that is a direct instantiation of the
  35491. system you wish to run. That image can then be copied on a bootable
  35492. device such as an USB drive or a memory card. The target machine would
  35493. then directly boot from it, without any kind of installation procedure.
  35494. The @command{guix system image} command is able to turn an operating
  35495. system definition into a bootable image. This command supports
  35496. different image types, such as @code{mbr-raw}, @code{iso9660} and
  35497. @code{docker}. Any modern @code{x86_64} machine will probably be able
  35498. to boot from an @code{iso9660} image. However, there are a few machines
  35499. out there that require specific image types. Those machines, in general
  35500. using @code{ARM} processors, may expect specific partitions at specific
  35501. offsets.
  35502. This chapter explains how to define customized system images and how to
  35503. turn them into actual bootable images.
  35504. @menu
  35505. * image Reference:: Detail of image declarations.
  35506. * Instantiate an Image:: How to instantiate an image record.
  35507. * image-type Reference:: Detail of image types declaration.
  35508. * Image Modules:: Definition of image modules.
  35509. @end menu
  35510. @node image Reference
  35511. @section @code{image} Reference
  35512. The @code{image} record, described right after, allows you to define a
  35513. customized bootable system image.
  35514. @deftp {Data Type} image
  35515. This is the data type representing a system image.
  35516. @table @asis
  35517. @item @code{name} (default: @code{#false})
  35518. The image name as a symbol, @code{'my-iso9660} for instance. The name
  35519. is optional and it defaults to @code{#false}.
  35520. @item @code{format}
  35521. The image format as a symbol. The following formats are supported:
  35522. @itemize
  35523. @item @code{disk-image}, a raw disk image composed of one or multiple
  35524. partitions.
  35525. @item @code{compressed-qcow2}, a compressed qcow2 image composed of
  35526. one or multiple partitions.
  35527. @item @code{docker}, a Docker image.
  35528. @item @code{iso9660}, an ISO-9660 image.
  35529. @item @code{tarball}, a tar.gz image archive.
  35530. @item @code{wsl2}, a WSL2 image.
  35531. @end itemize
  35532. @item @code{platform} (default: @code{#false})
  35533. The @code{platform} record the image is targeting (@pxref{Platforms}),
  35534. @code{aarch64-linux} for instance. By default, this field is set to
  35535. @code{#false} and the image will target the host platform.
  35536. @item @code{size} (default: @code{'guess})
  35537. The image size in bytes or @code{'guess}. The @code{'guess} symbol,
  35538. which is the default, means that the image size will be inferred based
  35539. on the image content.
  35540. @item @code{operating-system}
  35541. The image's @code{operating-system} record that is instantiated.
  35542. @item @code{partition-table-type} (default: @code{'mbr})
  35543. The image partition table type as a symbol. Possible values are
  35544. @code{'mbr} and @code{'gpt}. It default to @code{'mbr}.
  35545. @item @code{partitions} (default: @code{'()})
  35546. The image partitions as a list of @code{partition} records
  35547. (@pxref{partition Reference}).
  35548. @item @code{compression?} (default: @code{#true})
  35549. Whether the image content should be compressed, as a boolean. It
  35550. defaults to @code{#true} and only applies to @code{'iso9660} image
  35551. formats.
  35552. @item @code{volatile-root?} (default: @code{#true})
  35553. Whether the image root partition should be made volatile, as a boolean.
  35554. This is achieved by using a RAM backed file system (overlayfs) that is
  35555. mounted on top of the root partition by the initrd. It defaults to
  35556. @code{#true}. When set to @code{#false}, the image root partition is
  35557. mounted as read-write partition by the initrd.
  35558. @item @code{shared-store?} (default: @code{#false})
  35559. Whether the image's store should be shared with the host system, as a
  35560. boolean. This can be useful when creating images dedicated to virtual
  35561. machines. When set to @code{#false}, which is the default, the image's
  35562. @code{operating-system} closure is copied to the image. Otherwise, when
  35563. set to @code{#true}, it is assumed that the host store will be made
  35564. available at boot, using a @code{9p} mount for instance.
  35565. @item @code{shared-network?} (default: @code{#false})
  35566. Whether to use the host network interfaces within the image, as a
  35567. boolean. This is only used for the @code{'docker} image format. It
  35568. defaults to @code{#false}.
  35569. @item @code{substitutable?} (default: @code{#true})
  35570. Whether the image derivation should be substitutable, as a boolean. It
  35571. defaults to @code{true}.
  35572. @end table
  35573. @end deftp
  35574. @menu
  35575. * partition Reference::
  35576. @end menu
  35577. @node partition Reference
  35578. @subsection @code{partition} Reference
  35579. In @code{image} record may contain some partitions.
  35580. @deftp {Data Type} partition
  35581. This is the data type representing an image partition.
  35582. @table @asis
  35583. @item @code{size} (default: @code{'guess})
  35584. The partition size in bytes or @code{'guess}. The @code{'guess} symbol,
  35585. which is the default, means that the partition size will be inferred
  35586. based on the partition content.
  35587. @item @code{offset} (default: @code{0})
  35588. The partition's start offset in bytes, relative to the image start or
  35589. the previous partition end. It defaults to @code{0} which means that
  35590. there is no offset applied.
  35591. @item @code{file-system} (default: @code{"ext4"})
  35592. The partition file system as a string, defaulting to @code{"ext4"}. The
  35593. supported values are @code{"vfat"}, @code{"fat16"}, @code{"fat32"} and
  35594. @code{"ext4"}.
  35595. @item @code{file-system-options} (default: @code{'()})
  35596. The partition file system creation options that should be passed to the
  35597. partition creation tool, as a list of strings. This is only supported
  35598. when creating @code{"ext4"} partitions.
  35599. See the @code{"extended-options"} man page section of the
  35600. @code{"mke2fs"} tool for a more complete reference.
  35601. @item @code{label}
  35602. The partition label as a mandatory string, @code{"my-root"} for
  35603. instance.
  35604. @item @code{uuid} (default: @code{#false})
  35605. The partition UUID as an @code{uuid} record (@pxref{File Systems}). By
  35606. default it is @code{#false}, which means that the partition creation
  35607. tool will attribute a random UUID to the partition.
  35608. @item @code{flags} (default: @code{'()})
  35609. The partition flags as a list of symbols. Possible values are
  35610. @code{'boot} and @code{'esp}. The @code{'boot} flags should be set if
  35611. you want to boot from this partition. Exactly one partition should have
  35612. this flag set, usually the root one. The @code{'esp} flag identifies a
  35613. UEFI System Partition.
  35614. @item @code{initializer} (default: @code{#false})
  35615. The partition initializer procedure as a gexp. This procedure is called
  35616. to populate a partition. If no initializer is passed, the
  35617. @code{initialize-root-partition} procedure from the @code{(gnu build
  35618. image)} module is used.
  35619. @end table
  35620. @end deftp
  35621. @node Instantiate an Image
  35622. @section Instantiate an Image
  35623. Let's say you would like to create an MBR image with three distinct
  35624. partitions:
  35625. @itemize
  35626. @item The @acronym{ESP, EFI System Partition}, a partition of
  35627. 40@tie{}MiB at offset 1024@tie{}KiB with a vfat file system.
  35628. @item an ext4 partition of 50@tie{}MiB data file, and labeled ``data''.
  35629. @item an ext4 bootable partition containing the @code{%simple-os}
  35630. operating-system.
  35631. @end itemize
  35632. You would then write the following image definition in a
  35633. @code{my-image.scm} file for instance.
  35634. @lisp
  35635. (use-modules (gnu)
  35636. (gnu image)
  35637. (gnu tests)
  35638. (gnu system image)
  35639. (guix gexp))
  35640. (define MiB (expt 2 20))
  35641. (image
  35642. (format 'disk-image)
  35643. (operating-system %simple-os)
  35644. (partitions
  35645. (list
  35646. (partition
  35647. (size (* 40 MiB))
  35648. (offset (* 1024 1024))
  35649. (label "GNU-ESP")
  35650. (file-system "vfat")
  35651. (flags '(esp))
  35652. (initializer (gexp initialize-efi-partition)))
  35653. (partition
  35654. (size (* 50 MiB))
  35655. (label "DATA")
  35656. (file-system "ext4")
  35657. (initializer #~(lambda* (root . rest)
  35658. (mkdir root)
  35659. (call-with-output-file
  35660. (string-append root "/data")
  35661. (lambda (port)
  35662. (format port "my-data"))))))
  35663. (partition
  35664. (size 'guess)
  35665. (label root-label)
  35666. (file-system "ext4")
  35667. (flags '(boot))
  35668. (initializer (gexp initialize-root-partition))))))
  35669. @end lisp
  35670. Note that the first and third partitions use generic initializers
  35671. procedures, initialize-efi-partition and initialize-root-partition
  35672. respectively. The initialize-efi-partition installs a GRUB EFI loader
  35673. that is loading the GRUB bootloader located in the root partition. The
  35674. initialize-root-partition instantiates a complete system as defined by
  35675. the @code{%simple-os} operating-system.
  35676. You can now run:
  35677. @example
  35678. guix system image my-image.scm
  35679. @end example
  35680. to instantiate the @code{image} definition. That produces a disk image
  35681. which has the expected structure:
  35682. @example
  35683. $ parted $(guix system image my-image.scm) print
  35684. @dots{}
  35685. Model: (file)
  35686. Disk /gnu/store/yhylv1bp5b2ypb97pd3bbhz6jk5nbhxw-disk-image: 1714MB
  35687. Sector size (logical/physical): 512B/512B
  35688. Partition Table: msdos
  35689. Disk Flags:
  35690. Number Start End Size Type File system Flags
  35691. 1 1049kB 43.0MB 41.9MB primary fat16 esp
  35692. 2 43.0MB 95.4MB 52.4MB primary ext4
  35693. 3 95.4MB 1714MB 1619MB primary ext4 boot
  35694. @end example
  35695. The size of the @code{boot} partition has been inferred to @code{1619MB}
  35696. so that it is large enough to host the @code{%simple-os}
  35697. operating-system.
  35698. You can also use existing @code{image} record definitions and inherit
  35699. from them to simplify the @code{image} definition. The @code{(gnu
  35700. system image)} module provides the following @code{image} definition
  35701. variables.
  35702. @defvar efi-disk-image
  35703. A MBR disk-image composed of two partitions: a 64 bits ESP partition and
  35704. a ROOT boot partition. This image can be used on most @code{x86_64} and
  35705. @code{i686} machines, supporting BIOS or UEFI booting.
  35706. @end defvar
  35707. @defvar efi32-disk-image
  35708. Same as @code{efi-disk-image} but with a 32 bits EFI partition.
  35709. @end defvar
  35710. @defvar iso9660-image
  35711. An ISO-9660 image composed of a single bootable partition. This image
  35712. can also be used on most @code{x86_64} and @code{i686} machines.
  35713. @end defvar
  35714. @defvar docker-image
  35715. A Docker image that can be used to spawn a Docker container.
  35716. @end defvar
  35717. Using the @code{efi-disk-image} we can simplify our previous
  35718. @code{image} declaration this way:
  35719. @lisp
  35720. (use-modules (gnu)
  35721. (gnu image)
  35722. (gnu tests)
  35723. (gnu system image)
  35724. (guix gexp)
  35725. (ice-9 match))
  35726. (define MiB (expt 2 20))
  35727. (define data
  35728. (partition
  35729. (size (* 50 MiB))
  35730. (label "DATA")
  35731. (file-system "ext4")
  35732. (initializer #~(lambda* (root . rest)
  35733. (mkdir root)
  35734. (call-with-output-file
  35735. (string-append root "/data")
  35736. (lambda (port)
  35737. (format port "my-data")))))))
  35738. (image
  35739. (inherit efi-disk-image)
  35740. (operating-system %simple-os)
  35741. (partitions
  35742. (match (image-partitions efi-disk-image)
  35743. ((esp root)
  35744. (list esp data root)))))
  35745. @end lisp
  35746. This will give the exact same @code{image} instantiation but the
  35747. @code{image} declaration is simpler.
  35748. @node image-type Reference
  35749. @section image-type Reference
  35750. The @command{guix system image} command can, as we saw above, take a
  35751. file containing an @code{image} declaration as argument and produce an
  35752. actual disk image from it. The same command can also handle a file
  35753. containing an @code{operating-system} declaration as argument. In that
  35754. case, how is the @code{operating-system} turned into an image?
  35755. That's where the @code{image-type} record intervenes. This record
  35756. defines how to transform an @code{operating-system} record into an
  35757. @code{image} record.
  35758. @deftp {Data Type} image-type
  35759. This is the data type representing an image-type.
  35760. @table @asis
  35761. @item @code{name}
  35762. The image-type name as a mandatory symbol, @code{'efi32-raw} for
  35763. instance.
  35764. @item @code{constructor}
  35765. The image-type constructor, as a mandatory procedure that takes an
  35766. @code{operating-system} record as argument and returns an @code{image}
  35767. record.
  35768. @end table
  35769. @end deftp
  35770. There are several @code{image-type} records provided by the @code{(gnu
  35771. system image)} and the @code{(gnu system images @dots{})} modules.
  35772. @defvar mbr-raw-image-type
  35773. Build an image based on the @code{mbr-disk-image} image.
  35774. @end defvar
  35775. @defvar efi-raw-image-type
  35776. Build an image based on the @code{efi-disk-image} image.
  35777. @end defvar
  35778. @defvar efi32-raw-image-type
  35779. Build an image based on the @code{efi32-disk-image} image.
  35780. @end defvar
  35781. @defvar qcow2-image-type
  35782. Build an image based on the @code{mbr-disk-image} image but with the
  35783. @code{compressed-qcow2} image format.
  35784. @end defvar
  35785. @defvar iso-image-type
  35786. Build a compressed image based on the @code{iso9660-image} image.
  35787. @end defvar
  35788. @defvar uncompressed-iso-image-type
  35789. Build an image based on the @code{iso9660-image} image but with the
  35790. @code{compression?} field set to @code{#false}.
  35791. @end defvar
  35792. @defvar docker-image-type
  35793. Build an image based on the @code{docker-image} image.
  35794. @end defvar
  35795. @defvar raw-with-offset-image-type
  35796. Build an MBR image with a single partition starting at a @code{1024KiB}
  35797. offset. This is useful to leave some room to install a bootloader in
  35798. the post-MBR gap.
  35799. @end defvar
  35800. @defvar pinebook-pro-image-type
  35801. Build an image that is targeting the Pinebook Pro machine. The MBR
  35802. image contains a single partition starting at a @code{9MiB} offset. The
  35803. @code{u-boot-pinebook-pro-rk3399-bootloader} bootloader will be
  35804. installed in this gap.
  35805. @end defvar
  35806. @defvar rock64-image-type
  35807. Build an image that is targeting the Rock64 machine. The MBR image
  35808. contains a single partition starting at a @code{16MiB} offset. The
  35809. @code{u-boot-rock64-rk3328-bootloader} bootloader will be installed in
  35810. this gap.
  35811. @end defvar
  35812. @defvar novena-image-type
  35813. Build an image that is targeting the Novena machine. It has the same
  35814. characteristics as @code{raw-with-offset-image-type}.
  35815. @end defvar
  35816. @defvar pine64-image-type
  35817. Build an image that is targeting the Pine64 machine. It has the same
  35818. characteristics as @code{raw-with-offset-image-type}.
  35819. @end defvar
  35820. @defvar hurd-image-type
  35821. Build an image that is targeting a @code{i386} machine running the Hurd
  35822. kernel. The MBR image contains a single ext2 partitions with specific
  35823. @code{file-system-options} flags.
  35824. @end defvar
  35825. @defvar hurd-qcow2-image-type
  35826. Build an image similar to the one built by the @code{hurd-image-type}
  35827. but with the @code{format} set to @code{'compressed-qcow2}.
  35828. @end defvar
  35829. @defvar wsl2-image-type
  35830. Build an image for the @acronym{WSL2, Windows Subsystem for Linux 2}.
  35831. It can be imported by running:
  35832. @example
  35833. wsl --import Guix ./guix ./wsl2-image.tar.gz
  35834. wsl -d Guix
  35835. @end example
  35836. @end defvar
  35837. So, if we get back to the @code{guix system image} command taking an
  35838. @code{operating-system} declaration as argument. By default, the
  35839. @code{mbr-raw-image-type} is used to turn the provided
  35840. @code{operating-system} into an actual bootable image.
  35841. To use a different @code{image-type}, the @code{--image-type} option can
  35842. be used. The @code{--list-image-types} option will list all the
  35843. supported image types. It turns out to be a textual listing of all the
  35844. @code{image-types} variables described just above (@pxref{Invoking guix
  35845. system}).
  35846. @node Image Modules
  35847. @section Image Modules
  35848. Let's take the example of the Pine64, an ARM based machine. To be able
  35849. to produce an image targeting this board, we need the following
  35850. elements:
  35851. @itemize
  35852. @item An @code{operating-system} record containing at least
  35853. an appropriate kernel (@code{linux-libre-arm64-generic}) and bootloader
  35854. @code{u-boot-pine64-lts-bootloader}) for the Pine64.
  35855. @item Possibly, an @code{image-type} record providing a way to
  35856. turn an @code{operating-system} record to an @code{image} record
  35857. suitable for the Pine64.
  35858. @item An actual @code{image} that can be instantiated with the
  35859. @command{guix system image} command.
  35860. @end itemize
  35861. The @code{(gnu system images pine64)} module provides all those
  35862. elements: @code{pine64-barebones-os}, @code{pine64-image-type} and
  35863. @code{pine64-barebones-raw-image} respectively.
  35864. The module returns the @code{pine64-barebones-raw-image} in order for
  35865. users to be able to run:
  35866. @example
  35867. guix system image gnu/system/images/pine64.scm
  35868. @end example
  35869. Now, thanks to the @code{pine64-image-type} record declaring the
  35870. @code{'pine64-raw} @code{image-type}, one could also prepare a
  35871. @code{my-pine.scm} file with the following content:
  35872. @lisp
  35873. (use-modules (gnu system images pine64))
  35874. (operating-system
  35875. (inherit pine64-barebones-os)
  35876. (timezone "Europe/Athens"))
  35877. @end lisp
  35878. to customize the @code{pine64-barebones-os}, and run:
  35879. @example
  35880. $ guix system image --image-type=pine64-raw my-pine.scm
  35881. @end example
  35882. Note that there are other modules in the @code{gnu/system/images}
  35883. directory targeting @code{Novena}, @code{Pine64}, @code{PinebookPro} and
  35884. @code{Rock64} machines.
  35885. @node Installing Debugging Files
  35886. @chapter Installing Debugging Files
  35887. @cindex debugging files
  35888. Program binaries, as produced by the GCC compilers for instance, are
  35889. typically written in the ELF format, with a section containing
  35890. @dfn{debugging information}. Debugging information is what allows the
  35891. debugger, GDB, to map binary code to source code; it is required to
  35892. debug a compiled program in good conditions.
  35893. This chapter explains how to use separate debug info when packages
  35894. provide it, and how to rebuild packages with debug info when it's
  35895. missing.
  35896. @menu
  35897. * Separate Debug Info:: Installing 'debug' outputs.
  35898. * Rebuilding Debug Info:: Building missing debug info.
  35899. @end menu
  35900. @node Separate Debug Info
  35901. @section Separate Debug Info
  35902. The problem with debugging information is that is takes up a fair amount
  35903. of disk space. For example, debugging information for the GNU C Library
  35904. weighs in at more than 60 MiB@. Thus, as a user, keeping all the
  35905. debugging info of all the installed programs is usually not an option.
  35906. Yet, space savings should not come at the cost of an impediment to
  35907. debugging---especially in the GNU system, which should make it easier
  35908. for users to exert their computing freedom (@pxref{GNU Distribution}).
  35909. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  35910. mechanism that allows users to get the best of both worlds: debugging
  35911. information can be stripped from the binaries and stored in separate
  35912. files. GDB is then able to load debugging information from those files,
  35913. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  35914. with GDB}).
  35915. The GNU distribution takes advantage of this by storing debugging
  35916. information in the @code{lib/debug} sub-directory of a separate package
  35917. output unimaginatively called @code{debug} (@pxref{Packages with
  35918. Multiple Outputs}). Users can choose to install the @code{debug} output
  35919. of a package when they need it. For instance, the following command
  35920. installs the debugging information for the GNU C Library and for GNU
  35921. Guile:
  35922. @example
  35923. guix install glibc:debug guile:debug
  35924. @end example
  35925. GDB must then be told to look for debug files in the user's profile, by
  35926. setting the @code{debug-file-directory} variable (consider setting it
  35927. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  35928. GDB}):
  35929. @example
  35930. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  35931. @end example
  35932. From there on, GDB will pick up debugging information from the
  35933. @file{.debug} files under @file{~/.guix-profile/lib/debug}.
  35934. Below is an alternative GDB script which is useful when working with
  35935. other profiles. It takes advantage of the optional Guile integration in
  35936. GDB. This snippet is included by default on Guix System in the
  35937. @file{~/.gdbinit} file.
  35938. @example
  35939. guile
  35940. (use-modules (gdb))
  35941. (execute (string-append "set debug-file-directory "
  35942. (or (getenv "GDB_DEBUG_FILE_DIRECTORY")
  35943. "~/.guix-profile/lib/debug")))
  35944. end
  35945. @end example
  35946. In addition, you will most likely want GDB to be able to show the source
  35947. code being debugged. To do that, you will have to unpack the source
  35948. code of the package of interest (obtained with @code{guix build
  35949. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  35950. directory using the @code{directory} command (@pxref{Source Path,
  35951. @code{directory},, gdb, Debugging with GDB}).
  35952. @c XXX: keep me up-to-date
  35953. The @code{debug} output mechanism in Guix is implemented by the
  35954. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  35955. opt-in---debugging information is available only for the packages with
  35956. definitions explicitly declaring a @code{debug} output. To check
  35957. whether a package has a @code{debug} output, use @command{guix package
  35958. --list-available} (@pxref{Invoking guix package}).
  35959. Read on for how to deal with packages lacking a @code{debug} output.
  35960. @node Rebuilding Debug Info
  35961. @section Rebuilding Debug Info
  35962. @cindex debugging info, rebuilding
  35963. As we saw above, some packages, but not all, provide debugging info in a
  35964. @code{debug} output. What can you do when debugging info is missing?
  35965. The @option{--with-debug-info} option provides a solution to that: it
  35966. allows you to rebuild the package(s) for which debugging info is
  35967. missing---and only those---and to graft those onto the application
  35968. you're debugging. Thus, while it's not as fast as installing a
  35969. @code{debug} output, it is relatively inexpensive.
  35970. Let's illustrate that. Suppose you're experiencing a bug in Inkscape
  35971. and would like to see what's going on in GLib, a library that's deep
  35972. down in its dependency graph. As it turns out, GLib does not have a
  35973. @code{debug} output and the backtrace GDB shows is all sadness:
  35974. @example
  35975. (gdb) bt
  35976. #0 0x00007ffff5f92190 in g_getenv ()
  35977. from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0
  35978. #1 0x00007ffff608a7d6 in gobject_init_ctor ()
  35979. from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0
  35980. #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8,
  35981. env=env@@entry=0x7fffffffcfe8) at dl-init.c:72
  35982. #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>)
  35983. at dl-init.c:118
  35984. @end example
  35985. To address that, you install Inkscape linked against a variant GLib that
  35986. contains debug info:
  35987. @example
  35988. guix install inkscape --with-debug-info=glib
  35989. @end example
  35990. This time, debugging will be a whole lot nicer:
  35991. @example
  35992. $ gdb --args sh -c 'exec inkscape'
  35993. @dots{}
  35994. (gdb) b g_getenv
  35995. Function "g_getenv" not defined.
  35996. Make breakpoint pending on future shared library load? (y or [n]) y
  35997. Breakpoint 1 (g_getenv) pending.
  35998. (gdb) r
  35999. Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape
  36000. @dots{}
  36001. (gdb) bt
  36002. #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252
  36003. #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380
  36004. #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493
  36005. #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088,
  36006. env=env@@entry=0x7fffffffd0a8) at dl-init.c:72
  36007. @dots{}
  36008. @end example
  36009. Much better!
  36010. Note that there can be packages for which @option{--with-debug-info}
  36011. will not have the desired effect. @xref{Package Transformation Options,
  36012. @option{--with-debug-info}}, for more information.
  36013. @node Using TeX and LaTeX
  36014. @chapter Using @TeX{} and @LaTeX{}
  36015. @cindex @TeX{} packages
  36016. @cindex @LaTeX{} packages
  36017. Guix provides packages for the @TeX{}, @LaTeX{}, ConTeXt, LuaTeX, and
  36018. related typesetting systems, taken from the
  36019. @uref{https://www.tug.org/texlive/, @TeX{} Live distribution}. However,
  36020. because @TeX{} Live is so huge and because finding one's way in this
  36021. maze is tricky, so this section provides some guidance on how to deploy
  36022. the relevant packages to compile @TeX{} and @LaTeX{} documents.
  36023. @TeX{} Live currently comes in two mutually exclusive flavors in Guix:
  36024. @itemize
  36025. @item
  36026. The ``monolithic'' @code{texlive} package: it comes with @emph{every
  36027. single @TeX{} Live package} (roughly 4,200), but it is huge---more than
  36028. 4@tie{}GiB for a single package!
  36029. @item
  36030. A ``modular'' @TeX{} Live distribution, in which you only install the
  36031. packages, always prefixed with @samp{texlive-}, you need.
  36032. @end itemize
  36033. So to insist, these two flavors cannot be combined@footnote{No rule
  36034. without exception! As the monolithic @TeX{} Live does not contain the
  36035. @command{biber} executable, it is okay to combine it with
  36036. @code{texlive-biber}, which does.}. If in the modular setting your
  36037. document does not compile, the solution is not to add the monolithic
  36038. @code{texlive} package, but to add the set of missing packages from the
  36039. modular distribution.
  36040. Building a coherent system that provides all the essential tools and, at
  36041. the same time, satisfies all of its internal dependencies can be
  36042. a difficult task. It is therefore recommended to start with sets of
  36043. packages, called @dfn{collections}, and @dfn{schemes}, the name for
  36044. collections of collections. The following command lists available
  36045. schemes and collections (@pxref{guix-search,, Invoking guix package}):
  36046. @example
  36047. guix search texlive-\(scheme\|collection\) | recsel -p name,description
  36048. @end example
  36049. If needed, you may then complete your system with individual packages,
  36050. particularly when they belong to a large collection you're not otherwise
  36051. interested in.
  36052. For instance, the following manifest is a reasonable, yet frugal
  36053. starting point for a French @LaTeX{} user:
  36054. @lisp
  36055. (specifications->manifest
  36056. '("rubber"
  36057. "texlive-scheme-basic"
  36058. "texlive-collection-latexrecommended"
  36059. "texlive-collection-fontsrecommended"
  36060. "texlive-babel-french"
  36061. ;; From "latexextra" collection.
  36062. "texlive-tabularray"
  36063. ;; From "binextra" collection.
  36064. "texlive-texdoc"))
  36065. @end lisp
  36066. If you come across a document that does not compile in such a basic
  36067. setting, the main difficulty is finding the missing packages. In this
  36068. case, @command{pdflatex} and similar commands tend to fail with obscure
  36069. error messages along the lines of:
  36070. @example
  36071. doc.tex: File `tikz.sty' not found.
  36072. doc.tex:7: Emergency stop.
  36073. @end example
  36074. @noindent
  36075. or, for a missing font:
  36076. @example
  36077. kpathsea: Running mktexmf phvr7t
  36078. ! I can't find file `phvr7t'.
  36079. @end example
  36080. How do you determine what the missing package is? In the first case,
  36081. you will find the answer by running:
  36082. @example
  36083. $ guix search texlive tikz
  36084. name: texlive-pgf
  36085. version: 59745
  36086. @dots{}
  36087. @end example
  36088. In the second case, @command{guix search} turns up nothing. Instead,
  36089. you can search the @TeX{} Live package database using the
  36090. @command{tlmgr} command:
  36091. @example
  36092. $ tlmgr info phvr7t
  36093. tlmgr: cannot find package phvr7t, searching for other matches:
  36094. Packages containing `phvr7t' in their title/description:
  36095. Packages containing files matching `phvr7t':
  36096. helvetic:
  36097. texmf-dist/fonts/tfm/adobe/helvetic/phvr7t.tfm
  36098. texmf-dist/fonts/tfm/adobe/helvetic/phvr7tn.tfm
  36099. texmf-dist/fonts/vf/adobe/helvetic/phvr7t.vf
  36100. texmf-dist/fonts/vf/adobe/helvetic/phvr7tn.vf
  36101. tex4ht:
  36102. texmf-dist/tex4ht/ht-fonts/alias/adobe/helvetic/phvr7t.htf
  36103. @end example
  36104. @noindent
  36105. The file is available in the @TeX{} Live @code{helvetic} package, which
  36106. is known in Guix as @code{texlive-helvetic}. Quite a ride, but you
  36107. found it!
  36108. @node Security Updates
  36109. @chapter Security Updates
  36110. @cindex security updates
  36111. @cindex security vulnerabilities
  36112. Occasionally, important security vulnerabilities are discovered in software
  36113. packages and must be patched. Guix developers try hard to keep track of
  36114. known vulnerabilities and to apply fixes as soon as possible in the
  36115. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  36116. containing only security updates). The @command{guix lint} tool helps
  36117. developers find out about vulnerable versions of software packages in the
  36118. distribution:
  36119. @smallexample
  36120. $ guix lint -c cve
  36121. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  36122. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  36123. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  36124. @dots{}
  36125. @end smallexample
  36126. @xref{Invoking guix lint}, for more information.
  36127. Guix follows a functional
  36128. package management discipline (@pxref{Introduction}), which implies
  36129. that, when a package is changed, @emph{every package that depends on it}
  36130. must be rebuilt. This can significantly slow down the deployment of
  36131. fixes in core packages such as libc or Bash, since basically the whole
  36132. distribution would need to be rebuilt. Using pre-built binaries helps
  36133. (@pxref{Substitutes}), but deployment may still take more time than
  36134. desired.
  36135. @cindex grafts
  36136. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  36137. for fast deployment of critical updates without the costs associated
  36138. with a whole-distribution rebuild. The idea is to rebuild only the
  36139. package that needs to be patched, and then to ``graft'' it onto packages
  36140. explicitly installed by the user and that were previously referring to
  36141. the original package. The cost of grafting is typically very low, and
  36142. order of magnitudes lower than a full rebuild of the dependency chain.
  36143. @cindex replacements of packages, for grafts
  36144. For instance, suppose a security update needs to be applied to Bash.
  36145. Guix developers will provide a package definition for the ``fixed''
  36146. Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
  36147. Packages}). Then, the original package definition is augmented with a
  36148. @code{replacement} field pointing to the package containing the bug fix:
  36149. @lisp
  36150. (define bash
  36151. (package
  36152. (name "bash")
  36153. ;; @dots{}
  36154. (replacement bash-fixed)))
  36155. @end lisp
  36156. From there on, any package depending directly or indirectly on Bash---as
  36157. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  36158. gc})---that is installed is automatically ``rewritten'' to refer to
  36159. @code{bash-fixed} instead of @code{bash}. This grafting process takes
  36160. time proportional to the size of the package, usually less than a
  36161. minute for an ``average'' package on a recent machine. Grafting is
  36162. recursive: when an indirect dependency requires grafting, then grafting
  36163. ``propagates'' up to the package that the user is installing.
  36164. Currently, the length of the name and version of the graft and that of
  36165. the package it replaces (@code{bash-fixed} and @code{bash} in the example
  36166. above) must be equal. This restriction mostly comes from the fact that
  36167. grafting works by patching files, including binary files, directly.
  36168. Other restrictions may apply: for instance, when adding a graft to a
  36169. package providing a shared library, the original shared library and its
  36170. replacement must have the same @code{SONAME} and be binary-compatible.
  36171. The @option{--no-grafts} command-line option allows you to forcefully
  36172. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  36173. Thus, the command:
  36174. @example
  36175. guix build bash --no-grafts
  36176. @end example
  36177. @noindent
  36178. returns the store file name of the original Bash, whereas:
  36179. @example
  36180. guix build bash
  36181. @end example
  36182. @noindent
  36183. returns the store file name of the ``fixed'', replacement Bash. This
  36184. allows you to distinguish between the two variants of Bash.
  36185. To verify which Bash your whole profile refers to, you can run
  36186. (@pxref{Invoking guix gc}):
  36187. @example
  36188. guix gc -R $(readlink -f ~/.guix-profile) | grep bash
  36189. @end example
  36190. @noindent
  36191. @dots{} and compare the store file names that you get with those above.
  36192. Likewise for a complete Guix system generation:
  36193. @example
  36194. guix gc -R $(guix system build my-config.scm) | grep bash
  36195. @end example
  36196. Lastly, to check which Bash running processes are using, you can use the
  36197. @command{lsof} command:
  36198. @example
  36199. lsof | grep /gnu/store/.*bash
  36200. @end example
  36201. @node Bootstrapping
  36202. @chapter Bootstrapping
  36203. @c Adapted from the ELS 2013 paper.
  36204. @cindex bootstrapping
  36205. Bootstrapping in our context refers to how the distribution gets built
  36206. ``from nothing''. Remember that the build environment of a derivation
  36207. contains nothing but its declared inputs (@pxref{Introduction}). So
  36208. there's an obvious chicken-and-egg problem: how does the first package
  36209. get built? How does the first compiler get compiled?
  36210. It is tempting to think of this question as one that only die-hard
  36211. hackers may care about. However, while the answer to that question is
  36212. technical in nature, its implications are wide-ranging. How the
  36213. distribution is bootstrapped defines the extent to which we, as
  36214. individuals and as a collective of users and hackers, can trust the
  36215. software we run. It is a central concern from the standpoint of
  36216. @emph{security} and from a @emph{user freedom} viewpoint.
  36217. @cindex bootstrap binaries
  36218. The GNU system is primarily made of C code, with libc at its core. The
  36219. GNU build system itself assumes the availability of a Bourne shell and
  36220. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  36221. `grep'. Furthermore, build programs---programs that run
  36222. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  36223. (@pxref{Derivations}). Consequently, to be able to build anything at
  36224. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  36225. Binutils, libc, and the other packages mentioned above---the
  36226. @dfn{bootstrap binaries}.
  36227. These bootstrap binaries are ``taken for granted'', though we can also
  36228. re-create them if needed (@pxref{Preparing to Use the Bootstrap
  36229. Binaries}).
  36230. @menu
  36231. * Full-Source Bootstrap:: A Bootstrap worthy of GNU.
  36232. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  36233. @end menu
  36234. @node Full-Source Bootstrap
  36235. @section The Full-Source Bootstrap
  36236. Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
  36237. a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
  36238. Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
  36239. GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
  36240. ``taken for granted.''
  36241. Taking the bootstrap binaries for granted means that we consider them to
  36242. be a correct and trustworthy ``seed'' for building the complete system.
  36243. Therein lies a problem: the combined size of these bootstrap binaries is
  36244. about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
  36245. or even inspecting these is next to impossible.
  36246. For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
  36247. @dfn{full-source bootstrap}. This bootstrap is rooted in
  36248. @file{hex0-seed} from the @url{https://savannah.gnu.org/projects/stage0,
  36249. Stage0} package. The hex0 program is minimalist assembler: it reads
  36250. space-separated hexadecimal digits (nibbles) from a file, possibly
  36251. including comments, and emits on standard output the bytes corresponding
  36252. to those hexadecimal numbers. The source code of this initial hex0
  36253. program is a file called
  36254. @c XXX TODO: update to savannah url, once accepted there
  36255. @url{https://github.com/oriansj/bootstrap-seeds/blob/master/POSIX/x86/hex0_x86.hex0,@file{hex0_x86.hex0}}
  36256. and is written in the @code{hex0} language.
  36257. Hex0 is self-hosting, which means that it can build itself:
  36258. @example
  36259. ./hex0-seed hex0_x86.hex0 hex0
  36260. @end example
  36261. Hex0 it is the ASCII-equivalent of the binary program and can be
  36262. produced by doing something much like:
  36263. @example
  36264. sed 's/[;#].*$//g' hex0_x86.hex0 | xxd -r -p > hex0
  36265. chmod +x hex0
  36266. @end example
  36267. It is because of this ASCII-binary equivalence that we can bless this
  36268. initial 357-byte binary as source, and hence `full-source bootstrap''.
  36269. The bootstrap then continues: @code{hex0} builds @code{hex1} and then on
  36270. to @code{M0}, @code{hex2}, @code{M1}, @code{mescc-tools} and finally
  36271. @code{M2-Planet}. Then, using @code{mescc-tools}, @code{M2-Planet} we
  36272. build Mes (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a
  36273. Scheme interpreter and C compiler in Scheme). From here on starts
  36274. the more traditional @code{C}-based bootstrap of the GNU System.
  36275. Another step that Guix has taken is to replace the shell and all its
  36276. utilities with implementations in Guile Scheme, the @emph{Scheme-only
  36277. bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
  36278. POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
  36279. which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
  36280. Gzip, Sed, and Tar.
  36281. Building the GNU System from source is currently only possible by adding
  36282. some historical GNU packages as intermediate steps@footnote{Packages
  36283. such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
  36284. @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
  36285. @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
  36286. and GNU packages become more bootstrappable again (e.g., new releases of
  36287. GNU Sed will also ship as gzipped tarballs again, as alternative to the
  36288. hard to bootstrap @code{xz}-compression), this set of added packages can
  36289. hopefully be reduced again.
  36290. The graph below shows the resulting dependency graph for
  36291. @code{gcc-core-mesboot0}, the bootstrap compiler used for the
  36292. traditional bootstrap of the rest of the Guix System.
  36293. @c ./pre-inst-env guix graph -e '(@@ (gnu packages commencement) gcc-core-mesboot0)' | sed -re 's,((bootstrap-seeds|guile-bootstrap).*shape =) box,\1 ellipse,' > doc/images/gcc-core-mesboot0-graph.dot
  36294. @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
  36295. Work is ongoing to to bring these bootstraps to the @code{arm-linux} and
  36296. @code{aarch64-linux} architectures and to the Hurd.
  36297. If you are interested, join us on @samp{#bootstrappable} on the Libera.Chat
  36298. IRC network or discuss on @email{bug-mes@@gnu.org} or
  36299. @email{gash-devel@@nongnu.org}.
  36300. @node Preparing to Use the Bootstrap Binaries
  36301. @section Preparing to Use the Bootstrap Binaries
  36302. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  36303. @c large image, it's hard to scroll. Oh well.
  36304. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  36305. The figure above shows the very beginning of the dependency graph of the
  36306. distribution, corresponding to the package definitions of the @code{(gnu
  36307. packages bootstrap)} module. A similar figure can be generated with
  36308. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  36309. @example
  36310. guix graph -t derivation \
  36311. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  36312. | dot -Tps > gcc.ps
  36313. @end example
  36314. or, for the further Reduced Binary Seed bootstrap
  36315. @example
  36316. guix graph -t derivation \
  36317. -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
  36318. | dot -Tps > mes.ps
  36319. @end example
  36320. At this level of detail, things are
  36321. slightly complex. First, Guile itself consists of an ELF executable,
  36322. along with many source and compiled Scheme files that are dynamically
  36323. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  36324. tarball shown in this graph. This tarball is part of Guix's ``source''
  36325. distribution, and gets inserted into the store with @code{add-to-store}
  36326. (@pxref{The Store}).
  36327. But how do we write a derivation that unpacks this tarball and adds it
  36328. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  36329. derivation---the first one that gets built---uses @code{bash} as its
  36330. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  36331. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  36332. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  36333. the Guix source distribution, whose sole purpose is to allow the Guile
  36334. tarball to be unpacked.
  36335. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  36336. Guile that can be used to run subsequent build programs. Its first task
  36337. is to download tarballs containing the other pre-built binaries---this
  36338. is what the @file{.tar.xz.drv} derivations do. Guix modules such as
  36339. @code{ftp-client.scm} are used for this purpose. The
  36340. @code{module-import.drv} derivations import those modules in a directory
  36341. in the store, using the original layout. The
  36342. @code{module-import-compiled.drv} derivations compile those modules, and
  36343. write them in an output directory with the right layout. This
  36344. corresponds to the @code{#:modules} argument of
  36345. @code{build-expression->derivation} (@pxref{Derivations}).
  36346. Finally, the various tarballs are unpacked by the derivations
  36347. @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
  36348. @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
  36349. point we have a working C tool chain.
  36350. @unnumberedsec Building the Build Tools
  36351. Bootstrapping is complete when we have a full tool chain that does not
  36352. depend on the pre-built bootstrap tools discussed above. This
  36353. no-dependency requirement is verified by checking whether the files of
  36354. the final tool chain contain references to the @file{/gnu/store}
  36355. directories of the bootstrap inputs. The process that leads to this
  36356. ``final'' tool chain is described by the package definitions found in
  36357. the @code{(gnu packages commencement)} module.
  36358. The @command{guix graph} command allows us to ``zoom out'' compared to
  36359. the graph above, by looking at the level of package objects instead of
  36360. individual derivations---remember that a package may translate to
  36361. several derivations, typically one derivation to download its source,
  36362. one to build the Guile modules it needs, and one to actually build the
  36363. package from source. The command:
  36364. @example
  36365. guix graph -t bag \
  36366. -e '(@@@@ (gnu packages commencement)
  36367. glibc-final-with-bootstrap-bash)' | xdot -
  36368. @end example
  36369. @noindent
  36370. displays the dependency graph leading to the ``final'' C
  36371. library@footnote{You may notice the @code{glibc-intermediate} label,
  36372. suggesting that it is not @emph{quite} final, but as a good
  36373. approximation, we will consider it final.}, depicted below.
  36374. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  36375. @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  36376. The first tool that gets built with the bootstrap binaries is
  36377. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  36378. for all the following packages. From there Findutils and Diffutils get
  36379. built.
  36380. Then come the first-stage Binutils and GCC, built as pseudo cross
  36381. tools---i.e., with @option{--target} equal to @option{--host}. They are
  36382. used to build libc. Thanks to this cross-build trick, this libc is
  36383. guaranteed not to hold any reference to the initial tool chain.
  36384. From there the final Binutils and GCC (not shown above) are built. GCC
  36385. uses @command{ld} from the final Binutils, and links programs against
  36386. the just-built libc. This tool chain is used to build the other
  36387. packages used by Guix and by the GNU Build System: Guile, Bash,
  36388. Coreutils, etc.
  36389. And voilà! At this point we have the complete set of build tools that
  36390. the GNU Build System expects. These are in the @code{%final-inputs}
  36391. variable of the @code{(gnu packages commencement)} module, and are
  36392. implicitly used by any package that uses @code{gnu-build-system}
  36393. (@pxref{Build Systems, @code{gnu-build-system}}).
  36394. @unnumberedsec Building the Bootstrap Binaries
  36395. @cindex bootstrap binaries
  36396. Because the final tool chain does not depend on the bootstrap binaries,
  36397. those rarely need to be updated. Nevertheless, it is useful to have an
  36398. automated way to produce them, should an update occur, and this is what
  36399. the @code{(gnu packages make-bootstrap)} module provides.
  36400. The following command builds the tarballs containing the bootstrap binaries
  36401. (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
  36402. bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
  36403. and Guile, and a tarball containing a mixture of Coreutils and other basic
  36404. command-line tools):
  36405. @example
  36406. guix build bootstrap-tarballs
  36407. @end example
  36408. The generated tarballs are those that should be referred to in the
  36409. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  36410. this section.
  36411. Still here? Then perhaps by now you've started to wonder: when do we
  36412. reach a fixed point? That is an interesting question! The answer is
  36413. unknown, but if you would like to investigate further (and have
  36414. significant computational and storage resources to do so), then let us
  36415. know.
  36416. @unnumberedsec Reducing the Set of Bootstrap Binaries
  36417. Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
  36418. binary code! Why is that a problem? It's a problem because these big chunks
  36419. of binary code are practically non-auditable, which makes it hard to establish
  36420. what source code produced them. Every unauditable binary also leaves us
  36421. vulnerable to compiler backdoors as described by Ken Thompson in the 1984
  36422. paper @emph{Reflections on Trusting Trust}.
  36423. This is mitigated by the fact that our bootstrap binaries were generated
  36424. from an earlier Guix revision. Nevertheless it lacks the level of
  36425. transparency that we get in the rest of the package dependency graph,
  36426. where Guix always gives us a source-to-binary mapping. Thus, our goal
  36427. is to reduce the set of bootstrap binaries to the bare minimum.
  36428. The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
  36429. on-going projects to do that. One of these is about replacing the
  36430. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  36431. of increasing complexity, which could be built from source starting from
  36432. a simple and auditable assembler.
  36433. Our first major achievement is the replacement of of GCC, the GNU C Library
  36434. and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
  36435. (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
  36436. and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
  36437. bootstrapped yet and thus we inject them as binary seeds. We call this the
  36438. Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
  36439. binaries! Also, it has eliminated the C compiler binary; i686-linux and
  36440. x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
  36441. Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
  36442. also looking at any other bootstrap binaries. Your help is welcome!
  36443. @node Porting
  36444. @chapter Porting to a New Platform
  36445. As discussed above, the GNU distribution is self-contained, and
  36446. self-containment is achieved by relying on pre-built ``bootstrap
  36447. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  36448. operating system kernel, CPU architecture, and application binary
  36449. interface (ABI). Thus, to port the distribution to a platform that is
  36450. not yet supported, one must build those bootstrap binaries, and update
  36451. the @code{(gnu packages bootstrap)} module to use them on that platform.
  36452. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  36453. When everything goes well, and assuming the GNU tool chain supports the
  36454. target platform, this can be as simple as running a command like this
  36455. one:
  36456. @example
  36457. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  36458. @end example
  36459. For this to work, it is first required to register a new platform as
  36460. defined in the @code{(guix platform)} module. A platform is making the
  36461. connection between a GNU triplet (@pxref{Specifying Target Triplets, GNU
  36462. configuration triplets,, autoconf, Autoconf}), the equivalent
  36463. @var{system} in Nix notation, the name of the
  36464. @var{glibc-dynamic-linker}, and the corresponding Linux architecture
  36465. name if applicable (@pxref{Platforms}).
  36466. Once the bootstrap tarball are built, the @code{(gnu packages
  36467. bootstrap)} module needs to be updated to refer to these binaries on the
  36468. target platform. That is, the hashes and URLs of the bootstrap tarballs
  36469. for the new platform must be added alongside those of the currently
  36470. supported platforms. The bootstrap Guile tarball is treated specially:
  36471. it is expected to be available locally, and @file{gnu/local.mk} has
  36472. rules to download it for the supported architectures; a rule for the new
  36473. platform must be added as well.
  36474. In practice, there may be some complications. First, it may be that the
  36475. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  36476. above) is not recognized by all the GNU tools. Typically, glibc
  36477. recognizes some of these, whereas GCC uses an extra @option{--with-abi}
  36478. configure flag (see @code{gcc.scm} for examples of how to handle this).
  36479. Second, some of the required packages could fail to build for that
  36480. platform. Lastly, the generated binaries could be broken for some
  36481. reason.
  36482. @c *********************************************************************
  36483. @include contributing.texi
  36484. @c *********************************************************************
  36485. @node Acknowledgments
  36486. @chapter Acknowledgments
  36487. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  36488. which was designed and
  36489. implemented by Eelco Dolstra, with contributions from other people (see
  36490. the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
  36491. management, and promoted unprecedented features, such as transactional
  36492. package upgrades and rollbacks, per-user profiles, and referentially
  36493. transparent build processes. Without this work, Guix would not exist.
  36494. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  36495. an inspiration for Guix.
  36496. GNU@tie{}Guix itself is a collective work with contributions from a
  36497. number of people. See the @file{AUTHORS} file in Guix for more
  36498. information on these fine people. The @file{THANKS} file lists people
  36499. who have helped by reporting bugs, taking care of the infrastructure,
  36500. providing artwork and themes, making suggestions, and more---thank you!
  36501. @c *********************************************************************
  36502. @node GNU Free Documentation License
  36503. @appendix GNU Free Documentation License
  36504. @cindex license, GNU Free Documentation License
  36505. @include fdl-1.3.texi
  36506. @c *********************************************************************
  36507. @node Concept Index
  36508. @unnumbered Concept Index
  36509. @printindex cp
  36510. @node Programming Index
  36511. @unnumbered Programming Index
  36512. @syncodeindex tp fn
  36513. @syncodeindex vr fn
  36514. @printindex fn
  36515. @bye
  36516. @c Local Variables:
  36517. @c ispell-local-dictionary: "american";
  36518. @c End: