guix.texi 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guix.info
  5. @documentencoding UTF-8
  6. @settitle GNU Guix Reference Manual
  7. @c %**end of header
  8. @include version.texi
  9. @c Identifier of the OpenPGP key used to sign tarballs and such.
  10. @set OPENPGP-SIGNING-KEY-ID 27D586A4F8900854329FF09F1260E46482E63562
  11. @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=127547
  12. @c Base URL for downloads.
  13. @set BASE-URL https://ftp.gnu.org/gnu/guix
  14. @c The official substitute server used by default.
  15. @set SUBSTITUTE-SERVER-1 ci.guix.gnu.org
  16. @set SUBSTITUTE-SERVER-2 bordeaux.guix.gnu.org
  17. @set SUBSTITUTE-URLS https://@value{SUBSTITUTE-SERVER-1} https://@value{SUBSTITUTE-SERVER-2}
  18. @copying
  19. Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès@*
  20. Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
  21. Copyright @copyright{} 2013 Nikita Karetnikov@*
  22. Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
  23. Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
  24. Copyright @copyright{} 2014 Pierre-Antoine Rault@*
  25. Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
  26. Copyright @copyright{} 2015, 2016, 2017, 2019, 2020, 2021 Leo Famulari@*
  27. Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus@*
  28. Copyright @copyright{} 2016 Ben Woodcroft@*
  29. Copyright @copyright{} 2016, 2017, 2018, 2021 Chris Marusich@*
  30. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Efraim Flashner@*
  31. Copyright @copyright{} 2016 John Darrington@*
  32. Copyright @copyright{} 2016, 2017 Nikita Gillmann@*
  33. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Jan Nieuwenhuizen@*
  34. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Julien Lepiller@*
  35. Copyright @copyright{} 2016 Alex ter Weele@*
  36. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Christopher Baines@*
  37. Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
  38. Copyright @copyright{} 2017, 2018, 2020, 2021 Mathieu Othacehe@*
  39. Copyright @copyright{} 2017 Federico Beffa@*
  40. Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
  41. Copyright @copyright{} 2017 Thomas Danckaert@*
  42. Copyright @copyright{} 2017 humanitiesNerd@*
  43. Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@*
  44. Copyright @copyright{} 2017, 2018, 2019, 2020, 2021 Marius Bakke@*
  45. Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@*
  46. Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@*
  47. Copyright @copyright{} 2017, 2018, 2019, 2020, 2021 Tobias Geerinckx-Rice@*
  48. Copyright @copyright{} 2017 George Clemmer@*
  49. Copyright @copyright{} 2017 Andy Wingo@*
  50. Copyright @copyright{} 2017, 2018, 2019, 2020 Arun Isaac@*
  51. Copyright @copyright{} 2017 nee@*
  52. Copyright @copyright{} 2018 Rutger Helling@*
  53. Copyright @copyright{} 2018, 2021 Oleg Pykhalov@*
  54. Copyright @copyright{} 2018 Mike Gerwitz@*
  55. Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
  56. Copyright @copyright{} 2018, 2019 Gábor Boskovits@*
  57. Copyright @copyright{} 2018, 2019, 2020 Florian Pelz@*
  58. Copyright @copyright{} 2018 Laura Lazzati@*
  59. Copyright @copyright{} 2018 Alex Vong@*
  60. Copyright @copyright{} 2019 Josh Holland@*
  61. Copyright @copyright{} 2019, 2020 Diego Nicola Barbato@*
  62. Copyright @copyright{} 2019 Ivan Petkov@*
  63. Copyright @copyright{} 2019 Jakob L. Kreuze@*
  64. Copyright @copyright{} 2019 Kyle Andrews@*
  65. Copyright @copyright{} 2019 Alex Griffin@*
  66. Copyright @copyright{} 2019, 2020, 2021 Guillaume Le Vaillant@*
  67. Copyright @copyright{} 2020 Leo Prikler@*
  68. Copyright @copyright{} 2019, 2020 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 Pierre Langlois@*
  77. Copyright @copyright{} 2020 pinoaffe@*
  78. Copyright @copyright{} 2020 André Batista@*
  79. Copyright @copyright{} 2020, 2021 Alexandru-Sergiu Marton@*
  80. Copyright @copyright{} 2020 raingloom@*
  81. Copyright @copyright{} 2020 Daniel Brooks@*
  82. Copyright @copyright{} 2020 John Soo@*
  83. Copyright @copyright{} 2020 Jonathan Brielmaier@*
  84. Copyright @copyright{} 2020 Edgar Vincent@*
  85. Copyright @copyright{} 2021 Maxime Devos@*
  86. Copyright @copyright{} 2021 B. Wilson@*
  87. Copyright @copyright{} 2021 Xinglu Chen@*
  88. Copyright @copyright{} 2021 Raghav Gururajan@*
  89. Copyright @copyright{} 2021 Domagoj Stolfa@*
  90. Copyright @copyright{} 2021 Hui Lu@*
  91. Copyright @copyright{} 2021 pukkamustard@*
  92. Copyright @copyright{} 2021 Alice Brenon@*
  93. Copyright @copyright{} 2021 Josselin Poiret@*
  94. Permission is granted to copy, distribute and/or modify this document
  95. under the terms of the GNU Free Documentation License, Version 1.3 or
  96. any later version published by the Free Software Foundation; with no
  97. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  98. copy of the license is included in the section entitled ``GNU Free
  99. Documentation License''.
  100. @end copying
  101. @dircategory System administration
  102. @direntry
  103. * Guix: (guix). Manage installed software and system configuration.
  104. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  105. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  106. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  107. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  108. * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
  109. @end direntry
  110. @dircategory Software development
  111. @direntry
  112. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  113. * guix build: (guix)Invoking guix build. Building packages.
  114. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  115. @end direntry
  116. @titlepage
  117. @title GNU Guix Reference Manual
  118. @subtitle Using the GNU Guix Functional Package Manager
  119. @author The GNU Guix Developers
  120. @page
  121. @vskip 0pt plus 1filll
  122. Edition @value{EDITION} @*
  123. @value{UPDATED} @*
  124. @insertcopying
  125. @end titlepage
  126. @contents
  127. @c *********************************************************************
  128. @node Top
  129. @top GNU Guix
  130. This document describes GNU Guix version @value{VERSION}, a functional
  131. package management tool written for the GNU system.
  132. @c TRANSLATORS: You can replace the following paragraph with information on
  133. @c how to join your own translation team and how to report issues with the
  134. @c translation.
  135. This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
  136. GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
  137. Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
  138. Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
  139. Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
  140. would like to translate it in your native language, consider joining
  141. @uref{https://translate.fedoraproject.org/projects/guix/documentation-manual,
  142. Weblate} (@pxref{Translating Guix}).
  143. @menu
  144. * Introduction:: What is Guix about?
  145. * Installation:: Installing Guix.
  146. * System Installation:: Installing the whole operating system.
  147. * Getting Started:: Your first steps.
  148. * Package Management:: Package installation, upgrade, etc.
  149. * Channels:: Customizing the package collection.
  150. * Development:: Guix-aided software development.
  151. * Programming Interface:: Using Guix in Scheme.
  152. * Utilities:: Package management commands.
  153. * System Configuration:: Configuring the operating system.
  154. * Documentation:: Browsing software user manuals.
  155. * Installing Debugging Files:: Feeding the debugger.
  156. * Security Updates:: Deploying security fixes quickly.
  157. * Bootstrapping:: GNU/Linux built from scratch.
  158. * Porting:: Targeting another platform or kernel.
  159. * Contributing:: Your help needed!
  160. * Acknowledgments:: Thanks!
  161. * GNU Free Documentation License:: The license of this manual.
  162. * Concept Index:: Concepts.
  163. * Programming Index:: Data types, functions, and variables.
  164. @detailmenu
  165. --- The Detailed Node Listing ---
  166. Introduction
  167. * Managing Software the Guix Way:: What's special.
  168. * GNU Distribution:: The packages and tools.
  169. Installation
  170. * Binary Installation:: Getting Guix running in no time!
  171. * Requirements:: Software needed to build and run Guix.
  172. * Running the Test Suite:: Testing Guix.
  173. * Setting Up the Daemon:: Preparing the build daemon's environment.
  174. * Invoking guix-daemon:: Running the build daemon.
  175. * Application Setup:: Application-specific setup.
  176. * Upgrading Guix:: Upgrading Guix and its build daemon.
  177. Setting Up the Daemon
  178. * Build Environment Setup:: Preparing the isolated build environment.
  179. * Daemon Offload Setup:: Offloading builds to remote machines.
  180. * SELinux Support:: Using an SELinux policy for the daemon.
  181. System Installation
  182. * Limitations:: What you can expect.
  183. * Hardware Considerations:: Supported hardware.
  184. * USB Stick and DVD Installation:: Preparing the installation medium.
  185. * Preparing for Installation:: Networking, partitioning, etc.
  186. * Guided Graphical Installation:: Easy graphical installation.
  187. * Manual Installation:: Manual installation for wizards.
  188. * After System Installation:: When installation succeeded.
  189. * Installing Guix in a VM:: Guix System playground.
  190. * Building the Installation Image:: How this comes to be.
  191. Manual Installation
  192. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  193. * Proceeding with the Installation:: Installing.
  194. Package Management
  195. * Features:: How Guix will make your life brighter.
  196. * Invoking guix package:: Package installation, removal, etc.
  197. * Substitutes:: Downloading pre-built binaries.
  198. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  199. * Invoking guix gc:: Running the garbage collector.
  200. * Invoking guix pull:: Fetching the latest Guix and distribution.
  201. * Invoking guix time-machine:: Running an older revision of Guix.
  202. * Inferiors:: Interacting with another revision of Guix.
  203. * Invoking guix describe:: Display information about your Guix revision.
  204. * Invoking guix archive:: Exporting and importing store files.
  205. Substitutes
  206. * Official Substitute Servers:: One particular source of substitutes.
  207. * Substitute Server Authorization:: How to enable or disable substitutes.
  208. * Getting Substitutes from Other Servers:: Substitute diversity.
  209. * Substitute Authentication:: How Guix verifies substitutes.
  210. * Proxy Settings:: How to get substitutes via proxy.
  211. * Substitution Failure:: What happens when substitution fails.
  212. * On Trusting Binaries:: How can you trust that binary blob?
  213. Channels
  214. * Specifying Additional Channels:: Extending the package collection.
  215. * Using a Custom Guix Channel:: Using a customized Guix.
  216. * Replicating Guix:: Running the @emph{exact same} Guix.
  217. * Channel Authentication:: How Guix verifies what it fetches.
  218. * Channels with Substitutes:: Using channels with available substitutes.
  219. * Creating a Channel:: How to write your custom channel.
  220. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  221. * Declaring Channel Dependencies:: How to depend on other channels.
  222. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  223. * Primary URL:: Distinguishing mirror to original.
  224. * Writing Channel News:: Communicating information to channel's users.
  225. Development
  226. * Invoking guix environment:: Setting up development environments.
  227. * Invoking guix pack:: Creating software bundles.
  228. * The GCC toolchain:: Working with languages supported by GCC.
  229. * Invoking guix git authenticate:: Authenticating Git repositories.
  230. Programming Interface
  231. * Package Modules:: Packages from the programmer's viewpoint.
  232. * Defining Packages:: Defining new packages.
  233. * Defining Package Variants:: Customizing packages.
  234. * Build Systems:: Specifying how packages are built.
  235. * Build Phases:: Phases of the build process of a package.
  236. * Build Utilities:: Helpers for your package definitions and more.
  237. * The Store:: Manipulating the package store.
  238. * Derivations:: Low-level interface to package derivations.
  239. * The Store Monad:: Purely functional interface to the store.
  240. * G-Expressions:: Manipulating build expressions.
  241. * Invoking guix repl:: Programming Guix in Guile.
  242. Defining Packages
  243. * package Reference:: The package data type.
  244. * origin Reference:: The origin data type.
  245. Utilities
  246. * Invoking guix build:: Building packages from the command line.
  247. * Invoking guix edit:: Editing package definitions.
  248. * Invoking guix download:: Downloading a file and printing its hash.
  249. * Invoking guix hash:: Computing the cryptographic hash of a file.
  250. * Invoking guix import:: Importing package definitions.
  251. * Invoking guix refresh:: Updating package definitions.
  252. * Invoking guix style:: Styling package definitions.
  253. * Invoking guix lint:: Finding errors in package definitions.
  254. * Invoking guix size:: Profiling disk usage.
  255. * Invoking guix graph:: Visualizing the graph of packages.
  256. * Invoking guix publish:: Sharing substitutes.
  257. * Invoking guix challenge:: Challenging substitute servers.
  258. * Invoking guix copy:: Copying to and from a remote store.
  259. * Invoking guix container:: Process isolation.
  260. * Invoking guix weather:: Assessing substitute availability.
  261. * Invoking guix processes:: Listing client processes.
  262. Invoking @command{guix build}
  263. * Common Build Options:: Build options for most commands.
  264. * Package Transformation Options:: Creating variants of packages.
  265. * Additional Build Options:: Options specific to 'guix build'.
  266. * Debugging Build Failures:: Real life packaging experience.
  267. System Configuration
  268. * Using the Configuration System:: Customizing your GNU system.
  269. * operating-system Reference:: Detail of operating-system declarations.
  270. * File Systems:: Configuring file system mounts.
  271. * Mapped Devices:: Block device extra processing.
  272. * User Accounts:: Specifying user accounts.
  273. * Keyboard Layout:: How the system interprets key strokes.
  274. * Locales:: Language and cultural convention settings.
  275. * Services:: Specifying system services.
  276. * Setuid Programs:: Programs running with root privileges.
  277. * X.509 Certificates:: Authenticating HTTPS servers.
  278. * Name Service Switch:: Configuring libc's name service switch.
  279. * Initial RAM Disk:: Linux-Libre bootstrapping.
  280. * Bootloader Configuration:: Configuring the boot loader.
  281. * Invoking guix system:: Instantiating a system configuration.
  282. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  283. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  284. * Defining Services:: Adding new service definitions.
  285. Services
  286. * Base Services:: Essential system services.
  287. * Scheduled Job Execution:: The mcron service.
  288. * Log Rotation:: The rottlog service.
  289. * Networking Services:: Network setup, SSH daemon, etc.
  290. * Unattended Upgrades:: Automated system upgrades.
  291. * X Window:: Graphical display.
  292. * Printing Services:: Local and remote printer support.
  293. * Desktop Services:: D-Bus and desktop services.
  294. * Sound Services:: ALSA and Pulseaudio services.
  295. * Database Services:: SQL databases, key-value stores, etc.
  296. * Mail Services:: IMAP, POP3, SMTP, and all that.
  297. * Messaging Services:: Messaging services.
  298. * Telephony Services:: Telephony services.
  299. * Monitoring Services:: Monitoring services.
  300. * Kerberos Services:: Kerberos services.
  301. * LDAP Services:: LDAP services.
  302. * Web Services:: Web servers.
  303. * Certificate Services:: TLS certificates via Let's Encrypt.
  304. * DNS Services:: DNS daemons.
  305. * VPN Services:: VPN daemons.
  306. * Network File System:: NFS related services.
  307. * Continuous Integration:: Cuirass and Laminar services.
  308. * Power Management Services:: Extending battery life.
  309. * Audio Services:: The MPD.
  310. * Virtualization Services:: Virtualization services.
  311. * Version Control Services:: Providing remote access to Git repositories.
  312. * Game Services:: Game servers.
  313. * PAM Mount Service:: Service to mount volumes when logging in.
  314. * Guix Services:: Services relating specifically to Guix.
  315. * Linux Services:: Services tied to the Linux kernel.
  316. * Hurd Services:: Services specific for a Hurd System.
  317. * Miscellaneous Services:: Other services.
  318. Defining Services
  319. * Service Composition:: The model for composing services.
  320. * Service Types and Services:: Types and services.
  321. * Service Reference:: API reference.
  322. * Shepherd Services:: A particular type of service.
  323. Installing Debugging Files
  324. * Separate Debug Info:: Installing 'debug' outputs.
  325. * Rebuilding Debug Info:: Building missing debug info.
  326. Bootstrapping
  327. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  328. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  329. @end detailmenu
  330. @end menu
  331. @c *********************************************************************
  332. @node Introduction
  333. @chapter Introduction
  334. @cindex purpose
  335. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  336. using the international phonetic alphabet (IPA).} is a package
  337. management tool for and distribution of the GNU system.
  338. Guix makes it easy for unprivileged
  339. users to install, upgrade, or remove software packages, to roll back to a
  340. previous package set, to build packages from source, and generally
  341. assists with the creation and maintenance of software environments.
  342. @cindex Guix System
  343. @cindex GuixSD, now Guix System
  344. @cindex Guix System Distribution, now Guix System
  345. You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
  346. complements the available tools without interference (@pxref{Installation}),
  347. or you can use it as a standalone operating system distribution,
  348. @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
  349. System Distribution'' or ``GuixSD''. We now consider it makes more sense to
  350. group everything under the ``Guix'' banner since, after all, Guix System is
  351. readily available through the @command{guix system} command, even if you're
  352. using a different distro underneath!}. @xref{GNU Distribution}.
  353. @menu
  354. * Managing Software the Guix Way:: What's special.
  355. * GNU Distribution:: The packages and tools.
  356. @end menu
  357. @node Managing Software the Guix Way
  358. @section Managing Software the Guix Way
  359. @cindex user interfaces
  360. Guix provides a command-line package management interface
  361. (@pxref{Package Management}), tools to help with software development
  362. (@pxref{Development}), command-line utilities for more advanced usage
  363. (@pxref{Utilities}), as well as Scheme programming interfaces
  364. (@pxref{Programming Interface}).
  365. @cindex build daemon
  366. Its @dfn{build daemon} is responsible for building packages on behalf of
  367. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  368. binaries from authorized sources (@pxref{Substitutes}).
  369. @cindex extensibility of the distribution
  370. @cindex customization, of packages
  371. Guix includes package definitions for many GNU and non-GNU packages, all
  372. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  373. user's computing freedom}. It is @emph{extensible}: users can write
  374. their own package definitions (@pxref{Defining Packages}) and make them
  375. available as independent package modules (@pxref{Package Modules}). It
  376. is also @emph{customizable}: users can @emph{derive} specialized package
  377. definitions from existing ones, including from the command line
  378. (@pxref{Package Transformation Options}).
  379. @cindex functional package management
  380. @cindex isolation
  381. Under the hood, Guix implements the @dfn{functional package management}
  382. discipline pioneered by Nix (@pxref{Acknowledgments}).
  383. In Guix, the package build and installation process is seen
  384. as a @emph{function}, in the mathematical sense. That function takes inputs,
  385. such as build scripts, a compiler, and libraries, and
  386. returns an installed package. As a pure function, its result depends
  387. solely on its inputs---for instance, it cannot refer to software or
  388. scripts that were not explicitly passed as inputs. A build function
  389. always produces the same result when passed a given set of inputs. It
  390. cannot alter the environment of the running system in
  391. any way; for instance, it cannot create, modify, or delete files outside
  392. of its build and installation directories. This is achieved by running
  393. build processes in isolated environments (or @dfn{containers}), where only their
  394. explicit inputs are visible.
  395. @cindex store
  396. The result of package build functions is @dfn{cached} in the file
  397. system, in a special directory called @dfn{the store} (@pxref{The
  398. Store}). Each package is installed in a directory of its own in the
  399. store---by default under @file{/gnu/store}. The directory name contains
  400. a hash of all the inputs used to build that package; thus, changing an
  401. input yields a different directory name.
  402. This approach is the foundation for the salient features of Guix: support
  403. for transactional package upgrade and rollback, per-user installation, and
  404. garbage collection of packages (@pxref{Features}).
  405. @node GNU Distribution
  406. @section GNU Distribution
  407. @cindex Guix System
  408. Guix comes with a distribution of the GNU system consisting entirely of
  409. free software@footnote{The term ``free'' here refers to the
  410. @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
  411. users of that software}.}. The
  412. distribution can be installed on its own (@pxref{System Installation}),
  413. but it is also possible to install Guix as a package manager on top of
  414. an installed GNU/Linux system (@pxref{Installation}). When we need to
  415. distinguish between the two, we refer to the standalone distribution as
  416. Guix@tie{}System.
  417. The distribution provides core GNU packages such as GNU libc, GCC, and
  418. Binutils, as well as many GNU and non-GNU applications. The complete
  419. list of available packages can be browsed
  420. @url{https://www.gnu.org/software/guix/packages,on-line} or by
  421. running @command{guix package} (@pxref{Invoking guix package}):
  422. @example
  423. guix package --list-available
  424. @end example
  425. Our goal is to provide a practical 100% free software distribution of
  426. Linux-based and other variants of GNU, with a focus on the promotion and
  427. tight integration of GNU components, and an emphasis on programs and
  428. tools that help users exert that freedom.
  429. Packages are currently available on the following platforms:
  430. @table @code
  431. @item x86_64-linux
  432. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel.
  433. @item i686-linux
  434. Intel 32-bit architecture (IA32), Linux-Libre kernel.
  435. @item armhf-linux
  436. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  437. using the EABI hard-float application binary interface (ABI),
  438. and Linux-Libre kernel.
  439. @item aarch64-linux
  440. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
  441. @item i586-gnu
  442. @uref{https://hurd.gnu.org, GNU/Hurd} on the Intel 32-bit architecture
  443. (IA32).
  444. This configuration is experimental and under development. The easiest
  445. way for you to give it a try is by setting up an instance of
  446. @code{hurd-vm-service-type} on your GNU/Linux machine
  447. (@pxref{transparent-emulation-qemu, @code{hurd-vm-service-type}}).
  448. @xref{Contributing}, on how to help!
  449. @item mips64el-linux (deprecated)
  450. little-endian 64-bit MIPS processors, specifically the Loongson series,
  451. n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
  452. supported; in particular, there is no ongoing work to ensure that this
  453. architecture still works. Should someone decide they wish to revive this
  454. architecture then the code is still available.
  455. @item powerpc64le-linux
  456. little-endian 64-bit Power ISA processors, Linux-Libre kernel. This
  457. includes POWER9 systems such as the
  458. @uref{https://www.fsf.org/news/talos-ii-mainboard-and-talos-ii-lite-mainboard-now-fsf-certified-to-respect-your-freedom,
  459. RYF Talos II mainboard}. This platform is available as a "technology
  460. preview": although it is supported, substitutes are not yet available
  461. from the build farm (@pxref{Substitutes}), and some packages may fail to
  462. build (@pxref{Tracking Bugs and Patches}). That said, the Guix
  463. community is actively working on improving this support, and now is a
  464. great time to try it and get involved!
  465. @end table
  466. With Guix@tie{}System, you @emph{declare} all aspects of the operating system
  467. configuration and Guix takes care of instantiating the configuration in a
  468. transactional, reproducible, and stateless fashion (@pxref{System
  469. Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
  470. initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
  471. Manual}), the well-known GNU utilities and tool chain, as well as the
  472. graphical environment or system services of your choice.
  473. Guix System is available on all the above platforms except
  474. @code{mips64el-linux} and @code{powerpc64le-linux}.
  475. @noindent
  476. For information on porting to other architectures or kernels,
  477. @pxref{Porting}.
  478. Building this distribution is a cooperative effort, and you are invited
  479. to join! @xref{Contributing}, for information about how you can help.
  480. @c *********************************************************************
  481. @node Installation
  482. @chapter Installation
  483. @cindex installing Guix
  484. @quotation Note
  485. We recommend the use of this
  486. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  487. shell installer script} to install Guix on top of a running GNU/Linux system,
  488. thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
  489. with the installation of the package manager, which can be done on top of a
  490. running GNU/Linux system. If, instead, you want to install the complete GNU
  491. operating system, @pxref{System Installation}.} The script automates the
  492. download, installation, and initial configuration of Guix. It should be run
  493. as the root user.
  494. @end quotation
  495. @cindex foreign distro
  496. @cindex directories related to foreign distro
  497. When installed on a foreign distro, GNU@tie{}Guix complements the available
  498. tools without interference. Its data lives exclusively in two directories,
  499. usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
  500. such as @file{/etc}, are left untouched.
  501. Once installed, Guix can be updated by running @command{guix pull}
  502. (@pxref{Invoking guix pull}).
  503. If you prefer to perform the installation steps manually or want to tweak
  504. them, you may find the following subsections useful. They describe the
  505. software requirements of Guix, as well as how to install it manually and get
  506. ready to use it.
  507. @menu
  508. * Binary Installation:: Getting Guix running in no time!
  509. * Requirements:: Software needed to build and run Guix.
  510. * Running the Test Suite:: Testing Guix.
  511. * Setting Up the Daemon:: Preparing the build daemon's environment.
  512. * Invoking guix-daemon:: Running the build daemon.
  513. * Application Setup:: Application-specific setup.
  514. * Upgrading Guix:: Upgrading Guix and its build daemon.
  515. @end menu
  516. @node Binary Installation
  517. @section Binary Installation
  518. @cindex installing Guix from binaries
  519. @cindex installer script
  520. This section describes how to install Guix on an arbitrary system from a
  521. self-contained tarball providing binaries for Guix and for all its
  522. dependencies. This is often quicker than installing from source, which
  523. is described in the next sections. The only requirement is to have
  524. GNU@tie{}tar and Xz.
  525. @c Note duplicated from the ``Installation'' node.
  526. @quotation Note
  527. We recommend the use of this
  528. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  529. shell installer script}. The script automates the download, installation, and
  530. initial configuration steps described below. It should be run as the root
  531. user. As root, you can thus run this:
  532. @example
  533. cd /tmp
  534. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  535. chmod +x guix-install.sh
  536. ./guix-install.sh
  537. @end example
  538. When you're done, @pxref{Application Setup} for extra configuration you
  539. might need, and @ref{Getting Started} for your first steps!
  540. @end quotation
  541. Installing goes along these lines:
  542. @enumerate
  543. @item
  544. @cindex downloading Guix binary
  545. Download the binary tarball from
  546. @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
  547. where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
  548. @code{i686} (32-bits) machine already running the kernel Linux, and so on
  549. (@pxref{GNU Distribution}).
  550. @c The following is somewhat duplicated in ``System Installation''.
  551. Make sure to download the associated @file{.sig} file and to verify the
  552. authenticity of the tarball against it, along these lines:
  553. @example
  554. $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  555. $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  556. @end example
  557. If that command fails because you do not have the required public key,
  558. then run this command to import it:
  559. @example
  560. $ wget '@value{OPENPGP-SIGNING-KEY-URL}' \
  561. -qO - | gpg --import -
  562. @end example
  563. @noindent
  564. and rerun the @code{gpg --verify} command.
  565. Take note that a warning like ``This key is not certified with a trusted
  566. signature!'' is normal.
  567. @c end authentication part
  568. @item
  569. Now, you need to become the @code{root} user. Depending on your distribution,
  570. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  571. @example
  572. # cd /tmp
  573. # tar --warning=no-timestamp -xf \
  574. /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
  575. # mv var/guix /var/ && mv gnu /
  576. @end example
  577. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  578. The latter contains a ready-to-use profile for @code{root} (see next
  579. step).
  580. Do @emph{not} unpack the tarball on a working Guix system since that
  581. would overwrite its own essential files.
  582. The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  583. not emit warnings about ``implausibly old time stamps'' (such
  584. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  585. versions are fine).
  586. They stem from the fact that all the
  587. files in the archive have their modification time set to 1 (which
  588. means January 1st, 1970). This is done on purpose to make sure the
  589. archive content is independent of its creation time, thus making it
  590. reproducible.
  591. @item
  592. Make the profile available under @file{~root/.config/guix/current}, which is
  593. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  594. @example
  595. # mkdir -p ~root/.config/guix
  596. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  597. ~root/.config/guix/current
  598. @end example
  599. Source @file{etc/profile} to augment @env{PATH} and other relevant
  600. environment variables:
  601. @example
  602. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  603. source $GUIX_PROFILE/etc/profile
  604. @end example
  605. @item
  606. Create the group and user accounts for build users as explained below
  607. (@pxref{Build Environment Setup}).
  608. @item
  609. Run the daemon, and set it to automatically start on boot.
  610. If your host distro uses the systemd init system, this can be achieved
  611. with these commands:
  612. @c Versions of systemd that supported symlinked service files are not
  613. @c yet widely deployed, so we should suggest that users copy the service
  614. @c files into place.
  615. @c
  616. @c See this thread for more information:
  617. @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  618. @example
  619. # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  620. ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  621. /etc/systemd/system/
  622. # systemctl enable --now gnu-store.mount guix-daemon
  623. @end example
  624. If your host distro uses the Upstart init system:
  625. @example
  626. # initctl reload-configuration
  627. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  628. /etc/init/
  629. # start guix-daemon
  630. @end example
  631. Otherwise, you can still start the daemon manually with:
  632. @example
  633. # ~root/.config/guix/current/bin/guix-daemon \
  634. --build-users-group=guixbuild
  635. @end example
  636. @item
  637. Make the @command{guix} command available to other users on the machine,
  638. for instance with:
  639. @example
  640. # mkdir -p /usr/local/bin
  641. # cd /usr/local/bin
  642. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  643. @end example
  644. It is also a good idea to make the Info version of this manual available
  645. there:
  646. @example
  647. # mkdir -p /usr/local/share/info
  648. # cd /usr/local/share/info
  649. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  650. do ln -s $i ; done
  651. @end example
  652. That way, assuming @file{/usr/local/share/info} is in the search path,
  653. running @command{info guix} will open this manual (@pxref{Other Info
  654. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  655. Info search path).
  656. @item
  657. @cindex substitutes, authorization thereof
  658. To use substitutes from @code{@value{SUBSTITUTE-SERVER-1}},
  659. @code{@value{SUBSTITUTE-SERVER-2}} or a mirror (@pxref{Substitutes}),
  660. authorize them:
  661. @example
  662. # guix archive --authorize < \
  663. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
  664. # guix archive --authorize < \
  665. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
  666. @end example
  667. @quotation Note
  668. If you do not enable substitutes, Guix will end up building
  669. @emph{everything} from source on your machine, making each installation
  670. and upgrade very expensive. @xref{On Trusting Binaries}, for a
  671. discussion of reasons why one might want do disable substitutes.
  672. @end quotation
  673. @item
  674. Each user may need to perform a few additional steps to make their Guix
  675. environment ready for use, @pxref{Application Setup}.
  676. @end enumerate
  677. Voilà, the installation is complete!
  678. You can confirm that Guix is working by installing a sample package into
  679. the root profile:
  680. @example
  681. # guix install hello
  682. @end example
  683. The binary installation tarball can be (re)produced and verified simply
  684. by running the following command in the Guix source tree:
  685. @example
  686. make guix-binary.@var{system}.tar.xz
  687. @end example
  688. @noindent
  689. ...@: which, in turn, runs:
  690. @example
  691. guix pack -s @var{system} --localstatedir \
  692. --profile-name=current-guix guix
  693. @end example
  694. @xref{Invoking guix pack}, for more info on this handy tool.
  695. @node Requirements
  696. @section Requirements
  697. This section lists requirements when building Guix from source. The
  698. build procedure for Guix is the same as for other GNU software, and is
  699. not covered here. Please see the files @file{README} and @file{INSTALL}
  700. in the Guix source tree for additional details.
  701. @cindex official website
  702. GNU Guix is available for download from its website at
  703. @url{https://www.gnu.org/software/guix/}.
  704. GNU Guix depends on the following packages:
  705. @itemize
  706. @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x;
  707. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  708. 0.1.0 or later;
  709. @item
  710. @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
  711. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  712. Guile,, gnutls-guile, GnuTLS-Guile});
  713. @item
  714. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  715. or later;
  716. @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib},
  717. version 0.1.0 or later;
  718. @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
  719. @item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi};
  720. @item
  721. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.5.0
  722. or later;
  723. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
  724. 4.3.0 or later;
  725. @item @url{https://www.gnu.org/software/make/, GNU Make}.
  726. @end itemize
  727. The following dependencies are optional:
  728. @itemize
  729. @item
  730. @c Note: We need at least 0.13.0 for #:nodelay.
  731. Support for build offloading (@pxref{Daemon Offload Setup}) and
  732. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  733. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  734. version 0.13.0 or later.
  735. @item
  736. @uref{https://notabug.org/guile-zstd/guile-zstd, Guile-zstd}, for zstd
  737. compression and decompression in @command{guix publish} and for
  738. substitutes (@pxref{Invoking guix publish}).
  739. @item
  740. @uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for
  741. the @code{crate} importer (@pxref{Invoking guix import}).
  742. @item
  743. @uref{https://www.nongnu.org/guile-lib/doc/ref/htmlprag/, Guile-Lib} for
  744. the @code{go} importer (@pxref{Invoking guix import}) and for some of
  745. the ``updaters'' (@pxref{Invoking guix refresh}).
  746. @item
  747. When @url{http://www.bzip.org, libbz2} is available,
  748. @command{guix-daemon} can use it to compress build logs.
  749. @end itemize
  750. Unless @option{--disable-daemon} was passed to @command{configure}, the
  751. following packages are also needed:
  752. @itemize
  753. @item @url{https://gnupg.org/, GNU libgcrypt};
  754. @item @url{https://sqlite.org, SQLite 3};
  755. @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
  756. C++11 standard.
  757. @end itemize
  758. @cindex state directory
  759. When configuring Guix on a system that already has a Guix installation,
  760. be sure to specify the same state directory as the existing installation
  761. using the @option{--localstatedir} option of the @command{configure}
  762. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  763. GNU Coding Standards}). Usually, this @var{localstatedir} option is
  764. set to the value @file{/var}. The @command{configure} script protects
  765. against unintended misconfiguration of @var{localstatedir} so you do not
  766. inadvertently corrupt your store (@pxref{The Store}).
  767. @node Running the Test Suite
  768. @section Running the Test Suite
  769. @cindex test suite
  770. After a successful @command{configure} and @code{make} run, it is a good
  771. idea to run the test suite. It can help catch issues with the setup or
  772. environment, or bugs in Guix itself---and really, reporting test
  773. failures is a good way to help improve the software. To run the test
  774. suite, type:
  775. @example
  776. make check
  777. @end example
  778. Test cases can run in parallel: you can use the @code{-j} option of
  779. GNU@tie{}make to speed things up. The first run may take a few minutes
  780. on a recent machine; subsequent runs will be faster because the store
  781. that is created for test purposes will already have various things in
  782. cache.
  783. It is also possible to run a subset of the tests by defining the
  784. @code{TESTS} makefile variable as in this example:
  785. @example
  786. make check TESTS="tests/store.scm tests/cpio.scm"
  787. @end example
  788. By default, tests results are displayed at a file level. In order to
  789. see the details of every individual test cases, it is possible to define
  790. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  791. @example
  792. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  793. @end example
  794. The underlying SRFI 64 custom Automake test driver used for the 'check'
  795. test suite (located at @file{build-aux/test-driver.scm}) also allows
  796. selecting which test cases to run at a finer level, via its
  797. @option{--select} and @option{--exclude} options. Here's an example, to
  798. run all the test cases from the @file{tests/packages.scm} test file
  799. whose names start with ``transaction-upgrade-entry'':
  800. @example
  801. export SCM_LOG_DRIVER_FLAGS="--select=^transaction-upgrade-entry"
  802. make check TESTS="tests/packages.scm"
  803. @end example
  804. Those wishing to inspect the results of failed tests directly from the
  805. command line can add the @option{--errors-only=yes} option to the
  806. @code{SCM_LOG_DRIVER_FLAGS} makefile variable and set the @code{VERBOSE}
  807. Automake makefile variable, as in:
  808. @example
  809. make check SCM_LOG_DRIVER_FLAGS="--brief=no --errors-only=yes" VERBOSE=1
  810. @end example
  811. The @option{--show-duration=yes} option can be used to print the
  812. duration of the individual test cases, when used in combination with
  813. @option{--brief=no}:
  814. @example
  815. make check SCM_LOG_DRIVER_FLAGS="--brief=no --show-duration=yes"
  816. @end example
  817. @xref{Parallel Test Harness,,,automake,GNU Automake} for more
  818. information about the Automake Parallel Test Harness.
  819. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  820. @file{test-suite.log} file. Please specify the Guix version being used
  821. as well as version numbers of the dependencies (@pxref{Requirements}) in
  822. your message.
  823. Guix also comes with a whole-system test suite that tests complete
  824. Guix System instances. It can only run on systems where
  825. Guix is already installed, using:
  826. @example
  827. make check-system
  828. @end example
  829. @noindent
  830. or, again, by defining @code{TESTS} to select a subset of tests to run:
  831. @example
  832. make check-system TESTS="basic mcron"
  833. @end example
  834. These system tests are defined in the @code{(gnu tests @dots{})}
  835. modules. They work by running the operating systems under test with
  836. lightweight instrumentation in a virtual machine (VM). They can be
  837. computationally intensive or rather cheap, depending on whether
  838. substitutes are available for their dependencies (@pxref{Substitutes}).
  839. Some of them require a lot of storage space to hold VM images.
  840. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  841. all the details.
  842. @node Setting Up the Daemon
  843. @section Setting Up the Daemon
  844. @cindex daemon
  845. Operations such as building a package or running the garbage collector
  846. are all performed by a specialized process, the @dfn{build daemon}, on
  847. behalf of clients. Only the daemon may access the store and its
  848. associated database. Thus, any operation that manipulates the store
  849. goes through the daemon. For instance, command-line tools such as
  850. @command{guix package} and @command{guix build} communicate with the
  851. daemon (@i{via} remote procedure calls) to instruct it what to do.
  852. The following sections explain how to prepare the build daemon's
  853. environment. See also @ref{Substitutes}, for information on how to allow
  854. the daemon to download pre-built binaries.
  855. @menu
  856. * Build Environment Setup:: Preparing the isolated build environment.
  857. * Daemon Offload Setup:: Offloading builds to remote machines.
  858. * SELinux Support:: Using an SELinux policy for the daemon.
  859. @end menu
  860. @node Build Environment Setup
  861. @subsection Build Environment Setup
  862. @cindex build environment
  863. In a standard multi-user setup, Guix and its daemon---the
  864. @command{guix-daemon} program---are installed by the system
  865. administrator; @file{/gnu/store} is owned by @code{root} and
  866. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  867. Guix tools to build packages or otherwise access the store, and the
  868. daemon will do it on their behalf, ensuring that the store is kept in a
  869. consistent state, and allowing built packages to be shared among users.
  870. @cindex build users
  871. When @command{guix-daemon} runs as @code{root}, you may not want package
  872. build processes themselves to run as @code{root} too, for obvious
  873. security reasons. To avoid that, a special pool of @dfn{build users}
  874. should be created for use by build processes started by the daemon.
  875. These build users need not have a shell and a home directory: they will
  876. just be used when the daemon drops @code{root} privileges in build
  877. processes. Having several such users allows the daemon to launch
  878. distinct build processes under separate UIDs, which guarantees that they
  879. do not interfere with each other---an essential feature since builds are
  880. regarded as pure functions (@pxref{Introduction}).
  881. On a GNU/Linux system, a build user pool may be created like this (using
  882. Bash syntax and the @code{shadow} commands):
  883. @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  884. @c for why `-G' is needed.
  885. @example
  886. # groupadd --system guixbuild
  887. # for i in $(seq -w 1 10);
  888. do
  889. useradd -g guixbuild -G guixbuild \
  890. -d /var/empty -s $(which nologin) \
  891. -c "Guix build user $i" --system \
  892. guixbuilder$i;
  893. done
  894. @end example
  895. @noindent
  896. The number of build users determines how many build jobs may run in
  897. parallel, as specified by the @option{--max-jobs} option
  898. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  899. @command{guix system vm} and related commands, you may need to add the
  900. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  901. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  902. (@pxref{Invoking guix system}).
  903. The @code{guix-daemon} program may then be run as @code{root} with the
  904. following command@footnote{If your machine uses the systemd init system,
  905. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  906. file in @file{/etc/systemd/system} will ensure that
  907. @command{guix-daemon} is automatically started. Similarly, if your
  908. machine uses the Upstart init system, drop the
  909. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  910. file in @file{/etc/init}.}:
  911. @example
  912. # guix-daemon --build-users-group=guixbuild
  913. @end example
  914. @cindex chroot
  915. @noindent
  916. This way, the daemon starts build processes in a chroot, under one of
  917. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  918. environment contains nothing but:
  919. @c Keep this list in sync with libstore/build.cc! -----------------------
  920. @itemize
  921. @item
  922. a minimal @code{/dev} directory, created mostly independently from the
  923. host @code{/dev}@footnote{``Mostly'', because while the set of files
  924. that appear in the chroot's @code{/dev} is fixed, most of these files
  925. can only be created if the host has them.};
  926. @item
  927. the @code{/proc} directory; it only shows the processes of the container
  928. since a separate PID name space is used;
  929. @item
  930. @file{/etc/passwd} with an entry for the current user and an entry for
  931. user @file{nobody};
  932. @item
  933. @file{/etc/group} with an entry for the user's group;
  934. @item
  935. @file{/etc/hosts} with an entry that maps @code{localhost} to
  936. @code{127.0.0.1};
  937. @item
  938. a writable @file{/tmp} directory.
  939. @end itemize
  940. You can influence the directory where the daemon stores build trees
  941. @i{via} the @env{TMPDIR} environment variable. However, the build tree
  942. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  943. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  944. This way, the value of @env{TMPDIR} does not leak inside build
  945. environments, which avoids discrepancies in cases where build processes
  946. capture the name of their build tree.
  947. @vindex http_proxy
  948. @vindex https_proxy
  949. The daemon also honors the @env{http_proxy} and @env{https_proxy}
  950. environment variables for HTTP and HTTPS downloads it performs, be it
  951. for fixed-output derivations (@pxref{Derivations}) or for substitutes
  952. (@pxref{Substitutes}).
  953. If you are installing Guix as an unprivileged user, it is still possible
  954. to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
  955. However, build processes will not be isolated from one another, and not
  956. from the rest of the system. Thus, build processes may interfere with
  957. each other, and may access programs, libraries, and other files
  958. available on the system---making it much harder to view them as
  959. @emph{pure} functions.
  960. @node Daemon Offload Setup
  961. @subsection Using the Offload Facility
  962. @cindex offloading
  963. @cindex build hook
  964. When desired, the build daemon can @dfn{offload} derivation builds to
  965. other machines running Guix, using the @code{offload} @dfn{build
  966. hook}@footnote{This feature is available only when
  967. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  968. present.}. When that feature is enabled, a list of user-specified build
  969. machines is read from @file{/etc/guix/machines.scm}; every time a build
  970. is requested, for instance via @code{guix build}, the daemon attempts to
  971. offload it to one of the machines that satisfy the constraints of the
  972. derivation, in particular its system types---e.g., @code{x86_64-linux}.
  973. A single machine can have multiple system types, either because its
  974. architecture natively supports it, via emulation
  975. (@pxref{transparent-emulation-qemu, Transparent Emulation with QEMU}),
  976. or both. Missing prerequisites for the build are
  977. copied over SSH to the target machine, which then proceeds with the
  978. build; upon success the output(s) of the build are copied back to the
  979. initial machine. The offload facility comes with a basic scheduler that
  980. attempts to select the best machine. The best machine is chosen among
  981. the available machines based on criteria such as:
  982. @enumerate
  983. @item
  984. The availability of a build slot. A build machine can have as many
  985. build slots (connections) as the value of the @code{parallel-builds}
  986. field of its @code{build-machine} object.
  987. @item
  988. Its relative speed, as defined via the @code{speed} field of its
  989. @code{build-machine} object.
  990. @item
  991. Its load. The normalized machine load must be lower than a threshold
  992. value, configurable via the @code{overload-threshold} field of its
  993. @code{build-machine} object.
  994. @item
  995. Disk space availability. More than a 100 MiB must be available.
  996. @end enumerate
  997. The @file{/etc/guix/machines.scm} file typically looks like this:
  998. @lisp
  999. (list (build-machine
  1000. (name "eightysix.example.org")
  1001. (systems (list "x86_64-linux" "i686-linux"))
  1002. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  1003. (user "bob")
  1004. (speed 2.)) ;incredibly fast!
  1005. (build-machine
  1006. (name "armeight.example.org")
  1007. (systems (list "aarch64-linux"))
  1008. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  1009. (user "alice")
  1010. (private-key
  1011. (string-append (getenv "HOME")
  1012. "/.ssh/identity-for-guix"))))
  1013. @end lisp
  1014. @noindent
  1015. In the example above we specify a list of two build machines, one for
  1016. the @code{x86_64} and @code{i686} architectures and one for the
  1017. @code{aarch64} architecture.
  1018. In fact, this file is---not surprisingly!---a Scheme file that is
  1019. evaluated when the @code{offload} hook is started. Its return value
  1020. must be a list of @code{build-machine} objects. While this example
  1021. shows a fixed list of build machines, one could imagine, say, using
  1022. DNS-SD to return a list of potential build machines discovered in the
  1023. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  1024. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  1025. detailed below.
  1026. @deftp {Data Type} build-machine
  1027. This data type represents build machines to which the daemon may offload
  1028. builds. The important fields are:
  1029. @table @code
  1030. @item name
  1031. The host name of the remote machine.
  1032. @item systems
  1033. The system types the remote machine supports---e.g., @code{(list
  1034. "x86_64-linux" "i686-linux")}.
  1035. @item user
  1036. The user account to use when connecting to the remote machine over SSH.
  1037. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  1038. allow non-interactive logins.
  1039. @item host-key
  1040. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  1041. This is used to authenticate the machine when we connect to it. It is a
  1042. long string that looks like this:
  1043. @example
  1044. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  1045. @end example
  1046. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  1047. key can be found in a file such as
  1048. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  1049. If the machine is running the SSH daemon of GNU@tie{}lsh,
  1050. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  1051. similar file. It can be converted to the OpenSSH format using
  1052. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  1053. @example
  1054. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  1055. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  1056. @end example
  1057. @end table
  1058. A number of optional fields may be specified:
  1059. @table @asis
  1060. @item @code{port} (default: @code{22})
  1061. Port number of SSH server on the machine.
  1062. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  1063. The SSH private key file to use when connecting to the machine, in
  1064. OpenSSH format. This key must not be protected with a passphrase.
  1065. Note that the default value is the private key @emph{of the root
  1066. account}. Make sure it exists if you use the default.
  1067. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  1068. @itemx @code{compression-level} (default: @code{3})
  1069. The SSH-level compression methods and compression level requested.
  1070. Note that offloading relies on SSH compression to reduce bandwidth usage
  1071. when transferring files to and from build machines.
  1072. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  1073. File name of the Unix-domain socket @command{guix-daemon} is listening
  1074. to on that machine.
  1075. @item @code{overload-threshold} (default: @code{0.6})
  1076. The load threshold above which a potential offload machine is
  1077. disregarded by the offload scheduler. The value roughly translates to
  1078. the total processor usage of the build machine, ranging from 0.0 (0%) to
  1079. 1.0 (100%). It can also be disabled by setting
  1080. @code{overload-threshold} to @code{#f}.
  1081. @item @code{parallel-builds} (default: @code{1})
  1082. The number of builds that may run in parallel on the machine.
  1083. @item @code{speed} (default: @code{1.0})
  1084. A ``relative speed factor''. The offload scheduler will tend to prefer
  1085. machines with a higher speed factor.
  1086. @item @code{features} (default: @code{'()})
  1087. A list of strings denoting specific features supported by the machine.
  1088. An example is @code{"kvm"} for machines that have the KVM Linux modules
  1089. and corresponding hardware support. Derivations can request features by
  1090. name, and they will be scheduled on matching build machines.
  1091. @end table
  1092. @end deftp
  1093. The @command{guix} command must be in the search path on the build
  1094. machines. You can check whether this is the case by running:
  1095. @example
  1096. ssh build-machine guix repl --version
  1097. @end example
  1098. There is one last thing to do once @file{machines.scm} is in place. As
  1099. explained above, when offloading, files are transferred back and forth
  1100. between the machine stores. For this to work, you first need to
  1101. generate a key pair on each machine to allow the daemon to export signed
  1102. archives of files from the store (@pxref{Invoking guix archive}):
  1103. @example
  1104. # guix archive --generate-key
  1105. @end example
  1106. @noindent
  1107. Each build machine must authorize the key of the master machine so that
  1108. it accepts store items it receives from the master:
  1109. @example
  1110. # guix archive --authorize < master-public-key.txt
  1111. @end example
  1112. @noindent
  1113. Likewise, the master machine must authorize the key of each build machine.
  1114. All the fuss with keys is here to express pairwise mutual trust
  1115. relations between the master and the build machines. Concretely, when
  1116. the master receives files from a build machine (and @i{vice versa}), its
  1117. build daemon can make sure they are genuine, have not been tampered
  1118. with, and that they are signed by an authorized key.
  1119. @cindex offload test
  1120. To test whether your setup is operational, run this command on the
  1121. master node:
  1122. @example
  1123. # guix offload test
  1124. @end example
  1125. This will attempt to connect to each of the build machines specified in
  1126. @file{/etc/guix/machines.scm}, make sure Guix is
  1127. available on each machine, attempt to export to the machine and import
  1128. from it, and report any error in the process.
  1129. If you want to test a different machine file, just specify it on the
  1130. command line:
  1131. @example
  1132. # guix offload test machines-qualif.scm
  1133. @end example
  1134. Last, you can test the subset of the machines whose name matches a
  1135. regular expression like this:
  1136. @example
  1137. # guix offload test machines.scm '\.gnu\.org$'
  1138. @end example
  1139. @cindex offload status
  1140. To display the current load of all build hosts, run this command on the
  1141. main node:
  1142. @example
  1143. # guix offload status
  1144. @end example
  1145. @node SELinux Support
  1146. @subsection SELinux Support
  1147. @cindex SELinux, daemon policy
  1148. @cindex mandatory access control, SELinux
  1149. @cindex security, guix-daemon
  1150. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  1151. can be installed on a system where SELinux is enabled, in order to label
  1152. Guix files and to specify the expected behavior of the daemon. Since
  1153. Guix System does not provide an SELinux base policy, the daemon policy cannot
  1154. be used on Guix System.
  1155. @subsubsection Installing the SELinux policy
  1156. @cindex SELinux, policy installation
  1157. To install the policy run this command as root:
  1158. @example
  1159. semodule -i etc/guix-daemon.cil
  1160. @end example
  1161. Then relabel the file system with @code{restorecon} or by a different
  1162. mechanism provided by your system.
  1163. Once the policy is installed, the file system has been relabeled, and
  1164. the daemon has been restarted, it should be running in the
  1165. @code{guix_daemon_t} context. You can confirm this with the following
  1166. command:
  1167. @example
  1168. ps -Zax | grep guix-daemon
  1169. @end example
  1170. Monitor the SELinux log files as you run a command like @code{guix build
  1171. hello} to convince yourself that SELinux permits all necessary
  1172. operations.
  1173. @subsubsection Limitations
  1174. @cindex SELinux, limitations
  1175. This policy is not perfect. Here is a list of limitations or quirks
  1176. that should be considered when deploying the provided SELinux policy for
  1177. the Guix daemon.
  1178. @enumerate
  1179. @item
  1180. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  1181. operations involve contexts that have anything to do with
  1182. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  1183. but it would be preferable to define socket rules for only this label.
  1184. @item
  1185. @code{guix gc} cannot access arbitrary links to profiles. By design,
  1186. the file label of the destination of a symlink is independent of the
  1187. file label of the link itself. Although all profiles under
  1188. $localstatedir are labelled, the links to these profiles inherit the
  1189. label of the directory they are in. For links in the user’s home
  1190. directory this will be @code{user_home_t}. But for links from the root
  1191. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  1192. directory, etc, this won’t work. @code{guix gc} would be prevented from
  1193. reading and following these links.
  1194. @item
  1195. The daemon’s feature to listen for TCP connections might no longer work.
  1196. This might require extra rules, because SELinux treats network sockets
  1197. differently from files.
  1198. @item
  1199. Currently all files with a name matching the regular expression
  1200. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  1201. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  1202. that name in any profile would be permitted to run in the
  1203. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  1204. build a package that provides this executable and convince a user to
  1205. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  1206. At that point SELinux could not prevent it from accessing files that are
  1207. allowed for processes in that domain.
  1208. You will need to relabel the store directory after all upgrades to
  1209. @file{guix-daemon}, such as after running @code{guix pull}. Assuming the
  1210. store is in @file{/gnu}, you can do this with @code{restorecon -vR /gnu},
  1211. or by other means provided by your operating system.
  1212. We could generate a much more restrictive policy at installation time,
  1213. so that only the @emph{exact} file name of the currently installed
  1214. @code{guix-daemon} executable would be labelled with
  1215. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  1216. The downside is that root would have to install or upgrade the policy at
  1217. installation time whenever the Guix package that provides the
  1218. effectively running @code{guix-daemon} executable is upgraded.
  1219. @end enumerate
  1220. @node Invoking guix-daemon
  1221. @section Invoking @command{guix-daemon}
  1222. The @command{guix-daemon} program implements all the functionality to
  1223. access the store. This includes launching build processes, running the
  1224. garbage collector, querying the availability of a build result, etc. It
  1225. is normally run as @code{root} like this:
  1226. @example
  1227. # guix-daemon --build-users-group=guixbuild
  1228. @end example
  1229. @noindent
  1230. For details on how to set it up, @pxref{Setting Up the Daemon}.
  1231. @cindex chroot
  1232. @cindex container, build environment
  1233. @cindex build environment
  1234. @cindex reproducible builds
  1235. By default, @command{guix-daemon} launches build processes under
  1236. different UIDs, taken from the build group specified with
  1237. @option{--build-users-group}. In addition, each build process is run in a
  1238. chroot environment that only contains the subset of the store that the
  1239. build process depends on, as specified by its derivation
  1240. (@pxref{Programming Interface, derivation}), plus a set of specific
  1241. system directories. By default, the latter contains @file{/dev} and
  1242. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1243. @dfn{container}: in addition to having its own file system tree, it has
  1244. a separate mount name space, its own PID name space, network name space,
  1245. etc. This helps achieve reproducible builds (@pxref{Features}).
  1246. When the daemon performs a build on behalf of the user, it creates a
  1247. build directory under @file{/tmp} or under the directory specified by
  1248. its @env{TMPDIR} environment variable. This directory is shared with
  1249. the container for the duration of the build, though within the container,
  1250. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1251. The build directory is automatically deleted upon completion, unless the
  1252. build failed and the client specified @option{--keep-failed}
  1253. (@pxref{Common Build Options, @option{--keep-failed}}).
  1254. The daemon listens for connections and spawns one sub-process for each session
  1255. started by a client (one of the @command{guix} sub-commands). The
  1256. @command{guix processes} command allows you to get an overview of the activity
  1257. on your system by viewing each of the active sessions and clients.
  1258. @xref{Invoking guix processes}, for more information.
  1259. The following command-line options are supported:
  1260. @table @code
  1261. @item --build-users-group=@var{group}
  1262. Take users from @var{group} to run build processes (@pxref{Setting Up
  1263. the Daemon, build users}).
  1264. @item --no-substitutes
  1265. @cindex substitutes
  1266. Do not use substitutes for build products. That is, always build things
  1267. locally instead of allowing downloads of pre-built binaries
  1268. (@pxref{Substitutes}).
  1269. When the daemon runs with @option{--no-substitutes}, clients can still
  1270. explicitly enable substitution @i{via} the @code{set-build-options}
  1271. remote procedure call (@pxref{The Store}).
  1272. @anchor{daemon-substitute-urls}
  1273. @item --substitute-urls=@var{urls}
  1274. Consider @var{urls} the default whitespace-separated list of substitute
  1275. source URLs. When this option is omitted,
  1276. @indicateurl{@value{SUBSTITUTE-URLS}} is used.
  1277. This means that substitutes may be downloaded from @var{urls}, as long
  1278. as they are signed by a trusted signature (@pxref{Substitutes}).
  1279. @xref{Getting Substitutes from Other Servers}, for more information on
  1280. how to configure the daemon to get substitutes from other servers.
  1281. @cindex offloading
  1282. @item --no-offload
  1283. Do not use offload builds to other machines (@pxref{Daemon Offload
  1284. Setup}). That is, always build things locally instead of offloading
  1285. builds to remote machines.
  1286. @item --cache-failures
  1287. Cache build failures. By default, only successful builds are cached.
  1288. When this option is used, @command{guix gc --list-failures} can be used
  1289. to query the set of store items marked as failed; @command{guix gc
  1290. --clear-failures} removes store items from the set of cached failures.
  1291. @xref{Invoking guix gc}.
  1292. @item --cores=@var{n}
  1293. @itemx -c @var{n}
  1294. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1295. as available.
  1296. The default value is @code{0}, but it may be overridden by clients, such
  1297. as the @option{--cores} option of @command{guix build} (@pxref{Invoking
  1298. guix build}).
  1299. The effect is to define the @env{NIX_BUILD_CORES} environment variable
  1300. in the build process, which can then use it to exploit internal
  1301. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1302. @item --max-jobs=@var{n}
  1303. @itemx -M @var{n}
  1304. Allow at most @var{n} build jobs in parallel. The default value is
  1305. @code{1}. Setting it to @code{0} means that no builds will be performed
  1306. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1307. Setup}), or simply fail.
  1308. @item --max-silent-time=@var{seconds}
  1309. When the build or substitution process remains silent for more than
  1310. @var{seconds}, terminate it and report a build failure.
  1311. The default value is @code{0}, which disables the timeout.
  1312. The value specified here can be overridden by clients (@pxref{Common
  1313. Build Options, @option{--max-silent-time}}).
  1314. @item --timeout=@var{seconds}
  1315. Likewise, when the build or substitution process lasts for more than
  1316. @var{seconds}, terminate it and report a build failure.
  1317. The default value is @code{0}, which disables the timeout.
  1318. The value specified here can be overridden by clients (@pxref{Common
  1319. Build Options, @option{--timeout}}).
  1320. @item --rounds=@var{N}
  1321. Build each derivation @var{n} times in a row, and raise an error if
  1322. consecutive build results are not bit-for-bit identical. Note that this
  1323. setting can be overridden by clients such as @command{guix build}
  1324. (@pxref{Invoking guix build}).
  1325. When used in conjunction with @option{--keep-failed}, the differing
  1326. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1327. This makes it easy to look for differences between the two results.
  1328. @item --debug
  1329. Produce debugging output.
  1330. This is useful to debug daemon start-up issues, but then it may be
  1331. overridden by clients, for example the @option{--verbosity} option of
  1332. @command{guix build} (@pxref{Invoking guix build}).
  1333. @item --chroot-directory=@var{dir}
  1334. Add @var{dir} to the build chroot.
  1335. Doing this may change the result of build processes---for instance if
  1336. they use optional dependencies found in @var{dir} when it is available,
  1337. and not otherwise. For that reason, it is not recommended to do so.
  1338. Instead, make sure that each derivation declares all the inputs that it
  1339. needs.
  1340. @item --disable-chroot
  1341. Disable chroot builds.
  1342. Using this option is not recommended since, again, it would allow build
  1343. processes to gain access to undeclared dependencies. It is necessary,
  1344. though, when @command{guix-daemon} is running under an unprivileged user
  1345. account.
  1346. @item --log-compression=@var{type}
  1347. Compress build logs according to @var{type}, one of @code{gzip},
  1348. @code{bzip2}, or @code{none}.
  1349. Unless @option{--lose-logs} is used, all the build logs are kept in the
  1350. @var{localstatedir}. To save space, the daemon automatically compresses
  1351. them with Bzip2 by default.
  1352. @item --discover[=yes|no]
  1353. Whether to discover substitute servers on the local network using mDNS
  1354. and DNS-SD.
  1355. This feature is still experimental. However, here are a few
  1356. considerations.
  1357. @enumerate
  1358. @item
  1359. It might be faster/less expensive than fetching from remote servers;
  1360. @item
  1361. There are no security risks, only genuine substitutes will be used
  1362. (@pxref{Substitute Authentication});
  1363. @item
  1364. An attacker advertising @command{guix publish} on your LAN cannot serve
  1365. you malicious binaries, but they can learn what software you’re
  1366. installing;
  1367. @item
  1368. Servers may serve substitute over HTTP, unencrypted, so anyone on the
  1369. LAN can see what software you’re installing.
  1370. @end enumerate
  1371. It is also possible to enable or disable substitute server discovery at
  1372. run-time by running:
  1373. @example
  1374. herd discover guix-daemon on
  1375. herd discover guix-daemon off
  1376. @end example
  1377. @item --disable-deduplication
  1378. @cindex deduplication
  1379. Disable automatic file ``deduplication'' in the store.
  1380. By default, files added to the store are automatically ``deduplicated'':
  1381. if a newly added file is identical to another one found in the store,
  1382. the daemon makes the new file a hard link to the other file. This can
  1383. noticeably reduce disk usage, at the expense of slightly increased
  1384. input/output load at the end of a build process. This option disables
  1385. this optimization.
  1386. @item --gc-keep-outputs[=yes|no]
  1387. Tell whether the garbage collector (GC) must keep outputs of live
  1388. derivations.
  1389. @cindex GC roots
  1390. @cindex garbage collector roots
  1391. When set to @code{yes}, the GC will keep the outputs of any live
  1392. derivation available in the store---the @file{.drv} files. The default
  1393. is @code{no}, meaning that derivation outputs are kept only if they are
  1394. reachable from a GC root. @xref{Invoking guix gc}, for more on GC
  1395. roots.
  1396. @item --gc-keep-derivations[=yes|no]
  1397. Tell whether the garbage collector (GC) must keep derivations
  1398. corresponding to live outputs.
  1399. When set to @code{yes}, as is the case by default, the GC keeps
  1400. derivations---i.e., @file{.drv} files---as long as at least one of their
  1401. outputs is live. This allows users to keep track of the origins of
  1402. items in their store. Setting it to @code{no} saves a bit of disk
  1403. space.
  1404. In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
  1405. liveness to flow from outputs to derivations, and setting
  1406. @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
  1407. derivations to outputs. When both are set to @code{yes}, the effect is
  1408. to keep all the build prerequisites (the sources, compiler, libraries,
  1409. and other build-time tools) of live objects in the store, regardless of
  1410. whether these prerequisites are reachable from a GC root. This is
  1411. convenient for developers since it saves rebuilds or downloads.
  1412. @item --impersonate-linux-2.6
  1413. On Linux-based systems, impersonate Linux 2.6. This means that the
  1414. kernel's @command{uname} system call will report 2.6 as the release number.
  1415. This might be helpful to build programs that (usually wrongfully) depend
  1416. on the kernel version number.
  1417. @item --lose-logs
  1418. Do not keep build logs. By default they are kept under
  1419. @file{@var{localstatedir}/guix/log}.
  1420. @item --system=@var{system}
  1421. Assume @var{system} as the current system type. By default it is the
  1422. architecture/kernel pair found at configure time, such as
  1423. @code{x86_64-linux}.
  1424. @item --listen=@var{endpoint}
  1425. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1426. as the file name of a Unix-domain socket if it starts with
  1427. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1428. host name or host name and port to listen to. Here are a few examples:
  1429. @table @code
  1430. @item --listen=/gnu/var/daemon
  1431. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1432. creating it if needed.
  1433. @item --listen=localhost
  1434. @cindex daemon, remote access
  1435. @cindex remote access to the daemon
  1436. @cindex daemon, cluster setup
  1437. @cindex clusters, daemon setup
  1438. Listen for TCP connections on the network interface corresponding to
  1439. @code{localhost}, on port 44146.
  1440. @item --listen=128.0.0.42:1234
  1441. Listen for TCP connections on the network interface corresponding to
  1442. @code{128.0.0.42}, on port 1234.
  1443. @end table
  1444. This option can be repeated multiple times, in which case
  1445. @command{guix-daemon} accepts connections on all the specified
  1446. endpoints. Users can tell client commands what endpoint to connect to
  1447. by setting the @env{GUIX_DAEMON_SOCKET} environment variable
  1448. (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
  1449. @quotation Note
  1450. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1451. @option{--listen=@var{host}} is suitable on local networks, such as
  1452. clusters, where only trusted nodes may connect to the build daemon. In
  1453. other cases where remote access to the daemon is needed, we recommend
  1454. using Unix-domain sockets along with SSH.
  1455. @end quotation
  1456. When @option{--listen} is omitted, @command{guix-daemon} listens for
  1457. connections on the Unix-domain socket located at
  1458. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1459. @end table
  1460. @node Application Setup
  1461. @section Application Setup
  1462. @cindex foreign distro
  1463. When using Guix on top of GNU/Linux distribution other than Guix System---a
  1464. so-called @dfn{foreign distro}---a few additional steps are needed to
  1465. get everything in place. Here are some of them.
  1466. @subsection Locales
  1467. @anchor{locales-and-locpath}
  1468. @cindex locales, when not on Guix System
  1469. @vindex LOCPATH
  1470. @vindex GUIX_LOCPATH
  1471. Packages installed @i{via} Guix will not use the locale data of the
  1472. host system. Instead, you must first install one of the locale packages
  1473. available with Guix and then define the @env{GUIX_LOCPATH} environment
  1474. variable:
  1475. @example
  1476. $ guix install glibc-locales
  1477. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1478. @end example
  1479. Note that the @code{glibc-locales} package contains data for all the
  1480. locales supported by the GNU@tie{}libc and weighs in at around
  1481. 917@tie{}MiB@. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1482. limited to a few UTF-8 locales.
  1483. The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
  1484. (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
  1485. Manual}). There are two important differences though:
  1486. @enumerate
  1487. @item
  1488. @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1489. provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
  1490. to make sure the programs of the foreign distro will not end up loading
  1491. incompatible locale data.
  1492. @item
  1493. libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
  1494. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1495. should your Guix profile contain a mixture of programs linked against
  1496. different libc version, each libc version will only try to load locale
  1497. data in the right format.
  1498. @end enumerate
  1499. This is important because the locale data format used by different libc
  1500. versions may be incompatible.
  1501. @subsection Name Service Switch
  1502. @cindex name service switch, glibc
  1503. @cindex NSS (name service switch), glibc
  1504. @cindex nscd (name service caching daemon)
  1505. @cindex name service caching daemon (nscd)
  1506. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1507. the system run the GNU C library's @dfn{name service cache daemon},
  1508. @command{nscd}, which should be listening on the
  1509. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1510. installed with Guix may fail to look up host names or user accounts, or
  1511. may even crash. The next paragraphs explain why.
  1512. @cindex @file{nsswitch.conf}
  1513. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1514. an extensible mechanism for ``name lookups'' in general: host name
  1515. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1516. The GNU C Library Reference Manual}).
  1517. @cindex Network information service (NIS)
  1518. @cindex NIS (Network information service)
  1519. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1520. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1521. resolution of @code{.local} host names, the @code{nis} plugin allows
  1522. user account lookup using the Network information service (NIS), and so
  1523. on. These extra ``lookup services'' are configured system-wide in
  1524. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1525. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1526. Reference Manual}).
  1527. When they perform a name lookup---for instance by calling the
  1528. @code{getaddrinfo} function in C---applications first try to connect to
  1529. the nscd; on success, nscd performs name lookups on their behalf. If
  1530. the nscd is not running, then they perform the name lookup by
  1531. themselves, by loading the name lookup services into their own address
  1532. space and running it. These name lookup services---the
  1533. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1534. the host system's C library, rather than from the C library the
  1535. application is linked against (the C library coming from Guix).
  1536. And this is where the problem is: if your application is linked against
  1537. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1538. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1539. likely crash or have its name lookups fail unexpectedly.
  1540. Running @command{nscd} on the system, among other advantages, eliminates
  1541. this binary incompatibility problem because those @code{libnss_*.so}
  1542. files are loaded in the @command{nscd} process, not in applications
  1543. themselves.
  1544. @subsection X11 Fonts
  1545. @cindex fonts
  1546. The majority of graphical applications use Fontconfig to locate and load
  1547. fonts and perform X11-client-side rendering. The @code{fontconfig}
  1548. package in Guix looks for fonts in @file{$HOME/.guix-profile} by
  1549. default. Thus, to allow graphical applications installed with Guix to
  1550. display fonts, you have to install fonts with Guix as well. Essential
  1551. font packages include @code{font-ghostscript}, @code{font-dejavu}, and
  1552. @code{font-gnu-freefont}.
  1553. @cindex @code{fc-cache}
  1554. @cindex font cache
  1555. Once you have installed or removed fonts, or when you notice an
  1556. application that does not find fonts, you may need to install Fontconfig
  1557. and to force an update of its font cache by running:
  1558. @example
  1559. guix install fontconfig
  1560. fc-cache -rv
  1561. @end example
  1562. To display text written in Chinese languages, Japanese, or Korean in
  1563. graphical applications, consider installing
  1564. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1565. has multiple outputs, one per language family (@pxref{Packages with
  1566. Multiple Outputs}). For instance, the following command installs fonts
  1567. for Chinese languages:
  1568. @example
  1569. guix install font-adobe-source-han-sans:cn
  1570. @end example
  1571. @cindex @code{xterm}
  1572. Older programs such as @command{xterm} do not use Fontconfig and instead
  1573. rely on server-side font rendering. Such programs require to specify a
  1574. full name of a font using XLFD (X Logical Font Description), like this:
  1575. @example
  1576. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1577. @end example
  1578. To be able to use such full names for the TrueType fonts installed in
  1579. your Guix profile, you need to extend the font path of the X server:
  1580. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1581. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1582. @example
  1583. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1584. @end example
  1585. @cindex @code{xlsfonts}
  1586. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1587. to make sure your TrueType fonts are listed there.
  1588. @subsection X.509 Certificates
  1589. @cindex @code{nss-certs}
  1590. The @code{nss-certs} package provides X.509 certificates, which allow
  1591. programs to authenticate Web servers accessed over HTTPS.
  1592. When using Guix on a foreign distro, you can install this package and
  1593. define the relevant environment variables so that packages know where to
  1594. look for certificates. @xref{X.509 Certificates}, for detailed
  1595. information.
  1596. @subsection Emacs Packages
  1597. @cindex @code{emacs}
  1598. When you install Emacs packages with Guix, the Elisp files are placed
  1599. under the @file{share/emacs/site-lisp/} directory of the profile in
  1600. which they are installed. The Elisp libraries are made available to
  1601. Emacs through the @env{EMACSLOADPATH} environment variable, which is
  1602. set when installing Emacs itself.
  1603. Additionally, autoload definitions are automatically evaluated at the
  1604. initialization of Emacs, by the Guix-specific
  1605. @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
  1606. want to avoid auto-loading the Emacs packages installed with Guix, you
  1607. can do so by running Emacs with the @option{--no-site-file} option
  1608. (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1609. @node Upgrading Guix
  1610. @section Upgrading Guix
  1611. @cindex Upgrading Guix, on a foreign distro
  1612. To upgrade Guix, run:
  1613. @example
  1614. guix pull
  1615. @end example
  1616. @xref{Invoking guix pull}, for more information.
  1617. @cindex upgrading Guix for the root user, on a foreign distro
  1618. @cindex upgrading the Guix daemon, on a foreign distro
  1619. @cindex @command{guix pull} for the root user, on a foreign distro
  1620. On a foreign distro, you can upgrade the build daemon by running:
  1621. @example
  1622. sudo -i guix pull
  1623. @end example
  1624. @noindent
  1625. followed by (assuming your distro uses the systemd service management
  1626. tool):
  1627. @example
  1628. systemctl restart guix-daemon.service
  1629. @end example
  1630. On Guix System, upgrading the daemon is achieved by reconfiguring the
  1631. system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
  1632. @c TODO What else?
  1633. @c *********************************************************************
  1634. @node System Installation
  1635. @chapter System Installation
  1636. @cindex installing Guix System
  1637. @cindex Guix System, installation
  1638. This section explains how to install Guix System
  1639. on a machine. Guix, as a package manager, can
  1640. also be installed on top of a running GNU/Linux system,
  1641. @pxref{Installation}.
  1642. @ifinfo
  1643. @quotation Note
  1644. @c This paragraph is for people reading this from tty2 of the
  1645. @c installation image.
  1646. You are reading this documentation with an Info reader. For details on
  1647. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  1648. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  1649. Info}. Hit @kbd{l} afterwards to come back here.
  1650. Alternatively, run @command{info info} in another tty to keep the manual
  1651. available.
  1652. @end quotation
  1653. @end ifinfo
  1654. @menu
  1655. * Limitations:: What you can expect.
  1656. * Hardware Considerations:: Supported hardware.
  1657. * USB Stick and DVD Installation:: Preparing the installation medium.
  1658. * Preparing for Installation:: Networking, partitioning, etc.
  1659. * Guided Graphical Installation:: Easy graphical installation.
  1660. * Manual Installation:: Manual installation for wizards.
  1661. * After System Installation:: When installation succeeded.
  1662. * Installing Guix in a VM:: Guix System playground.
  1663. * Building the Installation Image:: How this comes to be.
  1664. @end menu
  1665. @node Limitations
  1666. @section Limitations
  1667. We consider Guix System to be ready for a wide range of ``desktop'' and server
  1668. use cases. The reliability guarantees it provides---transactional upgrades
  1669. and rollbacks, reproducibility---make it a solid foundation.
  1670. Nevertheless, before you proceed with the installation, be aware of the
  1671. following noteworthy limitations applicable to version @value{VERSION}:
  1672. @itemize
  1673. @item
  1674. More and more system services are provided (@pxref{Services}), but some
  1675. may be missing.
  1676. @item
  1677. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  1678. as well as a number of X11 window managers. However, KDE is currently
  1679. missing.
  1680. @end itemize
  1681. More than a disclaimer, this is an invitation to report issues (and success
  1682. stories!), and to join us in improving it. @xref{Contributing}, for more
  1683. info.
  1684. @node Hardware Considerations
  1685. @section Hardware Considerations
  1686. @cindex hardware support on Guix System
  1687. GNU@tie{}Guix focuses on respecting the user's computing freedom. It
  1688. builds around the kernel Linux-libre, which means that only hardware for
  1689. which free software drivers and firmware exist is supported. Nowadays,
  1690. a wide range of off-the-shelf hardware is supported on
  1691. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  1692. Ethernet controllers. Unfortunately, there are still areas where
  1693. hardware vendors deny users control over their own computing, and such
  1694. hardware is not supported on Guix System.
  1695. @cindex WiFi, hardware support
  1696. One of the main areas where free drivers or firmware are lacking is WiFi
  1697. devices. WiFi devices known to work include those using Atheros chips
  1698. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  1699. driver, and those using Broadcom/AirForce chips (BCM43xx with
  1700. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  1701. Linux-libre driver. Free firmware exists for both and is available
  1702. out-of-the-box on Guix System, as part of @code{%base-firmware}
  1703. (@pxref{operating-system Reference, @code{firmware}}).
  1704. @cindex RYF, Respects Your Freedom
  1705. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  1706. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  1707. certification program for hardware products that respect your freedom
  1708. and your privacy and ensure that you have control over your device. We
  1709. encourage you to check the list of RYF-certified devices.
  1710. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  1711. web site. It contains a catalog of hardware devices with information
  1712. about their support in GNU/Linux.
  1713. @node USB Stick and DVD Installation
  1714. @section USB Stick and DVD Installation
  1715. An ISO-9660 installation image that can be written to a USB stick or
  1716. burnt to a DVD can be downloaded from
  1717. @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso},
  1718. where you can replace @code{x86_64-linux} with one of:
  1719. @table @code
  1720. @item x86_64-linux
  1721. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  1722. @item i686-linux
  1723. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  1724. @end table
  1725. @c start duplication of authentication part from ``Binary Installation''
  1726. Make sure to download the associated @file{.sig} file and to verify the
  1727. authenticity of the image against it, along these lines:
  1728. @example
  1729. $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
  1730. $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
  1731. @end example
  1732. If that command fails because you do not have the required public key,
  1733. then run this command to import it:
  1734. @example
  1735. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  1736. -qO - | gpg --import -
  1737. @end example
  1738. @noindent
  1739. and rerun the @code{gpg --verify} command.
  1740. Take note that a warning like ``This key is not certified with a trusted
  1741. signature!'' is normal.
  1742. @c end duplication
  1743. This image contains the tools necessary for an installation.
  1744. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  1745. @unnumberedsubsec Copying to a USB Stick
  1746. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  1747. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  1748. copy the image with:
  1749. @example
  1750. dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
  1751. sync
  1752. @end example
  1753. Access to @file{/dev/sdX} usually requires root privileges.
  1754. @unnumberedsubsec Burning on a DVD
  1755. Insert a blank DVD into your machine, and determine
  1756. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  1757. copy the image with:
  1758. @example
  1759. growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
  1760. @end example
  1761. Access to @file{/dev/srX} usually requires root privileges.
  1762. @unnumberedsubsec Booting
  1763. Once this is done, you should be able to reboot the system and boot from
  1764. the USB stick or DVD@. The latter usually requires you to get in the
  1765. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  1766. In order to boot from Libreboot, switch to the command mode by pressing
  1767. the @kbd{c} key and type @command{search_grub usb}.
  1768. @xref{Installing Guix in a VM}, if, instead, you would like to install
  1769. Guix System in a virtual machine (VM).
  1770. @node Preparing for Installation
  1771. @section Preparing for Installation
  1772. Once you have booted, you can use the guided graphical installer, which makes
  1773. it easy to get started (@pxref{Guided Graphical Installation}). Alternatively,
  1774. if you are already familiar with GNU/Linux and if you want more control than
  1775. what the graphical installer provides, you can choose the ``manual''
  1776. installation process (@pxref{Manual Installation}).
  1777. The graphical installer is available on TTY1. You can obtain root shells on
  1778. TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
  1779. this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
  1780. is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  1781. Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
  1782. which allows you to select text with the left mouse button and to paste it
  1783. with the middle button.
  1784. @quotation Note
  1785. Installation requires access to the Internet so that any missing
  1786. dependencies of your system configuration can be downloaded. See the
  1787. ``Networking'' section below.
  1788. @end quotation
  1789. @node Guided Graphical Installation
  1790. @section Guided Graphical Installation
  1791. The graphical installer is a text-based user interface. It will guide you,
  1792. with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
  1793. The first dialog boxes allow you to set up the system as you use it during the
  1794. installation: you can choose the language, keyboard layout, and set up
  1795. networking, which will be used during the installation. The image below shows
  1796. the networking dialog.
  1797. @image{images/installer-network,5in,, networking setup with the graphical installer}
  1798. Later steps allow you to partition your hard disk, as shown in the image
  1799. below, to choose whether or not to use encrypted file systems, to enter the
  1800. host name and root password, and to create an additional account, among other
  1801. things.
  1802. @image{images/installer-partitions,5in,, partitioning with the graphical installer}
  1803. Note that, at any time, the installer allows you to exit the current
  1804. installation step and resume at a previous step, as show in the image below.
  1805. @image{images/installer-resume,5in,, resuming the installation process}
  1806. Once you're done, the installer produces an operating system configuration and
  1807. displays it (@pxref{Using the Configuration System}). At that point you can
  1808. hit ``OK'' and installation will proceed. On success, you can reboot into the
  1809. new system and enjoy. @xref{After System Installation}, for what's next!
  1810. @node Manual Installation
  1811. @section Manual Installation
  1812. This section describes how you would ``manually'' install GNU@tie{}Guix System
  1813. on your machine. This option requires familiarity with GNU/Linux, with the
  1814. shell, and with common administration tools. If you think this is not for
  1815. you, consider using the guided graphical installer (@pxref{Guided Graphical
  1816. Installation}).
  1817. The installation system provides root shells on TTYs 3 to 6; press
  1818. @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
  1819. many common tools needed to install the system. But it is also a full-blown
  1820. Guix System, which means that you can install additional packages, should you
  1821. need it, using @command{guix package} (@pxref{Invoking guix package}).
  1822. @menu
  1823. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  1824. * Proceeding with the Installation:: Installing.
  1825. @end menu
  1826. @node Keyboard Layout and Networking and Partitioning
  1827. @subsection Keyboard Layout, Networking, and Partitioning
  1828. Before you can install the system, you may want to adjust the keyboard layout,
  1829. set up networking, and partition your target hard disk. This section will
  1830. guide you through this.
  1831. @subsubsection Keyboard Layout
  1832. @cindex keyboard layout
  1833. The installation image uses the US qwerty keyboard layout. If you want
  1834. to change it, you can use the @command{loadkeys} command. For example,
  1835. the following command selects the Dvorak keyboard layout:
  1836. @example
  1837. loadkeys dvorak
  1838. @end example
  1839. See the files under @file{/run/current-system/profile/share/keymaps} for
  1840. a list of available keyboard layouts. Run @command{man loadkeys} for
  1841. more information.
  1842. @subsubsection Networking
  1843. Run the following command to see what your network interfaces are called:
  1844. @example
  1845. ifconfig -a
  1846. @end example
  1847. @noindent
  1848. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1849. @example
  1850. ip address
  1851. @end example
  1852. @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  1853. Wired interfaces have a name starting with @samp{e}; for example, the
  1854. interface corresponding to the first on-board Ethernet controller is
  1855. called @samp{eno1}. Wireless interfaces have a name starting with
  1856. @samp{w}, like @samp{w1p2s0}.
  1857. @table @asis
  1858. @item Wired connection
  1859. To configure a wired network run the following command, substituting
  1860. @var{interface} with the name of the wired interface you want to use.
  1861. @example
  1862. ifconfig @var{interface} up
  1863. @end example
  1864. @noindent
  1865. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1866. @example
  1867. ip link set @var{interface} up
  1868. @end example
  1869. @item Wireless connection
  1870. @cindex wireless
  1871. @cindex WiFi
  1872. To configure wireless networking, you can create a configuration file
  1873. for the @command{wpa_supplicant} configuration tool (its location is not
  1874. important) using one of the available text editors such as
  1875. @command{nano}:
  1876. @example
  1877. nano wpa_supplicant.conf
  1878. @end example
  1879. As an example, the following stanza can go to this file and will work
  1880. for many wireless networks, provided you give the actual SSID and
  1881. passphrase for the network you are connecting to:
  1882. @example
  1883. network=@{
  1884. ssid="@var{my-ssid}"
  1885. key_mgmt=WPA-PSK
  1886. psk="the network's secret passphrase"
  1887. @}
  1888. @end example
  1889. Start the wireless service and run it in the background with the
  1890. following command (substitute @var{interface} with the name of the
  1891. network interface you want to use):
  1892. @example
  1893. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  1894. @end example
  1895. Run @command{man wpa_supplicant} for more information.
  1896. @end table
  1897. @cindex DHCP
  1898. At this point, you need to acquire an IP address. On a network where IP
  1899. addresses are automatically assigned @i{via} DHCP, you can run:
  1900. @example
  1901. dhclient -v @var{interface}
  1902. @end example
  1903. Try to ping a server to see if networking is up and running:
  1904. @example
  1905. ping -c 3 gnu.org
  1906. @end example
  1907. Setting up network access is almost always a requirement because the
  1908. image does not contain all the software and tools that may be needed.
  1909. @cindex proxy, during system installation
  1910. If you need HTTP and HTTPS access to go through a proxy, run the
  1911. following command:
  1912. @example
  1913. herd set-http-proxy guix-daemon @var{URL}
  1914. @end example
  1915. @noindent
  1916. where @var{URL} is the proxy URL, for example
  1917. @code{http://example.org:8118}.
  1918. @cindex installing over SSH
  1919. If you want to, you can continue the installation remotely by starting
  1920. an SSH server:
  1921. @example
  1922. herd start ssh-daemon
  1923. @end example
  1924. Make sure to either set a password with @command{passwd}, or configure
  1925. OpenSSH public key authentication before logging in.
  1926. @subsubsection Disk Partitioning
  1927. Unless this has already been done, the next step is to partition, and
  1928. then format the target partition(s).
  1929. The installation image includes several partitioning tools, including
  1930. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  1931. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  1932. the partition layout you want:
  1933. @example
  1934. cfdisk
  1935. @end example
  1936. If your disk uses the GUID Partition Table (GPT) format and you plan to
  1937. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  1938. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  1939. manual}).
  1940. @cindex EFI, installation
  1941. @cindex UEFI, installation
  1942. @cindex ESP, EFI system partition
  1943. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  1944. (ESP) is required. This partition can be mounted at @file{/boot/efi} for
  1945. instance and must have the @code{esp} flag set. E.g., for @command{parted}:
  1946. @example
  1947. parted /dev/sda set 1 esp on
  1948. @end example
  1949. @quotation Note
  1950. @vindex grub-bootloader
  1951. @vindex grub-efi-bootloader
  1952. Unsure whether to use EFI- or BIOS-based GRUB? If the directory
  1953. @file{/sys/firmware/efi} exists in the installation image, then you should
  1954. probably perform an EFI installation, using @code{grub-efi-bootloader}.
  1955. Otherwise you should use the BIOS-based GRUB, known as
  1956. @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
  1957. bootloaders.
  1958. @end quotation
  1959. Once you are done partitioning the target hard disk drive, you have to
  1960. create a file system on the relevant partition(s)@footnote{Currently
  1961. Guix System only supports ext4, btrfs, JFS, and F2FS file systems. In
  1962. particular, code that reads file system UUIDs and labels only works for these
  1963. file system types.}. For the ESP, if you have one and assuming it is
  1964. @file{/dev/sda1}, run:
  1965. @example
  1966. mkfs.fat -F32 /dev/sda1
  1967. @end example
  1968. For the root file system, ext4 is the most widely used format. Other
  1969. file systems, such as Btrfs, support compression, which is reported to
  1970. nicely complement file deduplication that the daemon performs
  1971. independently of the file system (@pxref{Invoking guix-daemon,
  1972. deduplication}).
  1973. Preferably, assign file systems a label so that you can easily and
  1974. reliably refer to them in @code{file-system} declarations (@pxref{File
  1975. Systems}). This is typically done using the @code{-L} option of
  1976. @command{mkfs.ext4} and related commands. So, assuming the target root
  1977. partition lives at @file{/dev/sda2}, a file system with the label
  1978. @code{my-root} can be created with:
  1979. @example
  1980. mkfs.ext4 -L my-root /dev/sda2
  1981. @end example
  1982. @cindex encrypted disk
  1983. If you are instead planning to encrypt the root partition, you can use
  1984. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  1985. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  1986. @code{man cryptsetup}} for more information). Assuming you want to
  1987. store the root partition on @file{/dev/sda2}, the command sequence would
  1988. be along these lines:
  1989. @example
  1990. cryptsetup luksFormat /dev/sda2
  1991. cryptsetup open --type luks /dev/sda2 my-partition
  1992. mkfs.ext4 -L my-root /dev/mapper/my-partition
  1993. @end example
  1994. Once that is done, mount the target file system under @file{/mnt}
  1995. with a command like (again, assuming @code{my-root} is the label of the
  1996. root file system):
  1997. @example
  1998. mount LABEL=my-root /mnt
  1999. @end example
  2000. Also mount any other file systems you would like to use on the target
  2001. system relative to this path. If you have opted for @file{/boot/efi} as an
  2002. EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
  2003. found by @code{guix system init} afterwards.
  2004. Finally, if you plan to use one or more swap partitions (@pxref{Memory
  2005. Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
  2006. sure to initialize them with @command{mkswap}. Assuming you have one
  2007. swap partition on @file{/dev/sda3}, you would run:
  2008. @example
  2009. mkswap /dev/sda3
  2010. swapon /dev/sda3
  2011. @end example
  2012. Alternatively, you may use a swap file. For example, assuming that in
  2013. the new system you want to use the file @file{/swapfile} as a swap file,
  2014. you would run@footnote{This example will work for many types of file
  2015. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  2016. btrfs), the required steps may be different. For details, see the
  2017. manual pages for @command{mkswap} and @command{swapon}.}:
  2018. @example
  2019. # This is 10 GiB of swap space. Adjust "count" to change the size.
  2020. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  2021. # For security, make the file readable and writable only by root.
  2022. chmod 600 /mnt/swapfile
  2023. mkswap /mnt/swapfile
  2024. swapon /mnt/swapfile
  2025. @end example
  2026. Note that if you have encrypted the root partition and created a swap
  2027. file in its file system as described above, then the encryption also
  2028. protects the swap file, just like any other file in that file system.
  2029. @node Proceeding with the Installation
  2030. @subsection Proceeding with the Installation
  2031. With the target partitions ready and the target root mounted on
  2032. @file{/mnt}, we're ready to go. First, run:
  2033. @example
  2034. herd start cow-store /mnt
  2035. @end example
  2036. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  2037. during the installation phase are written to the target disk on @file{/mnt}
  2038. rather than kept in memory. This is necessary because the first phase of
  2039. the @command{guix system init} command (see below) entails downloads or
  2040. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  2041. Next, you have to edit a file and
  2042. provide the declaration of the operating system to be installed. To
  2043. that end, the installation system comes with three text editors. We
  2044. recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
  2045. supports syntax highlighting and parentheses matching; other editors
  2046. include mg (an Emacs clone), and
  2047. nvi (a clone of the original BSD @command{vi} editor).
  2048. We strongly recommend storing that file on the target root file system, say,
  2049. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  2050. configuration file once you have rebooted into the newly-installed system.
  2051. @xref{Using the Configuration System}, for an overview of the
  2052. configuration file. The example configurations discussed in that
  2053. section are available under @file{/etc/configuration} in the
  2054. installation image. Thus, to get started with a system configuration
  2055. providing a graphical display server (a ``desktop'' system), you can run
  2056. something along these lines:
  2057. @example
  2058. # mkdir /mnt/etc
  2059. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  2060. # nano /mnt/etc/config.scm
  2061. @end example
  2062. You should pay attention to what your configuration file contains, and
  2063. in particular:
  2064. @itemize
  2065. @item
  2066. Make sure the @code{bootloader-configuration} form refers to the targets
  2067. you want to install GRUB on. It should mention @code{grub-bootloader}
  2068. if you are installing GRUB in the legacy way, or
  2069. @code{grub-efi-bootloader} for newer UEFI systems. For legacy systems,
  2070. the @code{targets} field contain the names of the devices, like
  2071. @code{(list "/dev/sda")}; for UEFI systems it names the paths to mounted
  2072. EFI partitions, like @code{(list "/boot/efi")}; do make sure the paths
  2073. are currently mounted and a @code{file-system} entry is specified in
  2074. your configuration.
  2075. @item
  2076. Be sure that your file system labels match the value of their respective
  2077. @code{device} fields in your @code{file-system} configuration, assuming
  2078. your @code{file-system} configuration uses the @code{file-system-label}
  2079. procedure in its @code{device} field.
  2080. @item
  2081. If there are encrypted or RAID partitions, make sure to add a
  2082. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  2083. @end itemize
  2084. Once you are done preparing the configuration file, the new system must
  2085. be initialized (remember that the target root file system is mounted
  2086. under @file{/mnt}):
  2087. @example
  2088. guix system init /mnt/etc/config.scm /mnt
  2089. @end example
  2090. @noindent
  2091. This copies all the necessary files and installs GRUB on
  2092. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  2093. more information, @pxref{Invoking guix system}. This command may trigger
  2094. downloads or builds of missing packages, which can take some time.
  2095. Once that command has completed---and hopefully succeeded!---you can run
  2096. @command{reboot} and boot into the new system. The @code{root} password
  2097. in the new system is initially empty; other users' passwords need to be
  2098. initialized by running the @command{passwd} command as @code{root},
  2099. unless your configuration specifies otherwise
  2100. (@pxref{user-account-password, user account passwords}).
  2101. @xref{After System Installation}, for what's next!
  2102. @node After System Installation
  2103. @section After System Installation
  2104. Success, you've now booted into Guix System! From then on, you can update the
  2105. system whenever you want by running, say:
  2106. @example
  2107. guix pull
  2108. sudo guix system reconfigure /etc/config.scm
  2109. @end example
  2110. @noindent
  2111. This builds a new system generation with the latest packages and services
  2112. (@pxref{Invoking guix system}). We recommend doing that regularly so that
  2113. your system includes the latest security updates (@pxref{Security Updates}).
  2114. @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
  2115. @quotation Note
  2116. @cindex sudo vs. @command{guix pull}
  2117. Note that @command{sudo guix} runs your user's @command{guix} command and
  2118. @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
  2119. explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
  2120. The difference matters here, because @command{guix pull} updates
  2121. the @command{guix} command and package definitions only for the user it is run
  2122. as. This means that if you choose to use @command{guix system reconfigure} in
  2123. root's login shell, you'll need to @command{guix pull} separately.
  2124. @end quotation
  2125. Now, @pxref{Getting Started}, and
  2126. join us on @code{#guix} on the Libera Chat IRC network or on
  2127. @email{guix-devel@@gnu.org} to share your experience!
  2128. @node Installing Guix in a VM
  2129. @section Installing Guix in a Virtual Machine
  2130. @cindex virtual machine, Guix System installation
  2131. @cindex virtual private server (VPS)
  2132. @cindex VPS (virtual private server)
  2133. If you'd like to install Guix System in a virtual machine (VM) or on a
  2134. virtual private server (VPS) rather than on your beloved machine, this
  2135. section is for you.
  2136. To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
  2137. disk image, follow these steps:
  2138. @enumerate
  2139. @item
  2140. First, retrieve and decompress the Guix system installation image as
  2141. described previously (@pxref{USB Stick and DVD Installation}).
  2142. @item
  2143. Create a disk image that will hold the installed system. To make a
  2144. qcow2-formatted disk image, use the @command{qemu-img} command:
  2145. @example
  2146. qemu-img create -f qcow2 guix-system.img 50G
  2147. @end example
  2148. The resulting file will be much smaller than 50 GB (typically less than
  2149. 1 MB), but it will grow as the virtualized storage device is filled up.
  2150. @item
  2151. Boot the USB installation image in an VM:
  2152. @example
  2153. qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
  2154. -nic user,model=virtio-net-pci -boot menu=on,order=d \
  2155. -drive file=guix-system.img \
  2156. -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
  2157. @end example
  2158. @code{-enable-kvm} is optional, but significantly improves performance,
  2159. @pxref{Running Guix in a VM}.
  2160. @item
  2161. You're now root in the VM, proceed with the installation process.
  2162. @xref{Preparing for Installation}, and follow the instructions.
  2163. @end enumerate
  2164. Once installation is complete, you can boot the system that's on your
  2165. @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
  2166. that.
  2167. @node Building the Installation Image
  2168. @section Building the Installation Image
  2169. @cindex installation image
  2170. The installation image described above was built using the @command{guix
  2171. system} command, specifically:
  2172. @example
  2173. guix system image -t iso9660 gnu/system/install.scm
  2174. @end example
  2175. Have a look at @file{gnu/system/install.scm} in the source tree,
  2176. and see also @ref{Invoking guix system} for more information
  2177. about the installation image.
  2178. @section Building the Installation Image for ARM Boards
  2179. Many ARM boards require a specific variant of the
  2180. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  2181. If you build a disk image and the bootloader is not available otherwise
  2182. (on another boot drive etc), it's advisable to build an image that
  2183. includes the bootloader, specifically:
  2184. @example
  2185. guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  2186. @end example
  2187. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  2188. board, a list of possible boards will be printed.
  2189. @c *********************************************************************
  2190. @node Getting Started
  2191. @chapter Getting Started
  2192. Presumably, you've reached this section because either you have
  2193. installed Guix on top of another distribution (@pxref{Installation}), or
  2194. you've installed the standalone Guix System (@pxref{System
  2195. Installation}). It's time for you to get started using Guix and this
  2196. section aims to help you do that and give you a feel of what it's like.
  2197. Guix is about installing software, so probably the first thing you'll
  2198. want to do is to actually look for software. Let's say you're looking
  2199. for a text editor, you can run:
  2200. @example
  2201. guix search text editor
  2202. @end example
  2203. This command shows you a number of matching @dfn{packages}, each time
  2204. showing the package's name, version, a description, and additional info.
  2205. Once you've found out the one you want to use, let's say Emacs (ah ha!),
  2206. you can go ahead and install it (run this command as a regular user,
  2207. @emph{no need for root privileges}!):
  2208. @example
  2209. guix install emacs
  2210. @end example
  2211. @cindex profile
  2212. You've installed your first package, congrats! The package is now
  2213. visible in your default @dfn{profile}, @file{$HOME/.guix-profile}---a
  2214. profile is a directory containing installed packages.
  2215. In the process, you've
  2216. probably noticed that Guix downloaded pre-built binaries; or, if you
  2217. explicitly chose to @emph{not} use pre-built binaries, then probably
  2218. Guix is still building software (@pxref{Substitutes}, for more info).
  2219. Unless you're using Guix System, the @command{guix install} command must
  2220. have printed this hint:
  2221. @example
  2222. hint: Consider setting the necessary environment variables by running:
  2223. GUIX_PROFILE="$HOME/.guix-profile"
  2224. . "$GUIX_PROFILE/etc/profile"
  2225. Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
  2226. @end example
  2227. Indeed, you must now tell your shell where @command{emacs} and other
  2228. programs installed with Guix are to be found. Pasting the two lines
  2229. above will do just that: it will add
  2230. @code{$HOME/.guix-profile/bin}---which is where the installed package
  2231. is---to the @code{PATH} environment variable. You can paste these two
  2232. lines in your shell so they take effect right away, but more importantly
  2233. you should add them to @file{~/.bash_profile} (or equivalent file if you
  2234. do not use Bash) so that environment variables are set next time you
  2235. spawn a shell. You only need to do this once and other search paths
  2236. environment variables will be taken care of similarly---e.g., if you
  2237. eventually install @code{python} and Python libraries,
  2238. @env{GUIX_PYTHONPATH} will be defined.
  2239. You can go on installing packages at your will. To list installed
  2240. packages, run:
  2241. @example
  2242. guix package --list-installed
  2243. @end example
  2244. To remove a package, you would unsurprisingly run @command{guix remove}.
  2245. A distinguishing feature is the ability to @dfn{roll back} any operation
  2246. you made---installation, removal, upgrade---by simply typing:
  2247. @example
  2248. guix package --roll-back
  2249. @end example
  2250. This is because each operation is in fact a @dfn{transaction} that
  2251. creates a new @dfn{generation}. These generations and the difference
  2252. between them can be displayed by running:
  2253. @example
  2254. guix package --list-generations
  2255. @end example
  2256. Now you know the basics of package management!
  2257. @quotation Going further
  2258. @xref{Package Management}, for more about package management. You may
  2259. like @dfn{declarative} package management with @command{guix package
  2260. --manifest}, managing separate @dfn{profiles} with @option{--profile},
  2261. deleting old generations, collecting garbage, and other nifty features
  2262. that will come in handy as you become more familiar with Guix. If you
  2263. are a developer, @pxref{Development} for additional tools. And if
  2264. you're curious, @pxref{Features}, to peek under the hood.
  2265. @end quotation
  2266. Once you've installed a set of packages, you will want to periodically
  2267. @emph{upgrade} them to the latest and greatest version. To do that, you
  2268. will first pull the latest revision of Guix and its package collection:
  2269. @example
  2270. guix pull
  2271. @end example
  2272. The end result is a new @command{guix} command, under
  2273. @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
  2274. first time you run @command{guix pull}, be sure to follow the hint that
  2275. the command prints and, similar to what we saw above, paste these two
  2276. lines in your terminal and @file{.bash_profile}:
  2277. @example
  2278. GUIX_PROFILE="$HOME/.config/guix/current"
  2279. . "$GUIX_PROFILE/etc/profile"
  2280. @end example
  2281. @noindent
  2282. You must also instruct your shell to point to this new @command{guix}:
  2283. @example
  2284. hash guix
  2285. @end example
  2286. At this point, you're running a brand new Guix. You can thus go ahead
  2287. and actually upgrade all the packages you previously installed:
  2288. @example
  2289. guix upgrade
  2290. @end example
  2291. As you run this command, you will see that binaries are downloaded (or
  2292. perhaps some packages are built), and eventually you end up with the
  2293. upgraded packages. Should one of these upgraded packages not be to your
  2294. liking, remember you can always roll back!
  2295. You can display the exact revision of Guix you're currently using by
  2296. running:
  2297. @example
  2298. guix describe
  2299. @end example
  2300. The information it displays is @emph{all it takes to reproduce the exact
  2301. same Guix}, be it at a different point in time or on a different
  2302. machine.
  2303. @quotation Going further
  2304. @xref{Invoking guix pull}, for more information. @xref{Channels}, on
  2305. how to specify additional @dfn{channels} to pull packages from, how to
  2306. replicate Guix, and more. You may also find @command{time-machine}
  2307. handy (@pxref{Invoking guix time-machine}).
  2308. @end quotation
  2309. If you installed Guix System, one of the first things you'll want to do
  2310. is to upgrade your system. Once you've run @command{guix pull} to get
  2311. the latest Guix, you can upgrade the system like this:
  2312. @example
  2313. sudo guix system reconfigure /etc/config.scm
  2314. @end example
  2315. Upon completion, the system runs the latest versions of its software
  2316. packages. When you eventually reboot, you'll notice a sub-menu in the
  2317. bootloader that reads ``Old system generations'': it's what allows you
  2318. to boot @emph{an older generation of your system}, should the latest
  2319. generation be ``broken'' or otherwise unsatisfying. Just like for
  2320. packages, you can always @emph{roll back} to a previous generation
  2321. @emph{of the whole system}:
  2322. @example
  2323. sudo guix system roll-back
  2324. @end example
  2325. There are many things you'll probably want to tweak on your system:
  2326. adding new user accounts, adding new system services, fiddling with the
  2327. configuration of those services, etc. The system configuration is
  2328. @emph{entirely} described in the @file{/etc/config.scm} file.
  2329. @xref{Using the Configuration System}, to learn how to change it.
  2330. Now you know enough to get started!
  2331. @quotation Resources
  2332. The rest of this manual provides a reference for all things Guix. Here
  2333. are some additional resources you may find useful:
  2334. @itemize
  2335. @item
  2336. @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
  2337. ``how-to'' style of recipes for a variety of applications.
  2338. @item
  2339. The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
  2340. Card} lists in two pages most of the commands and options you'll ever
  2341. need.
  2342. @item
  2343. The web site contains @uref{https://guix.gnu.org/en/videos/,
  2344. instructional videos} covering topics such as everyday use of Guix, how
  2345. to get help, and how to become a contributor.
  2346. @item
  2347. @xref{Documentation}, to learn how to access documentation on your
  2348. computer.
  2349. @end itemize
  2350. We hope you will enjoy Guix as much as the community enjoys building it!
  2351. @end quotation
  2352. @c *********************************************************************
  2353. @node Package Management
  2354. @chapter Package Management
  2355. @cindex packages
  2356. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  2357. remove software packages, without having to know about their build
  2358. procedures or dependencies. Guix also goes beyond this obvious set of
  2359. features.
  2360. This chapter describes the main features of Guix, as well as the
  2361. package management tools it provides. Along with the command-line
  2362. interface described below (@pxref{Invoking guix package, @code{guix
  2363. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  2364. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  2365. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  2366. with it):
  2367. @example
  2368. guix install emacs-guix
  2369. @end example
  2370. @menu
  2371. * Features:: How Guix will make your life brighter.
  2372. * Invoking guix package:: Package installation, removal, etc.
  2373. * Substitutes:: Downloading pre-built binaries.
  2374. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  2375. * Invoking guix gc:: Running the garbage collector.
  2376. * Invoking guix pull:: Fetching the latest Guix and distribution.
  2377. * Invoking guix time-machine:: Running an older revision of Guix.
  2378. * Inferiors:: Interacting with another revision of Guix.
  2379. * Invoking guix describe:: Display information about your Guix revision.
  2380. * Invoking guix archive:: Exporting and importing store files.
  2381. @end menu
  2382. @node Features
  2383. @section Features
  2384. Here we assume you've already made your first steps with Guix
  2385. (@pxref{Getting Started}) and would like to get an overview about what's
  2386. going on under the hood.
  2387. When using Guix, each package ends up in the @dfn{package store}, in its
  2388. own directory---something that resembles
  2389. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  2390. Instead of referring to these directories, users have their own
  2391. @dfn{profile}, which points to the packages that they actually want to
  2392. use. These profiles are stored within each user's home directory, at
  2393. @code{$HOME/.guix-profile}.
  2394. For example, @code{alice} installs GCC 4.7.2. As a result,
  2395. @file{/home/alice/.guix-profile/bin/gcc} points to
  2396. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  2397. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  2398. simply continues to point to
  2399. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  2400. coexist on the same system without any interference.
  2401. The @command{guix package} command is the central tool to manage
  2402. packages (@pxref{Invoking guix package}). It operates on the per-user
  2403. profiles, and can be used @emph{with normal user privileges}.
  2404. @cindex transactions
  2405. The command provides the obvious install, remove, and upgrade
  2406. operations. Each invocation is actually a @emph{transaction}: either
  2407. the specified operation succeeds, or nothing happens. Thus, if the
  2408. @command{guix package} process is terminated during the transaction,
  2409. or if a power outage occurs during the transaction, then the user's
  2410. profile remains in its previous state, and remains usable.
  2411. In addition, any package transaction may be @emph{rolled back}. So, if,
  2412. for example, an upgrade installs a new version of a package that turns
  2413. out to have a serious bug, users may roll back to the previous instance
  2414. of their profile, which was known to work well. Similarly, the global
  2415. system configuration on Guix is subject to
  2416. transactional upgrades and roll-back
  2417. (@pxref{Using the Configuration System}).
  2418. All packages in the package store may be @emph{garbage-collected}.
  2419. Guix can determine which packages are still referenced by user
  2420. profiles, and remove those that are provably no longer referenced
  2421. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  2422. generations of their profile so that the packages they refer to can be
  2423. collected.
  2424. @cindex reproducibility
  2425. @cindex reproducible builds
  2426. Guix takes a @dfn{purely functional} approach to package
  2427. management, as described in the introduction (@pxref{Introduction}).
  2428. Each @file{/gnu/store} package directory name contains a hash of all the
  2429. inputs that were used to build that package---compiler, libraries, build
  2430. scripts, etc. This direct correspondence allows users to make sure a
  2431. given package installation matches the current state of their
  2432. distribution. It also helps maximize @dfn{build reproducibility}:
  2433. thanks to the isolated build environments that are used, a given build
  2434. is likely to yield bit-identical files when performed on different
  2435. machines (@pxref{Invoking guix-daemon, container}).
  2436. @cindex substitutes
  2437. This foundation allows Guix to support @dfn{transparent binary/source
  2438. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  2439. available from an external source---a @dfn{substitute}, Guix just
  2440. downloads it and unpacks it;
  2441. otherwise, it builds the package from source, locally
  2442. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  2443. reproducible, users do not have to trust servers that provide
  2444. substitutes: they can force a local build and @emph{challenge} providers
  2445. (@pxref{Invoking guix challenge}).
  2446. Control over the build environment is a feature that is also useful for
  2447. developers. The @command{guix environment} command allows developers of
  2448. a package to quickly set up the right development environment for their
  2449. package, without having to manually install the dependencies of the
  2450. package into their profile (@pxref{Invoking guix environment}).
  2451. @cindex replication, of software environments
  2452. @cindex provenance tracking, of software artifacts
  2453. All of Guix and its package definitions is version-controlled, and
  2454. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  2455. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  2456. Guix instance on a different machine or at a later point in time, which in
  2457. turn allows you to @emph{replicate complete software environments}, while
  2458. retaining precise @dfn{provenance tracking} of the software.
  2459. @node Invoking guix package
  2460. @section Invoking @command{guix package}
  2461. @cindex installing packages
  2462. @cindex removing packages
  2463. @cindex package installation
  2464. @cindex package removal
  2465. @cindex profile
  2466. The @command{guix package} command is the tool that allows users to
  2467. install, upgrade, and remove packages, as well as rolling back to
  2468. previous configurations. These operations work on a user
  2469. @dfn{profile}---a directory of installed packages. Each user has a
  2470. default profile in @file{$HOME/.guix-profile}.
  2471. The command operates only on the user's own profile,
  2472. and works with normal user privileges (@pxref{Features}). Its syntax
  2473. is:
  2474. @example
  2475. guix package @var{options}
  2476. @end example
  2477. @cindex transactions
  2478. Primarily, @var{options} specifies the operations to be performed during
  2479. the transaction. Upon completion, a new profile is created, but
  2480. previous @dfn{generations} of the profile remain available, should the user
  2481. want to roll back.
  2482. For example, to remove @code{lua} and install @code{guile} and
  2483. @code{guile-cairo} in a single transaction:
  2484. @example
  2485. guix package -r lua -i guile guile-cairo
  2486. @end example
  2487. @cindex aliases, for @command{guix package}
  2488. For your convenience, we also provide the following aliases:
  2489. @itemize
  2490. @item
  2491. @command{guix search} is an alias for @command{guix package -s},
  2492. @item
  2493. @command{guix install} is an alias for @command{guix package -i},
  2494. @item
  2495. @command{guix remove} is an alias for @command{guix package -r},
  2496. @item
  2497. @command{guix upgrade} is an alias for @command{guix package -u},
  2498. @item
  2499. and @command{guix show} is an alias for @command{guix package --show=}.
  2500. @end itemize
  2501. These aliases are less expressive than @command{guix package} and provide
  2502. fewer options, so in some cases you'll probably want to use @command{guix
  2503. package} directly.
  2504. @command{guix package} also supports a @dfn{declarative approach}
  2505. whereby the user specifies the exact set of packages to be available and
  2506. passes it @i{via} the @option{--manifest} option
  2507. (@pxref{profile-manifest, @option{--manifest}}).
  2508. @cindex profile
  2509. For each user, a symlink to the user's default profile is automatically
  2510. created in @file{$HOME/.guix-profile}. This symlink always points to the
  2511. current generation of the user's default profile. Thus, users can add
  2512. @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
  2513. variable, and so on.
  2514. @cindex search paths
  2515. If you are not using Guix System, consider adding the
  2516. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  2517. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  2518. shells get all the right environment variable definitions:
  2519. @example
  2520. GUIX_PROFILE="$HOME/.guix-profile" ; \
  2521. source "$GUIX_PROFILE/etc/profile"
  2522. @end example
  2523. In a multi-user setup, user profiles are stored in a place registered as
  2524. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  2525. to (@pxref{Invoking guix gc}). That directory is normally
  2526. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  2527. @var{localstatedir} is the value passed to @code{configure} as
  2528. @option{--localstatedir}, and @var{user} is the user name. The
  2529. @file{per-user} directory is created when @command{guix-daemon} is
  2530. started, and the @var{user} sub-directory is created by @command{guix
  2531. package}.
  2532. The @var{options} can be among the following:
  2533. @table @code
  2534. @item --install=@var{package} @dots{}
  2535. @itemx -i @var{package} @dots{}
  2536. Install the specified @var{package}s.
  2537. Each @var{package} may specify either a simple package name, such as
  2538. @code{guile}, or a package name followed by an at-sign and version number,
  2539. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  2540. case, the newest version prefixed by @code{1.8} is selected).
  2541. If no version number is specified, the
  2542. newest available version will be selected. In addition, @var{package}
  2543. may contain a colon, followed by the name of one of the outputs of the
  2544. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  2545. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  2546. name (and optionally version) are searched for among the GNU
  2547. distribution modules (@pxref{Package Modules}).
  2548. @cindex propagated inputs
  2549. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  2550. that automatically get installed along with the required package
  2551. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  2552. @code{package} objects}, for information about propagated inputs in
  2553. package definitions).
  2554. @anchor{package-cmd-propagated-inputs}
  2555. An example is the GNU MPC library: its C header files refer to those of
  2556. the GNU MPFR library, which in turn refer to those of the GMP library.
  2557. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  2558. in the profile; removing MPC also removes MPFR and GMP---unless they had
  2559. also been explicitly installed by the user.
  2560. Besides, packages sometimes rely on the definition of environment
  2561. variables for their search paths (see explanation of
  2562. @option{--search-paths} below). Any missing or possibly incorrect
  2563. environment variable definitions are reported here.
  2564. @item --install-from-expression=@var{exp}
  2565. @itemx -e @var{exp}
  2566. Install the package @var{exp} evaluates to.
  2567. @var{exp} must be a Scheme expression that evaluates to a
  2568. @code{<package>} object. This option is notably useful to disambiguate
  2569. between same-named variants of a package, with expressions such as
  2570. @code{(@@ (gnu packages base) guile-final)}.
  2571. Note that this option installs the first output of the specified
  2572. package, which may be insufficient when needing a specific output of a
  2573. multiple-output package.
  2574. @item --install-from-file=@var{file}
  2575. @itemx -f @var{file}
  2576. Install the package that the code within @var{file} evaluates to.
  2577. As an example, @var{file} might contain a definition like this
  2578. (@pxref{Defining Packages}):
  2579. @lisp
  2580. @include package-hello.scm
  2581. @end lisp
  2582. Developers may find it useful to include such a @file{guix.scm} file
  2583. in the root of their project source tree that can be used to test
  2584. development snapshots and create reproducible development environments
  2585. (@pxref{Invoking guix environment}).
  2586. The @var{file} may also contain a JSON representation of one or more
  2587. package definitions. Running @code{guix package -f} on
  2588. @file{hello.json} with the following contents would result in installing
  2589. the package @code{greeter} after building @code{myhello}:
  2590. @example
  2591. @verbatiminclude package-hello.json
  2592. @end example
  2593. @item --remove=@var{package} @dots{}
  2594. @itemx -r @var{package} @dots{}
  2595. Remove the specified @var{package}s.
  2596. As for @option{--install}, each @var{package} may specify a version number
  2597. and/or output name in addition to the package name. For instance,
  2598. @samp{-r glibc:debug} would remove the @code{debug} output of
  2599. @code{glibc}.
  2600. @item --upgrade[=@var{regexp} @dots{}]
  2601. @itemx -u [@var{regexp} @dots{}]
  2602. @cindex upgrading packages
  2603. Upgrade all the installed packages. If one or more @var{regexp}s are
  2604. specified, upgrade only installed packages whose name matches a
  2605. @var{regexp}. Also see the @option{--do-not-upgrade} option below.
  2606. Note that this upgrades package to the latest version of packages found
  2607. in the distribution currently installed. To update your distribution,
  2608. you should regularly run @command{guix pull} (@pxref{Invoking guix
  2609. pull}).
  2610. @cindex package transformations, upgrades
  2611. When upgrading, package transformations that were originally applied
  2612. when creating the profile are automatically re-applied (@pxref{Package
  2613. Transformation Options}). For example, assume you first installed Emacs
  2614. from the tip of its development branch with:
  2615. @example
  2616. guix install emacs-next --with-branch=emacs-next=master
  2617. @end example
  2618. Next time you run @command{guix upgrade}, Guix will again pull the tip
  2619. of the Emacs development branch and build @code{emacs-next} from that
  2620. checkout.
  2621. Note that transformation options such as @option{--with-branch} and
  2622. @option{--with-source} depend on external state; it is up to you to
  2623. ensure that they work as expected. You can also discard a
  2624. transformations that apply to a package by running:
  2625. @example
  2626. guix install @var{package}
  2627. @end example
  2628. @item --do-not-upgrade[=@var{regexp} @dots{}]
  2629. When used together with the @option{--upgrade} option, do @emph{not}
  2630. upgrade any packages whose name matches a @var{regexp}. For example, to
  2631. upgrade all packages in the current profile except those containing the
  2632. substring ``emacs'':
  2633. @example
  2634. $ guix package --upgrade . --do-not-upgrade emacs
  2635. @end example
  2636. @item @anchor{profile-manifest}--manifest=@var{file}
  2637. @itemx -m @var{file}
  2638. @cindex profile declaration
  2639. @cindex profile manifest
  2640. Create a new generation of the profile from the manifest object
  2641. returned by the Scheme code in @var{file}. This option can be repeated
  2642. several times, in which case the manifests are concatenated.
  2643. This allows you to @emph{declare} the profile's contents rather than
  2644. constructing it through a sequence of @option{--install} and similar
  2645. commands. The advantage is that @var{file} can be put under version
  2646. control, copied to different machines to reproduce the same profile, and
  2647. so on.
  2648. @c FIXME: Add reference to (guix profile) documentation when available.
  2649. @var{file} must return a @dfn{manifest} object, which is roughly a list
  2650. of packages:
  2651. @findex packages->manifest
  2652. @lisp
  2653. (use-package-modules guile emacs)
  2654. (packages->manifest
  2655. (list emacs
  2656. guile-2.0
  2657. ;; Use a specific package output.
  2658. (list guile-2.0 "debug")))
  2659. @end lisp
  2660. @findex specifications->manifest
  2661. In this example we have to know which modules define the @code{emacs}
  2662. and @code{guile-2.0} variables to provide the right
  2663. @code{use-package-modules} line, which can be cumbersome. We can
  2664. instead provide regular package specifications and let
  2665. @code{specifications->manifest} look up the corresponding package
  2666. objects, like this:
  2667. @lisp
  2668. (specifications->manifest
  2669. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  2670. @end lisp
  2671. @xref{export-manifest, @option{--export-manifest}}, to learn how to
  2672. obtain a manifest file from an existing profile.
  2673. @item --roll-back
  2674. @cindex rolling back
  2675. @cindex undoing transactions
  2676. @cindex transactions, undoing
  2677. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  2678. the last transaction.
  2679. When combined with options such as @option{--install}, roll back occurs
  2680. before any other actions.
  2681. When rolling back from the first generation that actually contains
  2682. installed packages, the profile is made to point to the @dfn{zeroth
  2683. generation}, which contains no files apart from its own metadata.
  2684. After having rolled back, installing, removing, or upgrading packages
  2685. overwrites previous future generations. Thus, the history of the
  2686. generations in a profile is always linear.
  2687. @item --switch-generation=@var{pattern}
  2688. @itemx -S @var{pattern}
  2689. @cindex generations
  2690. Switch to a particular generation defined by @var{pattern}.
  2691. @var{pattern} may be either a generation number or a number prefixed
  2692. with ``+'' or ``-''. The latter means: move forward/backward by a
  2693. specified number of generations. For example, if you want to return to
  2694. the latest generation after @option{--roll-back}, use
  2695. @option{--switch-generation=+1}.
  2696. The difference between @option{--roll-back} and
  2697. @option{--switch-generation=-1} is that @option{--switch-generation} will
  2698. not make a zeroth generation, so if a specified generation does not
  2699. exist, the current generation will not be changed.
  2700. @item --search-paths[=@var{kind}]
  2701. @cindex search paths
  2702. Report environment variable definitions, in Bash syntax, that may be
  2703. needed in order to use the set of installed packages. These environment
  2704. variables are used to specify @dfn{search paths} for files used by some
  2705. of the installed packages.
  2706. For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
  2707. environment variables to be defined so it can look for headers and
  2708. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  2709. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  2710. library are installed in the profile, then @option{--search-paths} will
  2711. suggest setting these variables to @file{@var{profile}/include} and
  2712. @file{@var{profile}/lib}, respectively.
  2713. The typical use case is to define these environment variables in the
  2714. shell:
  2715. @example
  2716. $ eval `guix package --search-paths`
  2717. @end example
  2718. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  2719. meaning that the returned environment variable definitions will either
  2720. be exact settings, or prefixes or suffixes of the current value of these
  2721. variables. When omitted, @var{kind} defaults to @code{exact}.
  2722. This option can also be used to compute the @emph{combined} search paths
  2723. of several profiles. Consider this example:
  2724. @example
  2725. $ guix package -p foo -i guile
  2726. $ guix package -p bar -i guile-json
  2727. $ guix package -p foo -p bar --search-paths
  2728. @end example
  2729. The last command above reports about the @env{GUILE_LOAD_PATH}
  2730. variable, even though, taken individually, neither @file{foo} nor
  2731. @file{bar} would lead to that recommendation.
  2732. @cindex profile, choosing
  2733. @item --profile=@var{profile}
  2734. @itemx -p @var{profile}
  2735. Use @var{profile} instead of the user's default profile.
  2736. @var{profile} must be the name of a file that will be created upon
  2737. completion. Concretely, @var{profile} will be a mere symbolic link
  2738. (``symlink'') pointing to the actual profile where packages are
  2739. installed:
  2740. @example
  2741. $ guix install hello -p ~/code/my-profile
  2742. @dots{}
  2743. $ ~/code/my-profile/bin/hello
  2744. Hello, world!
  2745. @end example
  2746. All it takes to get rid of the profile is to remove this symlink and its
  2747. siblings that point to specific generations:
  2748. @example
  2749. $ rm ~/code/my-profile ~/code/my-profile-*-link
  2750. @end example
  2751. @item --list-profiles
  2752. List all the user's profiles:
  2753. @example
  2754. $ guix package --list-profiles
  2755. /home/charlie/.guix-profile
  2756. /home/charlie/code/my-profile
  2757. /home/charlie/code/devel-profile
  2758. /home/charlie/tmp/test
  2759. @end example
  2760. When running as root, list all the profiles of all the users.
  2761. @cindex collisions, in a profile
  2762. @cindex colliding packages in profiles
  2763. @cindex profile collisions
  2764. @item --allow-collisions
  2765. Allow colliding packages in the new profile. Use at your own risk!
  2766. By default, @command{guix package} reports as an error @dfn{collisions}
  2767. in the profile. Collisions happen when two or more different versions
  2768. or variants of a given package end up in the profile.
  2769. @item --bootstrap
  2770. Use the bootstrap Guile to build the profile. This option is only
  2771. useful to distribution developers.
  2772. @end table
  2773. In addition to these actions, @command{guix package} supports the
  2774. following options to query the current state of a profile, or the
  2775. availability of packages:
  2776. @table @option
  2777. @item --search=@var{regexp}
  2778. @itemx -s @var{regexp}
  2779. @anchor{guix-search}
  2780. @cindex searching for packages
  2781. List the available packages whose name, synopsis, or description matches
  2782. @var{regexp} (in a case-insensitive fashion), sorted by relevance.
  2783. Print all the metadata of matching packages in
  2784. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  2785. GNU recutils manual}).
  2786. This allows specific fields to be extracted using the @command{recsel}
  2787. command, for instance:
  2788. @example
  2789. $ guix package -s malloc | recsel -p name,version,relevance
  2790. name: jemalloc
  2791. version: 4.5.0
  2792. relevance: 6
  2793. name: glibc
  2794. version: 2.25
  2795. relevance: 1
  2796. name: libgc
  2797. version: 7.6.0
  2798. relevance: 1
  2799. @end example
  2800. Similarly, to show the name of all the packages available under the
  2801. terms of the GNU@tie{}LGPL version 3:
  2802. @example
  2803. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  2804. name: elfutils
  2805. name: gmp
  2806. @dots{}
  2807. @end example
  2808. It is also possible to refine search results using several @code{-s} flags to
  2809. @command{guix package}, or several arguments to @command{guix search}. For
  2810. example, the following command returns a list of board games (this time using
  2811. the @command{guix search} alias):
  2812. @example
  2813. $ guix search '\<board\>' game | recsel -p name
  2814. name: gnubg
  2815. @dots{}
  2816. @end example
  2817. If we were to omit @code{-s game}, we would also get software packages
  2818. that deal with printed circuit boards; removing the angle brackets
  2819. around @code{board} would further add packages that have to do with
  2820. keyboards.
  2821. And now for a more elaborate example. The following command searches
  2822. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  2823. libraries, and prints the name and synopsis of the matching packages:
  2824. @example
  2825. $ guix search crypto library | \
  2826. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  2827. @end example
  2828. @noindent
  2829. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  2830. information on @dfn{selection expressions} for @code{recsel -e}.
  2831. @item --show=@var{package}
  2832. Show details about @var{package}, taken from the list of available packages, in
  2833. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  2834. recutils manual}).
  2835. @example
  2836. $ guix package --show=guile | recsel -p name,version
  2837. name: guile
  2838. version: 3.0.5
  2839. name: guile
  2840. version: 3.0.2
  2841. name: guile
  2842. version: 2.2.7
  2843. @dots{}
  2844. @end example
  2845. You may also specify the full name of a package to only get details about a
  2846. specific version of it (this time using the @command{guix show} alias):
  2847. @example
  2848. $ guix show guile@@3.0.5 | recsel -p name,version
  2849. name: guile
  2850. version: 3.0.5
  2851. @end example
  2852. @item --list-installed[=@var{regexp}]
  2853. @itemx -I [@var{regexp}]
  2854. List the currently installed packages in the specified profile, with the
  2855. most recently installed packages shown last. When @var{regexp} is
  2856. specified, list only installed packages whose name matches @var{regexp}.
  2857. For each installed package, print the following items, separated by
  2858. tabs: the package name, its version string, the part of the package that
  2859. is installed (for instance, @code{out} for the default output,
  2860. @code{include} for its headers, etc.), and the path of this package in
  2861. the store.
  2862. @item --list-available[=@var{regexp}]
  2863. @itemx -A [@var{regexp}]
  2864. List packages currently available in the distribution for this system
  2865. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  2866. available packages whose name matches @var{regexp}.
  2867. For each package, print the following items separated by tabs: its name,
  2868. its version string, the parts of the package (@pxref{Packages with
  2869. Multiple Outputs}), and the source location of its definition.
  2870. @item --list-generations[=@var{pattern}]
  2871. @itemx -l [@var{pattern}]
  2872. @cindex generations
  2873. Return a list of generations along with their creation dates; for each
  2874. generation, show the installed packages, with the most recently
  2875. installed packages shown last. Note that the zeroth generation is never
  2876. shown.
  2877. For each installed package, print the following items, separated by
  2878. tabs: the name of a package, its version string, the part of the package
  2879. that is installed (@pxref{Packages with Multiple Outputs}), and the
  2880. location of this package in the store.
  2881. When @var{pattern} is used, the command returns only matching
  2882. generations. Valid patterns include:
  2883. @itemize
  2884. @item @emph{Integers and comma-separated integers}. Both patterns denote
  2885. generation numbers. For instance, @option{--list-generations=1} returns
  2886. the first one.
  2887. And @option{--list-generations=1,8,2} outputs three generations in the
  2888. specified order. Neither spaces nor trailing commas are allowed.
  2889. @item @emph{Ranges}. @option{--list-generations=2..9} prints the
  2890. specified generations and everything in between. Note that the start of
  2891. a range must be smaller than its end.
  2892. It is also possible to omit the endpoint. For example,
  2893. @option{--list-generations=2..}, returns all generations starting from the
  2894. second one.
  2895. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  2896. or months by passing an integer along with the first letter of the
  2897. duration. For example, @option{--list-generations=20d} lists generations
  2898. that are up to 20 days old.
  2899. @end itemize
  2900. @item --delete-generations[=@var{pattern}]
  2901. @itemx -d [@var{pattern}]
  2902. When @var{pattern} is omitted, delete all generations except the current
  2903. one.
  2904. This command accepts the same patterns as @option{--list-generations}.
  2905. When @var{pattern} is specified, delete the matching generations. When
  2906. @var{pattern} specifies a duration, generations @emph{older} than the
  2907. specified duration match. For instance, @option{--delete-generations=1m}
  2908. deletes generations that are more than one month old.
  2909. If the current generation matches, it is @emph{not} deleted. Also, the
  2910. zeroth generation is never deleted.
  2911. Note that deleting generations prevents rolling back to them.
  2912. Consequently, this command must be used with care.
  2913. @cindex manifest, exporting
  2914. @anchor{export-manifest}
  2915. @item --export-manifest
  2916. Write to standard output a manifest suitable for @option{--manifest}
  2917. corresponding to the chosen profile(s).
  2918. This option is meant to help you migrate from the ``imperative''
  2919. operating mode---running @command{guix install}, @command{guix upgrade},
  2920. etc.---to the declarative mode that @option{--manifest} offers.
  2921. Be aware that the resulting manifest @emph{approximates} what your
  2922. profile actually contains; for instance, depending on how your profile
  2923. was created, it can refer to packages or package versions that are not
  2924. exactly what you specified.
  2925. Keep in mind that a manifest is purely symbolic: it only contains
  2926. package names and possibly versions, and their meaning varies over time.
  2927. If you wish to ``pin'' channels to the revisions that were used to build
  2928. the profile(s), see @option{--export-channels} below.
  2929. @cindex pinning, channel revisions of a profile
  2930. @item --export-channels
  2931. Write to standard output the list of channels used by the chosen
  2932. profile(s), in a format suitable for @command{guix pull --channels} or
  2933. @command{guix time-machine --channels} (@pxref{Channels}).
  2934. Together with @option{--export-manifest}, this option provides
  2935. information allowing you to replicate the current profile
  2936. (@pxref{Replicating Guix}).
  2937. However, note that the output of this command @emph{approximates} what
  2938. was actually used to build this profile. In particular, a single
  2939. profile might have been built from several different revisions of the
  2940. same channel. In that case, @option{--export-manifest} chooses the last
  2941. one and writes the list of other revisions in a comment. If you really
  2942. need to pick packages from different channel revisions, you can use
  2943. inferiors in your manifest to do so (@pxref{Inferiors}).
  2944. Together with @option{--export-manifest}, this is a good starting point
  2945. if you are willing to migrate from the ``imperative'' model to the fully
  2946. declarative model consisting of a manifest file along with a channels
  2947. file pinning the exact channel revision(s) you want.
  2948. @end table
  2949. Finally, since @command{guix package} may actually start build
  2950. processes, it supports all the common build options (@pxref{Common Build
  2951. Options}). It also supports package transformation options, such as
  2952. @option{--with-source}, and preserves them across upgrades
  2953. (@pxref{Package Transformation Options}).
  2954. @node Substitutes
  2955. @section Substitutes
  2956. @cindex substitutes
  2957. @cindex pre-built binaries
  2958. Guix supports transparent source/binary deployment, which means that it
  2959. can either build things locally, or download pre-built items from a
  2960. server, or both. We call these pre-built items @dfn{substitutes}---they
  2961. are substitutes for local build results. In many cases, downloading a
  2962. substitute is much faster than building things locally.
  2963. Substitutes can be anything resulting from a derivation build
  2964. (@pxref{Derivations}). Of course, in the common case, they are
  2965. pre-built package binaries, but source tarballs, for instance, which
  2966. also result from derivation builds, can be available as substitutes.
  2967. @menu
  2968. * Official Substitute Servers:: One particular source of substitutes.
  2969. * Substitute Server Authorization:: How to enable or disable substitutes.
  2970. * Getting Substitutes from Other Servers:: Substitute diversity.
  2971. * Substitute Authentication:: How Guix verifies substitutes.
  2972. * Proxy Settings:: How to get substitutes via proxy.
  2973. * Substitution Failure:: What happens when substitution fails.
  2974. * On Trusting Binaries:: How can you trust that binary blob?
  2975. @end menu
  2976. @node Official Substitute Servers
  2977. @subsection Official Substitute Servers
  2978. @cindex build farm
  2979. @code{@value{SUBSTITUTE-SERVER-1}} and
  2980. @code{@value{SUBSTITUTE-SERVER-2}} are both front-ends to official build
  2981. farms that build packages from Guix continuously for some architectures,
  2982. and make them available as substitutes. These are the default source of
  2983. substitutes; which can be overridden by passing the
  2984. @option{--substitute-urls} option either to @command{guix-daemon}
  2985. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  2986. or to client tools such as @command{guix package}
  2987. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  2988. option}).
  2989. Substitute URLs can be either HTTP or HTTPS.
  2990. HTTPS is recommended because communications are encrypted; conversely,
  2991. using HTTP makes all communications visible to an eavesdropper, who
  2992. could use the information gathered to determine, for instance, whether
  2993. your system has unpatched security vulnerabilities.
  2994. Substitutes from the official build farms are enabled by default when
  2995. using Guix System (@pxref{GNU Distribution}). However,
  2996. they are disabled by default when using Guix on a foreign distribution,
  2997. unless you have explicitly enabled them via one of the recommended
  2998. installation steps (@pxref{Installation}). The following paragraphs
  2999. describe how to enable or disable substitutes for the official build
  3000. farm; the same procedure can also be used to enable substitutes for any
  3001. other substitute server.
  3002. @node Substitute Server Authorization
  3003. @subsection Substitute Server Authorization
  3004. @cindex security
  3005. @cindex substitutes, authorization thereof
  3006. @cindex access control list (ACL), for substitutes
  3007. @cindex ACL (access control list), for substitutes
  3008. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER-1}}, @code{@value{SUBSTITUTE-SERVER-2}} or a mirror, you
  3009. must add the relevant public key to the access control list (ACL) of archive
  3010. imports, using the @command{guix archive} command (@pxref{Invoking guix
  3011. archive}). Doing so implies that you trust the substitute server to not
  3012. be compromised and to serve genuine substitutes.
  3013. @quotation Note
  3014. If you are using Guix System, you can skip this section: Guix System
  3015. authorizes substitutes from @code{@value{SUBSTITUTE-SERVER-1}} and
  3016. @code{@value{SUBSTITUTE-SERVER-2}} by default.
  3017. @end quotation
  3018. The public keys for each of the project maintained substitute servers
  3019. are installed along with Guix, in @code{@var{prefix}/share/guix/}, where
  3020. @var{prefix} is the installation prefix of Guix. If you installed Guix
  3021. from source, make sure you checked the GPG signature of
  3022. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  3023. Then, you can run something like this:
  3024. @example
  3025. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
  3026. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
  3027. @end example
  3028. Once this is in place, the output of a command like @code{guix build}
  3029. should change from something like:
  3030. @example
  3031. $ guix build emacs --dry-run
  3032. The following derivations would be built:
  3033. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  3034. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  3035. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  3036. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  3037. @dots{}
  3038. @end example
  3039. @noindent
  3040. to something like:
  3041. @example
  3042. $ guix build emacs --dry-run
  3043. 112.3 MB would be downloaded:
  3044. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  3045. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  3046. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  3047. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  3048. @dots{}
  3049. @end example
  3050. @noindent
  3051. The text changed from ``The following derivations would be built'' to
  3052. ``112.3 MB would be downloaded''. This indicates that substitutes from
  3053. the configured substitute servers are usable and will be downloaded,
  3054. when possible, for future builds.
  3055. @cindex substitutes, how to disable
  3056. The substitute mechanism can be disabled globally by running
  3057. @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
  3058. guix-daemon}). It can also be disabled temporarily by passing the
  3059. @option{--no-substitutes} option to @command{guix package},
  3060. @command{guix build}, and other command-line tools.
  3061. @node Getting Substitutes from Other Servers
  3062. @subsection Getting Substitutes from Other Servers
  3063. @cindex substitute servers, adding more
  3064. Guix can look up and fetch substitutes from several servers. This is
  3065. useful when you are using packages from additional channels for which
  3066. the official server does not have substitutes but another server
  3067. provides them. Another situation where this is useful is when you would
  3068. prefer to download from your organization's substitute server, resorting
  3069. to the official server only as a fallback or dismissing it altogether.
  3070. You can give Guix a list of substitute server URLs and it will check
  3071. them in the specified order. You also need to explicitly authorize the
  3072. public keys of substitute servers to instruct Guix to accept the
  3073. substitutes they sign.
  3074. On Guix System, this is achieved by modifying the configuration of the
  3075. @code{guix} service. Since the @code{guix} service is part of the
  3076. default lists of services, @code{%base-services} and
  3077. @code{%desktop-services}, you can use @code{modify-services} to change
  3078. its configuration and add the URLs and substitute keys that you want
  3079. (@pxref{Service Reference, @code{modify-services}}).
  3080. As an example, suppose you want to fetch substitutes from
  3081. @code{guix.example.org} and to authorize the signing key of that server,
  3082. in addition to the default @code{@value{SUBSTITUTE-SERVER-1}} and
  3083. @code{@value{SUBSTITUTE-SERVER-2}}. The resulting operating system
  3084. configuration will look something like:
  3085. @lisp
  3086. (operating-system
  3087. ;; @dots{}
  3088. (services
  3089. ;; Assume we're starting from '%desktop-services'. Replace it
  3090. ;; with the list of services you're actually using.
  3091. (modify-services %desktop-services
  3092. (guix-service-type config =>
  3093. (guix-configuration
  3094. (inherit config)
  3095. (substitute-urls
  3096. (append (list "https://guix.example.org")
  3097. %default-substitute-urls))
  3098. (authorized-keys
  3099. (append (list (local-file "./key.pub"))
  3100. %default-authorized-guix-keys)))))))
  3101. @end lisp
  3102. This assumes that the file @file{key.pub} contains the signing key of
  3103. @code{guix.example.org}. With this change in place in your operating
  3104. system configuration file (say @file{/etc/config.scm}), you can
  3105. reconfigure and restart the @code{guix-daemon} service or reboot so the
  3106. changes take effect:
  3107. @example
  3108. $ sudo guix system reconfigure /etc/config.scm
  3109. $ sudo herd restart guix-daemon
  3110. @end example
  3111. If you're running Guix on a ``foreign distro'', you would instead take
  3112. the following steps to get substitutes from additional servers:
  3113. @enumerate
  3114. @item
  3115. Edit the service configuration file for @code{guix-daemon}; when using
  3116. systemd, this is normally
  3117. @file{/etc/systemd/system/guix-daemon.service}. Add the
  3118. @option{--substitute-urls} option on the @command{guix-daemon} command
  3119. line and list the URLs of interest (@pxref{daemon-substitute-urls,
  3120. @code{guix-daemon --substitute-urls}}):
  3121. @example
  3122. @dots{} --substitute-urls='https://guix.example.org @value{SUBSTITUTE-URLS}'
  3123. @end example
  3124. @item
  3125. Restart the daemon. For systemd, it goes like this:
  3126. @example
  3127. systemctl daemon-reload
  3128. systemctl restart guix-daemon.service
  3129. @end example
  3130. @item
  3131. Authorize the key of the new server (@pxref{Invoking guix archive}):
  3132. @example
  3133. guix archive --authorize < key.pub
  3134. @end example
  3135. Again this assumes @file{key.pub} contains the public key that
  3136. @code{guix.example.org} uses to sign substitutes.
  3137. @end enumerate
  3138. Now you're all set! Substitutes will be preferably taken from
  3139. @code{https://guix.example.org}, using
  3140. @code{@value{SUBSTITUTE-SERVER-1}} then
  3141. @code{@value{SUBSTITUTE-SERVER-2}} as fallback options. Of course you
  3142. can list as many substitute servers as you like, with the caveat that
  3143. substitute lookup can be slowed down if too many servers need to be
  3144. contacted.
  3145. Note that there are also situations where one may want to add the URL of
  3146. a substitute server @emph{without} authorizing its key.
  3147. @xref{Substitute Authentication}, to understand this fine point.
  3148. @node Substitute Authentication
  3149. @subsection Substitute Authentication
  3150. @cindex digital signatures
  3151. Guix detects and raises an error when attempting to use a substitute
  3152. that has been tampered with. Likewise, it ignores substitutes that are
  3153. not signed, or that are not signed by one of the keys listed in the ACL.
  3154. There is one exception though: if an unauthorized server provides
  3155. substitutes that are @emph{bit-for-bit identical} to those provided by
  3156. an authorized server, then the unauthorized server becomes eligible for
  3157. downloads. For example, assume we have chosen two substitute servers
  3158. with this option:
  3159. @example
  3160. --substitute-urls="https://a.example.org https://b.example.org"
  3161. @end example
  3162. @noindent
  3163. @cindex reproducible builds
  3164. If the ACL contains only the key for @samp{b.example.org}, and if
  3165. @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
  3166. then Guix will download substitutes from @samp{a.example.org} because it
  3167. comes first in the list and can be considered a mirror of
  3168. @samp{b.example.org}. In practice, independent build machines usually
  3169. produce the same binaries, thanks to bit-reproducible builds (see
  3170. below).
  3171. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  3172. (in other words, the server is not authenticated), contrary to what
  3173. HTTPS clients such as Web browsers usually do. This is because Guix
  3174. authenticates substitute information itself, as explained above, which
  3175. is what we care about (whereas X.509 certificates are about
  3176. authenticating bindings between domain names and public keys).
  3177. @node Proxy Settings
  3178. @subsection Proxy Settings
  3179. @vindex http_proxy
  3180. @vindex https_proxy
  3181. Substitutes are downloaded over HTTP or HTTPS@. The @env{http_proxy} and
  3182. @env{https_proxy} environment variables can be set in the environment of
  3183. @command{guix-daemon} and are honored for downloads of substitutes.
  3184. Note that the value of those environment variables in the environment
  3185. where @command{guix build}, @command{guix package}, and other client
  3186. commands are run has @emph{absolutely no effect}.
  3187. @node Substitution Failure
  3188. @subsection Substitution Failure
  3189. Even when a substitute for a derivation is available, sometimes the
  3190. substitution attempt will fail. This can happen for a variety of
  3191. reasons: the substitute server might be offline, the substitute may
  3192. recently have been deleted, the connection might have been interrupted,
  3193. etc.
  3194. When substitutes are enabled and a substitute for a derivation is
  3195. available, but the substitution attempt fails, Guix will attempt to
  3196. build the derivation locally depending on whether or not
  3197. @option{--fallback} was given (@pxref{fallback-option,, common build
  3198. option @option{--fallback}}). Specifically, if @option{--fallback} was
  3199. omitted, then no local build will be performed, and the derivation is
  3200. considered to have failed. However, if @option{--fallback} was given,
  3201. then Guix will attempt to build the derivation locally, and the success
  3202. or failure of the derivation depends on the success or failure of the
  3203. local build. Note that when substitutes are disabled or no substitute
  3204. is available for the derivation in question, a local build will
  3205. @emph{always} be performed, regardless of whether or not
  3206. @option{--fallback} was given.
  3207. To get an idea of how many substitutes are available right now, you can
  3208. try running the @command{guix weather} command (@pxref{Invoking guix
  3209. weather}). This command provides statistics on the substitutes provided
  3210. by a server.
  3211. @node On Trusting Binaries
  3212. @subsection On Trusting Binaries
  3213. @cindex trust, of pre-built binaries
  3214. Today, each individual's control over their own computing is at the
  3215. mercy of institutions, corporations, and groups with enough power and
  3216. determination to subvert the computing infrastructure and exploit its
  3217. weaknesses. While using substitutes can be convenient, we encourage
  3218. users to also build on their own, or even run their own build farm, such
  3219. that the project run substitute servers are less of an interesting
  3220. target. One way to help is by publishing the software you build using
  3221. @command{guix publish} so that others have one more choice of server to
  3222. download substitutes from (@pxref{Invoking guix publish}).
  3223. Guix has the foundations to maximize build reproducibility
  3224. (@pxref{Features}). In most cases, independent builds of a given
  3225. package or derivation should yield bit-identical results. Thus, through
  3226. a diverse set of independent package builds, we can strengthen the
  3227. integrity of our systems. The @command{guix challenge} command aims to
  3228. help users assess substitute servers, and to assist developers in
  3229. finding out about non-deterministic package builds (@pxref{Invoking guix
  3230. challenge}). Similarly, the @option{--check} option of @command{guix
  3231. build} allows users to check whether previously-installed substitutes
  3232. are genuine by rebuilding them locally (@pxref{build-check,
  3233. @command{guix build --check}}).
  3234. In the future, we want Guix to have support to publish and retrieve
  3235. binaries to/from other users, in a peer-to-peer fashion. If you would
  3236. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  3237. @node Packages with Multiple Outputs
  3238. @section Packages with Multiple Outputs
  3239. @cindex multiple-output packages
  3240. @cindex package outputs
  3241. @cindex outputs
  3242. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  3243. source package leads to exactly one directory in the store. When running
  3244. @command{guix install glibc}, one installs the default output of the
  3245. GNU libc package; the default output is called @code{out}, but its name
  3246. can be omitted as shown in this command. In this particular case, the
  3247. default output of @code{glibc} contains all the C header files, shared
  3248. libraries, static libraries, Info documentation, and other supporting
  3249. files.
  3250. Sometimes it is more appropriate to separate the various types of files
  3251. produced from a single source package into separate outputs. For
  3252. instance, the GLib C library (used by GTK+ and related packages)
  3253. installs more than 20 MiB of reference documentation as HTML pages.
  3254. To save space for users who do not need it, the documentation goes to a
  3255. separate output, called @code{doc}. To install the main GLib output,
  3256. which contains everything but the documentation, one would run:
  3257. @example
  3258. guix install glib
  3259. @end example
  3260. @cindex documentation
  3261. The command to install its documentation is:
  3262. @example
  3263. guix install glib:doc
  3264. @end example
  3265. Some packages install programs with different ``dependency footprints''.
  3266. For instance, the WordNet package installs both command-line tools and
  3267. graphical user interfaces (GUIs). The former depend solely on the C
  3268. library, whereas the latter depend on Tcl/Tk and the underlying X
  3269. libraries. In this case, we leave the command-line tools in the default
  3270. output, whereas the GUIs are in a separate output. This allows users
  3271. who do not need the GUIs to save space. The @command{guix size} command
  3272. can help find out about such situations (@pxref{Invoking guix size}).
  3273. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  3274. There are several such multiple-output packages in the GNU distribution.
  3275. Other conventional output names include @code{lib} for libraries and
  3276. possibly header files, @code{bin} for stand-alone programs, and
  3277. @code{debug} for debugging information (@pxref{Installing Debugging
  3278. Files}). The outputs of a packages are listed in the third column of
  3279. the output of @command{guix package --list-available} (@pxref{Invoking
  3280. guix package}).
  3281. @node Invoking guix gc
  3282. @section Invoking @command{guix gc}
  3283. @cindex garbage collector
  3284. @cindex disk space
  3285. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  3286. The @command{guix gc} command allows users to explicitly run the garbage
  3287. collector to reclaim space from the @file{/gnu/store} directory. It is
  3288. the @emph{only} way to remove files from @file{/gnu/store}---removing
  3289. files or directories manually may break it beyond repair!
  3290. @cindex GC roots
  3291. @cindex garbage collector roots
  3292. The garbage collector has a set of known @dfn{roots}: any file under
  3293. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  3294. cannot be deleted; any other file is considered @dfn{dead} and may be
  3295. deleted. The set of garbage collector roots (``GC roots'' for short)
  3296. includes default user profiles; by default, the symlinks under
  3297. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  3298. added with @command{guix build --root}, for example (@pxref{Invoking
  3299. guix build}). The @command{guix gc --list-roots} command lists them.
  3300. Prior to running @code{guix gc --collect-garbage} to make space, it is
  3301. often useful to remove old generations from user profiles; that way, old
  3302. package builds referenced by those generations can be reclaimed. This
  3303. is achieved by running @code{guix package --delete-generations}
  3304. (@pxref{Invoking guix package}).
  3305. Our recommendation is to run a garbage collection periodically, or when
  3306. you are short on disk space. For instance, to guarantee that at least
  3307. 5@tie{}GB are available on your disk, simply run:
  3308. @example
  3309. guix gc -F 5G
  3310. @end example
  3311. It is perfectly safe to run as a non-interactive periodic job
  3312. (@pxref{Scheduled Job Execution}, for how to set up such a job).
  3313. Running @command{guix gc} with no arguments will collect as
  3314. much garbage as it can, but that is often inconvenient: you may find
  3315. yourself having to rebuild or re-download software that is ``dead'' from
  3316. the GC viewpoint but that is necessary to build other pieces of
  3317. software---e.g., the compiler tool chain.
  3318. The @command{guix gc} command has three modes of operation: it can be
  3319. used to garbage-collect any dead files (the default), to delete specific
  3320. files (the @option{--delete} option), to print garbage-collector
  3321. information, or for more advanced queries. The garbage collection
  3322. options are as follows:
  3323. @table @code
  3324. @item --collect-garbage[=@var{min}]
  3325. @itemx -C [@var{min}]
  3326. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  3327. sub-directories. This is the default operation when no option is
  3328. specified.
  3329. When @var{min} is given, stop once @var{min} bytes have been collected.
  3330. @var{min} may be a number of bytes, or it may include a unit as a
  3331. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  3332. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  3333. When @var{min} is omitted, collect all the garbage.
  3334. @item --free-space=@var{free}
  3335. @itemx -F @var{free}
  3336. Collect garbage until @var{free} space is available under
  3337. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  3338. as @code{500MiB}, as described above.
  3339. When @var{free} or more is already available in @file{/gnu/store}, do
  3340. nothing and exit immediately.
  3341. @item --delete-generations[=@var{duration}]
  3342. @itemx -d [@var{duration}]
  3343. Before starting the garbage collection process, delete all the generations
  3344. older than @var{duration}, for all the user profiles; when run as root, this
  3345. applies to all the profiles @emph{of all the users}.
  3346. For example, this command deletes all the generations of all your profiles
  3347. that are older than 2 months (except generations that are current), and then
  3348. proceeds to free space until at least 10 GiB are available:
  3349. @example
  3350. guix gc -d 2m -F 10G
  3351. @end example
  3352. @item --delete
  3353. @itemx -D
  3354. Attempt to delete all the store files and directories specified as
  3355. arguments. This fails if some of the files are not in the store, or if
  3356. they are still live.
  3357. @item --list-failures
  3358. List store items corresponding to cached build failures.
  3359. This prints nothing unless the daemon was started with
  3360. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  3361. @option{--cache-failures}}).
  3362. @item --list-roots
  3363. List the GC roots owned by the user; when run as root, list @emph{all} the GC
  3364. roots.
  3365. @item --list-busy
  3366. List store items in use by currently running processes. These store
  3367. items are effectively considered GC roots: they cannot be deleted.
  3368. @item --clear-failures
  3369. Remove the specified store items from the failed-build cache.
  3370. Again, this option only makes sense when the daemon is started with
  3371. @option{--cache-failures}. Otherwise, it does nothing.
  3372. @item --list-dead
  3373. Show the list of dead files and directories still present in the
  3374. store---i.e., files and directories no longer reachable from any root.
  3375. @item --list-live
  3376. Show the list of live store files and directories.
  3377. @end table
  3378. In addition, the references among existing store files can be queried:
  3379. @table @code
  3380. @item --references
  3381. @itemx --referrers
  3382. @cindex package dependencies
  3383. List the references (respectively, the referrers) of store files given
  3384. as arguments.
  3385. @item --requisites
  3386. @itemx -R
  3387. @cindex closure
  3388. List the requisites of the store files passed as arguments. Requisites
  3389. include the store files themselves, their references, and the references
  3390. of these, recursively. In other words, the returned list is the
  3391. @dfn{transitive closure} of the store files.
  3392. @xref{Invoking guix size}, for a tool to profile the size of the closure
  3393. of an element. @xref{Invoking guix graph}, for a tool to visualize
  3394. the graph of references.
  3395. @item --derivers
  3396. @cindex derivation
  3397. Return the derivation(s) leading to the given store items
  3398. (@pxref{Derivations}).
  3399. For example, this command:
  3400. @example
  3401. guix gc --derivers $(guix package -I ^emacs$ | cut -f4)
  3402. @end example
  3403. @noindent
  3404. returns the @file{.drv} file(s) leading to the @code{emacs} package
  3405. installed in your profile.
  3406. Note that there may be zero matching @file{.drv} files, for instance
  3407. because these files have been garbage-collected. There can also be more
  3408. than one matching @file{.drv} due to fixed-output derivations.
  3409. @end table
  3410. Lastly, the following options allow you to check the integrity of the
  3411. store and to control disk usage.
  3412. @table @option
  3413. @item --verify[=@var{options}]
  3414. @cindex integrity, of the store
  3415. @cindex integrity checking
  3416. Verify the integrity of the store.
  3417. By default, make sure that all the store items marked as valid in the
  3418. database of the daemon actually exist in @file{/gnu/store}.
  3419. When provided, @var{options} must be a comma-separated list containing one
  3420. or more of @code{contents} and @code{repair}.
  3421. When passing @option{--verify=contents}, the daemon computes the
  3422. content hash of each store item and compares it against its hash in the
  3423. database. Hash mismatches are reported as data corruptions. Because it
  3424. traverses @emph{all the files in the store}, this command can take a
  3425. long time, especially on systems with a slow disk drive.
  3426. @cindex repairing the store
  3427. @cindex corruption, recovering from
  3428. Using @option{--verify=repair} or @option{--verify=contents,repair}
  3429. causes the daemon to try to repair corrupt store items by fetching
  3430. substitutes for them (@pxref{Substitutes}). Because repairing is not
  3431. atomic, and thus potentially dangerous, it is available only to the
  3432. system administrator. A lightweight alternative, when you know exactly
  3433. which items in the store are corrupt, is @command{guix build --repair}
  3434. (@pxref{Invoking guix build}).
  3435. @item --optimize
  3436. @cindex deduplication
  3437. Optimize the store by hard-linking identical files---this is
  3438. @dfn{deduplication}.
  3439. The daemon performs deduplication after each successful build or archive
  3440. import, unless it was started with @option{--disable-deduplication}
  3441. (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
  3442. this option is primarily useful when the daemon was running with
  3443. @option{--disable-deduplication}.
  3444. @end table
  3445. @node Invoking guix pull
  3446. @section Invoking @command{guix pull}
  3447. @cindex upgrading Guix
  3448. @cindex updating Guix
  3449. @cindex @command{guix pull}
  3450. @cindex pull
  3451. @cindex security, @command{guix pull}
  3452. @cindex authenticity, of code obtained with @command{guix pull}
  3453. Packages are installed or upgraded to the latest version available in
  3454. the distribution currently available on your local machine. To update
  3455. that distribution, along with the Guix tools, you must run @command{guix
  3456. pull}: the command downloads the latest Guix source code and package
  3457. descriptions, and deploys it. Source code is downloaded from a
  3458. @uref{https://git-scm.com, Git} repository, by default the official
  3459. GNU@tie{}Guix repository, though this can be customized. @command{guix
  3460. pull} ensures that the code it downloads is @emph{authentic} by
  3461. verifying that commits are signed by Guix developers.
  3462. Specifically, @command{guix pull} downloads code from the @dfn{channels}
  3463. (@pxref{Channels}) specified by one of the followings, in this order:
  3464. @enumerate
  3465. @item
  3466. the @option{--channels} option;
  3467. @item
  3468. the user's @file{~/.config/guix/channels.scm} file;
  3469. @item
  3470. the system-wide @file{/etc/guix/channels.scm} file;
  3471. @item
  3472. the built-in default channels specified in the @code{%default-channels}
  3473. variable.
  3474. @end enumerate
  3475. On completion, @command{guix package} will use packages and package
  3476. versions from this just-retrieved copy of Guix. Not only that, but all
  3477. the Guix commands and Scheme modules will also be taken from that latest
  3478. version. New @command{guix} sub-commands added by the update also
  3479. become available.
  3480. Any user can update their Guix copy using @command{guix pull}, and the
  3481. effect is limited to the user who ran @command{guix pull}. For
  3482. instance, when user @code{root} runs @command{guix pull}, this has no
  3483. effect on the version of Guix that user @code{alice} sees, and vice
  3484. versa.
  3485. The result of running @command{guix pull} is a @dfn{profile} available
  3486. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  3487. make sure to add it to the beginning of your search path so that you use
  3488. the latest version, and similarly for the Info manual
  3489. (@pxref{Documentation}):
  3490. @example
  3491. export PATH="$HOME/.config/guix/current/bin:$PATH"
  3492. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  3493. @end example
  3494. The @option{--list-generations} or @option{-l} option lists past generations
  3495. produced by @command{guix pull}, along with details about their provenance:
  3496. @example
  3497. $ guix pull -l
  3498. Generation 1 Jun 10 2018 00:18:18
  3499. guix 65956ad
  3500. repository URL: https://git.savannah.gnu.org/git/guix.git
  3501. branch: origin/master
  3502. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  3503. Generation 2 Jun 11 2018 11:02:49
  3504. guix e0cc7f6
  3505. repository URL: https://git.savannah.gnu.org/git/guix.git
  3506. branch: origin/master
  3507. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  3508. 2 new packages: keepalived, libnfnetlink
  3509. 6 packages upgraded: emacs-nix-mode@@2.0.4,
  3510. guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
  3511. heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
  3512. Generation 3 Jun 13 2018 23:31:07 (current)
  3513. guix 844cc1c
  3514. repository URL: https://git.savannah.gnu.org/git/guix.git
  3515. branch: origin/master
  3516. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  3517. 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
  3518. 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
  3519. @end example
  3520. @xref{Invoking guix describe, @command{guix describe}}, for other ways to
  3521. describe the current status of Guix.
  3522. This @code{~/.config/guix/current} profile works exactly like the profiles
  3523. created by @command{guix package} (@pxref{Invoking guix package}). That
  3524. is, you can list generations, roll back to the previous
  3525. generation---i.e., the previous Guix---and so on:
  3526. @example
  3527. $ guix pull --roll-back
  3528. switched from generation 3 to 2
  3529. $ guix pull --delete-generations=1
  3530. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3531. @end example
  3532. You can also use @command{guix package} (@pxref{Invoking guix package})
  3533. to manage the profile by naming it explicitly:
  3534. @example
  3535. $ guix package -p ~/.config/guix/current --roll-back
  3536. switched from generation 3 to 2
  3537. $ guix package -p ~/.config/guix/current --delete-generations=1
  3538. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3539. @end example
  3540. The @command{guix pull} command is usually invoked with no arguments,
  3541. but it supports the following options:
  3542. @table @code
  3543. @item --url=@var{url}
  3544. @itemx --commit=@var{commit}
  3545. @itemx --branch=@var{branch}
  3546. Download code for the @code{guix} channel from the specified @var{url}, at the
  3547. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3548. string), or @var{branch}.
  3549. @cindex @file{channels.scm}, configuration file
  3550. @cindex configuration file for channels
  3551. These options are provided for convenience, but you can also specify your
  3552. configuration in the @file{~/.config/guix/channels.scm} file or using the
  3553. @option{--channels} option (see below).
  3554. @item --channels=@var{file}
  3555. @itemx -C @var{file}
  3556. Read the list of channels from @var{file} instead of
  3557. @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
  3558. @var{file} must contain Scheme code that
  3559. evaluates to a list of channel objects. @xref{Channels}, for more
  3560. information.
  3561. @cindex channel news
  3562. @item --news
  3563. @itemx -N
  3564. Display the list of packages added or upgraded since the previous
  3565. generation, as well as, occasionally, news written by channel authors
  3566. for their users (@pxref{Channels, Writing Channel News}).
  3567. The package information is the same as displayed upon @command{guix
  3568. pull} completion, but without ellipses; it is also similar to the output
  3569. of @command{guix pull -l} for the last generation (see below).
  3570. @item --list-generations[=@var{pattern}]
  3571. @itemx -l [@var{pattern}]
  3572. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  3573. is provided, the subset of generations that match @var{pattern}.
  3574. The syntax of @var{pattern} is the same as with @code{guix package
  3575. --list-generations} (@pxref{Invoking guix package}).
  3576. @item --roll-back
  3577. @cindex rolling back
  3578. @cindex undoing transactions
  3579. @cindex transactions, undoing
  3580. Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
  3581. undo the last transaction.
  3582. @item --switch-generation=@var{pattern}
  3583. @itemx -S @var{pattern}
  3584. @cindex generations
  3585. Switch to a particular generation defined by @var{pattern}.
  3586. @var{pattern} may be either a generation number or a number prefixed
  3587. with ``+'' or ``-''. The latter means: move forward/backward by a
  3588. specified number of generations. For example, if you want to return to
  3589. the latest generation after @option{--roll-back}, use
  3590. @option{--switch-generation=+1}.
  3591. @item --delete-generations[=@var{pattern}]
  3592. @itemx -d [@var{pattern}]
  3593. When @var{pattern} is omitted, delete all generations except the current
  3594. one.
  3595. This command accepts the same patterns as @option{--list-generations}.
  3596. When @var{pattern} is specified, delete the matching generations. When
  3597. @var{pattern} specifies a duration, generations @emph{older} than the
  3598. specified duration match. For instance, @option{--delete-generations=1m}
  3599. deletes generations that are more than one month old.
  3600. If the current generation matches, it is @emph{not} deleted.
  3601. Note that deleting generations prevents rolling back to them.
  3602. Consequently, this command must be used with care.
  3603. @xref{Invoking guix describe}, for a way to display information about the
  3604. current generation only.
  3605. @item --profile=@var{profile}
  3606. @itemx -p @var{profile}
  3607. Use @var{profile} instead of @file{~/.config/guix/current}.
  3608. @item --dry-run
  3609. @itemx -n
  3610. Show which channel commit(s) would be used and what would be built or
  3611. substituted but do not actually do it.
  3612. @item --allow-downgrades
  3613. Allow pulling older or unrelated revisions of channels than those
  3614. currently in use.
  3615. @cindex downgrade attacks, protection against
  3616. By default, @command{guix pull} protects against so-called ``downgrade
  3617. attacks'' whereby the Git repository of a channel would be reset to an
  3618. earlier or unrelated revision of itself, potentially leading you to
  3619. install older, known-vulnerable versions of software packages.
  3620. @quotation Note
  3621. Make sure you understand its security implications before using
  3622. @option{--allow-downgrades}.
  3623. @end quotation
  3624. @item --disable-authentication
  3625. Allow pulling channel code without authenticating it.
  3626. @cindex authentication, of channel code
  3627. By default, @command{guix pull} authenticates code downloaded from
  3628. channels by verifying that its commits are signed by authorized
  3629. developers, and raises an error if this is not the case. This option
  3630. instructs it to not perform any such verification.
  3631. @quotation Note
  3632. Make sure you understand its security implications before using
  3633. @option{--disable-authentication}.
  3634. @end quotation
  3635. @item --system=@var{system}
  3636. @itemx -s @var{system}
  3637. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  3638. the system type of the build host.
  3639. @item --bootstrap
  3640. Use the bootstrap Guile to build the latest Guix. This option is only
  3641. useful to Guix developers.
  3642. @end table
  3643. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  3644. repository and branch to pull from, as well as @emph{additional} repositories
  3645. containing package modules that should be deployed. @xref{Channels}, for more
  3646. information.
  3647. In addition, @command{guix pull} supports all the common build options
  3648. (@pxref{Common Build Options}).
  3649. @node Invoking guix time-machine
  3650. @section Invoking @command{guix time-machine}
  3651. @cindex @command{guix time-machine}
  3652. @cindex pinning, channels
  3653. @cindex replicating Guix
  3654. @cindex reproducibility, of Guix
  3655. The @command{guix time-machine} command provides access to other
  3656. revisions of Guix, for example to install older versions of packages,
  3657. or to reproduce a computation in an identical environment. The revision
  3658. of Guix to be used is defined by a commit or by a channel
  3659. description file created by @command{guix describe}
  3660. (@pxref{Invoking guix describe}).
  3661. The general syntax is:
  3662. @example
  3663. guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
  3664. @end example
  3665. where @var{command} and @var{arg}@dots{} are passed unmodified to the
  3666. @command{guix} command of the specified revision. The @var{options} that define
  3667. this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
  3668. @table @code
  3669. @item --url=@var{url}
  3670. @itemx --commit=@var{commit}
  3671. @itemx --branch=@var{branch}
  3672. Use the @code{guix} channel from the specified @var{url}, at the
  3673. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3674. string), or @var{branch}.
  3675. @item --channels=@var{file}
  3676. @itemx -C @var{file}
  3677. Read the list of channels from @var{file}. @var{file} must contain
  3678. Scheme code that evaluates to a list of channel objects.
  3679. @xref{Channels} for more information.
  3680. @end table
  3681. As for @command{guix pull}, the absence of any options means that the
  3682. latest commit on the master branch will be used. The command
  3683. @example
  3684. guix time-machine -- build hello
  3685. @end example
  3686. will thus build the package @code{hello} as defined in the master branch,
  3687. which is in general a newer revision of Guix than you have installed.
  3688. Time travel works in both directions!
  3689. Note that @command{guix time-machine} can trigger builds of channels and
  3690. their dependencies, and these are controlled by the standard build
  3691. options (@pxref{Common Build Options}).
  3692. @node Inferiors
  3693. @section Inferiors
  3694. @c TODO: Remove this once we're more confident about API stability.
  3695. @quotation Note
  3696. The functionality described here is a ``technology preview'' as of version
  3697. @value{VERSION}. As such, the interface is subject to change.
  3698. @end quotation
  3699. @cindex inferiors
  3700. @cindex composition of Guix revisions
  3701. Sometimes you might need to mix packages from the revision of Guix you're
  3702. currently running with packages available in a different revision of Guix.
  3703. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  3704. revisions in arbitrary ways.
  3705. @cindex inferior packages
  3706. Technically, an ``inferior'' is essentially a separate Guix process connected
  3707. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  3708. @code{(guix inferior)} module allows you to create inferiors and to
  3709. communicate with them. It also provides a high-level interface to browse and
  3710. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  3711. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  3712. to interact with a separate revision of Guix. For example, let's assume you
  3713. want to install in your profile the current @code{guile} package, along with
  3714. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  3715. because the newer @code{guile-json} has an incompatible API and you want to
  3716. run your code against the old API@. To do that, you could write a manifest for
  3717. use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
  3718. manifest, you would create an inferior for that old Guix revision you care
  3719. about, and you would look up the @code{guile-json} package in the inferior:
  3720. @lisp
  3721. (use-modules (guix inferior) (guix channels)
  3722. (srfi srfi-1)) ;for 'first'
  3723. (define channels
  3724. ;; This is the old revision from which we want to
  3725. ;; extract guile-json.
  3726. (list (channel
  3727. (name 'guix)
  3728. (url "https://git.savannah.gnu.org/git/guix.git")
  3729. (commit
  3730. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  3731. (define inferior
  3732. ;; An inferior representing the above revision.
  3733. (inferior-for-channels channels))
  3734. ;; Now create a manifest with the current "guile" package
  3735. ;; and the old "guile-json" package.
  3736. (packages->manifest
  3737. (list (first (lookup-inferior-packages inferior "guile-json"))
  3738. (specification->package "guile")))
  3739. @end lisp
  3740. On its first run, @command{guix package --manifest} might have to build the
  3741. channel you specified before it can create the inferior; subsequent runs will
  3742. be much faster because the Guix revision will be cached.
  3743. The @code{(guix inferior)} module provides the following procedures to open an
  3744. inferior:
  3745. @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
  3746. [#:cache-directory] [#:ttl]
  3747. Return an inferior for @var{channels}, a list of channels. Use the cache at
  3748. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  3749. This procedure opens a new connection to the build daemon.
  3750. As a side effect, this procedure may build or substitute binaries for
  3751. @var{channels}, which can take time.
  3752. @end deffn
  3753. @deffn {Scheme Procedure} open-inferior @var{directory} @
  3754. [#:command "bin/guix"]
  3755. Open the inferior Guix in @var{directory}, running
  3756. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  3757. the inferior could not be launched.
  3758. @end deffn
  3759. @cindex inferior packages
  3760. The procedures listed below allow you to obtain and manipulate inferior
  3761. packages.
  3762. @deffn {Scheme Procedure} inferior-packages @var{inferior}
  3763. Return the list of packages known to @var{inferior}.
  3764. @end deffn
  3765. @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
  3766. [@var{version}]
  3767. Return the sorted list of inferior packages matching @var{name} in
  3768. @var{inferior}, with highest version numbers first. If @var{version} is true,
  3769. return only packages with a version number prefixed by @var{version}.
  3770. @end deffn
  3771. @deffn {Scheme Procedure} inferior-package? @var{obj}
  3772. Return true if @var{obj} is an inferior package.
  3773. @end deffn
  3774. @deffn {Scheme Procedure} inferior-package-name @var{package}
  3775. @deffnx {Scheme Procedure} inferior-package-version @var{package}
  3776. @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
  3777. @deffnx {Scheme Procedure} inferior-package-description @var{package}
  3778. @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
  3779. @deffnx {Scheme Procedure} inferior-package-location @var{package}
  3780. @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
  3781. @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
  3782. @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
  3783. @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
  3784. @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
  3785. @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
  3786. @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
  3787. These procedures are the counterpart of package record accessors
  3788. (@pxref{package Reference}). Most of them work by querying the inferior
  3789. @var{package} comes from, so the inferior must still be live when you call
  3790. these procedures.
  3791. @end deffn
  3792. Inferior packages can be used transparently like any other package or
  3793. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  3794. transparently handled by the @code{packages->manifest} procedure, which is
  3795. commonly used in manifests (@pxref{Invoking guix package, the
  3796. @option{--manifest} option of @command{guix package}}). Thus you can insert
  3797. an inferior package pretty much anywhere you would insert a regular package:
  3798. in manifests, in the @code{packages} field of your @code{operating-system}
  3799. declaration, and so on.
  3800. @node Invoking guix describe
  3801. @section Invoking @command{guix describe}
  3802. @cindex reproducibility
  3803. @cindex replicating Guix
  3804. Often you may want to answer questions like: ``Which revision of Guix am I
  3805. using?'' or ``Which channels am I using?'' This is useful information in many
  3806. situations: if you want to @emph{replicate} an environment on a different
  3807. machine or user account, if you want to report a bug or to determine what
  3808. change in the channels you are using caused it, or if you want to record your
  3809. system state for reproducibility purposes. The @command{guix describe}
  3810. command answers these questions.
  3811. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  3812. displays the channel(s) that it was built from, including their repository URL
  3813. and commit IDs (@pxref{Channels}):
  3814. @example
  3815. $ guix describe
  3816. Generation 10 Sep 03 2018 17:32:44 (current)
  3817. guix e0fa68c
  3818. repository URL: https://git.savannah.gnu.org/git/guix.git
  3819. branch: master
  3820. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  3821. @end example
  3822. If you're familiar with the Git version control system, this is similar in
  3823. spirit to @command{git describe}; the output is also similar to that of
  3824. @command{guix pull --list-generations}, but limited to the current generation
  3825. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  3826. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  3827. information is all it takes to describe the revision of Guix you're using, and
  3828. also to replicate it.
  3829. To make it easier to replicate Guix, @command{guix describe} can also be asked
  3830. to return a list of channels instead of the human-readable description above:
  3831. @example
  3832. $ guix describe -f channels
  3833. (list (channel
  3834. (name 'guix)
  3835. (url "https://git.savannah.gnu.org/git/guix.git")
  3836. (commit
  3837. "e0fa68c7718fffd33d81af415279d6ddb518f727")
  3838. (introduction
  3839. (make-channel-introduction
  3840. "9edb3f66fd807b096b48283debdcddccfea34bad"
  3841. (openpgp-fingerprint
  3842. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
  3843. @end example
  3844. @noindent
  3845. You can save this to a file and feed it to @command{guix pull -C} on some
  3846. other machine or at a later point in time, which will instantiate @emph{this
  3847. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  3848. From there on, since you're able to deploy the same revision of Guix, you can
  3849. just as well @emph{replicate a complete software environment}. We humbly
  3850. think that this is @emph{awesome}, and we hope you'll like it too!
  3851. The details of the options supported by @command{guix describe} are as
  3852. follows:
  3853. @table @code
  3854. @item --format=@var{format}
  3855. @itemx -f @var{format}
  3856. Produce output in the specified @var{format}, one of:
  3857. @table @code
  3858. @item human
  3859. produce human-readable output;
  3860. @item channels
  3861. produce a list of channel specifications that can be passed to @command{guix
  3862. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  3863. guix pull});
  3864. @item channels-sans-intro
  3865. like @code{channels}, but omit the @code{introduction} field; use it to
  3866. produce a channel specification suitable for Guix version 1.1.0 or
  3867. earlier---the @code{introduction} field has to do with channel
  3868. authentication (@pxref{Channels, Channel Authentication}) and is not
  3869. supported by these older versions;
  3870. @item json
  3871. @cindex JSON
  3872. produce a list of channel specifications in JSON format;
  3873. @item recutils
  3874. produce a list of channel specifications in Recutils format.
  3875. @end table
  3876. @item --list-formats
  3877. Display available formats for @option{--format} option.
  3878. @item --profile=@var{profile}
  3879. @itemx -p @var{profile}
  3880. Display information about @var{profile}.
  3881. @end table
  3882. @node Invoking guix archive
  3883. @section Invoking @command{guix archive}
  3884. @cindex @command{guix archive}
  3885. @cindex archive
  3886. The @command{guix archive} command allows users to @dfn{export} files
  3887. from the store into a single archive, and to later @dfn{import} them on
  3888. a machine that runs Guix.
  3889. In particular, it allows store files to be transferred from one machine
  3890. to the store on another machine.
  3891. @quotation Note
  3892. If you're looking for a way to produce archives in a format suitable for
  3893. tools other than Guix, @pxref{Invoking guix pack}.
  3894. @end quotation
  3895. @cindex exporting store items
  3896. To export store files as an archive to standard output, run:
  3897. @example
  3898. guix archive --export @var{options} @var{specifications}...
  3899. @end example
  3900. @var{specifications} may be either store file names or package
  3901. specifications, as for @command{guix package} (@pxref{Invoking guix
  3902. package}). For instance, the following command creates an archive
  3903. containing the @code{gui} output of the @code{git} package and the main
  3904. output of @code{emacs}:
  3905. @example
  3906. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  3907. @end example
  3908. If the specified packages are not built yet, @command{guix archive}
  3909. automatically builds them. The build process may be controlled with the
  3910. common build options (@pxref{Common Build Options}).
  3911. To transfer the @code{emacs} package to a machine connected over SSH,
  3912. one would run:
  3913. @example
  3914. guix archive --export -r emacs | ssh the-machine guix archive --import
  3915. @end example
  3916. @noindent
  3917. Similarly, a complete user profile may be transferred from one machine
  3918. to another like this:
  3919. @example
  3920. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  3921. ssh the-machine guix archive --import
  3922. @end example
  3923. @noindent
  3924. However, note that, in both examples, all of @code{emacs} and the
  3925. profile as well as all of their dependencies are transferred (due to
  3926. @option{-r}), regardless of what is already available in the store on
  3927. the target machine. The @option{--missing} option can help figure out
  3928. which items are missing from the target store. The @command{guix copy}
  3929. command simplifies and optimizes this whole process, so this is probably
  3930. what you should use in this case (@pxref{Invoking guix copy}).
  3931. @cindex nar, archive format
  3932. @cindex normalized archive (nar)
  3933. @cindex nar bundle, archive format
  3934. Each store item is written in the @dfn{normalized archive} or @dfn{nar}
  3935. format (described below), and the output of @command{guix archive
  3936. --export} (and input of @command{guix archive --import}) is a @dfn{nar
  3937. bundle}.
  3938. The nar format is
  3939. comparable in spirit to `tar', but with differences
  3940. that make it more appropriate for our purposes. First, rather than
  3941. recording all Unix metadata for each file, the nar format only mentions
  3942. the file type (regular, directory, or symbolic link); Unix permissions
  3943. and owner/group are dismissed. Second, the order in which directory
  3944. entries are stored always follows the order of file names according to
  3945. the C locale collation order. This makes archive production fully
  3946. deterministic.
  3947. That nar bundle format is essentially the concatenation of zero or more
  3948. nars along with metadata for each store item it contains: its file name,
  3949. references, corresponding derivation, and a digital signature.
  3950. When exporting, the daemon digitally signs the contents of the archive,
  3951. and that digital signature is appended. When importing, the daemon
  3952. verifies the signature and rejects the import in case of an invalid
  3953. signature or if the signing key is not authorized.
  3954. @c FIXME: Add xref to daemon doc about signatures.
  3955. The main options are:
  3956. @table @code
  3957. @item --export
  3958. Export the specified store files or packages (see below). Write the
  3959. resulting archive to the standard output.
  3960. Dependencies are @emph{not} included in the output, unless
  3961. @option{--recursive} is passed.
  3962. @item -r
  3963. @itemx --recursive
  3964. When combined with @option{--export}, this instructs @command{guix archive}
  3965. to include dependencies of the given items in the archive. Thus, the
  3966. resulting archive is self-contained: it contains the closure of the
  3967. exported store items.
  3968. @item --import
  3969. Read an archive from the standard input, and import the files listed
  3970. therein into the store. Abort if the archive has an invalid digital
  3971. signature, or if it is signed by a public key not among the authorized
  3972. keys (see @option{--authorize} below).
  3973. @item --missing
  3974. Read a list of store file names from the standard input, one per line,
  3975. and write on the standard output the subset of these files missing from
  3976. the store.
  3977. @item --generate-key[=@var{parameters}]
  3978. @cindex signing, archives
  3979. Generate a new key pair for the daemon. This is a prerequisite before
  3980. archives can be exported with @option{--export}. This
  3981. operation is usually instantaneous but it can take time if the system's
  3982. entropy pool needs to be refilled. On Guix System,
  3983. @code{guix-service-type} takes care of generating this key pair the
  3984. first boot.
  3985. The generated key pair is typically stored under @file{/etc/guix}, in
  3986. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  3987. key, which must be kept secret). When @var{parameters} is omitted,
  3988. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  3989. versions before 1.6.0, it is a 4096-bit RSA key.
  3990. Alternatively, @var{parameters} can specify
  3991. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  3992. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  3993. Libgcrypt Reference Manual}).
  3994. @item --authorize
  3995. @cindex authorizing, archives
  3996. Authorize imports signed by the public key passed on standard input.
  3997. The public key must be in ``s-expression advanced format''---i.e., the
  3998. same format as the @file{signing-key.pub} file.
  3999. The list of authorized keys is kept in the human-editable file
  4000. @file{/etc/guix/acl}. The file contains
  4001. @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  4002. s-expressions''} and is structured as an access-control list in the
  4003. @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  4004. (SPKI)}.
  4005. @item --extract=@var{directory}
  4006. @itemx -x @var{directory}
  4007. Read a single-item archive as served by substitute servers
  4008. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  4009. low-level operation needed in only very narrow use cases; see below.
  4010. For example, the following command extracts the substitute for Emacs
  4011. served by @code{@value{SUBSTITUTE-SERVER-1}} to @file{/tmp/emacs}:
  4012. @example
  4013. $ wget -O - \
  4014. https://@value{SUBSTITUTE-SERVER-1}/nar/gzip/@dots{}-emacs-24.5 \
  4015. | gunzip | guix archive -x /tmp/emacs
  4016. @end example
  4017. Single-item archives are different from multiple-item archives produced
  4018. by @command{guix archive --export}; they contain a single store item,
  4019. and they do @emph{not} embed a signature. Thus this operation does
  4020. @emph{no} signature verification and its output should be considered
  4021. unsafe.
  4022. The primary purpose of this operation is to facilitate inspection of
  4023. archive contents coming from possibly untrusted substitute servers
  4024. (@pxref{Invoking guix challenge}).
  4025. @item --list
  4026. @itemx -t
  4027. Read a single-item archive as served by substitute servers
  4028. (@pxref{Substitutes}) and print the list of files it contains, as in
  4029. this example:
  4030. @example
  4031. $ wget -O - \
  4032. https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-emacs-26.3 \
  4033. | lzip -d | guix archive -t
  4034. @end example
  4035. @end table
  4036. @c *********************************************************************
  4037. @node Channels
  4038. @chapter Channels
  4039. @cindex channels
  4040. @cindex @file{channels.scm}, configuration file
  4041. @cindex configuration file for channels
  4042. @cindex @command{guix pull}, configuration file
  4043. @cindex configuration of @command{guix pull}
  4044. Guix and its package collection are updated by running @command{guix pull}
  4045. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  4046. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  4047. customized by defining @dfn{channels} in the
  4048. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  4049. of a Git repository to be deployed, and @command{guix pull} can be instructed
  4050. to pull from one or more channels. In other words, channels can be used
  4051. to @emph{customize} and to @emph{extend} Guix, as we will see below.
  4052. Guix is able to take into account security concerns and deal with authenticated
  4053. updates.
  4054. @menu
  4055. * Specifying Additional Channels:: Extending the package collection.
  4056. * Using a Custom Guix Channel:: Using a customized Guix.
  4057. * Replicating Guix:: Running the @emph{exact same} Guix.
  4058. * Channel Authentication:: How Guix verifies what it fetches.
  4059. * Channels with Substitutes:: Using channels with available substitutes.
  4060. * Creating a Channel:: How to write your custom channel.
  4061. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  4062. * Declaring Channel Dependencies:: How to depend on other channels.
  4063. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  4064. * Primary URL:: Distinguishing mirror to original.
  4065. * Writing Channel News:: Communicating information to channel's users.
  4066. @end menu
  4067. @node Specifying Additional Channels
  4068. @section Specifying Additional Channels
  4069. @cindex extending the package collection (channels)
  4070. @cindex variant packages (channels)
  4071. You can specify @emph{additional channels} to pull from. To use a channel, write
  4072. @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
  4073. @emph{in addition} to the default Guix channel(s):
  4074. @vindex %default-channels
  4075. @lisp
  4076. ;; Add variant packages to those Guix provides.
  4077. (cons (channel
  4078. (name 'variant-packages)
  4079. (url "https://example.org/variant-packages.git"))
  4080. %default-channels)
  4081. @end lisp
  4082. @noindent
  4083. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  4084. add a channel the list of channels that the variable @code{%default-channels}
  4085. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  4086. Manual}). With this file in place, @command{guix pull} builds not only Guix
  4087. but also the package modules from your own repository. The result in
  4088. @file{~/.config/guix/current} is the union of Guix with your own package
  4089. modules:
  4090. @example
  4091. $ guix pull --list-generations
  4092. @dots{}
  4093. Generation 19 Aug 27 2018 16:20:48
  4094. guix d894ab8
  4095. repository URL: https://git.savannah.gnu.org/git/guix.git
  4096. branch: master
  4097. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  4098. variant-packages dd3df5e
  4099. repository URL: https://example.org/variant-packages.git
  4100. branch: master
  4101. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  4102. 11 new packages: variant-gimp, variant-emacs-with-cool-features, @dots{}
  4103. 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
  4104. @end example
  4105. @noindent
  4106. The output of @command{guix pull} above shows that Generation@tie{}19 includes
  4107. both Guix and packages from the @code{variant-personal-packages} channel. Among
  4108. the new and upgraded packages that are listed, some like @code{variant-gimp} and
  4109. @code{variant-emacs-with-cool-features} might come from
  4110. @code{variant-packages}, while others come from the Guix default channel.
  4111. @node Using a Custom Guix Channel
  4112. @section Using a Custom Guix Channel
  4113. The channel called @code{guix} specifies where Guix itself---its command-line
  4114. tools as well as its package collection---should be downloaded. For instance,
  4115. suppose you want to update from another copy of the Guix repository at
  4116. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  4117. write in @code{~/.config/guix/channels.scm} this specification:
  4118. @lisp
  4119. ;; Tell 'guix pull' to use another repo.
  4120. (list (channel
  4121. (name 'guix)
  4122. (url "https://example.org/another-guix.git")
  4123. (branch "super-hacks")))
  4124. @end lisp
  4125. @noindent
  4126. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  4127. branch of the repository at @code{example.org}. The authentication concern is
  4128. addressed below ((@pxref{Channel Authentication}).
  4129. @node Replicating Guix
  4130. @section Replicating Guix
  4131. @cindex pinning, channels
  4132. @cindex replicating Guix
  4133. @cindex reproducibility, of Guix
  4134. The @command{guix pull --list-generations} output above shows precisely which
  4135. commits were used to build this instance of Guix. We can thus replicate it,
  4136. say, on another machine, by providing a channel specification in
  4137. @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
  4138. @lisp
  4139. ;; Deploy specific commits of my channels of interest.
  4140. (list (channel
  4141. (name 'guix)
  4142. (url "https://git.savannah.gnu.org/git/guix.git")
  4143. (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
  4144. (channel
  4145. (name 'variant-packages)
  4146. (url "https://example.org/variant-packages.git")
  4147. (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  4148. @end lisp
  4149. The @command{guix describe --format=channels} command can even generate this
  4150. list of channels directly (@pxref{Invoking guix describe}). The resulting
  4151. file can be used with the -C options of @command{guix pull}
  4152. (@pxref{Invoking guix pull}) or @command{guix time-machine}
  4153. (@pxref{Invoking guix time-machine}).
  4154. At this point the two machines run the @emph{exact same Guix}, with access to
  4155. the @emph{exact same packages}. The output of @command{guix build gimp} on
  4156. one machine will be exactly the same, bit for bit, as the output of the same
  4157. command on the other machine. It also means both machines have access to all
  4158. the source code of Guix and, transitively, to all the source code of every
  4159. package it defines.
  4160. This gives you super powers, allowing you to track the provenance of binary
  4161. artifacts with very fine grain, and to reproduce software environments at
  4162. will---some sort of ``meta reproducibility'' capabilities, if you will.
  4163. @xref{Inferiors}, for another way to take advantage of these super powers.
  4164. @node Channel Authentication
  4165. @section Channel Authentication
  4166. @anchor{channel-authentication}
  4167. @cindex authentication, of channel code
  4168. The @command{guix pull} and @command{guix time-machine} commands
  4169. @dfn{authenticate} the code retrieved from channels: they make sure each
  4170. commit that is fetched is signed by an authorized developer. The goal
  4171. is to protect from unauthorized modifications to the channel that would
  4172. lead users to run malicious code.
  4173. As a user, you must provide a @dfn{channel introduction} in your
  4174. channels file so that Guix knows how to authenticate its first commit.
  4175. A channel specification, including its introduction, looks something
  4176. along these lines:
  4177. @lisp
  4178. (channel
  4179. (name 'some-channel)
  4180. (url "https://example.org/some-channel.git")
  4181. (introduction
  4182. (make-channel-introduction
  4183. "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
  4184. (openpgp-fingerprint
  4185. "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4186. @end lisp
  4187. The specification above shows the name and URL of the channel. The call
  4188. to @code{make-channel-introduction} above specifies that authentication
  4189. of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
  4190. by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
  4191. For the main channel, called @code{guix}, you automatically get that
  4192. information from your Guix installation. For other channels, include
  4193. the channel introduction provided by the channel authors in your
  4194. @file{channels.scm} file. Make sure you retrieve the channel
  4195. introduction from a trusted source since that is the root of your trust.
  4196. If you're curious about the authentication mechanics, read on!
  4197. @node Channels with Substitutes
  4198. @section Channels with Substitutes
  4199. When running @command{guix pull}, Guix will first compile the
  4200. definitions of every available package. This is an expensive operation
  4201. for which substitutes (@pxref{Substitutes}) may be available. The
  4202. following snippet in @file{channels.scm} will ensure that @command{guix
  4203. pull} uses the latest commit with available substitutes for the package
  4204. definitions: this is done by querying the continuous integration
  4205. server at @url{https://ci.guix.gnu.org}.
  4206. @lisp
  4207. (use-modules (guix ci))
  4208. (list (channel-with-substitutes-available
  4209. %default-guix-channel
  4210. "https://ci.guix.gnu.org"))
  4211. @end lisp
  4212. Note that this does not mean that all the packages that you will
  4213. install after running @command{guix pull} will have available
  4214. substitutes. It only ensures that @command{guix pull} will not try to
  4215. compile package definitions. This is particularly useful when using
  4216. machines with limited resources.
  4217. @node Creating a Channel
  4218. @section Creating a Channel
  4219. @cindex personal packages (channels)
  4220. @cindex channels, for personal packages
  4221. Let's say you have a bunch of custom package variants or personal packages
  4222. that you think would make little sense to contribute to the Guix project, but
  4223. would like to have these packages transparently available to you at the
  4224. command line. You would first write modules containing those package
  4225. definitions (@pxref{Package Modules}), maintain them in a Git repository, and
  4226. then you and anyone else can use it as an additional channel to get packages
  4227. from. Neat, no?
  4228. @c What follows stems from discussions at
  4229. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  4230. @c earlier discussions on guix-devel@gnu.org.
  4231. @quotation Warning
  4232. Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
  4233. publish your personal channel to the world, we would like to share a few words
  4234. of caution:
  4235. @itemize
  4236. @item
  4237. Before publishing a channel, please consider contributing your package
  4238. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  4239. to free software of all sorts, and packages in Guix proper are readily
  4240. available to all Guix users and benefit from the project's quality assurance
  4241. process.
  4242. @item
  4243. When you maintain package definitions outside Guix, we, Guix developers,
  4244. consider that @emph{the compatibility burden is on you}. Remember that
  4245. package modules and package definitions are just Scheme code that uses various
  4246. programming interfaces (APIs). We want to remain free to change these APIs to
  4247. keep improving Guix, possibly in ways that break your channel. We never
  4248. change APIs gratuitously, but we will @emph{not} commit to freezing APIs
  4249. either.
  4250. @item
  4251. Corollary: if you're using an external channel and that channel breaks, please
  4252. @emph{report the issue to the channel authors}, not to the Guix project.
  4253. @end itemize
  4254. You've been warned! Having said this, we believe external channels are a
  4255. practical way to exert your freedom to augment Guix' package collection and to
  4256. share your improvements, which are basic tenets of
  4257. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  4258. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  4259. @end quotation
  4260. To create a channel, create a Git repository containing your own package
  4261. modules and make it available. The repository can contain anything, but a
  4262. useful channel will contain Guile modules that export packages. Once you
  4263. start using a channel, Guix will behave as if the root directory of that
  4264. channel's Git repository has been added to the Guile load path (@pxref{Load
  4265. Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
  4266. contains a file at @file{my-packages/my-tools.scm} that defines a Guile
  4267. module, then the module will be available under the name @code{(my-packages
  4268. my-tools)}, and you will be able to use it like any other module
  4269. (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
  4270. As a channel author, consider bundling authentication material with your
  4271. channel so that users can authenticate it. @xref{Channel
  4272. Authentication}, and @ref{Specifying Channel Authorizations}, for info
  4273. on how to do it.
  4274. @node Package Modules in a Sub-directory
  4275. @section Package Modules in a Sub-directory
  4276. @cindex subdirectory, channels
  4277. As a channel author, you may want to keep your channel modules in a
  4278. sub-directory. If your modules are in the sub-directory @file{guix}, you must
  4279. add a meta-data file @file{.guix-channel} that contains:
  4280. @lisp
  4281. (channel
  4282. (version 0)
  4283. (directory "guix"))
  4284. @end lisp
  4285. @node Declaring Channel Dependencies
  4286. @section Declaring Channel Dependencies
  4287. @cindex dependencies, channels
  4288. @cindex meta-data, channels
  4289. Channel authors may decide to augment a package collection provided by other
  4290. channels. They can declare their channel to be dependent on other channels in
  4291. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  4292. the channel repository.
  4293. The meta-data file should contain a simple S-expression like this:
  4294. @lisp
  4295. (channel
  4296. (version 0)
  4297. (dependencies
  4298. (channel
  4299. (name some-collection)
  4300. (url "https://example.org/first-collection.git")
  4301. ;; The 'introduction' bit below is optional: you would
  4302. ;; provide it for dependencies that can be authenticated.
  4303. (introduction
  4304. (channel-introduction
  4305. (version 0)
  4306. (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
  4307. (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4308. (channel
  4309. (name some-other-collection)
  4310. (url "https://example.org/second-collection.git")
  4311. (branch "testing"))))
  4312. @end lisp
  4313. In the above example this channel is declared to depend on two other channels,
  4314. which will both be fetched automatically. The modules provided by the channel
  4315. will be compiled in an environment where the modules of all these declared
  4316. channels are available.
  4317. For the sake of reliability and maintainability, you should avoid dependencies
  4318. on channels that you don't control, and you should aim to keep the number of
  4319. dependencies to a minimum.
  4320. @node Specifying Channel Authorizations
  4321. @section Specifying Channel Authorizations
  4322. @cindex channel authorizations
  4323. @anchor{channel-authorizations}
  4324. As we saw above, Guix ensures the source code it pulls from channels
  4325. comes from authorized developers. As a channel author, you need to
  4326. specify the list of authorized developers in the
  4327. @file{.guix-authorizations} file in the channel's Git repository. The
  4328. authentication rule is simple: each commit must be signed by a key
  4329. listed in the @file{.guix-authorizations} file of its parent
  4330. commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
  4331. (DAG). Each commit can have zero or more parents; ``regular'' commits
  4332. have one parent and merge commits have two parent commits. Read
  4333. @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
  4334. for Computer Scientists}} for a great overview.} The
  4335. @file{.guix-authorizations} file looks like this:
  4336. @lisp
  4337. ;; Example '.guix-authorizations' file.
  4338. (authorizations
  4339. (version 0) ;current file format version
  4340. (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
  4341. (name "alice"))
  4342. ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
  4343. (name "bob"))
  4344. ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
  4345. (name "charlie"))))
  4346. @end lisp
  4347. Each fingerprint is followed by optional key/value pairs, as in the
  4348. example above. Currently these key/value pairs are ignored.
  4349. This authentication rule creates a chicken-and-egg issue: how do we
  4350. authenticate the first commit? Related to that: how do we deal with
  4351. channels whose repository history contains unsigned commits and lack
  4352. @file{.guix-authorizations}? And how do we fork existing channels?
  4353. @cindex channel introduction
  4354. Channel introductions answer these questions by describing the first
  4355. commit of a channel that should be authenticated. The first time a
  4356. channel is fetched with @command{guix pull} or @command{guix
  4357. time-machine}, the command looks up the introductory commit and verifies
  4358. that it is signed by the specified OpenPGP key. From then on, it
  4359. authenticates commits according to the rule above.
  4360. Additionally, your channel must provide all the OpenPGP keys that were
  4361. ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
  4362. files, which can be either binary or ``ASCII-armored''. By default,
  4363. those @file{.key} files are searched for in the branch named
  4364. @code{keyring} but you can specify a different branch name in
  4365. @code{.guix-channel} like so:
  4366. @lisp
  4367. (channel
  4368. (version 0)
  4369. (keyring-reference "my-keyring-branch"))
  4370. @end lisp
  4371. To summarize, as the author of a channel, there are three things you have
  4372. to do to allow users to authenticate your code:
  4373. @enumerate
  4374. @item
  4375. Export the OpenPGP keys of past and present committers with @command{gpg
  4376. --export} and store them in @file{.key} files, by default in a branch
  4377. named @code{keyring} (we recommend making it an @dfn{orphan branch}).
  4378. @item
  4379. Introduce an initial @file{.guix-authorizations} in the channel's
  4380. repository. Do that in a signed commit (@pxref{Commit Access}, for
  4381. information on how to sign Git commits.)
  4382. @item
  4383. Advertise the channel introduction, for instance on your channel's web
  4384. page. The channel introduction, as we saw above, is the commit/key
  4385. pair---i.e., the commit that introduced @file{.guix-authorizations}, and
  4386. the fingerprint of the OpenPGP used to sign it.
  4387. @end enumerate
  4388. Before pushing to your public Git repository, you can run @command{guix
  4389. git-authenticate} to verify that you did sign all the commits you are
  4390. about to push with an authorized key:
  4391. @example
  4392. guix git authenticate @var{commit} @var{signer}
  4393. @end example
  4394. @noindent
  4395. where @var{commit} and @var{signer} are your channel introduction.
  4396. @xref{Invoking guix git authenticate}, for details.
  4397. Publishing a signed channel requires discipline: any mistake, such as an
  4398. unsigned commit or a commit signed by an unauthorized key, will prevent
  4399. users from pulling from your channel---well, that's the whole point of
  4400. authentication! Pay attention to merges in particular: merge commits
  4401. are considered authentic if and only if they are signed by a key present
  4402. in the @file{.guix-authorizations} file of @emph{both} branches.
  4403. @node Primary URL
  4404. @section Primary URL
  4405. @cindex primary URL, channels
  4406. Channel authors can indicate the primary URL of their channel's Git
  4407. repository in the @file{.guix-channel} file, like so:
  4408. @lisp
  4409. (channel
  4410. (version 0)
  4411. (url "https://example.org/guix.git"))
  4412. @end lisp
  4413. This allows @command{guix pull} to determine whether it is pulling code
  4414. from a mirror of the channel; when that is the case, it warns the user
  4415. that the mirror might be stale and displays the primary URL@. That way,
  4416. users cannot be tricked into fetching code from a stale mirror that does
  4417. not receive security updates.
  4418. This feature only makes sense for authenticated repositories, such as
  4419. the official @code{guix} channel, for which @command{guix pull} ensures
  4420. the code it fetches is authentic.
  4421. @node Writing Channel News
  4422. @section Writing Channel News
  4423. @cindex news, for channels
  4424. Channel authors may occasionally want to communicate to their users
  4425. information about important changes in the channel. You'd send them all
  4426. an email, but that's not convenient.
  4427. Instead, channels can provide a @dfn{news file}; when the channel users
  4428. run @command{guix pull}, that news file is automatically read and
  4429. @command{guix pull --news} can display the announcements that correspond
  4430. to the new commits that have been pulled, if any.
  4431. To do that, channel authors must first declare the name of the news file
  4432. in their @file{.guix-channel} file:
  4433. @lisp
  4434. (channel
  4435. (version 0)
  4436. (news-file "etc/news.txt"))
  4437. @end lisp
  4438. The news file itself, @file{etc/news.txt} in this example, must look
  4439. something like this:
  4440. @lisp
  4441. (channel-news
  4442. (version 0)
  4443. (entry (tag "the-bug-fix")
  4444. (title (en "Fixed terrible bug")
  4445. (fr "Oh la la"))
  4446. (body (en "@@emph@{Good news@}! It's fixed!")
  4447. (eo "Certe ĝi pli bone funkcias nun!")))
  4448. (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
  4449. (title (en "Added a great package")
  4450. (ca "Què vol dir guix?"))
  4451. (body (en "Don't miss the @@code@{hello@} package!"))))
  4452. @end lisp
  4453. While the news file is using the Scheme syntax, avoid naming it with a
  4454. @file{.scm} extension or else it will get picked up when building the
  4455. channel and yield an error since it is not a valid module.
  4456. Alternatively, you can move the channel module to a subdirectory and
  4457. store the news file in another directory.
  4458. The file consists of a list of @dfn{news entries}. Each entry is
  4459. associated with a commit or tag: it describes changes made in this
  4460. commit, possibly in preceding commits as well. Users see entries only
  4461. the first time they obtain the commit the entry refers to.
  4462. The @code{title} field should be a one-line summary while @code{body}
  4463. can be arbitrarily long, and both can contain Texinfo markup
  4464. (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
  4465. a list of language tag/message tuples, which allows @command{guix pull}
  4466. to display news in the language that corresponds to the user's locale.
  4467. If you want to translate news using a gettext-based workflow, you can
  4468. extract translatable strings with @command{xgettext} (@pxref{xgettext
  4469. Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
  4470. you write news entries in English first, the command below creates a PO
  4471. file containing the strings to translate:
  4472. @example
  4473. xgettext -o news.po -l scheme -ken etc/news.txt
  4474. @end example
  4475. To sum up, yes, you could use your channel as a blog. But beware, this
  4476. is @emph{not quite} what your users might expect.
  4477. @c *********************************************************************
  4478. @node Development
  4479. @chapter Development
  4480. @cindex software development
  4481. If you are a software developer, Guix provides tools that you should find
  4482. helpful---independently of the language you're developing in. This is what
  4483. this chapter is about.
  4484. The @command{guix environment} command provides a convenient way to set up
  4485. @dfn{development environments} containing all the dependencies and tools
  4486. necessary to work on the software package of your choice. The @command{guix
  4487. pack} command allows you to create @dfn{application bundles} that can be
  4488. easily distributed to users who do not run Guix.
  4489. @menu
  4490. * Invoking guix environment:: Setting up development environments.
  4491. * Invoking guix pack:: Creating software bundles.
  4492. * The GCC toolchain:: Working with languages supported by GCC.
  4493. * Invoking guix git authenticate:: Authenticating Git repositories.
  4494. @end menu
  4495. @node Invoking guix environment
  4496. @section Invoking @command{guix environment}
  4497. @cindex reproducible build environments
  4498. @cindex development environments
  4499. @cindex @command{guix environment}
  4500. @cindex environment, package build environment
  4501. The purpose of @command{guix environment} is to assist hackers in
  4502. creating reproducible development environments without polluting their
  4503. package profile. The @command{guix environment} tool takes one or more
  4504. packages, builds all of their inputs, and creates a shell
  4505. environment to use them.
  4506. The general syntax is:
  4507. @example
  4508. guix environment @var{options} @var{package}@dots{}
  4509. @end example
  4510. The following example spawns a new shell set up for the development of
  4511. GNU@tie{}Guile:
  4512. @example
  4513. guix environment guile
  4514. @end example
  4515. If the needed dependencies are not built yet, @command{guix environment}
  4516. automatically builds them. The environment of the new shell is an
  4517. augmented version of the environment that @command{guix environment} was
  4518. run in. It contains the necessary search paths for building the given
  4519. package added to the existing environment variables. To create
  4520. a ``pure'' environment, in which the original environment variables have
  4521. been unset, use the @option{--pure} option@footnote{Users sometimes
  4522. wrongfully augment environment variables such as @env{PATH} in their
  4523. @file{~/.bashrc} file. As a consequence, when @command{guix
  4524. environment} launches it, Bash may read @file{~/.bashrc}, thereby
  4525. introducing ``impurities'' in these environment variables. It is an
  4526. error to define such environment variables in @file{.bashrc}; instead,
  4527. they should be defined in @file{.bash_profile}, which is sourced only by
  4528. log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
  4529. Manual}, for details on Bash start-up files.}.
  4530. Exiting from a Guix environment is the same as exiting from the shell,
  4531. and will place the user back in the old environment before @command{guix
  4532. environment} was invoked. The next garbage collection (@pxref{Invoking
  4533. guix gc}) will clean up packages that were installed from within the
  4534. environment and are no longer used outside of it.
  4535. @vindex GUIX_ENVIRONMENT
  4536. @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
  4537. variable in the shell it spawns; its value is the file name of the
  4538. profile of this environment. This allows users to, say, define a
  4539. specific prompt for development environments in their @file{.bashrc}
  4540. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4541. @example
  4542. if [ -n "$GUIX_ENVIRONMENT" ]
  4543. then
  4544. export PS1="\u@@\h \w [dev]\$ "
  4545. fi
  4546. @end example
  4547. @noindent
  4548. ...@: or to browse the profile:
  4549. @example
  4550. $ ls "$GUIX_ENVIRONMENT/bin"
  4551. @end example
  4552. Additionally, more than one package may be specified, in which case the
  4553. union of the inputs for the given packages are used. For example, the
  4554. command below spawns a shell where all of the dependencies of both Guile
  4555. and Emacs are available:
  4556. @example
  4557. guix environment guile emacs
  4558. @end example
  4559. Sometimes an interactive shell session is not desired. An arbitrary
  4560. command may be invoked by placing the @code{--} token to separate the
  4561. command from the rest of the arguments:
  4562. @example
  4563. guix environment guile -- make -j4
  4564. @end example
  4565. In other situations, it is more convenient to specify the list of
  4566. packages needed in the environment. For example, the following command
  4567. runs @command{python} from an environment containing Python@tie{}3 and
  4568. NumPy:
  4569. @example
  4570. guix environment --ad-hoc python-numpy python -- python3
  4571. @end example
  4572. Furthermore, one might want the dependencies of a package and also some
  4573. additional packages that are not build-time or runtime dependencies, but
  4574. are useful when developing nonetheless. Because of this, the
  4575. @option{--ad-hoc} flag is positional. Packages appearing before
  4576. @option{--ad-hoc} are interpreted as packages whose dependencies will be
  4577. added to the environment. Packages appearing after are interpreted as
  4578. packages that will be added to the environment directly. For example,
  4579. the following command creates a Guix development environment that
  4580. additionally includes Git and strace:
  4581. @example
  4582. guix environment --pure guix --ad-hoc git strace
  4583. @end example
  4584. @cindex container
  4585. Sometimes it is desirable to isolate the environment as much as
  4586. possible, for maximal purity and reproducibility. In particular, when
  4587. using Guix on a host distro that is not Guix System, it is desirable to
  4588. prevent access to @file{/usr/bin} and other system-wide resources from
  4589. the development environment. For example, the following command spawns
  4590. a Guile REPL in a ``container'' where only the store and the current
  4591. working directory are mounted:
  4592. @example
  4593. guix environment --ad-hoc --container guile -- guile
  4594. @end example
  4595. @quotation Note
  4596. The @option{--container} option requires Linux-libre 3.19 or newer.
  4597. @end quotation
  4598. @cindex certificates
  4599. Another typical use case for containers is to run security-sensitive
  4600. applications such as a web browser. To run Eolie, we must expose and
  4601. share some files and directories; we include @code{nss-certs} and expose
  4602. @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
  4603. @env{DISPLAY} environment variable since containerized graphical
  4604. applications won't display without it.
  4605. @example
  4606. guix environment --preserve='^DISPLAY$' --container --network \
  4607. --expose=/etc/machine-id \
  4608. --expose=/etc/ssl/certs/ \
  4609. --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
  4610. --ad-hoc eolie nss-certs dbus -- eolie
  4611. @end example
  4612. The available options are summarized below.
  4613. @table @code
  4614. @item --root=@var{file}
  4615. @itemx -r @var{file}
  4616. @cindex persistent environment
  4617. @cindex garbage collector root, for environments
  4618. Make @var{file} a symlink to the profile for this environment, and
  4619. register it as a garbage collector root.
  4620. This is useful if you want to protect your environment from garbage
  4621. collection, to make it ``persistent''.
  4622. When this option is omitted, the environment is protected from garbage
  4623. collection only for the duration of the @command{guix environment}
  4624. session. This means that next time you recreate the same environment,
  4625. you could have to rebuild or re-download packages. @xref{Invoking guix
  4626. gc}, for more on GC roots.
  4627. @item --expression=@var{expr}
  4628. @itemx -e @var{expr}
  4629. Create an environment for the package or list of packages that
  4630. @var{expr} evaluates to.
  4631. For example, running:
  4632. @example
  4633. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  4634. @end example
  4635. starts a shell with the environment for this specific variant of the
  4636. PETSc package.
  4637. Running:
  4638. @example
  4639. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  4640. @end example
  4641. starts a shell with all the base system packages available.
  4642. The above commands only use the default output of the given packages.
  4643. To select other outputs, two element tuples can be specified:
  4644. @example
  4645. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  4646. @end example
  4647. @item --load=@var{file}
  4648. @itemx -l @var{file}
  4649. Create an environment for the package or list of packages that the code
  4650. within @var{file} evaluates to.
  4651. As an example, @var{file} might contain a definition like this
  4652. (@pxref{Defining Packages}):
  4653. @lisp
  4654. @verbatiminclude environment-gdb.scm
  4655. @end lisp
  4656. @item --manifest=@var{file}
  4657. @itemx -m @var{file}
  4658. Create an environment for the packages contained in the manifest object
  4659. returned by the Scheme code in @var{file}. This option can be repeated
  4660. several times, in which case the manifests are concatenated.
  4661. This is similar to the same-named option in @command{guix package}
  4662. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  4663. manifest files.
  4664. @item --ad-hoc
  4665. Include all specified packages in the resulting environment, as if an
  4666. @i{ad hoc} package were defined with them as inputs. This option is
  4667. useful for quickly creating an environment without having to write a
  4668. package expression to contain the desired inputs.
  4669. For instance, the command:
  4670. @example
  4671. guix environment --ad-hoc guile guile-sdl -- guile
  4672. @end example
  4673. runs @command{guile} in an environment where Guile and Guile-SDL are
  4674. available.
  4675. Note that this example implicitly asks for the default output of
  4676. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  4677. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  4678. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  4679. This option may be composed with the default behavior of @command{guix
  4680. environment}. Packages appearing before @option{--ad-hoc} are
  4681. interpreted as packages whose dependencies will be added to the
  4682. environment, the default behavior. Packages appearing after are
  4683. interpreted as packages that will be added to the environment directly.
  4684. @item --pure
  4685. Unset existing environment variables when building the new environment, except
  4686. those specified with @option{--preserve} (see below). This has the effect of
  4687. creating an environment in which search paths only contain package inputs.
  4688. @item --preserve=@var{regexp}
  4689. @itemx -E @var{regexp}
  4690. When used alongside @option{--pure}, preserve the environment variables
  4691. matching @var{regexp}---in other words, put them on a ``white list'' of
  4692. environment variables that must be preserved. This option can be repeated
  4693. several times.
  4694. @example
  4695. guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
  4696. -- mpirun @dots{}
  4697. @end example
  4698. This example runs @command{mpirun} in a context where the only environment
  4699. variables defined are @env{PATH}, environment variables whose name starts
  4700. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  4701. @env{USER}, etc.).
  4702. @item --search-paths
  4703. Display the environment variable definitions that make up the
  4704. environment.
  4705. @item --system=@var{system}
  4706. @itemx -s @var{system}
  4707. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  4708. @item --container
  4709. @itemx -C
  4710. @cindex container
  4711. Run @var{command} within an isolated container. The current working
  4712. directory outside the container is mapped inside the container.
  4713. Additionally, unless overridden with @option{--user}, a dummy home
  4714. directory is created that matches the current user's home directory, and
  4715. @file{/etc/passwd} is configured accordingly.
  4716. The spawned process runs as the current user outside the container. Inside
  4717. the container, it has the same UID and GID as the current user, unless
  4718. @option{--user} is passed (see below).
  4719. @item --network
  4720. @itemx -N
  4721. For containers, share the network namespace with the host system.
  4722. Containers created without this flag only have access to the loopback
  4723. device.
  4724. @item --link-profile
  4725. @itemx -P
  4726. For containers, link the environment profile to @file{~/.guix-profile}
  4727. within the container and set @code{GUIX_ENVIRONMENT} to that.
  4728. This is equivalent to making @file{~/.guix-profile} a symlink to the
  4729. actual profile within the container.
  4730. Linking will fail and abort the environment if the directory already
  4731. exists, which will certainly be the case if @command{guix environment}
  4732. was invoked in the user's home directory.
  4733. Certain packages are configured to look in @file{~/.guix-profile} for
  4734. configuration files and data;@footnote{For example, the
  4735. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  4736. for additional fonts.} @option{--link-profile} allows these programs to
  4737. behave as expected within the environment.
  4738. @item --user=@var{user}
  4739. @itemx -u @var{user}
  4740. For containers, use the username @var{user} in place of the current
  4741. user. The generated @file{/etc/passwd} entry within the container will
  4742. contain the name @var{user}, the home directory will be
  4743. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  4744. the UID and GID inside the container are 1000. @var{user}
  4745. need not exist on the system.
  4746. Additionally, any shared or exposed path (see @option{--share} and
  4747. @option{--expose} respectively) whose target is within the current user's
  4748. home directory will be remapped relative to @file{/home/USER}; this
  4749. includes the automatic mapping of the current working directory.
  4750. @example
  4751. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  4752. cd $HOME/wd
  4753. guix environment --container --user=foo \
  4754. --expose=$HOME/test \
  4755. --expose=/tmp/target=$HOME/target
  4756. @end example
  4757. While this will limit the leaking of user identity through home paths
  4758. and each of the user fields, this is only one useful component of a
  4759. broader privacy/anonymity solution---not one in and of itself.
  4760. @item --no-cwd
  4761. For containers, the default behavior is to share the current working
  4762. directory with the isolated container and immediately change to that
  4763. directory within the container. If this is undesirable,
  4764. @option{--no-cwd} will cause the current working directory to @emph{not}
  4765. be automatically shared and will change to the user's home directory
  4766. within the container instead. See also @option{--user}.
  4767. @item --expose=@var{source}[=@var{target}]
  4768. @itemx --share=@var{source}[=@var{target}]
  4769. For containers, @option{--expose} (resp. @option{--share}) exposes the
  4770. file system @var{source} from the host system as the read-only
  4771. (resp. writable) file system @var{target} within the container. If
  4772. @var{target} is not specified, @var{source} is used as the target mount
  4773. point in the container.
  4774. The example below spawns a Guile REPL in a container in which the user's
  4775. home directory is accessible read-only via the @file{/exchange}
  4776. directory:
  4777. @example
  4778. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  4779. @end example
  4780. @end table
  4781. @command{guix environment}
  4782. also supports all of the common build options that @command{guix
  4783. build} supports (@pxref{Common Build Options}) as well as package
  4784. transformation options (@pxref{Package Transformation Options}).
  4785. @node Invoking guix pack
  4786. @section Invoking @command{guix pack}
  4787. Occasionally you want to pass software to people who are not (yet!)
  4788. lucky enough to be using Guix. You'd tell them to run @command{guix
  4789. package -i @var{something}}, but that's not possible in this case. This
  4790. is where @command{guix pack} comes in.
  4791. @quotation Note
  4792. If you are looking for ways to exchange binaries among machines that
  4793. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  4794. publish}, and @ref{Invoking guix archive}.
  4795. @end quotation
  4796. @cindex pack
  4797. @cindex bundle
  4798. @cindex application bundle
  4799. @cindex software bundle
  4800. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  4801. @dfn{software bundle}: it creates a tarball or some other archive
  4802. containing the binaries of the software you're interested in, and all
  4803. its dependencies. The resulting archive can be used on any machine that
  4804. does not have Guix, and people can run the exact same binaries as those
  4805. you have with Guix. The pack itself is created in a bit-reproducible
  4806. fashion, so anyone can verify that it really contains the build results
  4807. that you pretend to be shipping.
  4808. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  4809. their dependencies, you can run:
  4810. @example
  4811. $ guix pack guile emacs emacs-geiser
  4812. @dots{}
  4813. /gnu/store/@dots{}-pack.tar.gz
  4814. @end example
  4815. The result here is a tarball containing a @file{/gnu/store} directory
  4816. with all the relevant packages. The resulting tarball contains a
  4817. @dfn{profile} with the three packages of interest; the profile is the
  4818. same as would be created by @command{guix package -i}. It is this
  4819. mechanism that is used to create Guix's own standalone binary tarball
  4820. (@pxref{Binary Installation}).
  4821. Users of this pack would have to run
  4822. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  4823. find inconvenient. To work around it, you can create, say, a
  4824. @file{/opt/gnu/bin} symlink to the profile:
  4825. @example
  4826. guix pack -S /opt/gnu/bin=bin guile emacs emacs-geiser
  4827. @end example
  4828. @noindent
  4829. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  4830. @cindex relocatable binaries, with @command{guix pack}
  4831. What if the recipient of your pack does not have root privileges on
  4832. their machine, and thus cannot unpack it in the root file system? In
  4833. that case, you will want to use the @option{--relocatable} option (see
  4834. below). This option produces @dfn{relocatable binaries}, meaning they
  4835. they can be placed anywhere in the file system hierarchy: in the example
  4836. above, users can unpack your tarball in their home directory and
  4837. directly run @file{./opt/gnu/bin/guile}.
  4838. @cindex Docker, build an image with guix pack
  4839. Alternatively, you can produce a pack in the Docker image format using
  4840. the following command:
  4841. @example
  4842. guix pack -f docker -S /bin=bin guile guile-readline
  4843. @end example
  4844. @noindent
  4845. The result is a tarball that can be passed to the @command{docker load}
  4846. command, followed by @code{docker run}:
  4847. @example
  4848. docker load < @var{file}
  4849. docker run -ti guile-guile-readline /bin/guile
  4850. @end example
  4851. @noindent
  4852. where @var{file} is the image returned by @var{guix pack}, and
  4853. @code{guile-guile-readline} is its ``image tag''. See the
  4854. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  4855. documentation} for more information.
  4856. @cindex Singularity, build an image with guix pack
  4857. @cindex SquashFS, build an image with guix pack
  4858. Yet another option is to produce a SquashFS image with the following
  4859. command:
  4860. @example
  4861. guix pack -f squashfs bash guile emacs emacs-geiser
  4862. @end example
  4863. @noindent
  4864. The result is a SquashFS file system image that can either be mounted or
  4865. directly be used as a file system container image with the
  4866. @uref{https://www.sylabs.io/docs/, Singularity container execution
  4867. environment}, using commands like @command{singularity shell} or
  4868. @command{singularity exec}.
  4869. Several command-line options allow you to customize your pack:
  4870. @table @code
  4871. @item --format=@var{format}
  4872. @itemx -f @var{format}
  4873. Produce a pack in the given @var{format}.
  4874. The available formats are:
  4875. @table @code
  4876. @item tarball
  4877. This is the default format. It produces a tarball containing all the
  4878. specified binaries and symlinks.
  4879. @item docker
  4880. This produces a tarball that follows the
  4881. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  4882. Docker Image Specification}. The ``repository name'' as it appears in
  4883. the output of the @command{docker images} command is computed from
  4884. package names passed on the command line or in the manifest file.
  4885. @item squashfs
  4886. This produces a SquashFS image containing all the specified binaries and
  4887. symlinks, as well as empty mount points for virtual file systems like
  4888. procfs.
  4889. @quotation Note
  4890. Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
  4891. For that reason, @command{guix pack -f squashfs} always implies @code{-S
  4892. /bin=bin}. Thus, your @command{guix pack} invocation must always start
  4893. with something like:
  4894. @example
  4895. guix pack -f squashfs bash @dots{}
  4896. @end example
  4897. If you forget the @code{bash} (or similar) package, @command{singularity
  4898. run} and @command{singularity exec} will fail with an unhelpful ``no
  4899. such file or directory'' message.
  4900. @end quotation
  4901. @item deb
  4902. This produces a Debian archive (a package with the @samp{.deb} file
  4903. extension) containing all the specified binaries and symbolic links,
  4904. that can be installed on top of any dpkg-based GNU(/Linux) distribution.
  4905. Advanced options can be revealed via the @option{--help-deb-format}
  4906. option. They allow embedding control files for more fine-grained
  4907. control, such as activating specific triggers or providing a maintainer
  4908. configure script to run arbitrary setup code upon installation.
  4909. @example
  4910. guix pack -f deb -C xz -S /usr/bin/hello=bin/hello hello
  4911. @end example
  4912. @quotation Note
  4913. Because archives produced with @command{guix pack} contain a collection
  4914. of store items and because each @command{dpkg} package must not have
  4915. conflicting files, in practice that means you likely won't be able to
  4916. install more than one such archive on a given system.
  4917. @end quotation
  4918. @quotation Warning
  4919. @command{dpkg} will assume ownership of any files contained in the pack
  4920. that it does @emph{not} know about. It is unwise to install
  4921. Guix-produced @samp{.deb} files on a system where @file{/gnu/store} is
  4922. shared by other software, such as a Guix installation or other, non-deb
  4923. packs.
  4924. @end quotation
  4925. @end table
  4926. @cindex relocatable binaries
  4927. @item --relocatable
  4928. @itemx -R
  4929. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  4930. anywhere in the file system hierarchy and run from there.
  4931. When this option is passed once, the resulting binaries require support for
  4932. @dfn{user namespaces} in the kernel Linux; when passed
  4933. @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
  4934. PRoot support, can be thought of as the abbreviation of ``Really
  4935. Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
  4936. other techniques if user namespaces are unavailable, and essentially
  4937. work anywhere---see below for the implications.
  4938. For example, if you create a pack containing Bash with:
  4939. @example
  4940. guix pack -RR -S /mybin=bin bash
  4941. @end example
  4942. @noindent
  4943. ...@: you can copy that pack to a machine that lacks Guix, and from your
  4944. home directory as a normal user, run:
  4945. @example
  4946. tar xf pack.tar.gz
  4947. ./mybin/sh
  4948. @end example
  4949. @noindent
  4950. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  4951. @file{/gnu/store} shows up and contains all the dependencies of
  4952. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  4953. altogether! That is probably the simplest way to deploy Guix-built
  4954. software on a non-Guix machine.
  4955. @quotation Note
  4956. By default, relocatable binaries rely on the @dfn{user namespace} feature of
  4957. the kernel Linux, which allows unprivileged users to mount or change root.
  4958. Old versions of Linux did not support it, and some GNU/Linux distributions
  4959. turn it off.
  4960. To produce relocatable binaries that work even in the absence of user
  4961. namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
  4962. case, binaries will try user namespace support and fall back to another
  4963. @dfn{execution engine} if user namespaces are not supported. The
  4964. following execution engines are supported:
  4965. @table @code
  4966. @item default
  4967. Try user namespaces and fall back to PRoot if user namespaces are not
  4968. supported (see below).
  4969. @item performance
  4970. Try user namespaces and fall back to Fakechroot if user namespaces are
  4971. not supported (see below).
  4972. @item userns
  4973. Run the program through user namespaces and abort if they are not
  4974. supported.
  4975. @item proot
  4976. Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
  4977. provides the necessary
  4978. support for file system virtualization. It achieves that by using the
  4979. @code{ptrace} system call on the running program. This approach has the
  4980. advantage to work without requiring special kernel support, but it incurs
  4981. run-time overhead every time a system call is made.
  4982. @item fakechroot
  4983. Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
  4984. Fakechroot} virtualizes file system accesses by intercepting calls to C
  4985. library functions such as @code{open}, @code{stat}, @code{exec}, and so
  4986. on. Unlike PRoot, it incurs very little overhead. However, it does not
  4987. always work: for example, some file system accesses made from within the
  4988. C library are not intercepted, and file system accesses made @i{via}
  4989. direct syscalls are not intercepted either, leading to erratic behavior.
  4990. @end table
  4991. @vindex GUIX_EXECUTION_ENGINE
  4992. When running a wrapped program, you can explicitly request one of the
  4993. execution engines listed above by setting the
  4994. @env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
  4995. @end quotation
  4996. @cindex entry point, for Docker images
  4997. @item --entry-point=@var{command}
  4998. Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
  4999. format supports it---currently @code{docker} and @code{squashfs} (Singularity)
  5000. support it. @var{command} must be relative to the profile contained in the
  5001. pack.
  5002. The entry point specifies the command that tools like @code{docker run} or
  5003. @code{singularity run} automatically start by default. For example, you can
  5004. do:
  5005. @example
  5006. guix pack -f docker --entry-point=bin/guile guile
  5007. @end example
  5008. The resulting pack can easily be loaded and @code{docker run} with no extra
  5009. arguments will spawn @code{bin/guile}:
  5010. @example
  5011. docker load -i pack.tar.gz
  5012. docker run @var{image-id}
  5013. @end example
  5014. @item --expression=@var{expr}
  5015. @itemx -e @var{expr}
  5016. Consider the package @var{expr} evaluates to.
  5017. This has the same purpose as the same-named option in @command{guix
  5018. build} (@pxref{Additional Build Options, @option{--expression} in
  5019. @command{guix build}}).
  5020. @item --manifest=@var{file}
  5021. @itemx -m @var{file}
  5022. Use the packages contained in the manifest object returned by the Scheme
  5023. code in @var{file}. This option can be repeated several times, in which
  5024. case the manifests are concatenated.
  5025. This has a similar purpose as the same-named option in @command{guix
  5026. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  5027. same manifest files. It allows you to define a collection of packages
  5028. once and use it both for creating profiles and for creating archives
  5029. for use on machines that do not have Guix installed. Note that you can
  5030. specify @emph{either} a manifest file @emph{or} a list of packages,
  5031. but not both.
  5032. @item --system=@var{system}
  5033. @itemx -s @var{system}
  5034. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  5035. the system type of the build host.
  5036. @item --target=@var{triplet}
  5037. @cindex cross-compilation
  5038. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  5039. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  5040. configuration triplets,, autoconf, Autoconf}).
  5041. @item --compression=@var{tool}
  5042. @itemx -C @var{tool}
  5043. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  5044. @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
  5045. compression.
  5046. @item --symlink=@var{spec}
  5047. @itemx -S @var{spec}
  5048. Add the symlinks specified by @var{spec} to the pack. This option can
  5049. appear several times.
  5050. @var{spec} has the form @code{@var{source}=@var{target}}, where
  5051. @var{source} is the symlink that will be created and @var{target} is the
  5052. symlink target.
  5053. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  5054. symlink pointing to the @file{bin} sub-directory of the profile.
  5055. @item --save-provenance
  5056. Save provenance information for the packages passed on the command line.
  5057. Provenance information includes the URL and commit of the channels in use
  5058. (@pxref{Channels}).
  5059. Provenance information is saved in the
  5060. @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
  5061. usual package metadata---the name and version of each package, their
  5062. propagated inputs, and so on. It is useful information to the recipient of
  5063. the pack, who then knows how the pack was (supposedly) obtained.
  5064. This option is not enabled by default because, like timestamps, provenance
  5065. information contributes nothing to the build process. In other words, there
  5066. is an infinity of channel URLs and commit IDs that can lead to the same pack.
  5067. Recording such ``silent'' metadata in the output thus potentially breaks the
  5068. source-to-binary bitwise reproducibility property.
  5069. @item --root=@var{file}
  5070. @itemx -r @var{file}
  5071. @cindex garbage collector root, for packs
  5072. Make @var{file} a symlink to the resulting pack, and register it as a garbage
  5073. collector root.
  5074. @item --localstatedir
  5075. @itemx --profile-name=@var{name}
  5076. Include the ``local state directory'', @file{/var/guix}, in the resulting
  5077. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  5078. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  5079. @file{~root/.guix-profile}.
  5080. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  5081. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  5082. the pack means that the store is ``complete'' and manageable by Guix;
  5083. not providing it pack means that the store is ``dead'': items cannot be
  5084. added to it or removed from it after extraction of the pack.
  5085. One use case for this is the Guix self-contained binary tarball
  5086. (@pxref{Binary Installation}).
  5087. @item --derivation
  5088. @itemx -d
  5089. Print the name of the derivation that builds the pack.
  5090. @item --bootstrap
  5091. Use the bootstrap binaries to build the pack. This option is only
  5092. useful to Guix developers.
  5093. @end table
  5094. In addition, @command{guix pack} supports all the common build options
  5095. (@pxref{Common Build Options}) and all the package transformation
  5096. options (@pxref{Package Transformation Options}).
  5097. @node The GCC toolchain
  5098. @section The GCC toolchain
  5099. @cindex GCC
  5100. @cindex ld-wrapper
  5101. @cindex linker wrapper
  5102. @cindex toolchain, for C development
  5103. @cindex toolchain, for Fortran development
  5104. If you need a complete toolchain for compiling and linking C or C++
  5105. source code, use the @code{gcc-toolchain} package. This package
  5106. provides a complete GCC toolchain for C/C++ development, including GCC
  5107. itself, the GNU C Library (headers and binaries, plus debugging symbols
  5108. in the @code{debug} output), Binutils, and a linker wrapper.
  5109. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  5110. passed to the linker, add corresponding @code{-rpath} arguments, and
  5111. invoke the actual linker with this new set of arguments. You can instruct the
  5112. wrapper to refuse to link against libraries not in the store by setting the
  5113. @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
  5114. The package @code{gfortran-toolchain} provides a complete GCC toolchain
  5115. for Fortran development. For other languages, please use
  5116. @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
  5117. @node Invoking guix git authenticate
  5118. @section Invoking @command{guix git authenticate}
  5119. The @command{guix git authenticate} command authenticates a Git checkout
  5120. following the same rule as for channels (@pxref{channel-authentication,
  5121. channel authentication}). That is, starting from a given commit, it
  5122. ensures that all subsequent commits are signed by an OpenPGP key whose
  5123. fingerprint appears in the @file{.guix-authorizations} file of its
  5124. parent commit(s).
  5125. You will find this command useful if you maintain a channel. But in
  5126. fact, this authentication mechanism is useful in a broader context, so
  5127. you might want to use it for Git repositories that have nothing to do
  5128. with Guix.
  5129. The general syntax is:
  5130. @example
  5131. guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
  5132. @end example
  5133. By default, this command authenticates the Git checkout in the current
  5134. directory; it outputs nothing and exits with exit code zero on success
  5135. and non-zero on failure. @var{commit} above denotes the first commit
  5136. where authentication takes place, and @var{signer} is the OpenPGP
  5137. fingerprint of public key used to sign @var{commit}. Together, they
  5138. form a ``channel introduction'' (@pxref{channel-authentication, channel
  5139. introduction}). The options below allow you to fine-tune the process.
  5140. @table @code
  5141. @item --repository=@var{directory}
  5142. @itemx -r @var{directory}
  5143. Open the Git repository in @var{directory} instead of the current
  5144. directory.
  5145. @item --keyring=@var{reference}
  5146. @itemx -k @var{reference}
  5147. Load OpenPGP keyring from @var{reference}, the reference of a branch
  5148. such as @code{origin/keyring} or @code{my-keyring}. The branch must
  5149. contain OpenPGP public keys in @file{.key} files, either in binary form
  5150. or ``ASCII-armored''. By default the keyring is loaded from the branch
  5151. named @code{keyring}.
  5152. @item --stats
  5153. Display commit signing statistics upon completion.
  5154. @item --cache-key=@var{key}
  5155. Previously-authenticated commits are cached in a file under
  5156. @file{~/.cache/guix/authentication}. This option forces the cache to be
  5157. stored in file @var{key} in that directory.
  5158. @item --historical-authorizations=@var{file}
  5159. By default, any commit whose parent commit(s) lack the
  5160. @file{.guix-authorizations} file is considered inauthentic. In
  5161. contrast, this option considers the authorizations in @var{file} for any
  5162. commit that lacks @file{.guix-authorizations}. The format of @var{file}
  5163. is the same as that of @file{.guix-authorizations}
  5164. (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
  5165. @end table
  5166. @c *********************************************************************
  5167. @node Programming Interface
  5168. @chapter Programming Interface
  5169. GNU Guix provides several Scheme programming interfaces (APIs) to
  5170. define, build, and query packages. The first interface allows users to
  5171. write high-level package definitions. These definitions refer to
  5172. familiar packaging concepts, such as the name and version of a package,
  5173. its build system, and its dependencies. These definitions can then be
  5174. turned into concrete build actions.
  5175. Build actions are performed by the Guix daemon, on behalf of users. In a
  5176. standard setup, the daemon has write access to the store---the
  5177. @file{/gnu/store} directory---whereas users do not. The recommended
  5178. setup also has the daemon perform builds in chroots, under specific
  5179. build users, to minimize interference with the rest of the system.
  5180. @cindex derivation
  5181. Lower-level APIs are available to interact with the daemon and the
  5182. store. To instruct the daemon to perform a build action, users actually
  5183. provide it with a @dfn{derivation}. A derivation is a low-level
  5184. representation of the build actions to be taken, and the environment in
  5185. which they should occur---derivations are to package definitions what
  5186. assembly is to C programs. The term ``derivation'' comes from the fact
  5187. that build results @emph{derive} from them.
  5188. This chapter describes all these APIs in turn, starting from high-level
  5189. package definitions.
  5190. @menu
  5191. * Package Modules:: Packages from the programmer's viewpoint.
  5192. * Defining Packages:: Defining new packages.
  5193. * Defining Package Variants:: Customizing packages.
  5194. * Build Systems:: Specifying how packages are built.
  5195. * Build Phases:: Phases of the build process of a package.
  5196. * Build Utilities:: Helpers for your package definitions and more.
  5197. * The Store:: Manipulating the package store.
  5198. * Derivations:: Low-level interface to package derivations.
  5199. * The Store Monad:: Purely functional interface to the store.
  5200. * G-Expressions:: Manipulating build expressions.
  5201. * Invoking guix repl:: Programming Guix in Guile
  5202. @end menu
  5203. @node Package Modules
  5204. @section Package Modules
  5205. From a programming viewpoint, the package definitions of the
  5206. GNU distribution are provided by Guile modules in the @code{(gnu packages
  5207. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  5208. packages @dots{})} module name space are not necessarily ``GNU
  5209. packages''. This module naming scheme follows the usual Guile module
  5210. naming convention: @code{gnu} means that these modules are distributed
  5211. as part of the GNU system, and @code{packages} identifies modules that
  5212. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  5213. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  5214. module exports a variable named @code{emacs}, which is bound to a
  5215. @code{<package>} object (@pxref{Defining Packages}).
  5216. The @code{(gnu packages @dots{})} module name space is
  5217. automatically scanned for packages by the command-line tools. For
  5218. instance, when running @code{guix install emacs}, all the @code{(gnu
  5219. packages @dots{})} modules are scanned until one that exports a package
  5220. object whose name is @code{emacs} is found. This package search
  5221. facility is implemented in the @code{(gnu packages)} module.
  5222. @cindex customization, of packages
  5223. @cindex package module search path
  5224. Users can store package definitions in modules with different
  5225. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  5226. name and module name must match. For instance, the @code{(my-packages
  5227. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  5228. relative to the load path specified with @option{--load-path} or
  5229. @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  5230. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  5231. these package definitions visible to the user interfaces:
  5232. @enumerate
  5233. @item
  5234. By adding the directory containing your package modules to the search path
  5235. with the @code{-L} flag of @command{guix package} and other commands
  5236. (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
  5237. environment variable described below.
  5238. @item
  5239. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  5240. pulls from it. A channel is essentially a Git repository containing package
  5241. modules. @xref{Channels}, for more information on how to define and use
  5242. channels.
  5243. @end enumerate
  5244. @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  5245. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  5246. This is a colon-separated list of directories to search for additional
  5247. package modules. Directories listed in this variable take precedence
  5248. over the own modules of the distribution.
  5249. @end defvr
  5250. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  5251. each package is built based solely on other packages in the
  5252. distribution. The root of this dependency graph is a small set of
  5253. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  5254. bootstrap)} module. For more information on bootstrapping,
  5255. @pxref{Bootstrapping}.
  5256. @node Defining Packages
  5257. @section Defining Packages
  5258. The high-level interface to package definitions is implemented in the
  5259. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  5260. example, the package definition, or @dfn{recipe}, for the GNU Hello
  5261. package looks like this:
  5262. @lisp
  5263. (define-module (gnu packages hello)
  5264. #:use-module (guix packages)
  5265. #:use-module (guix download)
  5266. #:use-module (guix build-system gnu)
  5267. #:use-module (guix licenses)
  5268. #:use-module (gnu packages gawk))
  5269. (define-public hello
  5270. (package
  5271. (name "hello")
  5272. (version "2.10")
  5273. (source (origin
  5274. (method url-fetch)
  5275. (uri (string-append "mirror://gnu/hello/hello-" version
  5276. ".tar.gz"))
  5277. (sha256
  5278. (base32
  5279. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  5280. (build-system gnu-build-system)
  5281. (arguments '(#:configure-flags '("--enable-silent-rules")))
  5282. (inputs (list gawk))
  5283. (synopsis "Hello, GNU world: An example GNU package")
  5284. (description "Guess what GNU Hello prints!")
  5285. (home-page "https://www.gnu.org/software/hello/")
  5286. (license gpl3+)))
  5287. @end lisp
  5288. @noindent
  5289. Without being a Scheme expert, the reader may have guessed the meaning
  5290. of the various fields here. This expression binds the variable
  5291. @code{hello} to a @code{<package>} object, which is essentially a record
  5292. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  5293. This package object can be inspected using procedures found in the
  5294. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  5295. returns---surprise!---@code{"hello"}.
  5296. With luck, you may be able to import part or all of the definition of
  5297. the package you are interested in from another repository, using the
  5298. @code{guix import} command (@pxref{Invoking guix import}).
  5299. In the example above, @code{hello} is defined in a module of its own,
  5300. @code{(gnu packages hello)}. Technically, this is not strictly
  5301. necessary, but it is convenient to do so: all the packages defined in
  5302. modules under @code{(gnu packages @dots{})} are automatically known to
  5303. the command-line tools (@pxref{Package Modules}).
  5304. There are a few points worth noting in the above package definition:
  5305. @itemize
  5306. @item
  5307. The @code{source} field of the package is an @code{<origin>} object
  5308. (@pxref{origin Reference}, for the complete reference).
  5309. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  5310. meaning that the source is a file to be downloaded over FTP or HTTP.
  5311. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  5312. the GNU mirrors defined in @code{(guix download)}.
  5313. The @code{sha256} field specifies the expected SHA256 hash of the file
  5314. being downloaded. It is mandatory, and allows Guix to check the
  5315. integrity of the file. The @code{(base32 @dots{})} form introduces the
  5316. base32 representation of the hash. You can obtain this information with
  5317. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  5318. hash} (@pxref{Invoking guix hash}).
  5319. @cindex patches
  5320. When needed, the @code{origin} form can also have a @code{patches} field
  5321. listing patches to be applied, and a @code{snippet} field giving a
  5322. Scheme expression to modify the source code.
  5323. @item
  5324. @cindex GNU Build System
  5325. The @code{build-system} field specifies the procedure to build the
  5326. package (@pxref{Build Systems}). Here, @code{gnu-build-system}
  5327. represents the familiar GNU Build System, where packages may be
  5328. configured, built, and installed with the usual @code{./configure &&
  5329. make && make check && make install} command sequence.
  5330. When you start packaging non-trivial software, you may need tools to
  5331. manipulate those build phases, manipulate files, and so on. @xref{Build
  5332. Utilities}, for more on this.
  5333. @item
  5334. The @code{arguments} field specifies options for the build system
  5335. (@pxref{Build Systems}). Here it is interpreted by
  5336. @code{gnu-build-system} as a request run @file{configure} with the
  5337. @option{--enable-silent-rules} flag.
  5338. @cindex quote
  5339. @cindex quoting
  5340. @findex '
  5341. @findex quote
  5342. What about these quote (@code{'}) characters? They are Scheme syntax to
  5343. introduce a literal list; @code{'} is synonymous with @code{quote}.
  5344. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  5345. for details. Here the value of the @code{arguments} field is a list of
  5346. arguments passed to the build system down the road, as with @code{apply}
  5347. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  5348. Manual}).
  5349. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  5350. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  5351. @code{#:configure-flags} is a keyword used to pass a keyword argument
  5352. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  5353. Reference Manual}).
  5354. @item
  5355. The @code{inputs} field specifies inputs to the build process---i.e.,
  5356. build-time or run-time dependencies of the package. Here, we add
  5357. an input, a reference to the @code{gawk}
  5358. variable; @code{gawk} is itself bound to a @code{<package>} object.
  5359. @cindex backquote (quasiquote)
  5360. @findex `
  5361. @findex quasiquote
  5362. @cindex comma (unquote)
  5363. @findex ,
  5364. @findex unquote
  5365. @findex ,@@
  5366. @findex unquote-splicing
  5367. Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
  5368. us to introduce a literal list in the @code{inputs} field, while
  5369. @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
  5370. value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
  5371. Reference Manual}).
  5372. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  5373. be specified as inputs here. Instead, @code{gnu-build-system} takes care
  5374. of ensuring that they are present (@pxref{Build Systems}).
  5375. However, any other dependencies need to be specified in the
  5376. @code{inputs} field. Any dependency not specified here will simply be
  5377. unavailable to the build process, possibly leading to a build failure.
  5378. @end itemize
  5379. @xref{package Reference}, for a full description of possible fields.
  5380. Once a package definition is in place, the
  5381. package may actually be built using the @code{guix build} command-line
  5382. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  5383. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  5384. package definition using the @command{guix edit} command
  5385. (@pxref{Invoking guix edit}).
  5386. @xref{Packaging Guidelines}, for
  5387. more information on how to test package definitions, and
  5388. @ref{Invoking guix lint}, for information on how to check a definition
  5389. for style conformance.
  5390. @vindex GUIX_PACKAGE_PATH
  5391. Lastly, @pxref{Channels}, for information
  5392. on how to extend the distribution by adding your own package definitions
  5393. in a ``channel''.
  5394. Finally, updating the package definition to a new upstream version
  5395. can be partly automated by the @command{guix refresh} command
  5396. (@pxref{Invoking guix refresh}).
  5397. Behind the scenes, a derivation corresponding to the @code{<package>}
  5398. object is first computed by the @code{package-derivation} procedure.
  5399. That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
  5400. The build actions it prescribes may then be realized by using the
  5401. @code{build-derivations} procedure (@pxref{The Store}).
  5402. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  5403. Return the @code{<derivation>} object of @var{package} for @var{system}
  5404. (@pxref{Derivations}).
  5405. @var{package} must be a valid @code{<package>} object, and @var{system}
  5406. must be a string denoting the target system type---e.g.,
  5407. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  5408. must be a connection to the daemon, which operates on the store
  5409. (@pxref{The Store}).
  5410. @end deffn
  5411. @noindent
  5412. @cindex cross-compilation
  5413. Similarly, it is possible to compute a derivation that cross-builds a
  5414. package for some other system:
  5415. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  5416. @var{package} @var{target} [@var{system}]
  5417. Return the @code{<derivation>} object of @var{package} cross-built from
  5418. @var{system} to @var{target}.
  5419. @var{target} must be a valid GNU triplet denoting the target hardware
  5420. and operating system, such as @code{"aarch64-linux-gnu"}
  5421. (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
  5422. @end deffn
  5423. Once you have package definitions, you can easily define @emph{variants}
  5424. of those packages. @xref{Defining Package Variants}, for more on that.
  5425. @menu
  5426. * package Reference:: The package data type.
  5427. * origin Reference:: The origin data type.
  5428. @end menu
  5429. @node package Reference
  5430. @subsection @code{package} Reference
  5431. This section summarizes all the options available in @code{package}
  5432. declarations (@pxref{Defining Packages}).
  5433. @deftp {Data Type} package
  5434. This is the data type representing a package recipe.
  5435. @table @asis
  5436. @item @code{name}
  5437. The name of the package, as a string.
  5438. @item @code{version}
  5439. The version of the package, as a string. @xref{Version Numbers}, for
  5440. guidelines.
  5441. @item @code{source}
  5442. An object telling how the source code for the package should be
  5443. acquired. Most of the time, this is an @code{origin} object, which
  5444. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  5445. can also be any other ``file-like'' object such as a @code{local-file},
  5446. which denotes a file from the local file system (@pxref{G-Expressions,
  5447. @code{local-file}}).
  5448. @item @code{build-system}
  5449. The build system that should be used to build the package (@pxref{Build
  5450. Systems}).
  5451. @item @code{arguments} (default: @code{'()})
  5452. The arguments that should be passed to the build system. This is a
  5453. list, typically containing sequential keyword-value pairs.
  5454. @item @code{inputs} (default: @code{'()})
  5455. @itemx @code{native-inputs} (default: @code{'()})
  5456. @itemx @code{propagated-inputs} (default: @code{'()})
  5457. @cindex inputs, of packages
  5458. These fields list dependencies of the package. Each element of these
  5459. lists is either a package, origin, or other ``file-like object''
  5460. (@pxref{G-Expressions}); to specify the output of that file-like object
  5461. that should be used, pass a two-element list where the second element is
  5462. the output (@pxref{Packages with Multiple Outputs}, for more on package
  5463. outputs). For example, the list below specifies three inputs:
  5464. @lisp
  5465. (list libffi libunistring
  5466. `(,glib "bin")) ;the "bin" output of GLib
  5467. @end lisp
  5468. In the example above, the @code{"out"} output of @code{libffi} and
  5469. @code{libunistring} is used.
  5470. @quotation Compatibility Note
  5471. Until version 1.3.0, input lists were a list of tuples,
  5472. where each tuple has a label for the input (a string) as its
  5473. first element, a package, origin, or derivation as its second element,
  5474. and optionally the name of the output thereof that should be used, which
  5475. defaults to @code{"out"}. For example, the list below is equivalent to
  5476. the one above, but using the @dfn{old input style}:
  5477. @lisp
  5478. ;; Old input style (deprecated).
  5479. `(("libffi" ,libffi)
  5480. ("libunistring" ,libunistring)
  5481. ("glib:bin" ,glib "bin")) ;the "bin" output of GLib
  5482. @end lisp
  5483. This style is now deprecated; it is still supported but support will be
  5484. removed in a future version. It should not be used for new package
  5485. definitions. @xref{Invoking guix style}, on how to migrate to the new
  5486. style.
  5487. @end quotation
  5488. @cindex cross compilation, package dependencies
  5489. The distinction between @code{native-inputs} and @code{inputs} is
  5490. necessary when considering cross-compilation. When cross-compiling,
  5491. dependencies listed in @code{inputs} are built for the @emph{target}
  5492. architecture; conversely, dependencies listed in @code{native-inputs}
  5493. are built for the architecture of the @emph{build} machine.
  5494. @code{native-inputs} is typically used to list tools needed at
  5495. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  5496. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  5497. this area (@pxref{Invoking guix lint}).
  5498. @anchor{package-propagated-inputs}
  5499. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  5500. specified packages will be automatically installed to profiles
  5501. (@pxref{Features, the role of profiles in Guix}) alongside the package
  5502. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  5503. package}}, for information on how @command{guix package} deals with
  5504. propagated inputs).
  5505. For example this is necessary when packaging a C/C++ library that needs
  5506. headers of another library to compile, or when a pkg-config file refers
  5507. to another one @i{via} its @code{Requires} field.
  5508. Another example where @code{propagated-inputs} is useful is for languages
  5509. that lack a facility to record the run-time search path akin to the
  5510. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  5511. more. When packaging libraries written in those languages, ensure they
  5512. can find library code they depend on at run time by listing run-time
  5513. dependencies in @code{propagated-inputs} rather than @code{inputs}.
  5514. @item @code{outputs} (default: @code{'("out")})
  5515. The list of output names of the package. @xref{Packages with Multiple
  5516. Outputs}, for typical uses of additional outputs.
  5517. @item @code{native-search-paths} (default: @code{'()})
  5518. @itemx @code{search-paths} (default: @code{'()})
  5519. A list of @code{search-path-specification} objects describing
  5520. search-path environment variables honored by the package.
  5521. @item @code{replacement} (default: @code{#f})
  5522. This must be either @code{#f} or a package object that will be used as a
  5523. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  5524. for details.
  5525. @item @code{synopsis}
  5526. A one-line description of the package.
  5527. @item @code{description}
  5528. A more elaborate description of the package.
  5529. @item @code{license}
  5530. @cindex license, of packages
  5531. The license of the package; a value from @code{(guix licenses)},
  5532. or a list of such values.
  5533. @item @code{home-page}
  5534. The URL to the home-page of the package, as a string.
  5535. @item @code{supported-systems} (default: @code{%supported-systems})
  5536. The list of systems supported by the package, as strings of the form
  5537. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  5538. @item @code{location} (default: source location of the @code{package} form)
  5539. The source location of the package. It is useful to override this when
  5540. inheriting from another package, in which case this field is not
  5541. automatically corrected.
  5542. @end table
  5543. @end deftp
  5544. @deffn {Scheme Syntax} this-package
  5545. When used in the @emph{lexical scope} of a package field definition, this
  5546. identifier resolves to the package being defined.
  5547. The example below shows how to add a package as a native input of itself when
  5548. cross-compiling:
  5549. @lisp
  5550. (package
  5551. (name "guile")
  5552. ;; ...
  5553. ;; When cross-compiled, Guile, for example, depends on
  5554. ;; a native version of itself. Add it here.
  5555. (native-inputs (if (%current-target-system)
  5556. (list this-package)
  5557. '())))
  5558. @end lisp
  5559. It is an error to refer to @code{this-package} outside a package definition.
  5560. @end deffn
  5561. The following helper procedures are provided to help deal with package
  5562. inputs.
  5563. @deffn {Scheme Procedure} lookup-package-input @var{package} @var{name}
  5564. @deffnx {Scheme Procedure} lookup-package-native-input @var{package} @var{name}
  5565. @deffnx {Scheme Procedure} lookup-package-propagated-input @var{package} @var{name}
  5566. @deffnx {Scheme Procedure} lookup-package-direct-input @var{package} @var{name}
  5567. Look up @var{name} among @var{package}'s inputs (or native, propagated,
  5568. or direct inputs). Return it if found, @code{#f} otherwise.
  5569. @var{name} is the name of a package depended on. Here's how you might
  5570. use it:
  5571. @lisp
  5572. (use-modules (guix packages) (gnu packages base))
  5573. (lookup-package-direct-input coreutils "gmp")
  5574. @result{} #<package gmp@@6.2.1 @dots{}>
  5575. @end lisp
  5576. In this example we obtain the @code{gmp} package that is among the
  5577. direct inputs of @code{coreutils}.
  5578. @end deffn
  5579. Because packages are regular Scheme objects that capture a complete
  5580. dependency graph and associated build procedures, it is often useful to
  5581. write procedures that take a package and return a modified version
  5582. thereof according to some parameters. Below are a few examples.
  5583. @cindex tool chain, choosing a package's tool chain
  5584. @deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain}
  5585. Return a variant of @var{package} that uses @var{toolchain} instead of
  5586. the default GNU C/C++ toolchain. @var{toolchain} must be a list of
  5587. inputs (label/package tuples) providing equivalent functionality, such
  5588. as the @code{gcc-toolchain} package.
  5589. The example below returns a variant of the @code{hello} package built
  5590. with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the
  5591. GNU C Library) instead of the default tool chain:
  5592. @lisp
  5593. (let ((toolchain (specification->package "gcc-toolchain@@10")))
  5594. (package-with-c-toolchain hello `(("toolchain" ,toolchain))))
  5595. @end lisp
  5596. The build tool chain is part of the @dfn{implicit inputs} of
  5597. packages---it's usually not listed as part of the various ``inputs''
  5598. fields and is instead pulled in by the build system. Consequently, this
  5599. procedure works by changing the build system of @var{package} so that it
  5600. pulls in @var{toolchain} instead of the defaults. @ref{Build Systems},
  5601. for more on build systems.
  5602. @end deffn
  5603. @node origin Reference
  5604. @subsection @code{origin} Reference
  5605. This section documents @dfn{origins}. An @code{origin} declaration
  5606. specifies data that must be ``produced''---downloaded, usually---and
  5607. whose content hash is known in advance. Origins are primarily used to
  5608. represent the source code of packages (@pxref{Defining Packages}). For
  5609. that reason, the @code{origin} form allows you to declare patches to
  5610. apply to the original source code as well as code snippets to modify it.
  5611. @deftp {Data Type} origin
  5612. This is the data type representing a source code origin.
  5613. @table @asis
  5614. @item @code{uri}
  5615. An object containing the URI of the source. The object type depends on
  5616. the @code{method} (see below). For example, when using the
  5617. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  5618. values are: a URL represented as a string, or a list thereof.
  5619. @cindex fixed-output derivations, for download
  5620. @item @code{method}
  5621. A monadic procedure that handles the given URI@. The procedure must
  5622. accept at least three arguments: the value of the @code{uri} field and
  5623. the hash algorithm and hash value specified by the @code{hash} field.
  5624. It must return a store item or a derivation in the store monad
  5625. (@pxref{The Store Monad}); most methods return a fixed-output derivation
  5626. (@pxref{Derivations}).
  5627. Commonly used methods include @code{url-fetch}, which fetches data from
  5628. a URL, and @code{git-fetch}, which fetches data from a Git repository
  5629. (see below).
  5630. @item @code{sha256}
  5631. A bytevector containing the SHA-256 hash of the source. This is
  5632. equivalent to providing a @code{content-hash} SHA256 object in the
  5633. @code{hash} field described below.
  5634. @item @code{hash}
  5635. The @code{content-hash} object of the source---see below for how to use
  5636. @code{content-hash}.
  5637. You can obtain this information using @code{guix download}
  5638. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  5639. guix hash}).
  5640. @item @code{file-name} (default: @code{#f})
  5641. The file name under which the source code should be saved. When this is
  5642. @code{#f}, a sensible default value will be used in most cases. In case
  5643. the source is fetched from a URL, the file name from the URL will be
  5644. used. For version control checkouts, it is recommended to provide the
  5645. file name explicitly because the default is not very descriptive.
  5646. @item @code{patches} (default: @code{'()})
  5647. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  5648. file-like objects}) pointing to patches to be applied to the source.
  5649. This list of patches must be unconditional. In particular, it cannot
  5650. depend on the value of @code{%current-system} or
  5651. @code{%current-target-system}.
  5652. @item @code{snippet} (default: @code{#f})
  5653. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  5654. in the source directory. This is a convenient way to modify the source,
  5655. sometimes more convenient than a patch.
  5656. @item @code{patch-flags} (default: @code{'("-p1")})
  5657. A list of command-line flags that should be passed to the @code{patch}
  5658. command.
  5659. @item @code{patch-inputs} (default: @code{#f})
  5660. Input packages or derivations to the patching process. When this is
  5661. @code{#f}, the usual set of inputs necessary for patching are provided,
  5662. such as GNU@tie{}Patch.
  5663. @item @code{modules} (default: @code{'()})
  5664. A list of Guile modules that should be loaded during the patching
  5665. process and while running the code in the @code{snippet} field.
  5666. @item @code{patch-guile} (default: @code{#f})
  5667. The Guile package that should be used in the patching process. When
  5668. this is @code{#f}, a sensible default is used.
  5669. @end table
  5670. @end deftp
  5671. @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
  5672. Construct a content hash object for the given @var{algorithm}, and with
  5673. @var{value} as its hash value. When @var{algorithm} is omitted, assume
  5674. it is @code{sha256}.
  5675. @var{value} can be a literal string, in which case it is base32-decoded,
  5676. or it can be a bytevector.
  5677. The following forms are all equivalent:
  5678. @lisp
  5679. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
  5680. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
  5681. sha256)
  5682. (content-hash (base32
  5683. "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
  5684. (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
  5685. sha256)
  5686. @end lisp
  5687. Technically, @code{content-hash} is currently implemented as a macro.
  5688. It performs sanity checks at macro-expansion time, when possible, such
  5689. as ensuring that @var{value} has the right size for @var{algorithm}.
  5690. @end deftp
  5691. As we have seen above, how exactly the data an origin refers to is
  5692. retrieved is determined by its @code{method} field. The @code{(guix
  5693. download)} module provides the most common method, @code{url-fetch},
  5694. described below.
  5695. @deffn {Scheme Procedure} url-fetch @var{url} @var{hash-algo} @var{hash} @
  5696. [name] [#:executable? #f]
  5697. Return a fixed-output derivation that fetches data from @var{url} (a
  5698. string, or a list of strings denoting alternate URLs), which is expected
  5699. to have hash @var{hash} of type @var{hash-algo} (a symbol). By default,
  5700. the file name is the base name of URL; optionally, @var{name} can
  5701. specify a different file name. When @var{executable?} is true, make the
  5702. downloaded file executable.
  5703. When one of the URL starts with @code{mirror://}, then its host part is
  5704. interpreted as the name of a mirror scheme, taken from @file{%mirror-file}.
  5705. Alternatively, when URL starts with @code{file://}, return the
  5706. corresponding file name in the store.
  5707. @end deffn
  5708. Likewise, the @code{(guix git-download)} module defines the
  5709. @code{git-fetch} origin method, which fetches data from a Git version
  5710. control repository, and the @code{git-reference} data type to describe
  5711. the repository and revision to fetch.
  5712. @deffn {Scheme Procedure} git-fetch @var{ref} @var{hash-algo} @var{hash}
  5713. Return a fixed-output derivation that fetches @var{ref}, a
  5714. @code{<git-reference>} object. The output is expected to have recursive
  5715. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  5716. the file name, or a generic name if @code{#f}.
  5717. @end deffn
  5718. @deftp {Data Type} git-reference
  5719. This data type represents a Git reference for @code{git-fetch} to
  5720. retrieve.
  5721. @table @asis
  5722. @item @code{url}
  5723. The URL of the Git repository to clone.
  5724. @item @code{commit}
  5725. This string denotes either the commit to fetch (a hexadecimal string),
  5726. or the tag to fetch. You can also use a ``short'' commit ID or a
  5727. @command{git describe} style identifier such as
  5728. @code{v1.0.1-10-g58d7909c97}.
  5729. @item @code{recursive?} (default: @code{#f})
  5730. This Boolean indicates whether to recursively fetch Git sub-modules.
  5731. @end table
  5732. The example below denotes the @code{v2.10} tag of the GNU@tie{}Hello
  5733. repository:
  5734. @lisp
  5735. (git-reference
  5736. (url "https://git.savannah.gnu.org/git/hello.git")
  5737. (commit "v2.10"))
  5738. @end lisp
  5739. This is equivalent to the reference below, which explicitly names the
  5740. commit:
  5741. @lisp
  5742. (git-reference
  5743. (url "https://git.savannah.gnu.org/git/hello.git")
  5744. (commit "dc7dc56a00e48fe6f231a58f6537139fe2908fb9"))
  5745. @end lisp
  5746. @end deftp
  5747. For Mercurial repositories, the module @code{(guix hg-download)} defines
  5748. the @code{hg-fetch} origin method and @code{hg-reference} data type for
  5749. support of the Mercurial version control system.
  5750. @deffn {Scheme Procedure} hg-fetch @var{ref} @var{hash-algo} @var{hash} @
  5751. [name]
  5752. Return a fixed-output derivation that fetches @var{ref}, a
  5753. @code{<hg-reference>} object. The output is expected to have recursive
  5754. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  5755. the file name, or a generic name if @code{#false}.
  5756. @end deffn
  5757. @node Defining Package Variants
  5758. @section Defining Package Variants
  5759. @cindex customizing packages
  5760. @cindex variants, of packages
  5761. One of the nice things with Guix is that, given a package definition,
  5762. you can easily @emph{derive} variants of that package---for a different
  5763. upstream version, with different dependencies, different compilation
  5764. options, and so on. Some of these custom packages can be defined
  5765. straight from the command line (@pxref{Package Transformation Options}).
  5766. This section describes how to define package variants in code. This can
  5767. be useful in ``manifests'' (@pxref{profile-manifest,
  5768. @option{--manifest}}) and in your own package collection
  5769. (@pxref{Creating a Channel}), among others!
  5770. @cindex inherit, for package definitions
  5771. As discussed earlier, packages are first-class objects in the Scheme
  5772. language. The @code{(guix packages)} module provides the @code{package}
  5773. construct to define new package objects (@pxref{package Reference}).
  5774. The easiest way to define a package variant is using the @code{inherit}
  5775. keyword together with @code{package}. This allows you to inherit from a
  5776. package definition while overriding the fields you want.
  5777. For example, given the @code{hello} variable, which contains a
  5778. definition for the current version of GNU@tie{}Hello, here's how you
  5779. would define a variant for version 2.2 (released in 2006, it's
  5780. vintage!):
  5781. @lisp
  5782. (use-modules (gnu packages base)) ;for 'hello'
  5783. (define hello-2.2
  5784. (package
  5785. (inherit hello)
  5786. (version "2.2")
  5787. (source (origin
  5788. (method url-fetch)
  5789. (uri (string-append "mirror://gnu/hello/hello-" version
  5790. ".tar.gz"))
  5791. (sha256
  5792. (base32
  5793. "0lappv4slgb5spyqbh6yl5r013zv72yqg2pcl30mginf3wdqd8k9"))))))
  5794. @end lisp
  5795. The example above corresponds to what the @option{--with-source} package
  5796. transformation option does. Essentially @code{hello-2.2} preserves all
  5797. the fields of @code{hello}, except @code{version} and @code{source},
  5798. which it overrides. Note that the original @code{hello} variable is
  5799. still there, in the @code{(gnu packages base)} module, unchanged. When
  5800. you define a custom package like this, you are really @emph{adding} a
  5801. new package definition; the original one remains available.
  5802. You can just as well define variants with a different set of
  5803. dependencies than the original package. For example, the default
  5804. @code{gdb} package depends on @code{guile}, but since that is an
  5805. optional dependency, you can define a variant that removes that
  5806. dependency like so:
  5807. @lisp
  5808. (use-modules (gnu packages gdb)) ;for 'gdb'
  5809. (define gdb-sans-guile
  5810. (package
  5811. (inherit gdb)
  5812. (inputs (modify-inputs (package-inputs gdb)
  5813. (delete "guile")))))
  5814. @end lisp
  5815. The @code{modify-inputs} form above removes the @code{"guile"} package
  5816. from the @code{inputs} field of @code{gdb}. The @code{modify-inputs}
  5817. macro is a helper that can prove useful anytime you want to remove, add,
  5818. or replace package inputs.
  5819. @deffn {Scheme Syntax} modify-inputs @var{inputs} @var{clauses}
  5820. Modify the given package inputs, as returned by @code{package-inputs} & co.,
  5821. according to the given clauses. The example below removes the GMP and ACL
  5822. inputs of Coreutils and adds libcap to the back of the input list:
  5823. @lisp
  5824. (modify-inputs (package-inputs coreutils)
  5825. (delete "gmp" "acl")
  5826. (append libcap))
  5827. @end lisp
  5828. The example below replaces the @code{guile} package from the inputs of
  5829. @code{guile-redis} with @code{guile-2.2}:
  5830. @lisp
  5831. (modify-inputs (package-inputs guile-redis)
  5832. (replace "guile" guile-2.2))
  5833. @end lisp
  5834. The last type of clause is @code{prepend}, to add inputs to the front of
  5835. the list.
  5836. @end deffn
  5837. In some cases, you may find it useful to write functions
  5838. (``procedures'', in Scheme parlance) that return a package based on some
  5839. parameters. For example, consider the @code{luasocket} library for the
  5840. Lua programming language. We want to create @code{luasocket} packages
  5841. for major versions of Lua. One way to do that is to define a procedure
  5842. that takes a Lua package and returns a @code{luasocket} package that
  5843. depends on it:
  5844. @lisp
  5845. (define (make-lua-socket name lua)
  5846. ;; Return a luasocket package built with LUA.
  5847. (package
  5848. (name name)
  5849. (version "3.0")
  5850. ;; several fields omitted
  5851. (inputs (list lua))
  5852. (synopsis "Socket library for Lua")))
  5853. (define-public lua5.1-socket
  5854. (make-lua-socket "lua5.1-socket" lua-5.1))
  5855. (define-public lua5.2-socket
  5856. (make-lua-socket "lua5.2-socket" lua-5.2))
  5857. @end lisp
  5858. Here we have defined packages @code{lua5.1-socket} and
  5859. @code{lua5.2-socket} by calling @code{make-lua-socket} with different
  5860. arguments. @xref{Procedures,,, guile, GNU Guile Reference Manual}, for
  5861. more info on procedures. Having top-level public definitions for these
  5862. two packages means that they can be referred to from the command line
  5863. (@pxref{Package Modules}).
  5864. @cindex package transformations
  5865. These are pretty simple package variants. As a convenience, the
  5866. @code{(guix transformations)} module provides a high-level interface
  5867. that directly maps to the more sophisticated package transformation
  5868. options (@pxref{Package Transformation Options}):
  5869. @deffn {Scheme Procedure} options->transformation @var{opts}
  5870. Return a procedure that, when passed an object to build (package,
  5871. derivation, etc.), applies the transformations specified by @var{opts} and returns
  5872. the resulting objects. @var{opts} must be a list of symbol/string pairs such as:
  5873. @lisp
  5874. ((with-branch . "guile-gcrypt=master")
  5875. (without-tests . "libgcrypt"))
  5876. @end lisp
  5877. Each symbol names a transformation and the corresponding string is an argument
  5878. to that transformation.
  5879. @end deffn
  5880. For instance, a manifest equivalent to this command:
  5881. @example
  5882. guix build guix \
  5883. --with-branch=guile-gcrypt=master \
  5884. --with-debug-info=zlib
  5885. @end example
  5886. @noindent
  5887. ... would look like this:
  5888. @lisp
  5889. (use-modules (guix transformations))
  5890. (define transform
  5891. ;; The package transformation procedure.
  5892. (options->transformation
  5893. '((with-branch . "guile-gcrypt=master")
  5894. (with-debug-info . "zlib"))))
  5895. (packages->manifest
  5896. (list (transform (specification->package "guix"))))
  5897. @end lisp
  5898. @cindex input rewriting
  5899. @cindex dependency graph rewriting
  5900. The @code{options->transformation} procedure is convenient, but it's
  5901. perhaps also not as flexible as you may like. How is it implemented?
  5902. The astute reader probably noticed that most package transformation
  5903. options go beyond the superficial changes shown in the first examples of
  5904. this section: they involve @dfn{input rewriting}, whereby the dependency
  5905. graph of a package is rewritten by replacing specific inputs by others.
  5906. Dependency graph rewriting, for the purposes of swapping packages in the
  5907. graph, is what the @code{package-input-rewriting} procedure in
  5908. @code{(guix packages)} implements.
  5909. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  5910. [@var{rewrite-name}] [#:deep? #t]
  5911. Return a procedure that, when passed a package, replaces its direct and
  5912. indirect dependencies, including implicit inputs when @var{deep?} is
  5913. true, according to @var{replacements}. @var{replacements} is a list of
  5914. package pairs; the first element of each pair is the package to replace,
  5915. and the second one is the replacement.
  5916. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  5917. the name of a package and returns its new name after rewrite.
  5918. @end deffn
  5919. @noindent
  5920. Consider this example:
  5921. @lisp
  5922. (define libressl-instead-of-openssl
  5923. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  5924. ;; recursively.
  5925. (package-input-rewriting `((,openssl . ,libressl))))
  5926. (define git-with-libressl
  5927. (libressl-instead-of-openssl git))
  5928. @end lisp
  5929. @noindent
  5930. Here we first define a rewriting procedure that replaces @var{openssl}
  5931. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  5932. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  5933. This is exactly what the @option{--with-input} command-line option does
  5934. (@pxref{Package Transformation Options, @option{--with-input}}).
  5935. The following variant of @code{package-input-rewriting} can match packages to
  5936. be replaced by name rather than by identity.
  5937. @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
  5938. Return a procedure that, given a package, applies the given
  5939. @var{replacements} to all the package graph, including implicit inputs
  5940. unless @var{deep?} is false. @var{replacements} is a list of
  5941. spec/procedures pair; each spec is a package specification such as
  5942. @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching
  5943. package and returns a replacement for that package.
  5944. @end deffn
  5945. The example above could be rewritten this way:
  5946. @lisp
  5947. (define libressl-instead-of-openssl
  5948. ;; Replace all the packages called "openssl" with LibreSSL.
  5949. (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
  5950. @end lisp
  5951. The key difference here is that, this time, packages are matched by spec and
  5952. not by identity. In other words, any package in the graph that is called
  5953. @code{openssl} will be replaced.
  5954. A more generic procedure to rewrite a package dependency graph is
  5955. @code{package-mapping}: it supports arbitrary changes to nodes in the
  5956. graph.
  5957. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f]
  5958. Return a procedure that, given a package, applies @var{proc} to all the packages
  5959. depended on and returns the resulting package. The procedure stops recursion
  5960. when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
  5961. applied to implicit inputs as well.
  5962. @end deffn
  5963. @node Build Systems
  5964. @section Build Systems
  5965. @cindex build system
  5966. Each package definition specifies a @dfn{build system} and arguments for
  5967. that build system (@pxref{Defining Packages}). This @code{build-system}
  5968. field represents the build procedure of the package, as well as implicit
  5969. dependencies of that build procedure.
  5970. Build systems are @code{<build-system>} objects. The interface to
  5971. create and manipulate them is provided by the @code{(guix build-system)}
  5972. module, and actual build systems are exported by specific modules.
  5973. @cindex bag (low-level package representation)
  5974. Under the hood, build systems first compile package objects to
  5975. @dfn{bags}. A @dfn{bag} is like a package, but with less
  5976. ornamentation---in other words, a bag is a lower-level representation of
  5977. a package, which includes all the inputs of that package, including some
  5978. that were implicitly added by the build system. This intermediate
  5979. representation is then compiled to a derivation (@pxref{Derivations}).
  5980. The @code{package-with-c-toolchain} is an example of a way to change the
  5981. implicit inputs that a package's build system pulls in (@pxref{package
  5982. Reference, @code{package-with-c-toolchain}}).
  5983. Build systems accept an optional list of @dfn{arguments}. In package
  5984. definitions, these are passed @i{via} the @code{arguments} field
  5985. (@pxref{Defining Packages}). They are typically keyword arguments
  5986. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  5987. Guile Reference Manual}). The value of these arguments is usually
  5988. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  5989. by the daemon (@pxref{Derivations}).
  5990. The main build system is @code{gnu-build-system}, which implements the
  5991. standard build procedure for GNU and many other packages. It
  5992. is provided by the @code{(guix build-system gnu)} module.
  5993. @defvr {Scheme Variable} gnu-build-system
  5994. @code{gnu-build-system} represents the GNU Build System, and variants
  5995. thereof (@pxref{Configuration, configuration and makefile conventions,,
  5996. standards, GNU Coding Standards}).
  5997. @cindex build phases
  5998. In a nutshell, packages using it are configured, built, and installed with
  5999. the usual @code{./configure && make && make check && make install}
  6000. command sequence. In practice, a few additional steps are often needed.
  6001. All these steps are split up in separate @dfn{phases}.
  6002. @xref{Build Phases}, for more info on build phases and ways to customize
  6003. them.
  6004. In addition, this build system ensures that the ``standard'' environment
  6005. for GNU packages is available. This includes tools such as GCC, libc,
  6006. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  6007. build-system gnu)} module for a complete list). We call these the
  6008. @dfn{implicit inputs} of a package, because package definitions do not
  6009. have to mention them.
  6010. This build system supports a number of keyword arguments, which can be
  6011. passed @i{via} the @code{arguments} field of a package. Here are some
  6012. of the main parameters:
  6013. @table @code
  6014. @item #:phases
  6015. This argument specifies build-side code that evaluates to an alist of
  6016. build phases. @xref{Build Phases}, for more information.
  6017. @item #:configure-flags
  6018. This is a list of flags (strings) passed to the @command{configure}
  6019. script. @xref{Defining Packages}, for an example.
  6020. @item #:make-flags
  6021. This list of strings contains flags passed as arguments to
  6022. @command{make} invocations in the @code{build}, @code{check}, and
  6023. @code{install} phases.
  6024. @item #:out-of-source?
  6025. This Boolean, @code{#f} by default, indicates whether to run builds in a
  6026. build directory separate from the source tree.
  6027. When it is true, the @code{configure} phase creates a separate build
  6028. directory, changes to that directory, and runs the @code{configure}
  6029. script from there. This is useful for packages that require it, such as
  6030. @code{glibc}.
  6031. @item #:tests?
  6032. This Boolean, @code{#t} by default, indicates whether the @code{check}
  6033. phase should run the package's test suite.
  6034. @item #:test-target
  6035. This string, @code{"check"} by default, gives the name of the makefile
  6036. target used by the @code{check} phase.
  6037. @item #:parallel-build?
  6038. @itemx #:parallel-tests?
  6039. These Boolean values specify whether to build, respectively run the test
  6040. suite, in parallel, with the @code{-j} flag of @command{make}. When
  6041. they are true, @code{make} is passed @code{-j@var{n}}, where @var{n} is
  6042. the number specified as the @option{--cores} option of
  6043. @command{guix-daemon} or that of the @command{guix} client command
  6044. (@pxref{Common Build Options, @option{--cores}}).
  6045. @cindex RUNPATH, validation
  6046. @item #:validate-runpath?
  6047. This Boolean, @code{#t} by default, determines whether to ``validate''
  6048. the @code{RUNPATH} of ELF binaries (@code{.so} shared libraries as well
  6049. as executables) previously installed by the @code{install} phase.
  6050. This validation step consists in making sure that all the shared
  6051. libraries needed by an ELF binary, which are listed as
  6052. @code{DT_NEEDED} entries in its @code{PT_DYNAMIC} segment, appear in the
  6053. @code{DT_RUNPATH} entry of that binary. In other words, it ensures that
  6054. running or using those binaries will not result in a ``file not found''
  6055. error at run time. @xref{Options, @option{-rpath},, ld, The GNU
  6056. Linker}, for more information on @code{RUNPATH}.
  6057. @item #:substitutable?
  6058. This Boolean, @code{#t} by default, tells whether the package outputs
  6059. should be substitutable---i.e., whether users should be able to obtain
  6060. substitutes for them instead of building locally (@pxref{Substitutes}).
  6061. @item #:allowed-references
  6062. @itemx #:disallowed-references
  6063. When true, these arguments must be a list of dependencies that must not
  6064. appear among the references of the build results. If, upon build
  6065. completion, some of these references are retained, the build process
  6066. fails.
  6067. This is useful to ensure that a package does not erroneously keep a
  6068. reference to some of it build-time inputs, in cases where doing so
  6069. would, for example, unnecessarily increase its size (@pxref{Invoking
  6070. guix size}).
  6071. @end table
  6072. Most other build systems support these keyword arguments.
  6073. @end defvr
  6074. Other @code{<build-system>} objects are defined to support other
  6075. conventions and tools used by free software packages. They inherit most
  6076. of @code{gnu-build-system}, and differ mainly in the set of inputs
  6077. implicitly added to the build process, and in the list of phases
  6078. executed. Some of these build systems are listed below.
  6079. @defvr {Scheme Variable} ant-build-system
  6080. This variable is exported by @code{(guix build-system ant)}. It
  6081. implements the build procedure for Java packages that can be built with
  6082. @url{https://ant.apache.org/, Ant build tool}.
  6083. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  6084. provided by the @code{icedtea} package to the set of inputs. Different
  6085. packages can be specified with the @code{#:ant} and @code{#:jdk}
  6086. parameters, respectively.
  6087. When the original package does not provide a suitable Ant build file,
  6088. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  6089. build file @file{build.xml} with tasks to build the specified jar
  6090. archive. In this case the parameter @code{#:source-dir} can be used to
  6091. specify the source sub-directory, defaulting to ``src''.
  6092. The @code{#:main-class} parameter can be used with the minimal ant
  6093. buildfile to specify the main class of the resulting jar. This makes the
  6094. jar file executable. The @code{#:test-include} parameter can be used to
  6095. specify the list of junit tests to run. It defaults to
  6096. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  6097. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  6098. because abstract classes cannot be run as tests.
  6099. The parameter @code{#:build-target} can be used to specify the Ant task
  6100. that should be run during the @code{build} phase. By default the
  6101. ``jar'' task will be run.
  6102. @end defvr
  6103. @defvr {Scheme Variable} android-ndk-build-system
  6104. @cindex Android distribution
  6105. @cindex Android NDK build system
  6106. This variable is exported by @code{(guix build-system android-ndk)}. It
  6107. implements a build procedure for Android NDK (native development kit)
  6108. packages using a Guix-specific build process.
  6109. The build system assumes that packages install their public interface
  6110. (header) files to the subdirectory @file{include} of the @code{out} output and
  6111. their libraries to the subdirectory @file{lib} the @code{out} output.
  6112. It's also assumed that the union of all the dependencies of a package
  6113. has no conflicting files.
  6114. For the time being, cross-compilation is not supported - so right now
  6115. the libraries and header files are assumed to be host tools.
  6116. @end defvr
  6117. @defvr {Scheme Variable} asdf-build-system/source
  6118. @defvrx {Scheme Variable} asdf-build-system/sbcl
  6119. @defvrx {Scheme Variable} asdf-build-system/ecl
  6120. These variables, exported by @code{(guix build-system asdf)}, implement
  6121. build procedures for Common Lisp packages using
  6122. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  6123. definition facility for Common Lisp programs and libraries.
  6124. The @code{asdf-build-system/source} system installs the packages in
  6125. source form, and can be loaded using any common lisp implementation, via
  6126. ASDF@. The others, such as @code{asdf-build-system/sbcl}, install binary
  6127. systems in the format which a particular implementation understands.
  6128. These build systems can also be used to produce executable programs, or
  6129. lisp images which contain a set of packages pre-loaded.
  6130. The build system uses naming conventions. For binary packages, the
  6131. package name should be prefixed with the lisp implementation, such as
  6132. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  6133. Additionally, the corresponding source package should be labeled using
  6134. the same convention as python packages (see @ref{Python Modules}), using
  6135. the @code{cl-} prefix.
  6136. In order to create executable programs and images, the build-side
  6137. procedures @code{build-program} and @code{build-image} can be used.
  6138. They should be called in a build phase after the
  6139. @code{create-asdf-configuration} phase, so that the system which was
  6140. just built can be used within the resulting image. @code{build-program}
  6141. requires a list of Common Lisp expressions to be passed as the
  6142. @code{#:entry-program} argument.
  6143. By default, all the @file{.asd} files present in the sources are read to
  6144. find system definitions. The @code{#:asd-files} parameter can be used
  6145. to specify the list of @file{.asd} files to read. Furthermore, if the
  6146. package defines a system for its tests in a separate file, it will be
  6147. loaded before the tests are run if it is specified by the
  6148. @code{#:test-asd-file} parameter. If it is not set, the files
  6149. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  6150. and @code{test.asd} will be tried if they exist.
  6151. If for some reason the package must be named in a different way than the
  6152. naming conventions suggest, or if several systems must be compiled, the
  6153. @code{#:asd-systems} parameter can be used to specify the list of system
  6154. names.
  6155. @end defvr
  6156. @defvr {Scheme Variable} cargo-build-system
  6157. @cindex Rust programming language
  6158. @cindex Cargo (Rust build system)
  6159. This variable is exported by @code{(guix build-system cargo)}. It
  6160. supports builds of packages using Cargo, the build tool of the
  6161. @uref{https://www.rust-lang.org, Rust programming language}.
  6162. It adds @code{rustc} and @code{cargo} to the set of inputs.
  6163. A different Rust package can be specified with the @code{#:rust} parameter.
  6164. Regular cargo dependencies should be added to the package definition similarly
  6165. to other packages; those needed only at build time to native-inputs, others to
  6166. inputs. If you need to add source-only crates then you should add them to via
  6167. the @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
  6168. spec can be a package or a source definition. Note that the spec must
  6169. evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
  6170. file at its root, or it will be ignored. Similarly, cargo dev-dependencies
  6171. should be added to the package definition via the
  6172. @code{#:cargo-development-inputs} parameter.
  6173. In its @code{configure} phase, this build system will make any source inputs
  6174. specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
  6175. parameters available to cargo. It will also remove an included
  6176. @code{Cargo.lock} file to be recreated by @code{cargo} during the
  6177. @code{build} phase. The @code{package} phase will run @code{cargo package}
  6178. to create a source crate for future use. The @code{install} phase installs
  6179. the binaries defined by the crate. Unless @code{install-source? #f} is
  6180. defined it will also install a source crate repository of itself and unpacked
  6181. sources, to ease in future hacking on rust packages.
  6182. @end defvr
  6183. @defvr {Scheme Variable} chicken-build-system
  6184. This variable is exported by @code{(guix build-system chicken)}. It
  6185. builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called
  6186. ``eggs'' or ``extensions''. CHICKEN generates C source code, which then
  6187. gets compiled by a C compiler, in this case GCC.
  6188. This build system adds @code{chicken} to the package inputs, as well as
  6189. the packages of @code{gnu-build-system}.
  6190. The build system can't (yet) deduce the egg's name automatically, so just like
  6191. with @code{go-build-system} and its @code{#:import-path}, you should define
  6192. @code{#:egg-name} in the package's @code{arguments} field.
  6193. For example, if you are packaging the @code{srfi-1} egg:
  6194. @lisp
  6195. (arguments '(#:egg-name "srfi-1"))
  6196. @end lisp
  6197. Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs}
  6198. because CHICKEN doesn't embed absolute references in compiled eggs.
  6199. Test dependencies should go to @code{native-inputs}, as usual.
  6200. @end defvr
  6201. @defvr {Scheme Variable} copy-build-system
  6202. This variable is exported by @code{(guix build-system copy)}. It
  6203. supports builds of simple packages that don't require much compiling,
  6204. mostly just moving files around.
  6205. It adds much of the @code{gnu-build-system} packages to the set of
  6206. inputs. Because of this, the @code{copy-build-system} does not require
  6207. all the boilerplate code often needed for the
  6208. @code{trivial-build-system}.
  6209. To further simplify the file installation process, an
  6210. @code{#:install-plan} argument is exposed to let the packager specify
  6211. which files go where. The install plan is a list of @code{(@var{source}
  6212. @var{target} [@var{filters}])}. @var{filters} are optional.
  6213. @itemize
  6214. @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
  6215. @itemize
  6216. @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
  6217. @item Otherwise install @var{source} as @var{target}.
  6218. @end itemize
  6219. @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
  6220. the trailing slash of @var{target} is implied with the same meaning
  6221. as above.
  6222. @itemize
  6223. @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
  6224. @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
  6225. @code{#:exclude-regexp}, only select files are installed depending on
  6226. the filters. Each filters is specified by a list of strings.
  6227. @itemize
  6228. @item With @code{#:include}, install all the files which the path suffix matches
  6229. at least one of the elements in the given list.
  6230. @item With @code{#:include-regexp}, install all the files which the
  6231. subpaths match at least one of the regular expressions in the given
  6232. list.
  6233. @item The @code{#:exclude} and @code{#:exclude-regexp} filters
  6234. are the complement of their inclusion counterpart. Without @code{#:include} flags,
  6235. install all files but those matching the exclusion filters.
  6236. If both inclusions and exclusions are specified, the exclusions are done
  6237. on top of the inclusions.
  6238. @end itemize
  6239. @end itemize
  6240. In all cases, the paths relative to @var{source} are preserved within
  6241. @var{target}.
  6242. @end itemize
  6243. Examples:
  6244. @itemize
  6245. @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
  6246. @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
  6247. @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
  6248. e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
  6249. @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
  6250. @file{share/my-app/sub/file}.
  6251. @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
  6252. @file{share/my-app/file}.
  6253. @end itemize
  6254. @end defvr
  6255. @cindex Clojure (programming language)
  6256. @cindex simple Clojure build system
  6257. @defvr {Scheme Variable} clojure-build-system
  6258. This variable is exported by @code{(guix build-system clojure)}. It implements
  6259. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  6260. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  6261. yet.
  6262. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  6263. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  6264. @code{#:zip} parameters, respectively.
  6265. A list of source directories, test directories and jar names can be specified
  6266. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  6267. parameters, respectively. Compile directory and main class can be specified
  6268. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  6269. Other parameters are documented below.
  6270. This build system is an extension of @code{ant-build-system}, but with the
  6271. following phases changed:
  6272. @table @code
  6273. @item build
  6274. This phase calls @code{compile} in Clojure to compile source files and runs
  6275. @command{jar} to create jars from both source files and compiled files
  6276. according to the include list and exclude list specified in
  6277. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  6278. has priority over the include list. These lists consist of symbols
  6279. representing Clojure libraries or the special keyword @code{#:all} representing
  6280. all Clojure libraries found under the source directories. The parameter
  6281. @code{#:omit-source?} decides if source should be included into the jars.
  6282. @item check
  6283. This phase runs tests according to the include list and exclude list specified
  6284. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  6285. meanings are analogous to that of @code{#:aot-include} and
  6286. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  6287. stands for all Clojure libraries found under the test directories. The
  6288. parameter @code{#:tests?} decides if tests should be run.
  6289. @item install
  6290. This phase installs all jars built previously.
  6291. @end table
  6292. Apart from the above, this build system also contains an additional phase:
  6293. @table @code
  6294. @item install-doc
  6295. This phase installs all top-level files with base name matching
  6296. @code{%doc-regex}. A different regex can be specified with the
  6297. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  6298. directories specified in @code{#:doc-dirs} are installed as well.
  6299. @end table
  6300. @end defvr
  6301. @defvr {Scheme Variable} cmake-build-system
  6302. This variable is exported by @code{(guix build-system cmake)}. It
  6303. implements the build procedure for packages using the
  6304. @url{https://www.cmake.org, CMake build tool}.
  6305. It automatically adds the @code{cmake} package to the set of inputs.
  6306. Which package is used can be specified with the @code{#:cmake}
  6307. parameter.
  6308. The @code{#:configure-flags} parameter is taken as a list of flags
  6309. passed to the @command{cmake} command. The @code{#:build-type}
  6310. parameter specifies in abstract terms the flags passed to the compiler;
  6311. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  6312. debugging information''), which roughly means that code is compiled with
  6313. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  6314. @end defvr
  6315. @defvr {Scheme Variable} dune-build-system
  6316. This variable is exported by @code{(guix build-system dune)}. It
  6317. supports builds of packages using @uref{https://dune.build/, Dune}, a build
  6318. tool for the OCaml programming language. It is implemented as an extension
  6319. of the @code{ocaml-build-system} which is described below. As such, the
  6320. @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
  6321. system.
  6322. It automatically adds the @code{dune} package to the set of inputs.
  6323. Which package is used can be specified with the @code{#:dune}
  6324. parameter.
  6325. There is no @code{configure} phase because dune packages typically don't
  6326. need to be configured. The @code{#:build-flags} parameter is taken as a
  6327. list of flags passed to the @code{dune} command during the build.
  6328. The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
  6329. command instead of the more recent @code{dune} command while building
  6330. a package. Its default value is @code{#f}.
  6331. The @code{#:package} parameter can be passed to specify a package name, which
  6332. is useful when a package contains multiple packages and you want to build
  6333. only one of them. This is equivalent to passing the @code{-p} argument to
  6334. @code{dune}.
  6335. @end defvr
  6336. @defvr {Scheme Variable} go-build-system
  6337. This variable is exported by @code{(guix build-system go)}. It
  6338. implements a build procedure for Go packages using the standard
  6339. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  6340. Go build mechanisms}.
  6341. The user is expected to provide a value for the key @code{#:import-path}
  6342. and, in some cases, @code{#:unpack-path}. The
  6343. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  6344. corresponds to the file system path expected by the package's build
  6345. scripts and any referring packages, and provides a unique way to
  6346. refer to a Go package. It is typically based on a combination of the
  6347. package source code's remote URI and file system hierarchy structure. In
  6348. some cases, you will need to unpack the package's source code to a
  6349. different directory structure than the one indicated by the import path,
  6350. and @code{#:unpack-path} should be used in such cases.
  6351. Packages that provide Go libraries should install their source code into
  6352. the built output. The key @code{#:install-source?}, which defaults to
  6353. @code{#t}, controls whether or not the source code is installed. It can
  6354. be set to @code{#f} for packages that only provide executable files.
  6355. Packages can be cross-built, and if a specific architecture or operating
  6356. system is desired then the keywords @code{#:goarch} and @code{#:goos}
  6357. can be used to force the package to be built for that architecture and
  6358. operating system. The combinations known to Go can be found
  6359. @url{"https://golang.org/doc/install/source#environment", in their
  6360. documentation}.
  6361. @end defvr
  6362. @defvr {Scheme Variable} glib-or-gtk-build-system
  6363. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  6364. is intended for use with packages making use of GLib or GTK+.
  6365. This build system adds the following two phases to the ones defined by
  6366. @code{gnu-build-system}:
  6367. @table @code
  6368. @item glib-or-gtk-wrap
  6369. The phase @code{glib-or-gtk-wrap} ensures that programs in
  6370. @file{bin/} are able to find GLib ``schemas'' and
  6371. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  6372. modules}. This is achieved by wrapping the programs in launch scripts
  6373. that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
  6374. environment variables.
  6375. It is possible to exclude specific package outputs from that wrapping
  6376. process by listing their names in the
  6377. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  6378. when an output is known not to contain any GLib or GTK+ binaries, and
  6379. where wrapping would gratuitously add a dependency of that output on
  6380. GLib and GTK+.
  6381. @item glib-or-gtk-compile-schemas
  6382. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  6383. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  6384. GSettings schemas} of GLib are compiled. Compilation is performed by the
  6385. @command{glib-compile-schemas} program. It is provided by the package
  6386. @code{glib:bin} which is automatically imported by the build system.
  6387. The @code{glib} package providing @command{glib-compile-schemas} can be
  6388. specified with the @code{#:glib} parameter.
  6389. @end table
  6390. Both phases are executed after the @code{install} phase.
  6391. @end defvr
  6392. @defvr {Scheme Variable} guile-build-system
  6393. This build system is for Guile packages that consist exclusively of Scheme
  6394. code and that are so lean that they don't even have a makefile, let alone a
  6395. @file{configure} script. It compiles Scheme code using @command{guild
  6396. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  6397. installs the @file{.scm} and @file{.go} files in the right place. It also
  6398. installs documentation.
  6399. This build system supports cross-compilation by using the
  6400. @option{--target} option of @samp{guild compile}.
  6401. Packages built with @code{guile-build-system} must provide a Guile package in
  6402. their @code{native-inputs} field.
  6403. @end defvr
  6404. @defvr {Scheme Variable} julia-build-system
  6405. This variable is exported by @code{(guix build-system julia)}. It
  6406. implements the build procedure used by @uref{https://julialang.org/,
  6407. julia} packages, which essentially is similar to running @samp{julia -e
  6408. 'using Pkg; Pkg.add(package)'} in an environment where
  6409. @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
  6410. Tests are run by calling @code{/test/runtests.jl}.
  6411. The Julia package name is read from the file @file{Project.toml}. This
  6412. value can be overridden by passing the argument @code{#:julia-package-name}
  6413. (which must be correctly capitalized).
  6414. Julia packages usually manage their binary dependencies via
  6415. @code{JLLWrappers.jl}, a Julia package that creates a module (named
  6416. after the wrapped library followed by @code{_jll.jl}.
  6417. To add the binary path @code{_jll.jl} packages, you need to patch the
  6418. files under @file{src/wrappers/}, replacing the call to the macro
  6419. @code{JLLWrappers.@@generate_wrapper_header}, adding as a second
  6420. argument containing the store path the binary.
  6421. As an example, in the MbedTLS Julia package, we add a build phase
  6422. (@pxref{Build Phases}) to insert the absolute file name of the wrapped
  6423. MbedTLS package:
  6424. @lisp
  6425. (add-after 'unpack 'override-binary-path
  6426. (lambda* (#:key inputs #:allow-other-keys)
  6427. (for-each (lambda (wrapper)
  6428. (substitute* wrapper
  6429. (("generate_wrapper_header.*")
  6430. (string-append
  6431. "generate_wrapper_header(\"MbedTLS\", \""
  6432. (assoc-ref inputs "mbedtls-apache") "\")\n"))))
  6433. ;; There's a Julia file for each platform, override them all.
  6434. (find-files "src/wrappers/" "\\.jl$"))))
  6435. @end lisp
  6436. Some older packages that aren't using @file{Package.toml} yet, will require
  6437. this file to be created, too. The function @code{julia-create-package-toml}
  6438. helps creating the file. You need to pass the outputs and the source of the
  6439. package, its name (the same as the @code{file-name} parameter), the package
  6440. uuid, the package version, and a list of dependencies specified by their name
  6441. and their uuid.
  6442. @end defvr
  6443. @defvr {Scheme Variable} maven-build-system
  6444. This variable is exported by @code{(guix build-system maven)}. It implements
  6445. a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
  6446. is a dependency and lifecycle management tool for Java. A user of Maven
  6447. specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
  6448. When Maven does not have one of the dependencies or plugins in its repository,
  6449. it will download them and use them to build the package.
  6450. The maven build system ensures that maven will not try to download any
  6451. dependency by running in offline mode. Maven will fail if a dependency is
  6452. missing. Before running Maven, the @file{pom.xml} (and subprojects) are
  6453. modified to specify the version of dependencies and plugins that match the
  6454. versions available in the guix build environment. Dependencies and plugins
  6455. must be installed in the fake maven repository at @file{lib/m2}, and are
  6456. symlinked into a proper repository before maven is run. Maven is instructed
  6457. to use that repository for the build and installs built artifacts there.
  6458. Changed files are copied to the @file{lib/m2} directory of the package output.
  6459. You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
  6460. or let the build system use the default @file{pom.xml} file in the sources.
  6461. In case you need to specify a dependency's version manually, you can use the
  6462. @code{#:local-packages} argument. It takes an association list where the key
  6463. is the groupId of the package and its value is an association list where the
  6464. key is the artifactId of the package and its value is the version you want to
  6465. override in the @file{pom.xml}.
  6466. Some packages use dependencies or plugins that are not useful at runtime nor
  6467. at build time in Guix. You can alter the @file{pom.xml} file to remove them
  6468. using the @code{#:exclude} argument. Its value is an association list where
  6469. the key is the groupId of the plugin or dependency you want to remove, and
  6470. the value is a list of artifactId you want to remove.
  6471. You can override the default @code{jdk} and @code{maven} packages with the
  6472. corresponding argument, @code{#:jdk} and @code{#:maven}.
  6473. The @code{#:maven-plugins} argument is a list of maven plugins used during
  6474. the build, with the same format as the @code{inputs} fields of the package
  6475. declaration. Its default value is @code{(default-maven-plugins)} which is
  6476. also exported.
  6477. @end defvr
  6478. @defvr {Scheme Variable} minetest-mod-build-system
  6479. This variable is exported by @code{(guix build-system minetest)}. It
  6480. implements a build procedure for @uref{https://www.minetest.net, Minetest}
  6481. mods, which consists of copying Lua code, images and other resources to
  6482. the location Minetest searches for mods. The build system also minimises
  6483. PNG images and verifies that Minetest can load the mod without errors.
  6484. @end defvr
  6485. @defvr {Scheme Variable} minify-build-system
  6486. This variable is exported by @code{(guix build-system minify)}. It
  6487. implements a minification procedure for simple JavaScript packages.
  6488. It adds @code{uglify-js} to the set of inputs and uses it to compress
  6489. all JavaScript files in the @file{src} directory. A different minifier
  6490. package can be specified with the @code{#:uglify-js} parameter, but it
  6491. is expected that the package writes the minified code to the standard
  6492. output.
  6493. When the input JavaScript files are not all located in the @file{src}
  6494. directory, the parameter @code{#:javascript-files} can be used to
  6495. specify a list of file names to feed to the minifier.
  6496. @end defvr
  6497. @defvr {Scheme Variable} ocaml-build-system
  6498. This variable is exported by @code{(guix build-system ocaml)}. It implements
  6499. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  6500. of choosing the correct set of commands to run for each package. OCaml
  6501. packages can expect many different commands to be run. This build system will
  6502. try some of them.
  6503. When the package has a @file{setup.ml} file present at the top-level, it will
  6504. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  6505. @code{ocaml setup.ml -install}. The build system will assume that this file
  6506. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  6507. care of setting the prefix and enabling tests if they are not disabled. You
  6508. can pass configure and build flags with the @code{#:configure-flags} and
  6509. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  6510. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  6511. bypass this system in the build and install phases.
  6512. When the package has a @file{configure} file, it is assumed that it is a
  6513. hand-made configure script that requires a different argument format than
  6514. in the @code{gnu-build-system}. You can add more flags with the
  6515. @code{#:configure-flags} key.
  6516. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  6517. @code{#t}), it will be used and more flags can be passed to the build and
  6518. install phases with the @code{#:make-flags} key.
  6519. Finally, some packages do not have these files and use a somewhat standard
  6520. location for its build system. In that case, the build system will run
  6521. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  6522. providing the path to the required findlib module. Additional flags can
  6523. be passed via the @code{#:build-flags} key. Install is taken care of by
  6524. @command{opam-installer}. In this case, the @code{opam} package must
  6525. be added to the @code{native-inputs} field of the package definition.
  6526. Note that most OCaml packages assume they will be installed in the same
  6527. directory as OCaml, which is not what we want in guix. In particular, they
  6528. will install @file{.so} files in their module's directory, which is usually
  6529. fine because it is in the OCaml compiler directory. In guix though, these
  6530. libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
  6531. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  6532. @file{.so} libraries should be installed.
  6533. @end defvr
  6534. @defvr {Scheme Variable} python-build-system
  6535. This variable is exported by @code{(guix build-system python)}. It
  6536. implements the more or less standard build procedure used by Python
  6537. packages, which consists in running @code{python setup.py build} and
  6538. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  6539. For packages that install stand-alone Python programs under @code{bin/},
  6540. it takes care of wrapping these programs so that their
  6541. @env{GUIX_PYTHONPATH} environment variable points to all the Python
  6542. libraries they depend on.
  6543. Which Python package is used to perform the build can be specified with
  6544. the @code{#:python} parameter. This is a useful way to force a package
  6545. to be built for a specific version of the Python interpreter, which
  6546. might be necessary if the package is only compatible with a single
  6547. interpreter version.
  6548. By default guix calls @code{setup.py} under control of
  6549. @code{setuptools}, much like @command{pip} does. Some packages are not
  6550. compatible with setuptools (and pip), thus you can disable this by
  6551. setting the @code{#:use-setuptools?} parameter to @code{#f}.
  6552. If a @code{"python"} output is available, the package is installed into it
  6553. instead of the default @code{"out"} output. This is useful for packages that
  6554. include a Python package as only a part of the software, and thus want to
  6555. combine the phases of @code{python-build-system} with another build system.
  6556. Python bindings are a common usecase.
  6557. @end defvr
  6558. @defvr {Scheme Variable} perl-build-system
  6559. This variable is exported by @code{(guix build-system perl)}. It
  6560. implements the standard build procedure for Perl packages, which either
  6561. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  6562. followed by @code{Build} and @code{Build install}; or in running
  6563. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  6564. @code{make} and @code{make install}, depending on which of
  6565. @code{Build.PL} or @code{Makefile.PL} is present in the package
  6566. distribution. Preference is given to the former if both @code{Build.PL}
  6567. and @code{Makefile.PL} exist in the package distribution. This
  6568. preference can be reversed by specifying @code{#t} for the
  6569. @code{#:make-maker?} parameter.
  6570. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  6571. passes flags specified by the @code{#:make-maker-flags} or
  6572. @code{#:module-build-flags} parameter, respectively.
  6573. Which Perl package is used can be specified with @code{#:perl}.
  6574. @end defvr
  6575. @defvr {Scheme Variable} renpy-build-system
  6576. This variable is exported by @code{(guix build-system renpy)}. It implements
  6577. the more or less standard build procedure used by Ren'py games, which consists
  6578. of loading @code{#:game} once, thereby creating bytecode for it.
  6579. It further creates a wrapper script in @code{bin/} and a desktop entry in
  6580. @code{share/applications}, both of which can be used to launch the game.
  6581. Which Ren'py package is used can be specified with @code{#:renpy}.
  6582. Games can also be installed in outputs other than ``out'' by using
  6583. @code{#:output}.
  6584. @end defvr
  6585. @defvr {Scheme Variable} qt-build-system
  6586. This variable is exported by @code{(guix build-system qt)}. It
  6587. is intended for use with applications using Qt or KDE.
  6588. This build system adds the following two phases to the ones defined by
  6589. @code{cmake-build-system}:
  6590. @table @code
  6591. @item check-setup
  6592. The phase @code{check-setup} prepares the environment for running
  6593. the checks as commonly used by Qt test programs.
  6594. For now this only sets some environment variables:
  6595. @code{QT_QPA_PLATFORM=offscreen},
  6596. @code{DBUS_FATAL_WARNINGS=0} and
  6597. @code{CTEST_OUTPUT_ON_FAILURE=1}.
  6598. This phase is added before the @code{check} phase.
  6599. It's a separate phase to ease adjusting if necessary.
  6600. @item qt-wrap
  6601. The phase @code{qt-wrap}
  6602. searches for Qt5 plugin paths, QML paths and some XDG in the inputs
  6603. and output. In case some path is found, all programs in the output's
  6604. @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
  6605. are wrapped in scripts defining the necessary environment variables.
  6606. It is possible to exclude specific package outputs from that wrapping process
  6607. by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
  6608. This is useful when an output is known not to contain any Qt binaries, and
  6609. where wrapping would gratuitously add a dependency of that output on Qt, KDE,
  6610. or such.
  6611. This phase is added after the @code{install} phase.
  6612. @end table
  6613. @end defvr
  6614. @defvr {Scheme Variable} r-build-system
  6615. This variable is exported by @code{(guix build-system r)}. It
  6616. implements the build procedure used by @uref{https://r-project.org, R}
  6617. packages, which essentially is little more than running @samp{R CMD
  6618. INSTALL --library=/gnu/store/@dots{}} in an environment where
  6619. @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
  6620. run after installation using the R function
  6621. @code{tools::testInstalledPackage}.
  6622. @end defvr
  6623. @defvr {Scheme Variable} rakudo-build-system
  6624. This variable is exported by @code{(guix build-system rakudo)}. It
  6625. implements the build procedure used by @uref{https://rakudo.org/,
  6626. Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
  6627. package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
  6628. installs the binaries, library files and the resources, as well as wrap
  6629. the files under the @code{bin/} directory. Tests can be skipped by
  6630. passing @code{#f} to the @code{tests?} parameter.
  6631. Which rakudo package is used can be specified with @code{rakudo}.
  6632. Which perl6-tap-harness package used for the tests can be specified with
  6633. @code{#:prove6} or removed by passing @code{#f} to the
  6634. @code{with-prove6?} parameter.
  6635. Which perl6-zef package used for tests and installing can be specified
  6636. with @code{#:zef} or removed by passing @code{#f} to the
  6637. @code{with-zef?} parameter.
  6638. @end defvr
  6639. @defvr {Scheme Variable} texlive-build-system
  6640. This variable is exported by @code{(guix build-system texlive)}. It is
  6641. used to build TeX packages in batch mode with a specified engine. The
  6642. build system sets the @env{TEXINPUTS} variable to find all TeX source
  6643. files in the inputs.
  6644. By default it runs @code{luatex} on all files ending on @code{ins}. A
  6645. different engine and format can be specified with the
  6646. @code{#:tex-format} argument. Different build targets can be specified
  6647. with the @code{#:build-targets} argument, which expects a list of file
  6648. names. The build system adds only @code{texlive-bin} and
  6649. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  6650. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  6651. and @code{#:texlive-latex-base}, respectively.
  6652. The @code{#:tex-directory} parameter tells the build system where to
  6653. install the built files under the texmf tree.
  6654. @end defvr
  6655. @defvr {Scheme Variable} ruby-build-system
  6656. This variable is exported by @code{(guix build-system ruby)}. It
  6657. implements the RubyGems build procedure used by Ruby packages, which
  6658. involves running @code{gem build} followed by @code{gem install}.
  6659. The @code{source} field of a package that uses this build system
  6660. typically references a gem archive, since this is the format that Ruby
  6661. developers use when releasing their software. The build system unpacks
  6662. the gem archive, potentially patches the source, runs the test suite,
  6663. repackages the gem, and installs it. Additionally, directories and
  6664. tarballs may be referenced to allow building unreleased gems from Git or
  6665. a traditional source release tarball.
  6666. Which Ruby package is used can be specified with the @code{#:ruby}
  6667. parameter. A list of additional flags to be passed to the @command{gem}
  6668. command can be specified with the @code{#:gem-flags} parameter.
  6669. @end defvr
  6670. @defvr {Scheme Variable} waf-build-system
  6671. This variable is exported by @code{(guix build-system waf)}. It
  6672. implements a build procedure around the @code{waf} script. The common
  6673. phases---@code{configure}, @code{build}, and @code{install}---are
  6674. implemented by passing their names as arguments to the @code{waf}
  6675. script.
  6676. The @code{waf} script is executed by the Python interpreter. Which
  6677. Python package is used to run the script can be specified with the
  6678. @code{#:python} parameter.
  6679. @end defvr
  6680. @defvr {Scheme Variable} scons-build-system
  6681. This variable is exported by @code{(guix build-system scons)}. It
  6682. implements the build procedure used by the SCons software construction
  6683. tool. This build system runs @code{scons} to build the package,
  6684. @code{scons test} to run tests, and then @code{scons install} to install
  6685. the package.
  6686. Additional flags to be passed to @code{scons} can be specified with the
  6687. @code{#:scons-flags} parameter. The default build and install targets
  6688. can be overridden with @code{#:build-targets} and
  6689. @code{#:install-targets} respectively. The version of Python used to
  6690. run SCons can be specified by selecting the appropriate SCons package
  6691. with the @code{#:scons} parameter.
  6692. @end defvr
  6693. @defvr {Scheme Variable} haskell-build-system
  6694. This variable is exported by @code{(guix build-system haskell)}. It
  6695. implements the Cabal build procedure used by Haskell packages, which
  6696. involves running @code{runhaskell Setup.hs configure
  6697. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  6698. Instead of installing the package by running @code{runhaskell Setup.hs
  6699. install}, to avoid trying to register libraries in the read-only
  6700. compiler store directory, the build system uses @code{runhaskell
  6701. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  6702. addition, the build system generates the package documentation by
  6703. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  6704. is passed. Optional Haddock parameters can be passed with the help of
  6705. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  6706. not found, the build system looks for @code{Setup.lhs} instead.
  6707. Which Haskell compiler is used can be specified with the @code{#:haskell}
  6708. parameter which defaults to @code{ghc}.
  6709. @end defvr
  6710. @defvr {Scheme Variable} dub-build-system
  6711. This variable is exported by @code{(guix build-system dub)}. It
  6712. implements the Dub build procedure used by D packages, which
  6713. involves running @code{dub build} and @code{dub run}.
  6714. Installation is done by copying the files manually.
  6715. Which D compiler is used can be specified with the @code{#:ldc}
  6716. parameter which defaults to @code{ldc}.
  6717. @end defvr
  6718. @anchor{emacs-build-system}
  6719. @defvr {Scheme Variable} emacs-build-system
  6720. This variable is exported by @code{(guix build-system emacs)}. It
  6721. implements an installation procedure similar to the packaging system
  6722. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  6723. It first creates the @code{@code{package}-autoloads.el} file, then it
  6724. byte compiles all Emacs Lisp files. Differently from the Emacs
  6725. packaging system, the Info documentation files are moved to the standard
  6726. documentation directory and the @file{dir} file is deleted. The Elisp
  6727. package files are installed directly under @file{share/emacs/site-lisp}.
  6728. @end defvr
  6729. @defvr {Scheme Variable} font-build-system
  6730. This variable is exported by @code{(guix build-system font)}. It
  6731. implements an installation procedure for font packages where upstream
  6732. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  6733. need to be copied into place. It copies font files to standard
  6734. locations in the output directory.
  6735. @end defvr
  6736. @defvr {Scheme Variable} meson-build-system
  6737. This variable is exported by @code{(guix build-system meson)}. It
  6738. implements the build procedure for packages that use
  6739. @url{https://mesonbuild.com, Meson} as their build system.
  6740. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  6741. of inputs, and they can be changed with the parameters @code{#:meson}
  6742. and @code{#:ninja} if needed.
  6743. This build system is an extension of @code{gnu-build-system}, but with the
  6744. following phases changed to some specific for Meson:
  6745. @table @code
  6746. @item configure
  6747. The phase runs @code{meson} with the flags specified in
  6748. @code{#:configure-flags}. The flag @option{--buildtype} is always set to
  6749. @code{debugoptimized} unless something else is specified in
  6750. @code{#:build-type}.
  6751. @item build
  6752. The phase runs @code{ninja} to build the package in parallel by default, but
  6753. this can be changed with @code{#:parallel-build?}.
  6754. @item check
  6755. The phase runs @code{ninja} with the target specified in @code{#:test-target},
  6756. which is @code{"test"} by default.
  6757. @item install
  6758. The phase runs @code{ninja install} and can not be changed.
  6759. @end table
  6760. Apart from that, the build system also adds the following phases:
  6761. @table @code
  6762. @item fix-runpath
  6763. This phase ensures that all binaries can find the libraries they need.
  6764. It searches for required libraries in subdirectories of the package
  6765. being built, and adds those to @code{RUNPATH} where needed. It also
  6766. removes references to libraries left over from the build phase by
  6767. @code{meson}, such as test dependencies, that aren't actually required
  6768. for the program to run.
  6769. @item glib-or-gtk-wrap
  6770. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6771. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6772. @item glib-or-gtk-compile-schemas
  6773. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6774. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6775. @end table
  6776. @end defvr
  6777. @defvr {Scheme Variable} linux-module-build-system
  6778. @code{linux-module-build-system} allows building Linux kernel modules.
  6779. @cindex build phases
  6780. This build system is an extension of @code{gnu-build-system}, but with the
  6781. following phases changed:
  6782. @table @code
  6783. @item configure
  6784. This phase configures the environment so that the Linux kernel's Makefile
  6785. can be used to build the external kernel module.
  6786. @item build
  6787. This phase uses the Linux kernel's Makefile in order to build the external
  6788. kernel module.
  6789. @item install
  6790. This phase uses the Linux kernel's Makefile in order to install the external
  6791. kernel module.
  6792. @end table
  6793. It is possible and useful to specify the Linux kernel to use for building
  6794. the module (in the @code{arguments} form of a package using the
  6795. @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
  6796. @end defvr
  6797. @defvr {Scheme Variable} node-build-system
  6798. This variable is exported by @code{(guix build-system node)}. It
  6799. implements the build procedure used by @uref{https://nodejs.org,
  6800. Node.js}, which implements an approximation of the @code{npm install}
  6801. command, followed by an @code{npm test} command.
  6802. Which Node.js package is used to interpret the @code{npm} commands can
  6803. be specified with the @code{#:node} parameter which defaults to
  6804. @code{node}.
  6805. @end defvr
  6806. Lastly, for packages that do not need anything as sophisticated, a
  6807. ``trivial'' build system is provided. It is trivial in the sense that
  6808. it provides basically no support: it does not pull any implicit inputs,
  6809. and does not have a notion of build phases.
  6810. @defvr {Scheme Variable} trivial-build-system
  6811. This variable is exported by @code{(guix build-system trivial)}.
  6812. This build system requires a @code{#:builder} argument. This argument
  6813. must be a Scheme expression that builds the package output(s)---as
  6814. with @code{build-expression->derivation} (@pxref{Derivations,
  6815. @code{build-expression->derivation}}).
  6816. @end defvr
  6817. @node Build Phases
  6818. @section Build Phases
  6819. @cindex build phases, for packages
  6820. Almost all package build systems implement a notion @dfn{build phases}:
  6821. a sequence of actions that the build system executes, when you build the
  6822. package, leading to the installed byproducts in the store. A notable
  6823. exception is the ``bare-bones'' @code{trivial-build-system}
  6824. (@pxref{Build Systems}).
  6825. As discussed in the previous section, those build systems provide a
  6826. standard list of phases. For @code{gnu-build-system}, the main build
  6827. phases are the following:
  6828. @table @code
  6829. @item unpack
  6830. Unpack the source tarball, and change the current directory to the
  6831. extracted source tree. If the source is actually a directory, copy it
  6832. to the build tree, and enter that directory.
  6833. @item patch-source-shebangs
  6834. Patch shebangs encountered in source files so they refer to the right
  6835. store file names. For instance, this changes @code{#!/bin/sh} to
  6836. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  6837. @item configure
  6838. Run the @file{configure} script with a number of default options, such
  6839. as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
  6840. by the @code{#:configure-flags} argument.
  6841. @item build
  6842. Run @code{make} with the list of flags specified with
  6843. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  6844. (the default), build with @code{make -j}.
  6845. @item check
  6846. Run @code{make check}, or some other target specified with
  6847. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  6848. @code{#:parallel-tests?} argument is true (the default), run @code{make
  6849. check -j}.
  6850. @item install
  6851. Run @code{make install} with the flags listed in @code{#:make-flags}.
  6852. @item patch-shebangs
  6853. Patch shebangs on the installed executable files.
  6854. @item strip
  6855. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  6856. is false), copying them to the @code{debug} output when available
  6857. (@pxref{Installing Debugging Files}).
  6858. @end table
  6859. Other build systems have similar phases, with some variations. For
  6860. example, @code{cmake-build-system} has same-named phases but its
  6861. @code{configure} phases runs @code{cmake} instead of @code{./configure}.
  6862. Others, such as @code{python-build-system}, have a wholly different list
  6863. of standard phases. All this code runs on the @dfn{build side}: it is
  6864. evaluated when you actually build the package, in a dedicated build
  6865. process spawned by the build daemon (@pxref{Invoking guix-daemon}).
  6866. Build phases are represented as association lists or ``alists''
  6867. (@pxref{Association Lists,,, guile, GNU Guile Reference Manual}) where
  6868. each key is a symbol for the name of the phase and the associated value
  6869. is a procedure that accepts an arbitrary number of arguments. By
  6870. convention, those procedures receive information about the build in the
  6871. form of @dfn{keyword parameters}, which they can use or ignore.
  6872. @vindex %standard-phases
  6873. For example, here is how @code{(guix build gnu-build-system)} defines
  6874. @code{%standard-phases}, the variable holding its alist of build
  6875. phases@footnote{We present a simplified view of those build phases, but
  6876. do take a look at @code{(guix build gnu-build-system)} to see all the
  6877. details!}:
  6878. @lisp
  6879. ;; The build phases of 'gnu-build-system'.
  6880. (define* (unpack #:key source #:allow-other-keys)
  6881. ;; Extract the source tarball.
  6882. (invoke "tar" "xvf" source))
  6883. (define* (configure #:key outputs #:allow-other-keys)
  6884. ;; Run the 'configure' script. Install to output "out".
  6885. (let ((out (assoc-ref outputs "out")))
  6886. (invoke "./configure"
  6887. (string-append "--prefix=" out))))
  6888. (define* (build #:allow-other-keys)
  6889. ;; Compile.
  6890. (invoke "make"))
  6891. (define* (check #:key (test-target "check") (tests? #true)
  6892. #:allow-other-keys)
  6893. ;; Run the test suite.
  6894. (if tests?
  6895. (invoke "make" test-target)
  6896. (display "test suite not run\n")))
  6897. (define* (install #:allow-other-keys)
  6898. ;; Install files to the prefix 'configure' specified.
  6899. (invoke "make" "install"))
  6900. (define %standard-phases
  6901. ;; The list of standard phases (quite a few are omitted
  6902. ;; for brevity). Each element is a symbol/procedure pair.
  6903. (list (cons 'unpack unpack)
  6904. (cons 'configure configure)
  6905. (cons 'build build)
  6906. (cons 'check check)
  6907. (cons 'install install)))
  6908. @end lisp
  6909. This shows how @code{%standard-phases} is defined as a list of
  6910. symbol/procedure pairs (@pxref{Pairs,,, guile, GNU Guile Reference
  6911. Manual}). The first pair associates the @code{unpack} procedure with
  6912. the @code{unpack} symbol---a name; the second pair defines the
  6913. @code{configure} phase similarly, and so on. When building a package
  6914. that uses @code{gnu-build-system} with its default list of phases, those
  6915. phases are executed sequentially. You can see the name of each phase
  6916. started and completed in the build log of packages that you build.
  6917. Let's now look at the procedures themselves. Each one is defined with
  6918. @code{define*}: @code{#:key} lists keyword parameters the procedure
  6919. accepts, possibly with a default value, and @code{#:allow-other-keys}
  6920. specifies that other keyword parameters are ignored (@pxref{Optional
  6921. Arguments,,, guile, GNU Guile Reference Manual}).
  6922. The @code{unpack} procedure honors the @code{source} parameter, which
  6923. the build system uses to pass the file name of the source tarball (or
  6924. version control checkout), and it ignores other parameters. The
  6925. @code{configure} phase only cares about the @code{outputs} parameter, an
  6926. alist mapping package output names to their store file name
  6927. (@pxref{Packages with Multiple Outputs}). It extracts the file name of
  6928. for @code{out}, the default output, and passes it to
  6929. @command{./configure} as the installation prefix, meaning that
  6930. @command{make install} will eventually copy all the files in that
  6931. directory (@pxref{Configuration, configuration and makefile
  6932. conventions,, standards, GNU Coding Standards}). @code{build} and
  6933. @code{install} ignore all their arguments. @code{check} honors the
  6934. @code{test-target} argument, which specifies the name of the Makefile
  6935. target to run tests; it prints a message and skips tests when
  6936. @code{tests?} is false.
  6937. @cindex build phases, customizing
  6938. The list of phases used for a particular package can be changed with the
  6939. @code{#:phases} parameter of the build system. Changing the set of
  6940. build phases boils down to building a new alist of phases based on the
  6941. @code{%standard-phases} alist described above. This can be done with
  6942. standard alist procedures such as @code{alist-delete} (@pxref{SRFI-1
  6943. Association Lists,,, guile, GNU Guile Reference Manual}); however, it is
  6944. more convenient to do so with @code{modify-phases} (@pxref{Build
  6945. Utilities, @code{modify-phases}}).
  6946. Here is an example of a package definition that removes the
  6947. @code{configure} phase of @code{%standard-phases} and inserts a new
  6948. phase before the @code{build} phase, called
  6949. @code{set-prefix-in-makefile}:
  6950. @lisp
  6951. (define-public example
  6952. (package
  6953. (name "example")
  6954. ;; other fields omitted
  6955. (build-system gnu-build-system)
  6956. (arguments
  6957. '(#:phases (modify-phases %standard-phases
  6958. (delete 'configure)
  6959. (add-before 'build 'set-prefix-in-makefile
  6960. (lambda* (#:key outputs #:allow-other-keys)
  6961. ;; Modify the makefile so that its
  6962. ;; 'PREFIX' variable points to "out".
  6963. (let ((out (assoc-ref outputs "out")))
  6964. (substitute* "Makefile"
  6965. (("PREFIX =.*")
  6966. (string-append "PREFIX = "
  6967. out "\n")))
  6968. #true))))))))
  6969. @end lisp
  6970. The new phase that is inserted is written as an anonymous procedure,
  6971. introduced with @code{lambda*}; it honors the @code{outputs} parameter
  6972. we have seen before. @xref{Build Utilities}, for more about the helpers
  6973. used by this phase, and for more examples of @code{modify-phases}.
  6974. @cindex code staging
  6975. @cindex staging, of code
  6976. Keep in mind that build phases are code evaluated at the time the
  6977. package is actually built. This explains why the whole
  6978. @code{modify-phases} expression above is quoted (it comes after the
  6979. @code{'} or apostrophe): it is @dfn{staged} for later execution.
  6980. @xref{G-Expressions}, for an explanation of code staging and the
  6981. @dfn{code strata} involved.
  6982. @node Build Utilities
  6983. @section Build Utilities
  6984. As soon as you start writing non-trivial package definitions
  6985. (@pxref{Defining Packages}) or other build actions
  6986. (@pxref{G-Expressions}), you will likely start looking for helpers for
  6987. ``shell-like'' actions---creating directories, copying and deleting
  6988. files recursively, manipulating build phases, and so on. The
  6989. @code{(guix build utils)} module provides such utility procedures.
  6990. Most build systems load @code{(guix build utils)} (@pxref{Build
  6991. Systems}). Thus, when writing custom build phases for your package
  6992. definitions, you can usually assume those procedures are in scope.
  6993. When writing G-expressions, you can import @code{(guix build utils)} on
  6994. the ``build side'' using @code{with-imported-modules} and then put it in
  6995. scope with the @code{use-modules} form (@pxref{Using Guile Modules,,,
  6996. guile, GNU Guile Reference Manual}):
  6997. @lisp
  6998. (with-imported-modules '((guix build utils)) ;import it
  6999. (computed-file "empty-tree"
  7000. #~(begin
  7001. ;; Put it in scope.
  7002. (use-modules (guix build utils))
  7003. ;; Happily use its 'mkdir-p' procedure.
  7004. (mkdir-p (string-append #$output "/a/b/c")))))
  7005. @end lisp
  7006. The remainder of this section is the reference for most of the utility
  7007. procedures provided by @code{(guix build utils)}.
  7008. @c TODO Document what's missing.
  7009. @subsection Dealing with Store File Names
  7010. This section documents procedures that deal with store file names.
  7011. @deffn {Scheme Procedure} %store-directory
  7012. Return the directory name of the store.
  7013. @end deffn
  7014. @deffn {Scheme Procedure} store-file-name? @var{file}
  7015. Return true if @var{file} is in the store.
  7016. @end deffn
  7017. @deffn {Scheme Procedure} strip-store-file-name @var{file}
  7018. Strip the @file{/gnu/store} and hash from @var{file}, a store file name.
  7019. The result is typically a @code{"@var{package}-@var{version}"} string.
  7020. @end deffn
  7021. @deffn {Scheme Procedure} package-name->name+version @var{name}
  7022. Given @var{name}, a package name like @code{"foo-0.9.1b"}, return two
  7023. values: @code{"foo"} and @code{"0.9.1b"}. When the version part is
  7024. unavailable, @var{name} and @code{#f} are returned. The first hyphen
  7025. followed by a digit is considered to introduce the version part.
  7026. @end deffn
  7027. @subsection File Types
  7028. The procedures below deal with files and file types.
  7029. @deffn {Scheme Procedure} directory-exists? @var{dir}
  7030. Return @code{#t} if @var{dir} exists and is a directory.
  7031. @end deffn
  7032. @deffn {Scheme Procedure} executable-file? @var{file}
  7033. Return @code{#t} if @var{file} exists and is executable.
  7034. @end deffn
  7035. @deffn {Scheme Procedure} symbolic-link? @var{file}
  7036. Return @code{#t} if @var{file} is a symbolic link (aka. a ``symlink'').
  7037. @end deffn
  7038. @deffn {Scheme Procedure} elf-file? @var{file}
  7039. @deffnx {Scheme Procedure} ar-file? @var{file}
  7040. @deffnx {Scheme Procedure} gzip-file? @var{file}
  7041. Return @code{#t} if @var{file} is, respectively, an ELF file, an
  7042. @code{ar} archive (such as a @file{.a} static library), or a gzip file.
  7043. @end deffn
  7044. @deffn {Scheme Procedure} reset-gzip-timestamp @var{file} [#:keep-mtime? #t]
  7045. If @var{file} is a gzip file, reset its embedded timestamp (as with
  7046. @command{gzip --no-name}) and return true. Otherwise return @code{#f}.
  7047. When @var{keep-mtime?} is true, preserve @var{file}'s modification time.
  7048. @end deffn
  7049. @subsection File Manipulation
  7050. The following procedures and macros help create, modify, and delete
  7051. files. They provide functionality comparable to common shell utilities
  7052. such as @command{mkdir -p}, @command{cp -r}, @command{rm -r}, and
  7053. @command{sed}. They complement Guile's extensive, but low-level, file
  7054. system interface (@pxref{POSIX,,, guile, GNU Guile Reference Manual}).
  7055. @deffn {Scheme Syntax} with-directory-excursion @var{directory} @var{body}@dots{}
  7056. Run @var{body} with @var{directory} as the process's current directory.
  7057. Essentially, this macro changes the current directory to @var{directory}
  7058. before evaluating @var{body}, using @code{chdir} (@pxref{Processes,,,
  7059. guile, GNU Guile Reference Manual}). It changes back to the initial
  7060. directory when the dynamic extent of @var{body} is left, be it @i{via}
  7061. normal procedure return or @i{via} a non-local exit such as an
  7062. exception.
  7063. @end deffn
  7064. @deffn {Scheme Procedure} mkdir-p @var{dir}
  7065. Create directory @var{dir} and all its ancestors.
  7066. @end deffn
  7067. @deffn {Scheme Procedure} install-file @var{file} @var{directory}
  7068. Create @var{directory} if it does not exist and copy @var{file} in there
  7069. under the same name.
  7070. @end deffn
  7071. @deffn {Scheme Procedure} make-file-writable @var{file}
  7072. Make @var{file} writable for its owner.
  7073. @end deffn
  7074. @deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
  7075. [#:log (current-output-port)] [#:follow-symlinks? #f] @
  7076. [#:copy-file copy-file] [#:keep-mtime? #f] [#:keep-permissions? #t]
  7077. Copy @var{source} directory to @var{destination}. Follow symlinks if
  7078. @var{follow-symlinks?} is true; otherwise, just preserve them. Call
  7079. @var{copy-file} to copy regular files. When @var{keep-mtime?} is true,
  7080. keep the modification time of the files in @var{source} on those of
  7081. @var{destination}. When @var{keep-permissions?} is true, preserve file
  7082. permissions. Write verbose output to the @var{log} port.
  7083. @end deffn
  7084. @deffn {Scheme Procedure} delete-file-recursively @var{dir} @
  7085. [#:follow-mounts? #f]
  7086. Delete @var{dir} recursively, like @command{rm -rf}, without following
  7087. symlinks. Don't follow mount points either, unless @var{follow-mounts?}
  7088. is true. Report but ignore errors.
  7089. @end deffn
  7090. @deffn {Scheme Syntax} substitute* @var{file} @
  7091. ((@var{regexp} @var{match-var}@dots{}) @var{body}@dots{}) @dots{}
  7092. Substitute @var{regexp} in @var{file} by the string returned by
  7093. @var{body}. @var{body} is evaluated with each @var{match-var} bound to
  7094. the corresponding positional regexp sub-expression. For example:
  7095. @lisp
  7096. (substitute* file
  7097. (("hello")
  7098. "good morning\n")
  7099. (("foo([a-z]+)bar(.*)$" all letters end)
  7100. (string-append "baz" letter end)))
  7101. @end lisp
  7102. Here, anytime a line of @var{file} contains @code{hello}, it is replaced
  7103. by @code{good morning}. Anytime a line of @var{file} matches the second
  7104. regexp, @code{all} is bound to the complete match, @code{letters} is bound
  7105. to the first sub-expression, and @code{end} is bound to the last one.
  7106. When one of the @var{match-var} is @code{_}, no variable is bound to the
  7107. corresponding match substring.
  7108. Alternatively, @var{file} may be a list of file names, in which case
  7109. they are all subject to the substitutions.
  7110. Be careful about using @code{$} to match the end of a line; by itself it
  7111. won't match the terminating newline of a line.
  7112. @end deffn
  7113. @subsection File Search
  7114. @cindex file, searching
  7115. This section documents procedures to search and filter files.
  7116. @deffn {Scheme Procedure} file-name-predicate @var{regexp}
  7117. Return a predicate that returns true when passed a file name whose base
  7118. name matches @var{regexp}.
  7119. @end deffn
  7120. @deffn {Scheme Procedure} find-files @var{dir} [@var{pred}] @
  7121. [#:stat lstat] [#:directories? #f] [#:fail-on-error? #f]
  7122. Return the lexicographically sorted list of files under @var{dir} for
  7123. which @var{pred} returns true. @var{pred} is passed two arguments: the
  7124. absolute file name, and its stat buffer; the default predicate always
  7125. returns true. @var{pred} can also be a regular expression, in which
  7126. case it is equivalent to @code{(file-name-predicate @var{pred})}.
  7127. @var{stat} is used to obtain file information; using @code{lstat} means
  7128. that symlinks are not followed. If @var{directories?} is true, then
  7129. directories will also be included. If @var{fail-on-error?} is true,
  7130. raise an exception upon error.
  7131. @end deffn
  7132. Here are a few examples where we assume that the current directory is
  7133. the root of the Guix source tree:
  7134. @lisp
  7135. ;; List all the regular files in the current directory.
  7136. (find-files ".")
  7137. @result{} ("./.dir-locals.el" "./.gitignore" @dots{})
  7138. ;; List all the .scm files under gnu/services.
  7139. (find-files "gnu/services" "\\.scm$")
  7140. @result{} ("gnu/services/admin.scm" "gnu/services/audio.scm" @dots{})
  7141. ;; List ar files in the current directory.
  7142. (find-files "." (lambda (file stat) (ar-file? file)))
  7143. @result{} ("./libformat.a" "./libstore.a" @dots{})
  7144. @end lisp
  7145. @deffn {Scheme Procedure} which @var{program}
  7146. Return the complete file name for @var{program} as found in
  7147. @code{$PATH}, or @code{#f} if @var{program} could not be found.
  7148. @end deffn
  7149. @deffn {Scheme Procedure} search-input-file @var{inputs} @var{name}
  7150. @deffnx {Scheme Procedure} search-input-directory @var{inputs} @var{name}
  7151. Return the complete file name for @var{name} as found in @var{inputs};
  7152. @code{search-input-file} searches for a regular file and
  7153. @code{search-input-directory} searches for a directory. If @var{name}
  7154. could not be found, an exception is raised.
  7155. Here, @var{inputs} must be an association list like @code{inputs} and
  7156. @code{native-inputs} as available to build phases (@pxref{Build
  7157. Phases}).
  7158. @end deffn
  7159. Here is a (simplified) example of how @code{search-input-file} is used
  7160. in a build phase of the @code{wireguard-tools} package:
  7161. @lisp
  7162. (add-after 'install 'wrap-wg-quick
  7163. (lambda* (#:key inputs outputs #:allow-other-keys)
  7164. (let ((coreutils (string-append (assoc-ref inputs "coreutils")
  7165. "/bin")))
  7166. (wrap-program (search-input-file outputs "bin/wg-quick")
  7167. #:sh (search-input-file inputs "bin/bash")
  7168. `("PATH" ":" prefix ,(list coreutils))))))
  7169. @end lisp
  7170. @subsection Build Phases
  7171. @cindex build phases
  7172. The @code{(guix build utils)} also contains tools to manipulate build
  7173. phases as used by build systems (@pxref{Build Systems}). Build phases
  7174. are represented as association lists or ``alists'' (@pxref{Association
  7175. Lists,,, guile, GNU Guile Reference Manual}) where each key is a symbol
  7176. naming the phase and the associated value is a procedure (@pxref{Build
  7177. Phases}).
  7178. Guile core and the @code{(srfi srfi-1)} module both provide tools to
  7179. manipulate alists. The @code{(guix build utils)} module complements
  7180. those with tools written with build phases in mind.
  7181. @cindex build phases, modifying
  7182. @deffn {Scheme Syntax} modify-phases @var{phases} @var{clause}@dots{}
  7183. Modify @var{phases} sequentially as per each @var{clause}, which may
  7184. have one of the following forms:
  7185. @lisp
  7186. (delete @var{old-phase-name})
  7187. (replace @var{old-phase-name} @var{new-phase})
  7188. (add-before @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7189. (add-after @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7190. @end lisp
  7191. Where every @var{phase-name} above is an expression evaluating to a
  7192. symbol, and @var{new-phase} an expression evaluating to a procedure.
  7193. @end deffn
  7194. The example below is taken from the definition of the @code{grep}
  7195. package. It adds a phase to run after the @code{install} phase, called
  7196. @code{fix-egrep-and-fgrep}. That phase is a procedure (@code{lambda*}
  7197. is for anonymous procedures) that takes a @code{#:outputs} keyword
  7198. argument and ignores extra keyword arguments (@pxref{Optional
  7199. Arguments,,, guile, GNU Guile Reference Manual}, for more on
  7200. @code{lambda*} and optional and keyword arguments.) The phase uses
  7201. @code{substitute*} to modify the installed @file{egrep} and @file{fgrep}
  7202. scripts so that they refer to @code{grep} by its absolute file name:
  7203. @lisp
  7204. (modify-phases %standard-phases
  7205. (add-after 'install 'fix-egrep-and-fgrep
  7206. ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
  7207. ;; absolute file name instead of searching for it in $PATH.
  7208. (lambda* (#:key outputs #:allow-other-keys)
  7209. (let* ((out (assoc-ref outputs "out"))
  7210. (bin (string-append out "/bin")))
  7211. (substitute* (list (string-append bin "/egrep")
  7212. (string-append bin "/fgrep"))
  7213. (("^exec grep")
  7214. (string-append "exec " bin "/grep")))
  7215. #t))))
  7216. @end lisp
  7217. In the example below, phases are modified in two ways: the standard
  7218. @code{configure} phase is deleted, presumably because the package does
  7219. not have a @file{configure} script or anything similar, and the default
  7220. @code{install} phase is replaced by one that manually copies the
  7221. executable files to be installed:
  7222. @lisp
  7223. (modify-phases %standard-phases
  7224. (delete 'configure) ;no 'configure' script
  7225. (replace 'install
  7226. (lambda* (#:key outputs #:allow-other-keys)
  7227. ;; The package's Makefile doesn't provide an "install"
  7228. ;; rule so do it by ourselves.
  7229. (let ((bin (string-append (assoc-ref outputs "out")
  7230. "/bin")))
  7231. (install-file "footswitch" bin)
  7232. (install-file "scythe" bin)
  7233. #t))))
  7234. @end lisp
  7235. @c TODO: Add more examples.
  7236. @node The Store
  7237. @section The Store
  7238. @cindex store
  7239. @cindex store items
  7240. @cindex store paths
  7241. Conceptually, the @dfn{store} is the place where derivations that have
  7242. been built successfully are stored---by default, @file{/gnu/store}.
  7243. Sub-directories in the store are referred to as @dfn{store items} or
  7244. sometimes @dfn{store paths}. The store has an associated database that
  7245. contains information such as the store paths referred to by each store
  7246. path, and the list of @emph{valid} store items---results of successful
  7247. builds. This database resides in @file{@var{localstatedir}/guix/db},
  7248. where @var{localstatedir} is the state directory specified @i{via}
  7249. @option{--localstatedir} at configure time, usually @file{/var}.
  7250. The store is @emph{always} accessed by the daemon on behalf of its clients
  7251. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  7252. connect to the daemon over a Unix-domain socket, send requests to it,
  7253. and read the result---these are remote procedure calls, or RPCs.
  7254. @quotation Note
  7255. Users must @emph{never} modify files under @file{/gnu/store} directly.
  7256. This would lead to inconsistencies and break the immutability
  7257. assumptions of Guix's functional model (@pxref{Introduction}).
  7258. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  7259. how to check the integrity of the store and attempt recovery from
  7260. accidental modifications.
  7261. @end quotation
  7262. The @code{(guix store)} module provides procedures to connect to the
  7263. daemon, and to perform RPCs. These are described below. By default,
  7264. @code{open-connection}, and thus all the @command{guix} commands,
  7265. connect to the local daemon or to the URI specified by the
  7266. @env{GUIX_DAEMON_SOCKET} environment variable.
  7267. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  7268. When set, the value of this variable should be a file name or a URI
  7269. designating the daemon endpoint. When it is a file name, it denotes a
  7270. Unix-domain socket to connect to. In addition to file names, the
  7271. supported URI schemes are:
  7272. @table @code
  7273. @item file
  7274. @itemx unix
  7275. These are for Unix-domain sockets.
  7276. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  7277. @file{/var/guix/daemon-socket/socket}.
  7278. @item guix
  7279. @cindex daemon, remote access
  7280. @cindex remote access to the daemon
  7281. @cindex daemon, cluster setup
  7282. @cindex clusters, daemon setup
  7283. These URIs denote connections over TCP/IP, without encryption nor
  7284. authentication of the remote host. The URI must specify the host name
  7285. and optionally a port number (by default port 44146 is used):
  7286. @example
  7287. guix://master.guix.example.org:1234
  7288. @end example
  7289. This setup is suitable on local networks, such as clusters, where only
  7290. trusted nodes may connect to the build daemon at
  7291. @code{master.guix.example.org}.
  7292. The @option{--listen} option of @command{guix-daemon} can be used to
  7293. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  7294. @option{--listen}}).
  7295. @item ssh
  7296. @cindex SSH access to build daemons
  7297. These URIs allow you to connect to a remote daemon over SSH@. This
  7298. feature requires Guile-SSH (@pxref{Requirements}) and a working
  7299. @command{guile} binary in @env{PATH} on the destination machine. It
  7300. supports public key and GSSAPI authentication. A typical URL might look
  7301. like this:
  7302. @example
  7303. ssh://charlie@@guix.example.org:22
  7304. @end example
  7305. As for @command{guix copy}, the usual OpenSSH client configuration files
  7306. are honored (@pxref{Invoking guix copy}).
  7307. @end table
  7308. Additional URI schemes may be supported in the future.
  7309. @c XXX: Remove this note when the protocol incurs fewer round trips
  7310. @c and when (guix derivations) no longer relies on file system access.
  7311. @quotation Note
  7312. The ability to connect to remote build daemons is considered
  7313. experimental as of @value{VERSION}. Please get in touch with us to
  7314. share any problems or suggestions you may have (@pxref{Contributing}).
  7315. @end quotation
  7316. @end defvr
  7317. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  7318. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  7319. @var{reserve-space?} is true, instruct it to reserve a little bit of
  7320. extra space on the file system so that the garbage collector can still
  7321. operate should the disk become full. Return a server object.
  7322. @var{file} defaults to @code{%default-socket-path}, which is the normal
  7323. location given the options that were passed to @command{configure}.
  7324. @end deffn
  7325. @deffn {Scheme Procedure} close-connection @var{server}
  7326. Close the connection to @var{server}.
  7327. @end deffn
  7328. @defvr {Scheme Variable} current-build-output-port
  7329. This variable is bound to a SRFI-39 parameter, which refers to the port
  7330. where build and error logs sent by the daemon should be written.
  7331. @end defvr
  7332. Procedures that make RPCs all take a server object as their first
  7333. argument.
  7334. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  7335. @cindex invalid store items
  7336. Return @code{#t} when @var{path} designates a valid store item and
  7337. @code{#f} otherwise (an invalid item may exist on disk but still be
  7338. invalid, for instance because it is the result of an aborted or failed
  7339. build).
  7340. A @code{&store-protocol-error} condition is raised if @var{path} is not
  7341. prefixed by the store directory (@file{/gnu/store}).
  7342. @end deffn
  7343. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  7344. Add @var{text} under file @var{name} in the store, and return its store
  7345. path. @var{references} is the list of store paths referred to by the
  7346. resulting store path.
  7347. @end deffn
  7348. @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
  7349. [@var{mode}]
  7350. Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
  7351. file names, or derivation/output pairs, using the specified
  7352. @var{mode}---@code{(build-mode normal)} by default.
  7353. @end deffn
  7354. Note that the @code{(guix monads)} module provides a monad as well as
  7355. monadic versions of the above procedures, with the goal of making it
  7356. more convenient to work with code that accesses the store (@pxref{The
  7357. Store Monad}).
  7358. @c FIXME
  7359. @i{This section is currently incomplete.}
  7360. @node Derivations
  7361. @section Derivations
  7362. @cindex derivations
  7363. Low-level build actions and the environment in which they are performed
  7364. are represented by @dfn{derivations}. A derivation contains the
  7365. following pieces of information:
  7366. @itemize
  7367. @item
  7368. The outputs of the derivation---derivations produce at least one file or
  7369. directory in the store, but may produce more.
  7370. @item
  7371. @cindex build-time dependencies
  7372. @cindex dependencies, build-time
  7373. The inputs of the derivations---i.e., its build-time dependencies---which may
  7374. be other derivations or plain files in the store (patches, build scripts,
  7375. etc.).
  7376. @item
  7377. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  7378. @item
  7379. The file name of a build script in the store, along with the arguments
  7380. to be passed.
  7381. @item
  7382. A list of environment variables to be defined.
  7383. @end itemize
  7384. @cindex derivation path
  7385. Derivations allow clients of the daemon to communicate build actions to
  7386. the store. They exist in two forms: as an in-memory representation,
  7387. both on the client- and daemon-side, and as files in the store whose
  7388. name end in @file{.drv}---these files are referred to as @dfn{derivation
  7389. paths}. Derivations paths can be passed to the @code{build-derivations}
  7390. procedure to perform the build actions they prescribe (@pxref{The
  7391. Store}).
  7392. @cindex fixed-output derivations
  7393. Operations such as file downloads and version-control checkouts for
  7394. which the expected content hash is known in advance are modeled as
  7395. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  7396. of a fixed-output derivation are independent of its inputs---e.g., a
  7397. source code download produces the same result regardless of the download
  7398. method and tools being used.
  7399. @cindex references
  7400. @cindex run-time dependencies
  7401. @cindex dependencies, run-time
  7402. The outputs of derivations---i.e., the build results---have a set of
  7403. @dfn{references}, as reported by the @code{references} RPC or the
  7404. @command{guix gc --references} command (@pxref{Invoking guix gc}). References
  7405. are the set of run-time dependencies of the build results. References are a
  7406. subset of the inputs of the derivation; this subset is automatically computed
  7407. by the build daemon by scanning all the files in the outputs.
  7408. The @code{(guix derivations)} module provides a representation of
  7409. derivations as Scheme objects, along with procedures to create and
  7410. otherwise manipulate derivations. The lowest-level primitive to create
  7411. a derivation is the @code{derivation} procedure:
  7412. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  7413. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7414. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  7415. [#:system (%current-system)] [#:references-graphs #f] @
  7416. [#:allowed-references #f] [#:disallowed-references #f] @
  7417. [#:leaked-env-vars #f] [#:local-build? #f] @
  7418. [#:substitutable? #t] [#:properties '()]
  7419. Build a derivation with the given arguments, and return the resulting
  7420. @code{<derivation>} object.
  7421. When @var{hash} and @var{hash-algo} are given, a
  7422. @dfn{fixed-output derivation} is created---i.e., one whose result is
  7423. known in advance, such as a file download. If, in addition,
  7424. @var{recursive?} is true, then that fixed output may be an executable
  7425. file or a directory and @var{hash} must be the hash of an archive
  7426. containing this output.
  7427. When @var{references-graphs} is true, it must be a list of file
  7428. name/store path pairs. In that case, the reference graph of each store
  7429. path is exported in the build environment in the corresponding file, in
  7430. a simple text format.
  7431. When @var{allowed-references} is true, it must be a list of store items
  7432. or outputs that the derivation's output may refer to. Likewise,
  7433. @var{disallowed-references}, if true, must be a list of things the
  7434. outputs may @emph{not} refer to.
  7435. When @var{leaked-env-vars} is true, it must be a list of strings
  7436. denoting environment variables that are allowed to ``leak'' from the
  7437. daemon's environment to the build environment. This is only applicable
  7438. to fixed-output derivations---i.e., when @var{hash} is true. The main
  7439. use is to allow variables such as @code{http_proxy} to be passed to
  7440. derivations that download files.
  7441. When @var{local-build?} is true, declare that the derivation is not a
  7442. good candidate for offloading and should rather be built locally
  7443. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  7444. where the costs of data transfers would outweigh the benefits.
  7445. When @var{substitutable?} is false, declare that substitutes of the
  7446. derivation's output should not be used (@pxref{Substitutes}). This is
  7447. useful, for instance, when building packages that capture details of the
  7448. host CPU instruction set.
  7449. @var{properties} must be an association list describing ``properties'' of the
  7450. derivation. It is kept as-is, uninterpreted, in the derivation.
  7451. @end deffn
  7452. @noindent
  7453. Here's an example with a shell script as its builder, assuming
  7454. @var{store} is an open connection to the daemon, and @var{bash} points
  7455. to a Bash executable in the store:
  7456. @lisp
  7457. (use-modules (guix utils)
  7458. (guix store)
  7459. (guix derivations))
  7460. (let ((builder ; add the Bash script to the store
  7461. (add-text-to-store store "my-builder.sh"
  7462. "echo hello world > $out\n" '())))
  7463. (derivation store "foo"
  7464. bash `("-e" ,builder)
  7465. #:inputs `((,bash) (,builder))
  7466. #:env-vars '(("HOME" . "/homeless"))))
  7467. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  7468. @end lisp
  7469. As can be guessed, this primitive is cumbersome to use directly. A
  7470. better approach is to write build scripts in Scheme, of course! The
  7471. best course of action for that is to write the build code as a
  7472. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  7473. information, @pxref{G-Expressions}.
  7474. Once upon a time, @code{gexp->derivation} did not exist and constructing
  7475. derivations with build code written in Scheme was achieved with
  7476. @code{build-expression->derivation}, documented below. This procedure
  7477. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  7478. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  7479. @var{name} @var{exp} @
  7480. [#:system (%current-system)] [#:inputs '()] @
  7481. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7482. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  7483. [#:references-graphs #f] [#:allowed-references #f] @
  7484. [#:disallowed-references #f] @
  7485. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  7486. Return a derivation that executes Scheme expression @var{exp} as a
  7487. builder for derivation @var{name}. @var{inputs} must be a list of
  7488. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  7489. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  7490. modules from the current search path to be copied in the store,
  7491. compiled, and made available in the load path during the execution of
  7492. @var{exp}---e.g., @code{((guix build utils) (guix build
  7493. gnu-build-system))}.
  7494. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  7495. to a list of output/path pairs, and where @code{%build-inputs} is bound
  7496. to a list of string/output-path pairs made from @var{inputs}.
  7497. Optionally, @var{env-vars} is a list of string pairs specifying the name
  7498. and value of environment variables visible to the builder. The builder
  7499. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  7500. @var{exp} returns @code{#f}, the build is considered to have failed.
  7501. @var{exp} is built using @var{guile-for-build} (a derivation). When
  7502. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  7503. @code{%guile-for-build} fluid is used instead.
  7504. See the @code{derivation} procedure for the meaning of
  7505. @var{references-graphs}, @var{allowed-references},
  7506. @var{disallowed-references}, @var{local-build?}, and
  7507. @var{substitutable?}.
  7508. @end deffn
  7509. @noindent
  7510. Here's an example of a single-output derivation that creates a directory
  7511. containing one file:
  7512. @lisp
  7513. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  7514. (mkdir out) ; create /gnu/store/@dots{}-goo
  7515. (call-with-output-file (string-append out "/test")
  7516. (lambda (p)
  7517. (display '(hello guix) p))))))
  7518. (build-expression->derivation store "goo" builder))
  7519. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  7520. @end lisp
  7521. @node The Store Monad
  7522. @section The Store Monad
  7523. @cindex monad
  7524. The procedures that operate on the store described in the previous
  7525. sections all take an open connection to the build daemon as their first
  7526. argument. Although the underlying model is functional, they either have
  7527. side effects or depend on the current state of the store.
  7528. The former is inconvenient: the connection to the build daemon has to be
  7529. carried around in all those functions, making it impossible to compose
  7530. functions that do not take that parameter with functions that do. The
  7531. latter can be problematic: since store operations have side effects
  7532. and/or depend on external state, they have to be properly sequenced.
  7533. @cindex monadic values
  7534. @cindex monadic functions
  7535. This is where the @code{(guix monads)} module comes in. This module
  7536. provides a framework for working with @dfn{monads}, and a particularly
  7537. useful monad for our uses, the @dfn{store monad}. Monads are a
  7538. construct that allows two things: associating ``context'' with values
  7539. (in our case, the context is the store), and building sequences of
  7540. computations (here computations include accesses to the store). Values
  7541. in a monad---values that carry this additional context---are called
  7542. @dfn{monadic values}; procedures that return such values are called
  7543. @dfn{monadic procedures}.
  7544. Consider this ``normal'' procedure:
  7545. @lisp
  7546. (define (sh-symlink store)
  7547. ;; Return a derivation that symlinks the 'bash' executable.
  7548. (let* ((drv (package-derivation store bash))
  7549. (out (derivation->output-path drv))
  7550. (sh (string-append out "/bin/bash")))
  7551. (build-expression->derivation store "sh"
  7552. `(symlink ,sh %output))))
  7553. @end lisp
  7554. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  7555. as a monadic function:
  7556. @lisp
  7557. (define (sh-symlink)
  7558. ;; Same, but return a monadic value.
  7559. (mlet %store-monad ((drv (package->derivation bash)))
  7560. (gexp->derivation "sh"
  7561. #~(symlink (string-append #$drv "/bin/bash")
  7562. #$output))))
  7563. @end lisp
  7564. There are several things to note in the second version: the @code{store}
  7565. parameter is now implicit and is ``threaded'' in the calls to the
  7566. @code{package->derivation} and @code{gexp->derivation} monadic
  7567. procedures, and the monadic value returned by @code{package->derivation}
  7568. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  7569. As it turns out, the call to @code{package->derivation} can even be
  7570. omitted since it will take place implicitly, as we will see later
  7571. (@pxref{G-Expressions}):
  7572. @lisp
  7573. (define (sh-symlink)
  7574. (gexp->derivation "sh"
  7575. #~(symlink (string-append #$bash "/bin/bash")
  7576. #$output)))
  7577. @end lisp
  7578. @c See
  7579. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  7580. @c for the funny quote.
  7581. Calling the monadic @code{sh-symlink} has no effect. As someone once
  7582. said, ``you exit a monad like you exit a building on fire: by running''.
  7583. So, to exit the monad and get the desired effect, one must use
  7584. @code{run-with-store}:
  7585. @lisp
  7586. (run-with-store (open-connection) (sh-symlink))
  7587. @result{} /gnu/store/...-sh-symlink
  7588. @end lisp
  7589. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  7590. new ``meta-commands'' to make it easier to deal with monadic procedures:
  7591. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  7592. to ``run'' a single monadic value through the store:
  7593. @example
  7594. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  7595. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7596. @end example
  7597. The latter enters a recursive REPL, where all the return values are
  7598. automatically run through the store:
  7599. @example
  7600. scheme@@(guile-user)> ,enter-store-monad
  7601. store-monad@@(guile-user) [1]> (package->derivation hello)
  7602. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7603. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  7604. $3 = "/gnu/store/@dots{}-foo"
  7605. store-monad@@(guile-user) [1]> ,q
  7606. scheme@@(guile-user)>
  7607. @end example
  7608. @noindent
  7609. Note that non-monadic values cannot be returned in the
  7610. @code{store-monad} REPL.
  7611. The main syntactic forms to deal with monads in general are provided by
  7612. the @code{(guix monads)} module and are described below.
  7613. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  7614. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  7615. in @var{monad}.
  7616. @end deffn
  7617. @deffn {Scheme Syntax} return @var{val}
  7618. Return a monadic value that encapsulates @var{val}.
  7619. @end deffn
  7620. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  7621. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  7622. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  7623. referred to as ``bind'', but that name denotes an unrelated procedure in
  7624. Guile. Thus we use this somewhat cryptic symbol inherited from the
  7625. Haskell language.}. There can be one @var{mproc} or several of them, as
  7626. in this example:
  7627. @lisp
  7628. (run-with-state
  7629. (with-monad %state-monad
  7630. (>>= (return 1)
  7631. (lambda (x) (return (+ 1 x)))
  7632. (lambda (x) (return (* 2 x)))))
  7633. 'some-state)
  7634. @result{} 4
  7635. @result{} some-state
  7636. @end lisp
  7637. @end deffn
  7638. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  7639. @var{body} ...
  7640. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  7641. @var{body} ...
  7642. Bind the variables @var{var} to the monadic values @var{mval} in
  7643. @var{body}, which is a sequence of expressions. As with the bind
  7644. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  7645. value ``contained'' in @var{mval} and making @var{var} refer to that
  7646. raw, non-monadic value within the scope of the @var{body}. The form
  7647. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  7648. @var{val}, as per @code{let}. The binding operations occur in sequence
  7649. from left to right. The last expression of @var{body} must be a monadic
  7650. expression, and its result will become the result of the @code{mlet} or
  7651. @code{mlet*} when run in the @var{monad}.
  7652. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  7653. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  7654. @end deffn
  7655. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  7656. Bind @var{mexp} and the following monadic expressions in sequence,
  7657. returning the result of the last expression. Every expression in the
  7658. sequence must be a monadic expression.
  7659. This is akin to @code{mlet}, except that the return values of the
  7660. monadic expressions are ignored. In that sense, it is analogous to
  7661. @code{begin}, but applied to monadic expressions.
  7662. @end deffn
  7663. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  7664. When @var{condition} is true, evaluate the sequence of monadic
  7665. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  7666. @var{condition} is false, return @code{*unspecified*} in the current
  7667. monad. Every expression in the sequence must be a monadic expression.
  7668. @end deffn
  7669. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  7670. When @var{condition} is false, evaluate the sequence of monadic
  7671. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  7672. @var{condition} is true, return @code{*unspecified*} in the current
  7673. monad. Every expression in the sequence must be a monadic expression.
  7674. @end deffn
  7675. @cindex state monad
  7676. The @code{(guix monads)} module provides the @dfn{state monad}, which
  7677. allows an additional value---the state---to be @emph{threaded} through
  7678. monadic procedure calls.
  7679. @defvr {Scheme Variable} %state-monad
  7680. The state monad. Procedures in the state monad can access and change
  7681. the state that is threaded.
  7682. Consider the example below. The @code{square} procedure returns a value
  7683. in the state monad. It returns the square of its argument, but also
  7684. increments the current state value:
  7685. @lisp
  7686. (define (square x)
  7687. (mlet %state-monad ((count (current-state)))
  7688. (mbegin %state-monad
  7689. (set-current-state (+ 1 count))
  7690. (return (* x x)))))
  7691. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  7692. @result{} (0 1 4)
  7693. @result{} 3
  7694. @end lisp
  7695. When ``run'' through @code{%state-monad}, we obtain that additional state
  7696. value, which is the number of @code{square} calls.
  7697. @end defvr
  7698. @deffn {Monadic Procedure} current-state
  7699. Return the current state as a monadic value.
  7700. @end deffn
  7701. @deffn {Monadic Procedure} set-current-state @var{value}
  7702. Set the current state to @var{value} and return the previous state as a
  7703. monadic value.
  7704. @end deffn
  7705. @deffn {Monadic Procedure} state-push @var{value}
  7706. Push @var{value} to the current state, which is assumed to be a list,
  7707. and return the previous state as a monadic value.
  7708. @end deffn
  7709. @deffn {Monadic Procedure} state-pop
  7710. Pop a value from the current state and return it as a monadic value.
  7711. The state is assumed to be a list.
  7712. @end deffn
  7713. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  7714. Run monadic value @var{mval} starting with @var{state} as the initial
  7715. state. Return two values: the resulting value, and the resulting state.
  7716. @end deffn
  7717. The main interface to the store monad, provided by the @code{(guix
  7718. store)} module, is as follows.
  7719. @defvr {Scheme Variable} %store-monad
  7720. The store monad---an alias for @code{%state-monad}.
  7721. Values in the store monad encapsulate accesses to the store. When its
  7722. effect is needed, a value of the store monad must be ``evaluated'' by
  7723. passing it to the @code{run-with-store} procedure (see below).
  7724. @end defvr
  7725. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  7726. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  7727. open store connection.
  7728. @end deffn
  7729. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  7730. Return as a monadic value the absolute file name in the store of the file
  7731. containing @var{text}, a string. @var{references} is a list of store items that the
  7732. resulting text file refers to; it defaults to the empty list.
  7733. @end deffn
  7734. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  7735. Return as a monadic value the absolute file name in the store of the file
  7736. containing @var{data}, a bytevector. @var{references} is a list of store
  7737. items that the resulting binary file refers to; it defaults to the empty list.
  7738. @end deffn
  7739. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  7740. [#:recursive? #t] [#:select? (const #t)]
  7741. Return the name of @var{file} once interned in the store. Use
  7742. @var{name} as its store name, or the basename of @var{file} if
  7743. @var{name} is omitted.
  7744. When @var{recursive?} is true, the contents of @var{file} are added
  7745. recursively; if @var{file} designates a flat file and @var{recursive?}
  7746. is true, its contents are added, and its permission bits are kept.
  7747. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  7748. @var{stat})} for each directory entry, where @var{file} is the entry's
  7749. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  7750. entries for which @var{select?} does not return true.
  7751. The example below adds a file to the store, under two different names:
  7752. @lisp
  7753. (run-with-store (open-connection)
  7754. (mlet %store-monad ((a (interned-file "README"))
  7755. (b (interned-file "README" "LEGU-MIN")))
  7756. (return (list a b))))
  7757. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  7758. @end lisp
  7759. @end deffn
  7760. The @code{(guix packages)} module exports the following package-related
  7761. monadic procedures:
  7762. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  7763. [#:system (%current-system)] [#:target #f] @
  7764. [#:output "out"]
  7765. Return as a monadic
  7766. value in the absolute file name of @var{file} within the @var{output}
  7767. directory of @var{package}. When @var{file} is omitted, return the name
  7768. of the @var{output} directory of @var{package}. When @var{target} is
  7769. true, use it as a cross-compilation target triplet.
  7770. Note that this procedure does @emph{not} build @var{package}. Thus, the
  7771. result might or might not designate an existing file. We recommend not
  7772. using this procedure unless you know what you are doing.
  7773. @end deffn
  7774. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  7775. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  7776. @var{target} [@var{system}]
  7777. Monadic version of @code{package-derivation} and
  7778. @code{package-cross-derivation} (@pxref{Defining Packages}).
  7779. @end deffn
  7780. @node G-Expressions
  7781. @section G-Expressions
  7782. @cindex G-expression
  7783. @cindex build code quoting
  7784. So we have ``derivations'', which represent a sequence of build actions
  7785. to be performed to produce an item in the store (@pxref{Derivations}).
  7786. These build actions are performed when asking the daemon to actually
  7787. build the derivations; they are run by the daemon in a container
  7788. (@pxref{Invoking guix-daemon}).
  7789. @cindex code staging
  7790. @cindex staging, of code
  7791. @cindex strata of code
  7792. It should come as no surprise that we like to write these build actions
  7793. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  7794. code@footnote{The term @dfn{stratum} in this context was coined by
  7795. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  7796. Kiselyov, who has written insightful
  7797. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  7798. on this topic}, refers to this kind of code generation as
  7799. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  7800. to the daemon, etc.---and the ``build code''---code that actually
  7801. performs build actions, such as making directories, invoking
  7802. @command{make}, and so on (@pxref{Build Phases}).
  7803. To describe a derivation and its build actions, one typically needs to
  7804. embed build code inside host code. It boils down to manipulating build
  7805. code as data, and the homoiconicity of Scheme---code has a direct
  7806. representation as data---comes in handy for that. But we need more than
  7807. the normal @code{quasiquote} mechanism in Scheme to construct build
  7808. expressions.
  7809. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  7810. S-expressions adapted to build expressions. G-expressions, or
  7811. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  7812. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  7813. @code{#$}, and @code{#$@@}), which are comparable to
  7814. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  7815. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  7816. GNU Guile Reference Manual}). However, there are major differences:
  7817. @itemize
  7818. @item
  7819. Gexps are meant to be written to a file and run or manipulated by other
  7820. processes.
  7821. @item
  7822. When a high-level object such as a package or derivation is unquoted
  7823. inside a gexp, the result is as if its output file name had been
  7824. introduced.
  7825. @item
  7826. Gexps carry information about the packages or derivations they refer to,
  7827. and these dependencies are automatically added as inputs to the build
  7828. processes that use them.
  7829. @end itemize
  7830. @cindex lowering, of high-level objects in gexps
  7831. This mechanism is not limited to package and derivation
  7832. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  7833. derivations or files in the store can be defined,
  7834. such that these objects can also be inserted
  7835. into gexps. For example, a useful type of high-level objects that can be
  7836. inserted in a gexp is ``file-like objects'', which make it easy to
  7837. add files to the store and to refer to them in
  7838. derivations and such (see @code{local-file} and @code{plain-file}
  7839. below).
  7840. To illustrate the idea, here is an example of a gexp:
  7841. @lisp
  7842. (define build-exp
  7843. #~(begin
  7844. (mkdir #$output)
  7845. (chdir #$output)
  7846. (symlink (string-append #$coreutils "/bin/ls")
  7847. "list-files")))
  7848. @end lisp
  7849. This gexp can be passed to @code{gexp->derivation}; we obtain a
  7850. derivation that builds a directory containing exactly one symlink to
  7851. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  7852. @lisp
  7853. (gexp->derivation "the-thing" build-exp)
  7854. @end lisp
  7855. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  7856. substituted to the reference to the @var{coreutils} package in the
  7857. actual build code, and @var{coreutils} is automatically made an input to
  7858. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  7859. output)}) is replaced by a string containing the directory name of the
  7860. output of the derivation.
  7861. @cindex cross compilation
  7862. In a cross-compilation context, it is useful to distinguish between
  7863. references to the @emph{native} build of a package---that can run on the
  7864. host---versus references to cross builds of a package. To that end, the
  7865. @code{#+} plays the same role as @code{#$}, but is a reference to a
  7866. native package build:
  7867. @lisp
  7868. (gexp->derivation "vi"
  7869. #~(begin
  7870. (mkdir #$output)
  7871. (mkdir (string-append #$output "/bin"))
  7872. (system* (string-append #+coreutils "/bin/ln")
  7873. "-s"
  7874. (string-append #$emacs "/bin/emacs")
  7875. (string-append #$output "/bin/vi")))
  7876. #:target "aarch64-linux-gnu")
  7877. @end lisp
  7878. @noindent
  7879. In the example above, the native build of @var{coreutils} is used, so
  7880. that @command{ln} can actually run on the host; but then the
  7881. cross-compiled build of @var{emacs} is referenced.
  7882. @cindex imported modules, for gexps
  7883. @findex with-imported-modules
  7884. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  7885. able to use certain Guile modules from the ``host environment'' in the
  7886. gexp, so those modules should be imported in the ``build environment''.
  7887. The @code{with-imported-modules} form allows you to express that:
  7888. @lisp
  7889. (let ((build (with-imported-modules '((guix build utils))
  7890. #~(begin
  7891. (use-modules (guix build utils))
  7892. (mkdir-p (string-append #$output "/bin"))))))
  7893. (gexp->derivation "empty-dir"
  7894. #~(begin
  7895. #$build
  7896. (display "success!\n")
  7897. #t)))
  7898. @end lisp
  7899. @noindent
  7900. In this example, the @code{(guix build utils)} module is automatically
  7901. pulled into the isolated build environment of our gexp, such that
  7902. @code{(use-modules (guix build utils))} works as expected.
  7903. @cindex module closure
  7904. @findex source-module-closure
  7905. Usually you want the @emph{closure} of the module to be imported---i.e.,
  7906. the module itself and all the modules it depends on---rather than just
  7907. the module; failing to do that, attempts to use the module will fail
  7908. because of missing dependent modules. The @code{source-module-closure}
  7909. procedure computes the closure of a module by looking at its source file
  7910. headers, which comes in handy in this case:
  7911. @lisp
  7912. (use-modules (guix modules)) ;for 'source-module-closure'
  7913. (with-imported-modules (source-module-closure
  7914. '((guix build utils)
  7915. (gnu build vm)))
  7916. (gexp->derivation "something-with-vms"
  7917. #~(begin
  7918. (use-modules (guix build utils)
  7919. (gnu build vm))
  7920. @dots{})))
  7921. @end lisp
  7922. @cindex extensions, for gexps
  7923. @findex with-extensions
  7924. In the same vein, sometimes you want to import not just pure-Scheme
  7925. modules, but also ``extensions'' such as Guile bindings to C libraries
  7926. or other ``full-blown'' packages. Say you need the @code{guile-json}
  7927. package available on the build side, here's how you would do it:
  7928. @lisp
  7929. (use-modules (gnu packages guile)) ;for 'guile-json'
  7930. (with-extensions (list guile-json)
  7931. (gexp->derivation "something-with-json"
  7932. #~(begin
  7933. (use-modules (json))
  7934. @dots{})))
  7935. @end lisp
  7936. The syntactic form to construct gexps is summarized below.
  7937. @deffn {Scheme Syntax} #~@var{exp}
  7938. @deffnx {Scheme Syntax} (gexp @var{exp})
  7939. Return a G-expression containing @var{exp}. @var{exp} may contain one
  7940. or more of the following forms:
  7941. @table @code
  7942. @item #$@var{obj}
  7943. @itemx (ungexp @var{obj})
  7944. Introduce a reference to @var{obj}. @var{obj} may have one of the
  7945. supported types, for example a package or a
  7946. derivation, in which case the @code{ungexp} form is replaced by its
  7947. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  7948. If @var{obj} is a list, it is traversed and references to supported
  7949. objects are substituted similarly.
  7950. If @var{obj} is another gexp, its contents are inserted and its
  7951. dependencies are added to those of the containing gexp.
  7952. If @var{obj} is another kind of object, it is inserted as is.
  7953. @item #$@var{obj}:@var{output}
  7954. @itemx (ungexp @var{obj} @var{output})
  7955. This is like the form above, but referring explicitly to the
  7956. @var{output} of @var{obj}---this is useful when @var{obj} produces
  7957. multiple outputs (@pxref{Packages with Multiple Outputs}).
  7958. @item #+@var{obj}
  7959. @itemx #+@var{obj}:output
  7960. @itemx (ungexp-native @var{obj})
  7961. @itemx (ungexp-native @var{obj} @var{output})
  7962. Same as @code{ungexp}, but produces a reference to the @emph{native}
  7963. build of @var{obj} when used in a cross compilation context.
  7964. @item #$output[:@var{output}]
  7965. @itemx (ungexp output [@var{output}])
  7966. Insert a reference to derivation output @var{output}, or to the main
  7967. output when @var{output} is omitted.
  7968. This only makes sense for gexps passed to @code{gexp->derivation}.
  7969. @item #$@@@var{lst}
  7970. @itemx (ungexp-splicing @var{lst})
  7971. Like the above, but splices the contents of @var{lst} inside the
  7972. containing list.
  7973. @item #+@@@var{lst}
  7974. @itemx (ungexp-native-splicing @var{lst})
  7975. Like the above, but refers to native builds of the objects listed in
  7976. @var{lst}.
  7977. @end table
  7978. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  7979. of the @code{gexp?} type (see below).
  7980. @end deffn
  7981. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  7982. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  7983. in their execution environment.
  7984. Each item in @var{modules} can be the name of a module, such as
  7985. @code{(guix build utils)}, or it can be a module name, followed by an
  7986. arrow, followed by a file-like object:
  7987. @lisp
  7988. `((guix build utils)
  7989. (guix gcrypt)
  7990. ((guix config) => ,(scheme-file "config.scm"
  7991. #~(define-module @dots{}))))
  7992. @end lisp
  7993. @noindent
  7994. In the example above, the first two modules are taken from the search
  7995. path, and the last one is created from the given file-like object.
  7996. This form has @emph{lexical} scope: it has an effect on the gexps
  7997. directly defined in @var{body}@dots{}, but not on those defined, say, in
  7998. procedures called from @var{body}@dots{}.
  7999. @end deffn
  8000. @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
  8001. Mark the gexps defined in @var{body}@dots{} as requiring
  8002. @var{extensions} in their build and execution environment.
  8003. @var{extensions} is typically a list of package objects such as those
  8004. defined in the @code{(gnu packages guile)} module.
  8005. Concretely, the packages listed in @var{extensions} are added to the
  8006. load path while compiling imported modules in @var{body}@dots{}; they
  8007. are also added to the load path of the gexp returned by
  8008. @var{body}@dots{}.
  8009. @end deffn
  8010. @deffn {Scheme Procedure} gexp? @var{obj}
  8011. Return @code{#t} if @var{obj} is a G-expression.
  8012. @end deffn
  8013. G-expressions are meant to be written to disk, either as code building
  8014. some derivation, or as plain files in the store. The monadic procedures
  8015. below allow you to do that (@pxref{The Store Monad}, for more
  8016. information about monads).
  8017. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  8018. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  8019. [#:hash #f] [#:hash-algo #f] @
  8020. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  8021. [#:module-path @code{%load-path}] @
  8022. [#:effective-version "2.2"] @
  8023. [#:references-graphs #f] [#:allowed-references #f] @
  8024. [#:disallowed-references #f] @
  8025. [#:leaked-env-vars #f] @
  8026. [#:script-name (string-append @var{name} "-builder")] @
  8027. [#:deprecation-warnings #f] @
  8028. [#:local-build? #f] [#:substitutable? #t] @
  8029. [#:properties '()] [#:guile-for-build #f]
  8030. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  8031. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  8032. stored in a file called @var{script-name}. When @var{target} is true,
  8033. it is used as the cross-compilation target triplet for packages referred
  8034. to by @var{exp}.
  8035. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  8036. Its meaning is to
  8037. make @var{modules} available in the evaluation context of @var{exp};
  8038. @var{modules} is a list of names of Guile modules searched in
  8039. @var{module-path} to be copied in the store, compiled, and made available in
  8040. the load path during the execution of @var{exp}---e.g., @code{((guix
  8041. build utils) (guix build gnu-build-system))}.
  8042. @var{effective-version} determines the string to use when adding extensions of
  8043. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  8044. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  8045. applicable.
  8046. When @var{references-graphs} is true, it must be a list of tuples of one of the
  8047. following forms:
  8048. @example
  8049. (@var{file-name} @var{package})
  8050. (@var{file-name} @var{package} @var{output})
  8051. (@var{file-name} @var{derivation})
  8052. (@var{file-name} @var{derivation} @var{output})
  8053. (@var{file-name} @var{store-item})
  8054. @end example
  8055. The right-hand-side of each element of @var{references-graphs} is automatically made
  8056. an input of the build process of @var{exp}. In the build environment, each
  8057. @var{file-name} contains the reference graph of the corresponding item, in a simple
  8058. text format.
  8059. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  8060. In the latter case, the list denotes store items that the result is allowed to
  8061. refer to. Any reference to another store item will lead to a build error.
  8062. Similarly for @var{disallowed-references}, which can list items that must not be
  8063. referenced by the outputs.
  8064. @var{deprecation-warnings} determines whether to show deprecation warnings while
  8065. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  8066. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  8067. @end deffn
  8068. @cindex file-like objects
  8069. The @code{local-file}, @code{plain-file}, @code{computed-file},
  8070. @code{program-file}, and @code{scheme-file} procedures below return
  8071. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  8072. these objects lead to a file in the store. Consider this G-expression:
  8073. @lisp
  8074. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  8075. #$(local-file "/tmp/my-nscd.conf"))
  8076. @end lisp
  8077. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  8078. to the store. Once expanded, for instance @i{via}
  8079. @code{gexp->derivation}, the G-expression refers to that copy under
  8080. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  8081. does not have any effect on what the G-expression does.
  8082. @code{plain-file} can be used similarly; it differs in that the file
  8083. content is directly passed as a string.
  8084. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  8085. [#:recursive? #f] [#:select? (const #t)]
  8086. Return an object representing local file @var{file} to add to the store;
  8087. this object can be used in a gexp. If @var{file} is a literal string
  8088. denoting a relative file name, it is looked up relative to the source
  8089. file where it appears; if @var{file} is not a literal string, it is
  8090. looked up relative to the current working directory at run time.
  8091. @var{file} will be added to the store under @var{name}--by default the
  8092. base name of @var{file}.
  8093. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  8094. designates a flat file and @var{recursive?} is true, its contents are added, and its
  8095. permission bits are kept.
  8096. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  8097. @var{stat})} for each directory entry, where @var{file} is the entry's
  8098. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  8099. entries for which @var{select?} does not return true.
  8100. This is the declarative counterpart of the @code{interned-file} monadic
  8101. procedure (@pxref{The Store Monad, @code{interned-file}}).
  8102. @end deffn
  8103. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  8104. Return an object representing a text file called @var{name} with the given
  8105. @var{content} (a string or a bytevector) to be added to the store.
  8106. This is the declarative counterpart of @code{text-file}.
  8107. @end deffn
  8108. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  8109. [#:local-build? #t]
  8110. [#:options '()]
  8111. Return an object representing the store item @var{name}, a file or
  8112. directory computed by @var{gexp}. When @var{local-build?} is true (the
  8113. default), the derivation is built locally. @var{options} is a list of
  8114. additional arguments to pass to @code{gexp->derivation}.
  8115. This is the declarative counterpart of @code{gexp->derivation}.
  8116. @end deffn
  8117. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  8118. [#:guile (default-guile)] [#:module-path %load-path] @
  8119. [#:system (%current-system)] [#:target #f]
  8120. Return an executable script @var{name} that runs @var{exp} using
  8121. @var{guile}, with @var{exp}'s imported modules in its search path.
  8122. Look up @var{exp}'s modules in @var{module-path}.
  8123. The example below builds a script that simply invokes the @command{ls}
  8124. command:
  8125. @lisp
  8126. (use-modules (guix gexp) (gnu packages base))
  8127. (gexp->script "list-files"
  8128. #~(execl #$(file-append coreutils "/bin/ls")
  8129. "ls"))
  8130. @end lisp
  8131. When ``running'' it through the store (@pxref{The Store Monad,
  8132. @code{run-with-store}}), we obtain a derivation that produces an
  8133. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  8134. @example
  8135. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  8136. !#
  8137. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  8138. @end example
  8139. @end deffn
  8140. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  8141. [#:guile #f] [#:module-path %load-path]
  8142. Return an object representing the executable store item @var{name} that
  8143. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  8144. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  8145. This is the declarative counterpart of @code{gexp->script}.
  8146. @end deffn
  8147. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  8148. [#:set-load-path? #t] [#:module-path %load-path] @
  8149. [#:splice? #f] @
  8150. [#:guile (default-guile)]
  8151. Return a derivation that builds a file @var{name} containing @var{exp}.
  8152. When @var{splice?} is true, @var{exp} is considered to be a list of
  8153. expressions that will be spliced in the resulting file.
  8154. When @var{set-load-path?} is true, emit code in the resulting file to
  8155. set @code{%load-path} and @code{%load-compiled-path} to honor
  8156. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  8157. @var{module-path}.
  8158. The resulting file holds references to all the dependencies of @var{exp}
  8159. or a subset thereof.
  8160. @end deffn
  8161. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
  8162. [#:splice? #f] [#:set-load-path? #t]
  8163. Return an object representing the Scheme file @var{name} that contains
  8164. @var{exp}.
  8165. This is the declarative counterpart of @code{gexp->file}.
  8166. @end deffn
  8167. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  8168. Return as a monadic value a derivation that builds a text file
  8169. containing all of @var{text}. @var{text} may list, in addition to
  8170. strings, objects of any type that can be used in a gexp: packages,
  8171. derivations, local file objects, etc. The resulting store file holds
  8172. references to all these.
  8173. This variant should be preferred over @code{text-file} anytime the file
  8174. to create will reference items from the store. This is typically the
  8175. case when building a configuration file that embeds store file names,
  8176. like this:
  8177. @lisp
  8178. (define (profile.sh)
  8179. ;; Return the name of a shell script in the store that
  8180. ;; initializes the 'PATH' environment variable.
  8181. (text-file* "profile.sh"
  8182. "export PATH=" coreutils "/bin:"
  8183. grep "/bin:" sed "/bin\n"))
  8184. @end lisp
  8185. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  8186. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  8187. preventing them from being garbage-collected during its lifetime.
  8188. @end deffn
  8189. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  8190. Return an object representing store file @var{name} containing
  8191. @var{text}. @var{text} is a sequence of strings and file-like objects,
  8192. as in:
  8193. @lisp
  8194. (mixed-text-file "profile"
  8195. "export PATH=" coreutils "/bin:" grep "/bin")
  8196. @end lisp
  8197. This is the declarative counterpart of @code{text-file*}.
  8198. @end deffn
  8199. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  8200. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  8201. Each item in @var{files} must be a two-element list where the first element is the
  8202. file name to use in the new directory, and the second element is a gexp
  8203. denoting the target file. Here's an example:
  8204. @lisp
  8205. (file-union "etc"
  8206. `(("hosts" ,(plain-file "hosts"
  8207. "127.0.0.1 localhost"))
  8208. ("bashrc" ,(plain-file "bashrc"
  8209. "alias ls='ls --color=auto'"))))
  8210. @end lisp
  8211. This yields an @code{etc} directory containing these two files.
  8212. @end deffn
  8213. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  8214. Return a directory that is the union of @var{things}, where @var{things} is a list of
  8215. file-like objects denoting directories. For example:
  8216. @lisp
  8217. (directory-union "guile+emacs" (list guile emacs))
  8218. @end lisp
  8219. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  8220. @end deffn
  8221. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  8222. Return a file-like object that expands to the concatenation of @var{obj}
  8223. and @var{suffix}, where @var{obj} is a lowerable object and each
  8224. @var{suffix} is a string.
  8225. As an example, consider this gexp:
  8226. @lisp
  8227. (gexp->script "run-uname"
  8228. #~(system* #$(file-append coreutils
  8229. "/bin/uname")))
  8230. @end lisp
  8231. The same effect could be achieved with:
  8232. @lisp
  8233. (gexp->script "run-uname"
  8234. #~(system* (string-append #$coreutils
  8235. "/bin/uname")))
  8236. @end lisp
  8237. There is one difference though: in the @code{file-append} case, the
  8238. resulting script contains the absolute file name as a string, whereas in
  8239. the second case, the resulting script contains a @code{(string-append
  8240. @dots{})} expression to construct the file name @emph{at run time}.
  8241. @end deffn
  8242. @deffn {Scheme Syntax} let-system @var{system} @var{body}@dots{}
  8243. @deffnx {Scheme Syntax} let-system (@var{system} @var{target}) @var{body}@dots{}
  8244. Bind @var{system} to the currently targeted system---e.g.,
  8245. @code{"x86_64-linux"}---within @var{body}.
  8246. In the second case, additionally bind @var{target} to the current
  8247. cross-compilation target---a GNU triplet such as
  8248. @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
  8249. cross-compiling.
  8250. @code{let-system} is useful in the occasional case where the object
  8251. spliced into the gexp depends on the target system, as in this example:
  8252. @lisp
  8253. #~(system*
  8254. #+(let-system system
  8255. (cond ((string-prefix? "armhf-" system)
  8256. (file-append qemu "/bin/qemu-system-arm"))
  8257. ((string-prefix? "x86_64-" system)
  8258. (file-append qemu "/bin/qemu-system-x86_64"))
  8259. (else
  8260. (error "dunno!"))))
  8261. "-net" "user" #$image)
  8262. @end lisp
  8263. @end deffn
  8264. @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
  8265. This macro is similar to the @code{parameterize} form for
  8266. dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
  8267. Guile Reference Manual}). The key difference is that it takes effect
  8268. when the file-like object returned by @var{exp} is lowered to a
  8269. derivation or store item.
  8270. A typical use of @code{with-parameters} is to force the system in effect
  8271. for a given object:
  8272. @lisp
  8273. (with-parameters ((%current-system "i686-linux"))
  8274. coreutils)
  8275. @end lisp
  8276. The example above returns an object that corresponds to the i686 build
  8277. of Coreutils, regardless of the current value of @code{%current-system}.
  8278. @end deffn
  8279. Of course, in addition to gexps embedded in ``host'' code, there are
  8280. also modules containing build tools. To make it clear that they are
  8281. meant to be used in the build stratum, these modules are kept in the
  8282. @code{(guix build @dots{})} name space.
  8283. @cindex lowering, of high-level objects in gexps
  8284. Internally, high-level objects are @dfn{lowered}, using their compiler,
  8285. to either derivations or store items. For instance, lowering a package
  8286. yields a derivation, and lowering a @code{plain-file} yields a store
  8287. item. This is achieved using the @code{lower-object} monadic procedure.
  8288. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  8289. [#:target #f]
  8290. Return as a value in @code{%store-monad} the derivation or store item
  8291. corresponding to @var{obj} for @var{system}, cross-compiling for
  8292. @var{target} if @var{target} is true. @var{obj} must be an object that
  8293. has an associated gexp compiler, such as a @code{<package>}.
  8294. @end deffn
  8295. @deffn {Procedure} gexp->approximate-sexp @var{gexp}
  8296. Sometimes, it may be useful to convert a G-exp into a S-exp. For
  8297. example, some linters (@pxref{Invoking guix lint}) peek into the build
  8298. phases of a package to detect potential problems. This conversion can
  8299. be achieved with this procedure. However, some information can be lost
  8300. in the process. More specifically, lowerable objects will be silently
  8301. replaced with some arbitrary object -- currently the list
  8302. @code{(*approximate*)}, but this may change.
  8303. @end deffn
  8304. @node Invoking guix repl
  8305. @section Invoking @command{guix repl}
  8306. @cindex REPL, read-eval-print loop, script
  8307. The @command{guix repl} command makes it easier to program Guix in Guile
  8308. by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
  8309. programming (@pxref{Using Guile Interactively,,, guile,
  8310. GNU Guile Reference Manual}), or by running Guile scripts
  8311. (@pxref{Running Guile Scripts,,, guile,
  8312. GNU Guile Reference Manual}).
  8313. Compared to just launching the @command{guile}
  8314. command, @command{guix repl} guarantees that all the Guix modules and all its
  8315. dependencies are available in the search path.
  8316. The general syntax is:
  8317. @example
  8318. guix repl @var{options} [@var{file} @var{args}]
  8319. @end example
  8320. When a @var{file} argument is provided, @var{file} is
  8321. executed as a Guile scripts:
  8322. @example
  8323. guix repl my-script.scm
  8324. @end example
  8325. To pass arguments to the script, use @code{--} to prevent them from
  8326. being interpreted as arguments to @command{guix repl} itself:
  8327. @example
  8328. guix repl -- my-script.scm --input=foo.txt
  8329. @end example
  8330. To make a script executable directly from the shell, using the guix
  8331. executable that is on the user's search path, add the following two
  8332. lines at the top of the script:
  8333. @example
  8334. @code{#!/usr/bin/env -S guix repl --}
  8335. @code{!#}
  8336. @end example
  8337. Without a file name argument, a Guile REPL is started:
  8338. @example
  8339. $ guix repl
  8340. scheme@@(guile-user)> ,use (gnu packages base)
  8341. scheme@@(guile-user)> coreutils
  8342. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  8343. @end example
  8344. @cindex inferiors
  8345. In addition, @command{guix repl} implements a simple machine-readable REPL
  8346. protocol for use by @code{(guix inferior)}, a facility to interact with
  8347. @dfn{inferiors}, separate processes running a potentially different revision
  8348. of Guix.
  8349. The available options are as follows:
  8350. @table @code
  8351. @item --type=@var{type}
  8352. @itemx -t @var{type}
  8353. Start a REPL of the given @var{TYPE}, which can be one of the following:
  8354. @table @code
  8355. @item guile
  8356. This is default, and it spawns a standard full-featured Guile REPL.
  8357. @item machine
  8358. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  8359. that the @code{(guix inferior)} module speaks.
  8360. @end table
  8361. @item --listen=@var{endpoint}
  8362. By default, @command{guix repl} reads from standard input and writes to
  8363. standard output. When this option is passed, it will instead listen for
  8364. connections on @var{endpoint}. Here are examples of valid options:
  8365. @table @code
  8366. @item --listen=tcp:37146
  8367. Accept connections on localhost on port 37146.
  8368. @item --listen=unix:/tmp/socket
  8369. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  8370. @end table
  8371. @item --load-path=@var{directory}
  8372. @itemx -L @var{directory}
  8373. Add @var{directory} to the front of the package module search path
  8374. (@pxref{Package Modules}).
  8375. This allows users to define their own packages and make them visible to
  8376. the script or REPL.
  8377. @item -q
  8378. Inhibit loading of the @file{~/.guile} file. By default, that
  8379. configuration file is loaded when spawning a @code{guile} REPL.
  8380. @end table
  8381. @c *********************************************************************
  8382. @node Utilities
  8383. @chapter Utilities
  8384. This section describes Guix command-line utilities. Some of them are
  8385. primarily targeted at developers and users who write new package
  8386. definitions, while others are more generally useful. They complement
  8387. the Scheme programming interface of Guix in a convenient way.
  8388. @menu
  8389. * Invoking guix build:: Building packages from the command line.
  8390. * Invoking guix edit:: Editing package definitions.
  8391. * Invoking guix download:: Downloading a file and printing its hash.
  8392. * Invoking guix hash:: Computing the cryptographic hash of a file.
  8393. * Invoking guix import:: Importing package definitions.
  8394. * Invoking guix refresh:: Updating package definitions.
  8395. * Invoking guix style:: Styling package definitions.
  8396. * Invoking guix lint:: Finding errors in package definitions.
  8397. * Invoking guix size:: Profiling disk usage.
  8398. * Invoking guix graph:: Visualizing the graph of packages.
  8399. * Invoking guix publish:: Sharing substitutes.
  8400. * Invoking guix challenge:: Challenging substitute servers.
  8401. * Invoking guix copy:: Copying to and from a remote store.
  8402. * Invoking guix container:: Process isolation.
  8403. * Invoking guix weather:: Assessing substitute availability.
  8404. * Invoking guix processes:: Listing client processes.
  8405. @end menu
  8406. @node Invoking guix build
  8407. @section Invoking @command{guix build}
  8408. @cindex package building
  8409. @cindex @command{guix build}
  8410. The @command{guix build} command builds packages or derivations and
  8411. their dependencies, and prints the resulting store paths. Note that it
  8412. does not modify the user's profile---this is the job of the
  8413. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  8414. it is mainly useful for distribution developers.
  8415. The general syntax is:
  8416. @example
  8417. guix build @var{options} @var{package-or-derivation}@dots{}
  8418. @end example
  8419. As an example, the following command builds the latest versions of Emacs
  8420. and of Guile, displays their build logs, and finally displays the
  8421. resulting directories:
  8422. @example
  8423. guix build emacs guile
  8424. @end example
  8425. Similarly, the following command builds all the available packages:
  8426. @example
  8427. guix build --quiet --keep-going \
  8428. $(guix package -A | awk '@{ print $1 "@@" $2 @}')
  8429. @end example
  8430. @var{package-or-derivation} may be either the name of a package found in
  8431. the software distribution such as @code{coreutils} or
  8432. @code{coreutils@@8.20}, or a derivation such as
  8433. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  8434. package with the corresponding name (and optionally version) is searched
  8435. for among the GNU distribution modules (@pxref{Package Modules}).
  8436. Alternatively, the @option{--expression} option may be used to specify a
  8437. Scheme expression that evaluates to a package; this is useful when
  8438. disambiguating among several same-named packages or package variants is
  8439. needed.
  8440. There may be zero or more @var{options}. The available options are
  8441. described in the subsections below.
  8442. @menu
  8443. * Common Build Options:: Build options for most commands.
  8444. * Package Transformation Options:: Creating variants of packages.
  8445. * Additional Build Options:: Options specific to 'guix build'.
  8446. * Debugging Build Failures:: Real life packaging experience.
  8447. @end menu
  8448. @node Common Build Options
  8449. @subsection Common Build Options
  8450. A number of options that control the build process are common to
  8451. @command{guix build} and other commands that can spawn builds, such as
  8452. @command{guix package} or @command{guix archive}. These are the
  8453. following:
  8454. @table @code
  8455. @item --load-path=@var{directory}
  8456. @itemx -L @var{directory}
  8457. Add @var{directory} to the front of the package module search path
  8458. (@pxref{Package Modules}).
  8459. This allows users to define their own packages and make them visible to
  8460. the command-line tools.
  8461. @item --keep-failed
  8462. @itemx -K
  8463. Keep the build tree of failed builds. Thus, if a build fails, its build
  8464. tree is kept under @file{/tmp}, in a directory whose name is shown at
  8465. the end of the build log. This is useful when debugging build issues.
  8466. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  8467. build issues.
  8468. This option implies @option{--no-offload}, and it has no effect when
  8469. connecting to a remote daemon with a @code{guix://} URI (@pxref{The
  8470. Store, the @env{GUIX_DAEMON_SOCKET} variable}).
  8471. @item --keep-going
  8472. @itemx -k
  8473. Keep going when some of the derivations fail to build; return only once
  8474. all the builds have either completed or failed.
  8475. The default behavior is to stop as soon as one of the specified
  8476. derivations has failed.
  8477. @item --dry-run
  8478. @itemx -n
  8479. Do not build the derivations.
  8480. @anchor{fallback-option}
  8481. @item --fallback
  8482. When substituting a pre-built binary fails, fall back to building
  8483. packages locally (@pxref{Substitution Failure}).
  8484. @item --substitute-urls=@var{urls}
  8485. @anchor{client-substitute-urls}
  8486. Consider @var{urls} the whitespace-separated list of substitute source
  8487. URLs, overriding the default list of URLs of @command{guix-daemon}
  8488. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  8489. This means that substitutes may be downloaded from @var{urls}, provided
  8490. they are signed by a key authorized by the system administrator
  8491. (@pxref{Substitutes}).
  8492. When @var{urls} is the empty string, substitutes are effectively
  8493. disabled.
  8494. @item --no-substitutes
  8495. Do not use substitutes for build products. That is, always build things
  8496. locally instead of allowing downloads of pre-built binaries
  8497. (@pxref{Substitutes}).
  8498. @item --no-grafts
  8499. Do not ``graft'' packages. In practice, this means that package updates
  8500. available as grafts are not applied. @xref{Security Updates}, for more
  8501. information on grafts.
  8502. @item --rounds=@var{n}
  8503. Build each derivation @var{n} times in a row, and raise an error if
  8504. consecutive build results are not bit-for-bit identical.
  8505. This is a useful way to detect non-deterministic builds processes.
  8506. Non-deterministic build processes are a problem because they make it
  8507. practically impossible for users to @emph{verify} whether third-party
  8508. binaries are genuine. @xref{Invoking guix challenge}, for more.
  8509. When used in conjunction with @option{--keep-failed}, the differing
  8510. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8511. This makes it easy to look for differences between the two results.
  8512. @item --no-offload
  8513. Do not use offload builds to other machines (@pxref{Daemon Offload
  8514. Setup}). That is, always build things locally instead of offloading
  8515. builds to remote machines.
  8516. @item --max-silent-time=@var{seconds}
  8517. When the build or substitution process remains silent for more than
  8518. @var{seconds}, terminate it and report a build failure.
  8519. By default, the daemon's setting is honored (@pxref{Invoking
  8520. guix-daemon, @option{--max-silent-time}}).
  8521. @item --timeout=@var{seconds}
  8522. Likewise, when the build or substitution process lasts for more than
  8523. @var{seconds}, terminate it and report a build failure.
  8524. By default, the daemon's setting is honored (@pxref{Invoking
  8525. guix-daemon, @option{--timeout}}).
  8526. @c Note: This option is actually not part of %standard-build-options but
  8527. @c most programs honor it.
  8528. @cindex verbosity, of the command-line tools
  8529. @cindex build logs, verbosity
  8530. @item -v @var{level}
  8531. @itemx --verbosity=@var{level}
  8532. Use the given verbosity @var{level}, an integer. Choosing 0 means that
  8533. no output is produced, 1 is for quiet output; 2 is similar to 1 but it
  8534. additionally displays download URLs; 3 shows all the build log output on
  8535. standard error.
  8536. @item --cores=@var{n}
  8537. @itemx -c @var{n}
  8538. Allow the use of up to @var{n} CPU cores for the build. The special
  8539. value @code{0} means to use as many CPU cores as available.
  8540. @item --max-jobs=@var{n}
  8541. @itemx -M @var{n}
  8542. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  8543. guix-daemon, @option{--max-jobs}}, for details about this option and the
  8544. equivalent @command{guix-daemon} option.
  8545. @item --debug=@var{level}
  8546. Produce debugging output coming from the build daemon. @var{level} must be an
  8547. integer between 0 and 5; higher means more verbose output. Setting a level of
  8548. 4 or more may be helpful when debugging setup issues with the build daemon.
  8549. @end table
  8550. Behind the scenes, @command{guix build} is essentially an interface to
  8551. the @code{package-derivation} procedure of the @code{(guix packages)}
  8552. module, and to the @code{build-derivations} procedure of the @code{(guix
  8553. derivations)} module.
  8554. In addition to options explicitly passed on the command line,
  8555. @command{guix build} and other @command{guix} commands that support
  8556. building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
  8557. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  8558. Users can define this variable to a list of command line options that
  8559. will automatically be used by @command{guix build} and other
  8560. @command{guix} commands that can perform builds, as in the example
  8561. below:
  8562. @example
  8563. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  8564. @end example
  8565. These options are parsed independently, and the result is appended to
  8566. the parsed command-line options.
  8567. @end defvr
  8568. @node Package Transformation Options
  8569. @subsection Package Transformation Options
  8570. @cindex package variants
  8571. Another set of command-line options supported by @command{guix build}
  8572. and also @command{guix package} are @dfn{package transformation
  8573. options}. These are options that make it possible to define @dfn{package
  8574. variants}---for instance, packages built from different source code.
  8575. This is a convenient way to create customized packages on the fly
  8576. without having to type in the definitions of package variants
  8577. (@pxref{Defining Packages}).
  8578. Package transformation options are preserved across upgrades:
  8579. @command{guix upgrade} attempts to apply transformation options
  8580. initially used when creating the profile to the upgraded packages.
  8581. The available options are listed below. Most commands support them and
  8582. also support a @option{--help-transform} option that lists all the
  8583. available options and a synopsis (these options are not shown in the
  8584. @option{--help} output for brevity).
  8585. @table @code
  8586. @item --with-source=@var{source}
  8587. @itemx --with-source=@var{package}=@var{source}
  8588. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  8589. Use @var{source} as the source of @var{package}, and @var{version} as
  8590. its version number.
  8591. @var{source} must be a file name or a URL, as for @command{guix
  8592. download} (@pxref{Invoking guix download}).
  8593. When @var{package} is omitted,
  8594. it is taken to be the package name specified on the
  8595. command line that matches the base of @var{source}---e.g.,
  8596. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  8597. package is @code{guile}.
  8598. Likewise, when @var{version} is omitted, the version string is inferred from
  8599. @var{source}; in the previous example, it is @code{2.0.10}.
  8600. This option allows users to try out versions of packages other than the
  8601. one provided by the distribution. The example below downloads
  8602. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  8603. the @code{ed} package:
  8604. @example
  8605. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  8606. @end example
  8607. As a developer, @option{--with-source} makes it easy to test release
  8608. candidates:
  8609. @example
  8610. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  8611. @end example
  8612. @dots{} or to build from a checkout in a pristine environment:
  8613. @example
  8614. $ git clone git://git.sv.gnu.org/guix.git
  8615. $ guix build guix --with-source=guix@@1.0=./guix
  8616. @end example
  8617. @item --with-input=@var{package}=@var{replacement}
  8618. Replace dependency on @var{package} by a dependency on
  8619. @var{replacement}. @var{package} must be a package name, and
  8620. @var{replacement} must be a package specification such as @code{guile}
  8621. or @code{guile@@1.8}.
  8622. For instance, the following command builds Guix, but replaces its
  8623. dependency on the current stable version of Guile with a dependency on
  8624. the legacy version of Guile, @code{guile@@2.0}:
  8625. @example
  8626. guix build --with-input=guile=guile@@2.0 guix
  8627. @end example
  8628. This is a recursive, deep replacement. So in this example, both
  8629. @code{guix} and its dependency @code{guile-json} (which also depends on
  8630. @code{guile}) get rebuilt against @code{guile@@2.0}.
  8631. This is implemented using the @code{package-input-rewriting} Scheme
  8632. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  8633. @item --with-graft=@var{package}=@var{replacement}
  8634. This is similar to @option{--with-input} but with an important difference:
  8635. instead of rebuilding the whole dependency chain, @var{replacement} is
  8636. built and then @dfn{grafted} onto the binaries that were initially
  8637. referring to @var{package}. @xref{Security Updates}, for more
  8638. information on grafts.
  8639. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  8640. and all its dependencies, replacing references to the version of GnuTLS
  8641. they currently refer to:
  8642. @example
  8643. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  8644. @end example
  8645. This has the advantage of being much faster than rebuilding everything.
  8646. But there is a caveat: it works if and only if @var{package} and
  8647. @var{replacement} are strictly compatible---for example, if they provide
  8648. a library, the application binary interface (ABI) of those libraries
  8649. must be compatible. If @var{replacement} is somehow incompatible with
  8650. @var{package}, then the resulting package may be unusable. Use with
  8651. care!
  8652. @cindex debugging info, rebuilding
  8653. @item --with-debug-info=@var{package}
  8654. Build @var{package} in a way that preserves its debugging info and graft
  8655. it onto packages that depend on it. This is useful if @var{package}
  8656. does not already provide debugging info as a @code{debug} output
  8657. (@pxref{Installing Debugging Files}).
  8658. For example, suppose you're experiencing a crash in Inkscape and would
  8659. like to see what's up in GLib, a library deep down in Inkscape's
  8660. dependency graph. GLib lacks a @code{debug} output, so debugging is
  8661. tough. Fortunately, you rebuild GLib with debugging info and tack it on
  8662. Inkscape:
  8663. @example
  8664. guix install inkscape --with-debug-info=glib
  8665. @end example
  8666. Only GLib needs to be recompiled so this takes a reasonable amount of
  8667. time. @xref{Installing Debugging Files}, for more info.
  8668. @quotation Note
  8669. Under the hood, this option works by passing the @samp{#:strip-binaries?
  8670. #f} to the build system of the package of interest (@pxref{Build
  8671. Systems}). Most build systems support that option but some do not. In
  8672. that case, an error is raised.
  8673. Likewise, if a C/C++ package is built without @code{-g} (which is rarely
  8674. the case), debugging info will remain unavailable even when
  8675. @code{#:strip-binaries?} is false.
  8676. @end quotation
  8677. @cindex tool chain, changing the build tool chain of a package
  8678. @item --with-c-toolchain=@var{package}=@var{toolchain}
  8679. This option changes the compilation of @var{package} and everything that
  8680. depends on it so that they get built with @var{toolchain} instead of the
  8681. default GNU tool chain for C/C++.
  8682. Consider this example:
  8683. @example
  8684. guix build octave-cli \
  8685. --with-c-toolchain=fftw=gcc-toolchain@@10 \
  8686. --with-c-toolchain=fftwf=gcc-toolchain@@10
  8687. @end example
  8688. The command above builds a variant of the @code{fftw} and @code{fftwf}
  8689. packages using version 10 of @code{gcc-toolchain} instead of the default
  8690. tool chain, and then builds a variant of the GNU@tie{}Octave
  8691. command-line interface using them. GNU@tie{}Octave itself is also built
  8692. with @code{gcc-toolchain@@10}.
  8693. This other example builds the Hardware Locality (@code{hwloc}) library
  8694. and its dependents up to @code{intel-mpi-benchmarks} with the Clang C
  8695. compiler:
  8696. @example
  8697. guix build --with-c-toolchain=hwloc=clang-toolchain \
  8698. intel-mpi-benchmarks
  8699. @end example
  8700. @quotation Note
  8701. There can be application binary interface (ABI) incompatibilities among
  8702. tool chains. This is particularly true of the C++ standard library and
  8703. run-time support libraries such as that of OpenMP@. By rebuilding all
  8704. dependents with the same tool chain, @option{--with-c-toolchain} minimizes
  8705. the risks of incompatibility but cannot entirely eliminate them. Choose
  8706. @var{package} wisely.
  8707. @end quotation
  8708. @item --with-git-url=@var{package}=@var{url}
  8709. @cindex Git, using the latest commit
  8710. @cindex latest commit, building
  8711. Build @var{package} from the latest commit of the @code{master} branch of the
  8712. Git repository at @var{url}. Git sub-modules of the repository are fetched,
  8713. recursively.
  8714. For example, the following command builds the NumPy Python library against the
  8715. latest commit of the master branch of Python itself:
  8716. @example
  8717. guix build python-numpy \
  8718. --with-git-url=python=https://github.com/python/cpython
  8719. @end example
  8720. This option can also be combined with @option{--with-branch} or
  8721. @option{--with-commit} (see below).
  8722. @cindex continuous integration
  8723. Obviously, since it uses the latest commit of the given branch, the result of
  8724. such a command varies over time. Nevertheless it is a convenient way to
  8725. rebuild entire software stacks against the latest commit of one or more
  8726. packages. This is particularly useful in the context of continuous
  8727. integration (CI).
  8728. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  8729. consecutive accesses to the same repository. You may want to clean it up once
  8730. in a while to save disk space.
  8731. @item --with-branch=@var{package}=@var{branch}
  8732. Build @var{package} from the latest commit of @var{branch}. If the
  8733. @code{source} field of @var{package} is an origin with the @code{git-fetch}
  8734. method (@pxref{origin Reference}) or a @code{git-checkout} object, the
  8735. repository URL is taken from that @code{source}. Otherwise you have to use
  8736. @option{--with-git-url} to specify the URL of the Git repository.
  8737. For instance, the following command builds @code{guile-sqlite3} from the
  8738. latest commit of its @code{master} branch, and then builds @code{guix} (which
  8739. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  8740. specific @code{guile-sqlite3} build:
  8741. @example
  8742. guix build --with-branch=guile-sqlite3=master cuirass
  8743. @end example
  8744. @item --with-commit=@var{package}=@var{commit}
  8745. This is similar to @option{--with-branch}, except that it builds from
  8746. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  8747. Git commit SHA1 identifier, a tag, or a @command{git describe} style
  8748. identifier such as @code{1.0-3-gabc123}.
  8749. @item --with-patch=@var{package}=@var{file}
  8750. Add @var{file} to the list of patches applied to @var{package}, where
  8751. @var{package} is a spec such as @code{python@@3.8} or @code{glibc}.
  8752. @var{file} must contain a patch; it is applied with the flags specified
  8753. in the @code{origin} of @var{package} (@pxref{origin Reference}), which
  8754. by default includes @code{-p1} (@pxref{patch Directories,,, diffutils,
  8755. Comparing and Merging Files}).
  8756. As an example, the command below rebuilds Coreutils with the GNU C
  8757. Library (glibc) patched with the given patch:
  8758. @example
  8759. guix build coreutils --with-patch=glibc=./glibc-frob.patch
  8760. @end example
  8761. In this example, glibc itself as well as everything that leads to
  8762. Coreutils in the dependency graph is rebuilt.
  8763. @cindex upstream, latest version
  8764. @item --with-latest=@var{package}
  8765. So you like living on the bleeding edge? This option is for you! It
  8766. replaces occurrences of @var{package} in the dependency graph with its
  8767. latest upstream version, as reported by @command{guix refresh}
  8768. (@pxref{Invoking guix refresh}).
  8769. It does so by determining the latest upstream release of @var{package}
  8770. (if possible), downloading it, and authenticating it @emph{if} it comes
  8771. with an OpenPGP signature.
  8772. As an example, the command below builds Guix against the latest version
  8773. of Guile-JSON:
  8774. @example
  8775. guix build guix --with-latest=guile-json
  8776. @end example
  8777. There are limitations. First, in cases where the tool cannot or does
  8778. not know how to authenticate source code, you are at risk of running
  8779. malicious code; a warning is emitted in this case. Second, this option
  8780. simply changes the source used in the existing package definitions,
  8781. which is not always sufficient: there might be additional dependencies
  8782. that need to be added, patches to apply, and more generally the quality
  8783. assurance work that Guix developers normally do will be missing.
  8784. You've been warned! In all the other cases, it's a snappy way to stay
  8785. on top. We encourage you to submit patches updating the actual package
  8786. definitions once you have successfully tested an upgrade
  8787. (@pxref{Contributing}).
  8788. @cindex test suite, skipping
  8789. @item --without-tests=@var{package}
  8790. Build @var{package} without running its tests. This can be useful in
  8791. situations where you want to skip the lengthy test suite of a
  8792. intermediate package, or if a package's test suite fails in a
  8793. non-deterministic fashion. It should be used with care because running
  8794. the test suite is a good way to ensure a package is working as intended.
  8795. Turning off tests leads to a different store item. Consequently, when
  8796. using this option, anything that depends on @var{package} must be
  8797. rebuilt, as in this example:
  8798. @example
  8799. guix install --without-tests=python python-notebook
  8800. @end example
  8801. The command above installs @code{python-notebook} on top of
  8802. @code{python} built without running its test suite. To do so, it also
  8803. rebuilds everything that depends on @code{python}, including
  8804. @code{python-notebook} itself.
  8805. Internally, @option{--without-tests} relies on changing the
  8806. @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
  8807. Systems}). Note that some packages use a customized @code{check} phase
  8808. that does not respect a @code{#:tests? #f} setting. Therefore,
  8809. @option{--without-tests} has no effect on these packages.
  8810. @end table
  8811. Wondering how to achieve the same effect using Scheme code, for example
  8812. in your manifest, or how to write your own package transformation?
  8813. @xref{Defining Package Variants}, for an overview of the programming
  8814. interfaces available.
  8815. @node Additional Build Options
  8816. @subsection Additional Build Options
  8817. The command-line options presented below are specific to @command{guix
  8818. build}.
  8819. @table @code
  8820. @item --quiet
  8821. @itemx -q
  8822. Build quietly, without displaying the build log; this is equivalent to
  8823. @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
  8824. (or similar) and can always be retrieved using the @option{--log-file} option.
  8825. @item --file=@var{file}
  8826. @itemx -f @var{file}
  8827. Build the package, derivation, or other file-like object that the code within
  8828. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  8829. As an example, @var{file} might contain a package definition like this
  8830. (@pxref{Defining Packages}):
  8831. @lisp
  8832. @include package-hello.scm
  8833. @end lisp
  8834. The @var{file} may also contain a JSON representation of one or more
  8835. package definitions. Running @code{guix build -f} on @file{hello.json}
  8836. with the following contents would result in building the packages
  8837. @code{myhello} and @code{greeter}:
  8838. @example
  8839. @verbatiminclude package-hello.json
  8840. @end example
  8841. @item --manifest=@var{manifest}
  8842. @itemx -m @var{manifest}
  8843. Build all packages listed in the given @var{manifest}
  8844. (@pxref{profile-manifest, @option{--manifest}}).
  8845. @item --expression=@var{expr}
  8846. @itemx -e @var{expr}
  8847. Build the package or derivation @var{expr} evaluates to.
  8848. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  8849. guile-1.8)}, which unambiguously designates this specific variant of
  8850. version 1.8 of Guile.
  8851. Alternatively, @var{expr} may be a G-expression, in which case it is used
  8852. as a build program passed to @code{gexp->derivation}
  8853. (@pxref{G-Expressions}).
  8854. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  8855. (@pxref{The Store Monad}). The procedure must return a derivation as a
  8856. monadic value, which is then passed through @code{run-with-store}.
  8857. @item --source
  8858. @itemx -S
  8859. Build the source derivations of the packages, rather than the packages
  8860. themselves.
  8861. For instance, @code{guix build -S gcc} returns something like
  8862. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  8863. source tarball.
  8864. The returned source tarball is the result of applying any patches and
  8865. code snippets specified in the package @code{origin} (@pxref{Defining
  8866. Packages}).
  8867. @cindex source, verification
  8868. As with other derivations, the result of building a source derivation
  8869. can be verified using the @option{--check} option (@pxref{build-check}).
  8870. This is useful to validate that a (potentially already built or
  8871. substituted, thus cached) package source matches against its declared
  8872. hash.
  8873. Note that @command{guix build -S} compiles the sources only of the
  8874. specified packages. They do not include the sources of statically
  8875. linked dependencies and by themselves are insufficient for reproducing
  8876. the packages.
  8877. @item --sources
  8878. Fetch and return the source of @var{package-or-derivation} and all their
  8879. dependencies, recursively. This is a handy way to obtain a local copy
  8880. of all the source code needed to build @var{packages}, allowing you to
  8881. eventually build them even without network access. It is an extension
  8882. of the @option{--source} option and can accept one of the following
  8883. optional argument values:
  8884. @table @code
  8885. @item package
  8886. This value causes the @option{--sources} option to behave in the same way
  8887. as the @option{--source} option.
  8888. @item all
  8889. Build the source derivations of all packages, including any source that
  8890. might be listed as @code{inputs}. This is the default value.
  8891. @example
  8892. $ guix build --sources tzdata
  8893. The following derivations will be built:
  8894. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  8895. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  8896. @end example
  8897. @item transitive
  8898. Build the source derivations of all packages, as well of all transitive
  8899. inputs to the packages. This can be used e.g.@: to
  8900. prefetch package source for later offline building.
  8901. @example
  8902. $ guix build --sources=transitive tzdata
  8903. The following derivations will be built:
  8904. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  8905. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  8906. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  8907. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  8908. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  8909. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  8910. @dots{}
  8911. @end example
  8912. @end table
  8913. @item --system=@var{system}
  8914. @itemx -s @var{system}
  8915. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  8916. the system type of the build host. The @command{guix build} command allows
  8917. you to repeat this option several times, in which case it builds for all the
  8918. specified systems; other commands ignore extraneous @option{-s} options.
  8919. @quotation Note
  8920. The @option{--system} flag is for @emph{native} compilation and must not
  8921. be confused with cross-compilation. See @option{--target} below for
  8922. information on cross-compilation.
  8923. @end quotation
  8924. An example use of this is on Linux-based systems, which can emulate
  8925. different personalities. For instance, passing
  8926. @option{--system=i686-linux} on an @code{x86_64-linux} system or
  8927. @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
  8928. you to build packages in a complete 32-bit environment.
  8929. @quotation Note
  8930. Building for an @code{armhf-linux} system is unconditionally enabled on
  8931. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  8932. allow for this functionality, notably the ThunderX.
  8933. @end quotation
  8934. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  8935. is enabled (@pxref{Virtualization Services,
  8936. @code{qemu-binfmt-service-type}}), you can build for any system for
  8937. which a QEMU @code{binfmt_misc} handler is installed.
  8938. Builds for a system other than that of the machine you are using can
  8939. also be offloaded to a remote machine of the right architecture.
  8940. @xref{Daemon Offload Setup}, for more information on offloading.
  8941. @item --target=@var{triplet}
  8942. @cindex cross-compilation
  8943. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  8944. as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
  8945. configuration triplets,, autoconf, Autoconf}).
  8946. @anchor{build-check}
  8947. @item --check
  8948. @cindex determinism, checking
  8949. @cindex reproducibility, checking
  8950. Rebuild @var{package-or-derivation}, which are already available in the
  8951. store, and raise an error if the build results are not bit-for-bit
  8952. identical.
  8953. This mechanism allows you to check whether previously installed
  8954. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  8955. of a package is deterministic. @xref{Invoking guix challenge}, for more
  8956. background information and tools.
  8957. When used in conjunction with @option{--keep-failed}, the differing
  8958. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8959. This makes it easy to look for differences between the two results.
  8960. @item --repair
  8961. @cindex repairing store items
  8962. @cindex corruption, recovering from
  8963. Attempt to repair the specified store items, if they are corrupt, by
  8964. re-downloading or rebuilding them.
  8965. This operation is not atomic and thus restricted to @code{root}.
  8966. @item --derivations
  8967. @itemx -d
  8968. Return the derivation paths, not the output paths, of the given
  8969. packages.
  8970. @item --root=@var{file}
  8971. @itemx -r @var{file}
  8972. @cindex GC roots, adding
  8973. @cindex garbage collector roots, adding
  8974. Make @var{file} a symlink to the result, and register it as a garbage
  8975. collector root.
  8976. Consequently, the results of this @command{guix build} invocation are
  8977. protected from garbage collection until @var{file} is removed. When
  8978. that option is omitted, build results are eligible for garbage
  8979. collection as soon as the build completes. @xref{Invoking guix gc}, for
  8980. more on GC roots.
  8981. @item --log-file
  8982. @cindex build logs, access
  8983. Return the build log file names or URLs for the given
  8984. @var{package-or-derivation}, or raise an error if build logs are
  8985. missing.
  8986. This works regardless of how packages or derivations are specified. For
  8987. instance, the following invocations are equivalent:
  8988. @example
  8989. guix build --log-file $(guix build -d guile)
  8990. guix build --log-file $(guix build guile)
  8991. guix build --log-file guile
  8992. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  8993. @end example
  8994. If a log is unavailable locally, and unless @option{--no-substitutes} is
  8995. passed, the command looks for a corresponding log on one of the
  8996. substitute servers (as specified with @option{--substitute-urls}).
  8997. So for instance, imagine you want to see the build log of GDB on MIPS,
  8998. but you are actually on an @code{x86_64} machine:
  8999. @example
  9000. $ guix build --log-file gdb -s aarch64-linux
  9001. https://@value{SUBSTITUTE-SERVER-1}/log/@dots{}-gdb-7.10
  9002. @end example
  9003. You can freely access a huge library of build logs!
  9004. @end table
  9005. @node Debugging Build Failures
  9006. @subsection Debugging Build Failures
  9007. @cindex build failures, debugging
  9008. When defining a new package (@pxref{Defining Packages}), you will
  9009. probably find yourself spending some time debugging and tweaking the
  9010. build until it succeeds. To do that, you need to operate the build
  9011. commands yourself in an environment as close as possible to the one the
  9012. build daemon uses.
  9013. To that end, the first thing to do is to use the @option{--keep-failed}
  9014. or @option{-K} option of @command{guix build}, which will keep the
  9015. failed build tree in @file{/tmp} or whatever directory you specified as
  9016. @env{TMPDIR} (@pxref{Common Build Options, @option{--keep-failed}}).
  9017. From there on, you can @command{cd} to the failed build tree and source
  9018. the @file{environment-variables} file, which contains all the
  9019. environment variable definitions that were in place when the build
  9020. failed. So let's say you're debugging a build failure in package
  9021. @code{foo}; a typical session would look like this:
  9022. @example
  9023. $ guix build foo -K
  9024. @dots{} @i{build fails}
  9025. $ cd /tmp/guix-build-foo.drv-0
  9026. $ source ./environment-variables
  9027. $ cd foo-1.2
  9028. @end example
  9029. Now, you can invoke commands as if you were the daemon (almost) and
  9030. troubleshoot your build process.
  9031. Sometimes it happens that, for example, a package's tests pass when you
  9032. run them manually but they fail when the daemon runs them. This can
  9033. happen because the daemon runs builds in containers where, unlike in our
  9034. environment above, network access is missing, @file{/bin/sh} does not
  9035. exist, etc. (@pxref{Build Environment Setup}).
  9036. In such cases, you may need to run inspect the build process from within
  9037. a container similar to the one the build daemon creates:
  9038. @example
  9039. $ guix build -K foo
  9040. @dots{}
  9041. $ cd /tmp/guix-build-foo.drv-0
  9042. $ guix environment --no-grafts -C foo --ad-hoc strace gdb
  9043. [env]# source ./environment-variables
  9044. [env]# cd foo-1.2
  9045. @end example
  9046. Here, @command{guix environment -C} creates a container and spawns a new
  9047. shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
  9048. strace gdb} part adds the @command{strace} and @command{gdb} commands to
  9049. the container, which you may find handy while debugging. The
  9050. @option{--no-grafts} option makes sure we get the exact same
  9051. environment, with ungrafted packages (@pxref{Security Updates}, for more
  9052. info on grafts).
  9053. To get closer to a container like that used by the build daemon, we can
  9054. remove @file{/bin/sh}:
  9055. @example
  9056. [env]# rm /bin/sh
  9057. @end example
  9058. (Don't worry, this is harmless: this is all happening in the throw-away
  9059. container created by @command{guix environment}.)
  9060. The @command{strace} command is probably not in the search path, but we
  9061. can run:
  9062. @example
  9063. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  9064. @end example
  9065. In this way, not only you will have reproduced the environment variables
  9066. the daemon uses, you will also be running the build process in a container
  9067. similar to the one the daemon uses.
  9068. @node Invoking guix edit
  9069. @section Invoking @command{guix edit}
  9070. @cindex @command{guix edit}
  9071. @cindex package definition, editing
  9072. So many packages, so many source files! The @command{guix edit} command
  9073. facilitates the life of users and packagers by pointing their editor at
  9074. the source file containing the definition of the specified packages.
  9075. For instance:
  9076. @example
  9077. guix edit gcc@@4.9 vim
  9078. @end example
  9079. @noindent
  9080. launches the program specified in the @env{VISUAL} or in the
  9081. @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  9082. and that of Vim.
  9083. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  9084. have created your own packages on @env{GUIX_PACKAGE_PATH}
  9085. (@pxref{Package Modules}), you will be able to edit the package
  9086. recipes. In other cases, you will be able to examine the read-only recipes
  9087. for packages currently in the store.
  9088. Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
  9089. @option{--load-path=@var{directory}} (or in short @option{-L
  9090. @var{directory}}) allows you to add @var{directory} to the front of the
  9091. package module search path and so make your own packages visible.
  9092. @node Invoking guix download
  9093. @section Invoking @command{guix download}
  9094. @cindex @command{guix download}
  9095. @cindex downloading package sources
  9096. When writing a package definition, developers typically need to download
  9097. a source tarball, compute its SHA256 hash, and write that
  9098. hash in the package definition (@pxref{Defining Packages}). The
  9099. @command{guix download} tool helps with this task: it downloads a file
  9100. from the given URI, adds it to the store, and prints both its file name
  9101. in the store and its SHA256 hash.
  9102. The fact that the downloaded file is added to the store saves bandwidth:
  9103. when the developer eventually tries to build the newly defined package
  9104. with @command{guix build}, the source tarball will not have to be
  9105. downloaded again because it is already in the store. It is also a
  9106. convenient way to temporarily stash files, which may be deleted
  9107. eventually (@pxref{Invoking guix gc}).
  9108. The @command{guix download} command supports the same URIs as used in
  9109. package definitions. In particular, it supports @code{mirror://} URIs.
  9110. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  9111. Guile bindings for GnuTLS are available in the user's environment; when
  9112. they are not available, an error is raised. @xref{Guile Preparations,
  9113. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  9114. GnuTLS-Guile}, for more information.
  9115. @command{guix download} verifies HTTPS server certificates by loading
  9116. the certificates of X.509 authorities from the directory pointed to by
  9117. the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
  9118. Certificates}), unless @option{--no-check-certificate} is used.
  9119. The following options are available:
  9120. @table @code
  9121. @item --hash=@var{algorithm}
  9122. @itemx -H @var{algorithm}
  9123. Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
  9124. hash}, for more information.
  9125. @item --format=@var{fmt}
  9126. @itemx -f @var{fmt}
  9127. Write the hash in the format specified by @var{fmt}. For more
  9128. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  9129. @item --no-check-certificate
  9130. Do not validate the X.509 certificates of HTTPS servers.
  9131. When using this option, you have @emph{absolutely no guarantee} that you
  9132. are communicating with the authentic server responsible for the given
  9133. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  9134. @item --output=@var{file}
  9135. @itemx -o @var{file}
  9136. Save the downloaded file to @var{file} instead of adding it to the
  9137. store.
  9138. @end table
  9139. @node Invoking guix hash
  9140. @section Invoking @command{guix hash}
  9141. @cindex @command{guix hash}
  9142. The @command{guix hash} command computes the hash of a file.
  9143. It is primarily a convenience tool for anyone contributing to the
  9144. distribution: it computes the cryptographic hash of a file, which can be
  9145. used in the definition of a package (@pxref{Defining Packages}).
  9146. The general syntax is:
  9147. @example
  9148. guix hash @var{option} @var{file}
  9149. @end example
  9150. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  9151. hash of data read from standard input. @command{guix hash} has the
  9152. following options:
  9153. @table @code
  9154. @item --hash=@var{algorithm}
  9155. @itemx -H @var{algorithm}
  9156. Compute a hash using the specified @var{algorithm}, @code{sha256} by
  9157. default.
  9158. @var{algorithm} must the name of a cryptographic hash algorithm
  9159. supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
  9160. @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
  9161. Reference Manual}).
  9162. @item --format=@var{fmt}
  9163. @itemx -f @var{fmt}
  9164. Write the hash in the format specified by @var{fmt}.
  9165. Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
  9166. (@code{hex} and @code{hexadecimal} can be used as well).
  9167. If the @option{--format} option is not specified, @command{guix hash}
  9168. will output the hash in @code{nix-base32}. This representation is used
  9169. in the definitions of packages.
  9170. @item --recursive
  9171. @itemx -r
  9172. Compute the hash on @var{file} recursively.
  9173. In this case, the hash is computed on an archive containing @var{file},
  9174. including its children if it is a directory. Some of the metadata of
  9175. @var{file} is part of the archive; for instance, when @var{file} is a
  9176. regular file, the hash is different depending on whether @var{file} is
  9177. executable or not. Metadata such as time stamps has no impact on the
  9178. hash (@pxref{Invoking guix archive}).
  9179. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  9180. @c it exists.
  9181. @item --exclude-vcs
  9182. @itemx -x
  9183. When combined with @option{--recursive}, exclude version control system
  9184. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
  9185. @vindex git-fetch
  9186. As an example, here is how you would compute the hash of a Git checkout,
  9187. which is useful when using the @code{git-fetch} method (@pxref{origin
  9188. Reference}):
  9189. @example
  9190. $ git clone http://example.org/foo.git
  9191. $ cd foo
  9192. $ guix hash -rx .
  9193. @end example
  9194. @end table
  9195. @node Invoking guix import
  9196. @section Invoking @command{guix import}
  9197. @cindex importing packages
  9198. @cindex package import
  9199. @cindex package conversion
  9200. @cindex Invoking @command{guix import}
  9201. The @command{guix import} command is useful for people who would like to
  9202. add a package to the distribution with as little work as
  9203. possible---a legitimate demand. The command knows of a few
  9204. repositories from which it can ``import'' package metadata. The result
  9205. is a package definition, or a template thereof, in the format we know
  9206. (@pxref{Defining Packages}).
  9207. The general syntax is:
  9208. @example
  9209. guix import @var{importer} @var{options}@dots{}
  9210. @end example
  9211. @var{importer} specifies the source from which to import package
  9212. metadata, and @var{options} specifies a package identifier and other
  9213. options specific to @var{importer}.
  9214. Some of the importers rely on the ability to run the @command{gpgv} command.
  9215. For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
  9216. gnupg} if needed.
  9217. Currently, the available ``importers'' are:
  9218. @table @code
  9219. @item gnu
  9220. Import metadata for the given GNU package. This provides a template
  9221. for the latest version of that GNU package, including the hash of its
  9222. source tarball, and its canonical synopsis and description.
  9223. Additional information such as the package dependencies and its
  9224. license needs to be figured out manually.
  9225. For example, the following command returns a package definition for
  9226. GNU@tie{}Hello:
  9227. @example
  9228. guix import gnu hello
  9229. @end example
  9230. Specific command-line options are:
  9231. @table @code
  9232. @item --key-download=@var{policy}
  9233. As for @command{guix refresh}, specify the policy to handle missing
  9234. OpenPGP keys when verifying the package signature. @xref{Invoking guix
  9235. refresh, @option{--key-download}}.
  9236. @end table
  9237. @item pypi
  9238. @cindex pypi
  9239. Import metadata from the @uref{https://pypi.python.org/, Python Package
  9240. Index}. Information is taken from the JSON-formatted description
  9241. available at @code{pypi.python.org} and usually includes all the relevant
  9242. information, including package dependencies. For maximum efficiency, it
  9243. is recommended to install the @command{unzip} utility, so that the
  9244. importer can unzip Python wheels and gather data from them.
  9245. The command below imports metadata for the @code{itsdangerous} Python
  9246. package:
  9247. @example
  9248. guix import pypi itsdangerous
  9249. @end example
  9250. @table @code
  9251. @item --recursive
  9252. @itemx -r
  9253. Traverse the dependency graph of the given upstream package recursively
  9254. and generate package expressions for all those packages that are not yet
  9255. in Guix.
  9256. @end table
  9257. @item gem
  9258. @cindex gem
  9259. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  9260. is taken from the JSON-formatted description available at
  9261. @code{rubygems.org} and includes most relevant information, including
  9262. runtime dependencies. There are some caveats, however. The metadata
  9263. doesn't distinguish between synopses and descriptions, so the same string
  9264. is used for both fields. Additionally, the details of non-Ruby
  9265. dependencies required to build native extensions is unavailable and left
  9266. as an exercise to the packager.
  9267. The command below imports metadata for the @code{rails} Ruby package:
  9268. @example
  9269. guix import gem rails
  9270. @end example
  9271. @table @code
  9272. @item --recursive
  9273. @itemx -r
  9274. Traverse the dependency graph of the given upstream package recursively
  9275. and generate package expressions for all those packages that are not yet
  9276. in Guix.
  9277. @end table
  9278. @item minetest
  9279. @cindex minetest
  9280. @cindex ContentDB
  9281. Import metadata from @uref{https://content.minetest.net, ContentDB}.
  9282. Information is taken from the JSON-formatted metadata provided through
  9283. @uref{https://content.minetest.net/help/api/, ContentDB's API} and
  9284. includes most relevant information, including dependencies. There are
  9285. some caveats, however. The license information is often incomplete.
  9286. The commit hash is sometimes missing. The descriptions are in the
  9287. Markdown format, but Guix uses Texinfo instead. Texture packs and
  9288. subgames are unsupported.
  9289. The command below imports metadata for the Mesecons mod by Jeija:
  9290. @example
  9291. guix import minetest Jeija/mesecons
  9292. @end example
  9293. The author name can also be left out:
  9294. @example
  9295. guix import minetest mesecons
  9296. @end example
  9297. @table @code
  9298. @item --recursive
  9299. @itemx -r
  9300. Traverse the dependency graph of the given upstream package recursively
  9301. and generate package expressions for all those packages that are not yet
  9302. in Guix.
  9303. @end table
  9304. @item cpan
  9305. @cindex CPAN
  9306. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  9307. Information is taken from the JSON-formatted metadata provided through
  9308. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  9309. relevant information, such as module dependencies. License information
  9310. should be checked closely. If Perl is available in the store, then the
  9311. @code{corelist} utility will be used to filter core modules out of the
  9312. list of dependencies.
  9313. The command command below imports metadata for the Acme::Boolean Perl
  9314. module:
  9315. @example
  9316. guix import cpan Acme::Boolean
  9317. @end example
  9318. @item cran
  9319. @cindex CRAN
  9320. @cindex Bioconductor
  9321. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  9322. central repository for the @uref{https://r-project.org, GNU@tie{}R
  9323. statistical and graphical environment}.
  9324. Information is extracted from the @file{DESCRIPTION} file of the package.
  9325. The command command below imports metadata for the Cairo R package:
  9326. @example
  9327. guix import cran Cairo
  9328. @end example
  9329. When @option{--recursive} is added, the importer will traverse the
  9330. dependency graph of the given upstream package recursively and generate
  9331. package expressions for all those packages that are not yet in Guix.
  9332. When @option{--style=specification} is added, the importer will generate
  9333. package definitions whose inputs are package specifications instead of
  9334. references to package variables. This is useful when generated package
  9335. definitions are to be appended to existing user modules, as the list of
  9336. used package modules need not be changed. The default is
  9337. @option{--style=variable}.
  9338. When @option{--archive=bioconductor} is added, metadata is imported from
  9339. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  9340. packages for the analysis and comprehension of high-throughput
  9341. genomic data in bioinformatics.
  9342. Information is extracted from the @file{DESCRIPTION} file contained in the
  9343. package archive.
  9344. The command below imports metadata for the GenomicRanges R package:
  9345. @example
  9346. guix import cran --archive=bioconductor GenomicRanges
  9347. @end example
  9348. Finally, you can also import R packages that have not yet been published on
  9349. CRAN or Bioconductor as long as they are in a git repository. Use
  9350. @option{--archive=git} followed by the URL of the git repository:
  9351. @example
  9352. guix import cran --archive=git https://github.com/immunogenomics/harmony
  9353. @end example
  9354. @item texlive
  9355. @cindex TeX Live
  9356. @cindex CTAN
  9357. Import metadata from @uref{https://www.ctan.org/, CTAN}, the
  9358. comprehensive TeX archive network for TeX packages that are part of the
  9359. @uref{https://www.tug.org/texlive/, TeX Live distribution}.
  9360. Information about the package is obtained through the XML API provided
  9361. by CTAN, while the source code is downloaded from the SVN repository of
  9362. the Tex Live project. This is done because the CTAN does not keep
  9363. versioned archives.
  9364. The command command below imports metadata for the @code{fontspec}
  9365. TeX package:
  9366. @example
  9367. guix import texlive fontspec
  9368. @end example
  9369. When @option{--archive=@var{directory}} is added, the source code is
  9370. downloaded not from the @file{latex} sub-directory of the
  9371. @file{texmf-dist/source} tree in the TeX Live SVN repository, but from
  9372. the specified sibling @var{directory} under the same root.
  9373. The command below imports metadata for the @code{ifxetex} package from
  9374. CTAN while fetching the sources from the directory
  9375. @file{texmf/source/generic}:
  9376. @example
  9377. guix import texlive --archive=generic ifxetex
  9378. @end example
  9379. @item json
  9380. @cindex JSON, import
  9381. Import package metadata from a local JSON file. Consider the following
  9382. example package definition in JSON format:
  9383. @example
  9384. @{
  9385. "name": "hello",
  9386. "version": "2.10",
  9387. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  9388. "build-system": "gnu",
  9389. "home-page": "https://www.gnu.org/software/hello/",
  9390. "synopsis": "Hello, GNU world: An example GNU package",
  9391. "description": "GNU Hello prints a greeting.",
  9392. "license": "GPL-3.0+",
  9393. "native-inputs": ["gettext"]
  9394. @}
  9395. @end example
  9396. The field names are the same as for the @code{<package>} record
  9397. (@xref{Defining Packages}). References to other packages are provided
  9398. as JSON lists of quoted package specification strings such as
  9399. @code{guile} or @code{guile@@2.0}.
  9400. The importer also supports a more explicit source definition using the
  9401. common fields for @code{<origin>} records:
  9402. @example
  9403. @{
  9404. @dots{}
  9405. "source": @{
  9406. "method": "url-fetch",
  9407. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  9408. "sha256": @{
  9409. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  9410. @}
  9411. @}
  9412. @dots{}
  9413. @}
  9414. @end example
  9415. The command below reads metadata from the JSON file @code{hello.json}
  9416. and outputs a package expression:
  9417. @example
  9418. guix import json hello.json
  9419. @end example
  9420. @item hackage
  9421. @cindex hackage
  9422. Import metadata from the Haskell community's central package archive
  9423. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  9424. Cabal files and includes all the relevant information, including package
  9425. dependencies.
  9426. Specific command-line options are:
  9427. @table @code
  9428. @item --stdin
  9429. @itemx -s
  9430. Read a Cabal file from standard input.
  9431. @item --no-test-dependencies
  9432. @itemx -t
  9433. Do not include dependencies required only by the test suites.
  9434. @item --cabal-environment=@var{alist}
  9435. @itemx -e @var{alist}
  9436. @var{alist} is a Scheme alist defining the environment in which the
  9437. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  9438. @code{arch}, @code{impl} and a string representing the name of a flag.
  9439. The value associated with a flag has to be either the symbol
  9440. @code{true} or @code{false}. The value associated with other keys
  9441. has to conform to the Cabal file format definition. The default value
  9442. associated with the keys @code{os}, @code{arch} and @code{impl} is
  9443. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  9444. @item --recursive
  9445. @itemx -r
  9446. Traverse the dependency graph of the given upstream package recursively
  9447. and generate package expressions for all those packages that are not yet
  9448. in Guix.
  9449. @end table
  9450. The command below imports metadata for the latest version of the
  9451. HTTP Haskell package without including test dependencies and
  9452. specifying the value of the flag @samp{network-uri} as @code{false}:
  9453. @example
  9454. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  9455. @end example
  9456. A specific package version may optionally be specified by following the
  9457. package name by an at-sign and a version number as in the following example:
  9458. @example
  9459. guix import hackage mtl@@2.1.3.1
  9460. @end example
  9461. @item stackage
  9462. @cindex stackage
  9463. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  9464. It takes a package name, looks up the package version included in a
  9465. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  9466. release and uses the @code{hackage} importer to retrieve its metadata.
  9467. Note that it is up to you to select an LTS release compatible with the
  9468. GHC compiler used by Guix.
  9469. Specific command-line options are:
  9470. @table @code
  9471. @item --no-test-dependencies
  9472. @itemx -t
  9473. Do not include dependencies required only by the test suites.
  9474. @item --lts-version=@var{version}
  9475. @itemx -l @var{version}
  9476. @var{version} is the desired LTS release version. If omitted the latest
  9477. release is used.
  9478. @item --recursive
  9479. @itemx -r
  9480. Traverse the dependency graph of the given upstream package recursively
  9481. and generate package expressions for all those packages that are not yet
  9482. in Guix.
  9483. @end table
  9484. The command below imports metadata for the HTTP Haskell package
  9485. included in the LTS Stackage release version 7.18:
  9486. @example
  9487. guix import stackage --lts-version=7.18 HTTP
  9488. @end example
  9489. @item elpa
  9490. @cindex elpa
  9491. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  9492. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  9493. Specific command-line options are:
  9494. @table @code
  9495. @item --archive=@var{repo}
  9496. @itemx -a @var{repo}
  9497. @var{repo} identifies the archive repository from which to retrieve the
  9498. information. Currently the supported repositories and their identifiers
  9499. are:
  9500. @itemize -
  9501. @item
  9502. @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  9503. identifier. This is the default.
  9504. Packages from @code{elpa.gnu.org} are signed with one of the keys
  9505. contained in the GnuPG keyring at
  9506. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  9507. @code{emacs} package (@pxref{Package Installation, ELPA package
  9508. signatures,, emacs, The GNU Emacs Manual}).
  9509. @item
  9510. @uref{https://elpa.nongnu.org/nongnu/, NonGNU}, selected by the
  9511. @code{nongnu} identifier.
  9512. @item
  9513. @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
  9514. @code{melpa-stable} identifier.
  9515. @item
  9516. @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
  9517. identifier.
  9518. @end itemize
  9519. @item --recursive
  9520. @itemx -r
  9521. Traverse the dependency graph of the given upstream package recursively
  9522. and generate package expressions for all those packages that are not yet
  9523. in Guix.
  9524. @end table
  9525. @item crate
  9526. @cindex crate
  9527. Import metadata from the crates.io Rust package repository
  9528. @uref{https://crates.io, crates.io}, as in this example:
  9529. @example
  9530. guix import crate blake2-rfc
  9531. @end example
  9532. The crate importer also allows you to specify a version string:
  9533. @example
  9534. guix import crate constant-time-eq@@0.1.0
  9535. @end example
  9536. Additional options include:
  9537. @table @code
  9538. @item --recursive
  9539. @itemx -r
  9540. Traverse the dependency graph of the given upstream package recursively
  9541. and generate package expressions for all those packages that are not yet
  9542. in Guix.
  9543. @end table
  9544. @item opam
  9545. @cindex OPAM
  9546. @cindex OCaml
  9547. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  9548. repository used by the OCaml community.
  9549. Additional options include:
  9550. @table @code
  9551. @item --recursive
  9552. @itemx -r
  9553. Traverse the dependency graph of the given upstream package recursively
  9554. and generate package expressions for all those packages that are not yet
  9555. in Guix.
  9556. @item --repo
  9557. By default, packages are searched in the official OPAM repository. This
  9558. option, which can be used more than once, lets you add other repositories
  9559. which will be searched for packages. It accepts as valid arguments:
  9560. @itemize
  9561. @item the name of a known repository - can be one of @code{opam},
  9562. @code{coq} (equivalent to @code{coq-released}),
  9563. @code{coq-core-dev}, @code{coq-extra-dev} or @code{grew}.
  9564. @item the URL of a repository as expected by the
  9565. @code{opam repository add} command (for instance, the URL equivalent
  9566. of the above @code{opam} name would be
  9567. @uref{https://opam.ocaml.org}).
  9568. @item the path to a local copy of a repository (a directory containing a
  9569. @file{packages/} sub-directory).
  9570. @end itemize
  9571. Repositories are assumed to be passed to this option by order of
  9572. preference. The additional repositories will not replace the default
  9573. @code{opam} repository, which is always kept as a fallback.
  9574. Also, please note that versions are not compared accross repositories.
  9575. The first repository (from left to right) that has at least one version
  9576. of a given package will prevail over any others, and the version
  9577. imported will be the latest one found @emph{in this repository only}.
  9578. @end table
  9579. @item go
  9580. @cindex go
  9581. Import metadata for a Go module using
  9582. @uref{https://proxy.golang.org, proxy.golang.org}.
  9583. @example
  9584. guix import go gopkg.in/yaml.v2
  9585. @end example
  9586. It is possible to use a package specification with a @code{@@VERSION}
  9587. suffix to import a specific version.
  9588. Additional options include:
  9589. @table @code
  9590. @item --recursive
  9591. @itemx -r
  9592. Traverse the dependency graph of the given upstream package recursively
  9593. and generate package expressions for all those packages that are not yet
  9594. in Guix.
  9595. @item --pin-versions
  9596. When using this option, the importer preserves the exact versions of the
  9597. Go modules dependencies instead of using their latest available
  9598. versions. This can be useful when attempting to import packages that
  9599. recursively depend on former versions of themselves to build. When
  9600. using this mode, the symbol of the package is made by appending the
  9601. version to its name, so that multiple versions of the same package can
  9602. coexist.
  9603. @end table
  9604. @item egg
  9605. @cindex egg
  9606. Import metadata for @uref{https://wiki.call-cc.org/eggs, CHICKEN eggs}.
  9607. The information is taken from @file{PACKAGE.egg} files found in the
  9608. @uref{git://code.call-cc.org/eggs-5-latest, eggs-5-latest} Git
  9609. repository. However, it does not provide all the information that we
  9610. need, there is no ``description'' field, and the licenses used are not
  9611. always precise (BSD is often used instead of BSD-N).
  9612. @example
  9613. guix import egg sourcehut
  9614. @end example
  9615. Additional options include:
  9616. @table @code
  9617. @item --recursive
  9618. @itemx -r
  9619. Traverse the dependency graph of the given upstream package recursively
  9620. and generate package expressions for all those packages that are not yet
  9621. in Guix.
  9622. @end table
  9623. @end table
  9624. The structure of the @command{guix import} code is modular. It would be
  9625. useful to have more importers for other package formats, and your help
  9626. is welcome here (@pxref{Contributing}).
  9627. @node Invoking guix refresh
  9628. @section Invoking @command{guix refresh}
  9629. @cindex @command {guix refresh}
  9630. The primary audience of the @command{guix refresh} command is packagers.
  9631. As a user, you may be interested in the @option{--with-latest} option,
  9632. which can bring you package update superpowers built upon @command{guix
  9633. refresh} (@pxref{Package Transformation Options,
  9634. @option{--with-latest}}). By default, @command{guix refresh} reports
  9635. any packages provided by the distribution that are outdated compared to
  9636. the latest upstream version, like this:
  9637. @example
  9638. $ guix refresh
  9639. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  9640. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  9641. @end example
  9642. Alternatively, one can specify packages to consider, in which case a
  9643. warning is emitted for packages that lack an updater:
  9644. @example
  9645. $ guix refresh coreutils guile guile-ssh
  9646. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  9647. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  9648. @end example
  9649. @command{guix refresh} browses the upstream repository of each package and determines
  9650. the highest version number of the releases therein. The command
  9651. knows how to update specific types of packages: GNU packages, ELPA
  9652. packages, etc.---see the documentation for @option{--type} below. There
  9653. are many packages, though, for which it lacks a method to determine
  9654. whether a new upstream release is available. However, the mechanism is
  9655. extensible, so feel free to get in touch with us to add a new method!
  9656. @table @code
  9657. @item --recursive
  9658. Consider the packages specified, and all the packages upon which they depend.
  9659. @example
  9660. $ guix refresh --recursive coreutils
  9661. gnu/packages/acl.scm:40:13: acl would be upgraded from 2.2.53 to 2.3.1
  9662. gnu/packages/m4.scm:30:12: 1.4.18 is already the latest version of m4
  9663. gnu/packages/xml.scm:68:2: warning: no updater for expat
  9664. gnu/packages/multiprecision.scm:40:12: 6.1.2 is already the latest version of gmp
  9665. @dots{}
  9666. @end example
  9667. @end table
  9668. Sometimes the upstream name differs from the package name used in Guix,
  9669. and @command{guix refresh} needs a little help. Most updaters honor the
  9670. @code{upstream-name} property in package definitions, which can be used
  9671. to that effect:
  9672. @lisp
  9673. (define-public network-manager
  9674. (package
  9675. (name "network-manager")
  9676. ;; @dots{}
  9677. (properties '((upstream-name . "NetworkManager")))))
  9678. @end lisp
  9679. When passed @option{--update}, it modifies distribution source files to
  9680. update the version numbers and source tarball hashes of those package
  9681. recipes (@pxref{Defining Packages}). This is achieved by downloading
  9682. each package's latest source tarball and its associated OpenPGP
  9683. signature, authenticating the downloaded tarball against its signature
  9684. using @command{gpgv}, and finally computing its hash---note that GnuPG must be
  9685. installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
  9686. When the public
  9687. key used to sign the tarball is missing from the user's keyring, an
  9688. attempt is made to automatically retrieve it from a public key server;
  9689. when this is successful, the key is added to the user's keyring; otherwise,
  9690. @command{guix refresh} reports an error.
  9691. The following options are supported:
  9692. @table @code
  9693. @item --expression=@var{expr}
  9694. @itemx -e @var{expr}
  9695. Consider the package @var{expr} evaluates to.
  9696. This is useful to precisely refer to a package, as in this example:
  9697. @example
  9698. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  9699. @end example
  9700. This command lists the dependents of the ``final'' libc (essentially all
  9701. the packages).
  9702. @item --update
  9703. @itemx -u
  9704. Update distribution source files (package recipes) in place. This is
  9705. usually run from a checkout of the Guix source tree (@pxref{Running
  9706. Guix Before It Is Installed}):
  9707. @example
  9708. $ ./pre-inst-env guix refresh -s non-core -u
  9709. @end example
  9710. @xref{Defining Packages}, for more information on package definitions.
  9711. @item --select=[@var{subset}]
  9712. @itemx -s @var{subset}
  9713. Select all the packages in @var{subset}, one of @code{core} or
  9714. @code{non-core}.
  9715. The @code{core} subset refers to all the packages at the core of the
  9716. distribution---i.e., packages that are used to build ``everything
  9717. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  9718. changing one of these packages in the distribution entails a rebuild of
  9719. all the others. Thus, such updates are an inconvenience to users in
  9720. terms of build time or bandwidth used to achieve the upgrade.
  9721. The @code{non-core} subset refers to the remaining packages. It is
  9722. typically useful in cases where an update of the core packages would be
  9723. inconvenient.
  9724. @item --manifest=@var{file}
  9725. @itemx -m @var{file}
  9726. Select all the packages from the manifest in @var{file}. This is useful to
  9727. check if any packages of the user manifest can be updated.
  9728. @item --type=@var{updater}
  9729. @itemx -t @var{updater}
  9730. Select only packages handled by @var{updater} (may be a comma-separated
  9731. list of updaters). Currently, @var{updater} may be one of:
  9732. @table @code
  9733. @item gnu
  9734. the updater for GNU packages;
  9735. @item savannah
  9736. the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
  9737. @item sourceforge
  9738. the updater for packages hosted at @uref{https://sourceforge.net, SourceForge};
  9739. @item gnome
  9740. the updater for GNOME packages;
  9741. @item kde
  9742. the updater for KDE packages;
  9743. @item xorg
  9744. the updater for X.org packages;
  9745. @item kernel.org
  9746. the updater for packages hosted on kernel.org;
  9747. @item egg
  9748. the updater for @uref{https://wiki.call-cc.org/eggs/, Egg} packages;
  9749. @item elpa
  9750. the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
  9751. @item cran
  9752. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  9753. @item bioconductor
  9754. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  9755. @item cpan
  9756. the updater for @uref{https://www.cpan.org/, CPAN} packages;
  9757. @item pypi
  9758. the updater for @uref{https://pypi.python.org, PyPI} packages.
  9759. @item gem
  9760. the updater for @uref{https://rubygems.org, RubyGems} packages.
  9761. @item github
  9762. the updater for @uref{https://github.com, GitHub} packages.
  9763. @item hackage
  9764. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  9765. @item stackage
  9766. the updater for @uref{https://www.stackage.org, Stackage} packages.
  9767. @item crate
  9768. the updater for @uref{https://crates.io, Crates} packages.
  9769. @item launchpad
  9770. the updater for @uref{https://launchpad.net, Launchpad} packages.
  9771. @item generic-html
  9772. a generic updater that crawls the HTML page where the source tarball of
  9773. the package is hosted, when applicable.
  9774. @end table
  9775. For instance, the following command only checks for updates of Emacs
  9776. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  9777. @example
  9778. $ guix refresh --type=elpa,cran
  9779. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  9780. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  9781. @end example
  9782. @item --list-updaters
  9783. @itemx -L
  9784. List available updaters and exit (see @option{--type} above).
  9785. For each updater, display the fraction of packages it covers; at the
  9786. end, display the fraction of packages covered by all these updaters.
  9787. @end table
  9788. In addition, @command{guix refresh} can be passed one or more package
  9789. names, as in this example:
  9790. @example
  9791. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  9792. @end example
  9793. @noindent
  9794. The command above specifically updates the @code{emacs} and
  9795. @code{idutils} packages. The @option{--select} option would have no
  9796. effect in this case. You might also want to update definitions that
  9797. correspond to the packages installed in your profile:
  9798. @example
  9799. $ ./pre-inst-env guix refresh -u \
  9800. $(guix package --list-installed | cut -f1)
  9801. @end example
  9802. When considering whether to upgrade a package, it is sometimes
  9803. convenient to know which packages would be affected by the upgrade and
  9804. should be checked for compatibility. For this the following option may
  9805. be used when passing @command{guix refresh} one or more package names:
  9806. @table @code
  9807. @item --list-dependent
  9808. @itemx -l
  9809. List top-level dependent packages that would need to be rebuilt as a
  9810. result of upgrading one or more packages.
  9811. @xref{Invoking guix graph, the @code{reverse-package} type of
  9812. @command{guix graph}}, for information on how to visualize the list of
  9813. dependents of a package.
  9814. @end table
  9815. Be aware that the @option{--list-dependent} option only
  9816. @emph{approximates} the rebuilds that would be required as a result of
  9817. an upgrade. More rebuilds might be required under some circumstances.
  9818. @example
  9819. $ guix refresh --list-dependent flex
  9820. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  9821. hop@@2.4.0 emacs-geiser@@0.13 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  9822. @end example
  9823. The command above lists a set of packages that could be built to check
  9824. for compatibility with an upgraded @code{flex} package.
  9825. @table @code
  9826. @item --list-transitive
  9827. List all the packages which one or more packages depend upon.
  9828. @example
  9829. $ guix refresh --list-transitive flex
  9830. flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
  9831. 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{}
  9832. @end example
  9833. @end table
  9834. The command above lists a set of packages which, when changed, would cause
  9835. @code{flex} to be rebuilt.
  9836. The following options can be used to customize GnuPG operation:
  9837. @table @code
  9838. @item --gpg=@var{command}
  9839. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  9840. for in @code{$PATH}.
  9841. @item --keyring=@var{file}
  9842. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  9843. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  9844. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  9845. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  9846. information on a tool to manipulate keybox files).
  9847. When this option is omitted, @command{guix refresh} uses
  9848. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  9849. signing keys. OpenPGP signatures are checked against keys from this keyring;
  9850. missing keys are downloaded to this keyring as well (see
  9851. @option{--key-download} below).
  9852. You can export keys from your default GPG keyring into a keybox file using
  9853. commands like this one:
  9854. @example
  9855. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  9856. @end example
  9857. Likewise, you can fetch keys to a specific keybox file like this:
  9858. @example
  9859. gpg --no-default-keyring --keyring mykeyring.kbx \
  9860. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  9861. @end example
  9862. @xref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  9863. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  9864. @item --key-download=@var{policy}
  9865. Handle missing OpenPGP keys according to @var{policy}, which may be one
  9866. of:
  9867. @table @code
  9868. @item always
  9869. Always download missing OpenPGP keys from the key server, and add them
  9870. to the user's GnuPG keyring.
  9871. @item never
  9872. Never try to download missing OpenPGP keys. Instead just bail out.
  9873. @item interactive
  9874. When a package signed with an unknown OpenPGP key is encountered, ask
  9875. the user whether to download it or not. This is the default behavior.
  9876. @end table
  9877. @item --key-server=@var{host}
  9878. Use @var{host} as the OpenPGP key server when importing a public key.
  9879. @item --load-path=@var{directory}
  9880. Add @var{directory} to the front of the package module search path
  9881. (@pxref{Package Modules}).
  9882. This allows users to define their own packages and make them visible to
  9883. the command-line tools.
  9884. @end table
  9885. The @code{github} updater uses the
  9886. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  9887. releases. When used repeatedly e.g.@: when refreshing all packages,
  9888. GitHub will eventually refuse to answer any further API requests. By
  9889. default 60 API requests per hour are allowed, and a full refresh on all
  9890. GitHub packages in Guix requires more than this. Authentication with
  9891. GitHub through the use of an API token alleviates these limits. To use
  9892. an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
  9893. token procured from @uref{https://github.com/settings/tokens} or
  9894. otherwise.
  9895. @node Invoking guix style
  9896. @section Invoking @command{guix style}
  9897. The @command{guix style} command helps packagers style their package
  9898. definitions according to the latest fashionable trends. The command
  9899. currently focuses on one aspect: the style of package inputs. It may
  9900. eventually be extended to handle other stylistic matters.
  9901. The way package inputs are written is going through a transition
  9902. (@pxref{package Reference}, for more on package inputs). Until version
  9903. 1.3.0, package inputs were written using the ``old style'', where each
  9904. input was given an explicit label, most of the time the package name:
  9905. @lisp
  9906. (package
  9907. ;; @dots{}
  9908. ;; The "old style" (deprecated).
  9909. (inputs `(("libunistring" ,libunistring)
  9910. ("libffi" ,libffi))))
  9911. @end lisp
  9912. Today, the old style is deprecated and the preferred style looks like
  9913. this:
  9914. @lisp
  9915. (package
  9916. ;; @dots{}
  9917. ;; The "new style".
  9918. (inputs (list libunistring libffi)))
  9919. @end lisp
  9920. Likewise, uses of @code{alist-delete} and friends to manipulate inputs
  9921. is now deprecated in favor of @code{modify-inputs} (@pxref{Defining
  9922. Package Variants}, for more info on @code{modify-inputs}).
  9923. In the vast majority of cases, this is a purely mechanical change on the
  9924. surface syntax that does not even incur a package rebuild. Running
  9925. @command{guix style} can do that for you, whether you're working on
  9926. packages in Guix proper or in an external channel.
  9927. The general syntax is:
  9928. @example
  9929. guix style [@var{options}] @var{package}@dots{}
  9930. @end example
  9931. This causes @command{guix style} to analyze and rewrite the definition
  9932. of @var{package}@dots{}. It does so in a conservative way: preserving
  9933. comments and bailing out if it cannot make sense of the code that
  9934. appears in an inputs field. The available options are listed below.
  9935. @table @code
  9936. @item --load-path=@var{directory}
  9937. @itemx -L @var{directory}
  9938. Add @var{directory} to the front of the package module search path
  9939. (@pxref{Package Modules}).
  9940. @item --expression=@var{expr}
  9941. @itemx -e @var{expr}
  9942. Style the package @var{expr} evaluates to.
  9943. For example, running:
  9944. @example
  9945. guix style -e '(@@ (gnu packages gcc) gcc-5)'
  9946. @end example
  9947. styles the @code{gcc-5} package definition.
  9948. @item --input-simplification=@var{policy}
  9949. Specify the package input simplification policy for cases where an input
  9950. label does not match the corresponding package name. @var{policy} may
  9951. be one of the following:
  9952. @table @code
  9953. @item silent
  9954. Simplify inputs only when the change is ``silent'', meaning that the
  9955. package does not need to be rebuilt (its derivation is unchanged).
  9956. @item safe
  9957. Simplify inputs only when that is ``safe'' to do: the package might need
  9958. to be rebuilt, but the change is known to have no observable effect.
  9959. @item always
  9960. Simplify inputs even when input labels do not match package names, and
  9961. even if that might have an observable effect.
  9962. @end table
  9963. The default is @code{silent}, meaning that input simplifications do not
  9964. trigger any package rebuild.
  9965. @end table
  9966. @node Invoking guix lint
  9967. @section Invoking @command{guix lint}
  9968. @cindex @command{guix lint}
  9969. @cindex package, checking for errors
  9970. The @command{guix lint} command is meant to help package developers avoid
  9971. common errors and use a consistent style. It runs a number of checks on
  9972. a given set of packages in order to find common mistakes in their
  9973. definitions. Available @dfn{checkers} include (see
  9974. @option{--list-checkers} for a complete list):
  9975. @table @code
  9976. @item synopsis
  9977. @itemx description
  9978. Validate certain typographical and stylistic rules about package
  9979. descriptions and synopses.
  9980. @item inputs-should-be-native
  9981. Identify inputs that should most likely be native inputs.
  9982. @item source
  9983. @itemx home-page
  9984. @itemx mirror-url
  9985. @itemx github-url
  9986. @itemx source-file-name
  9987. Probe @code{home-page} and @code{source} URLs and report those that are
  9988. invalid. Suggest a @code{mirror://} URL when applicable. If the
  9989. @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
  9990. URL@. Check that the source file name is meaningful, e.g.@: is not just a
  9991. version number or ``git-checkout'', without a declared @code{file-name}
  9992. (@pxref{origin Reference}).
  9993. @item source-unstable-tarball
  9994. Parse the @code{source} URL to determine if a tarball from GitHub is
  9995. autogenerated or if it is a release tarball. Unfortunately GitHub's
  9996. autogenerated tarballs are sometimes regenerated.
  9997. @item derivation
  9998. Check that the derivation of the given packages can be successfully
  9999. computed for all the supported systems (@pxref{Derivations}).
  10000. @item profile-collisions
  10001. Check whether installing the given packages in a profile would lead to
  10002. collisions. Collisions occur when several packages with the same name
  10003. but a different version or a different store file name are propagated.
  10004. @xref{package Reference, @code{propagated-inputs}}, for more information
  10005. on propagated inputs.
  10006. @item archival
  10007. @cindex Software Heritage, source code archive
  10008. @cindex archival of source code, Software Heritage
  10009. Checks whether the package's source code is archived at
  10010. @uref{https://www.softwareheritage.org, Software Heritage}.
  10011. When the source code that is not archived comes from a version-control system
  10012. (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
  10013. ``save'' request so that it eventually archives it. This ensures that the
  10014. source will remain available in the long term, and that Guix can fall back to
  10015. Software Heritage should the source code disappear from its original host.
  10016. The status of recent ``save'' requests can be
  10017. @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
  10018. When source code is a tarball obtained with @code{url-fetch}, simply print a
  10019. message when it is not archived. As of this writing, Software Heritage does
  10020. not allow requests to save arbitrary tarballs; we are working on ways to
  10021. ensure that non-VCS source code is also archived.
  10022. Software Heritage
  10023. @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
  10024. request rate per IP address}. When the limit is reached, @command{guix lint}
  10025. prints a message and the @code{archival} checker stops doing anything until
  10026. that limit has been reset.
  10027. @item cve
  10028. @cindex security vulnerabilities
  10029. @cindex CVE, Common Vulnerabilities and Exposures
  10030. Report known vulnerabilities found in the Common Vulnerabilities and
  10031. Exposures (CVE) databases of the current and past year
  10032. @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
  10033. NIST}.
  10034. To view information about a particular vulnerability, visit pages such as:
  10035. @itemize
  10036. @item
  10037. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  10038. @item
  10039. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  10040. @end itemize
  10041. @noindent
  10042. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  10043. @code{CVE-2015-7554}.
  10044. Package developers can specify in package recipes the
  10045. @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
  10046. name and version of the package when they differ from the name or version
  10047. that Guix uses, as in this example:
  10048. @lisp
  10049. (package
  10050. (name "grub")
  10051. ;; @dots{}
  10052. ;; CPE calls this package "grub2".
  10053. (properties '((cpe-name . "grub2")
  10054. (cpe-version . "2.3"))))
  10055. @end lisp
  10056. @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
  10057. Some entries in the CVE database do not specify which version of a
  10058. package they apply to, and would thus ``stick around'' forever. Package
  10059. developers who found CVE alerts and verified they can be ignored can
  10060. declare them as in this example:
  10061. @lisp
  10062. (package
  10063. (name "t1lib")
  10064. ;; @dots{}
  10065. ;; These CVEs no longer apply and can be safely ignored.
  10066. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  10067. "CVE-2011-1553"
  10068. "CVE-2011-1554"
  10069. "CVE-2011-5244")))))
  10070. @end lisp
  10071. @item formatting
  10072. Warn about obvious source code formatting issues: trailing white space,
  10073. use of tabulations, etc.
  10074. @item input-labels
  10075. Report old-style input labels that do not match the name of the
  10076. corresponding package. This aims to help migrate from the ``old input
  10077. style''. @xref{package Reference}, for more information on package
  10078. inputs and input styles. @xref{Invoking guix style}, on how to migrate
  10079. to the new style.
  10080. @end table
  10081. The general syntax is:
  10082. @example
  10083. guix lint @var{options} @var{package}@dots{}
  10084. @end example
  10085. If no package is given on the command line, then all packages are checked.
  10086. The @var{options} may be zero or more of the following:
  10087. @table @code
  10088. @item --list-checkers
  10089. @itemx -l
  10090. List and describe all the available checkers that will be run on packages
  10091. and exit.
  10092. @item --checkers
  10093. @itemx -c
  10094. Only enable the checkers specified in a comma-separated list using the
  10095. names returned by @option{--list-checkers}.
  10096. @item --exclude
  10097. @itemx -x
  10098. Only disable the checkers specified in a comma-separated list using the
  10099. names returned by @option{--list-checkers}.
  10100. @item --no-network
  10101. @itemx -n
  10102. Only enable the checkers that do not depend on Internet access.
  10103. @item --load-path=@var{directory}
  10104. @itemx -L @var{directory}
  10105. Add @var{directory} to the front of the package module search path
  10106. (@pxref{Package Modules}).
  10107. This allows users to define their own packages and make them visible to
  10108. the command-line tools.
  10109. @end table
  10110. @node Invoking guix size
  10111. @section Invoking @command{guix size}
  10112. @cindex size
  10113. @cindex package size
  10114. @cindex closure
  10115. @cindex @command{guix size}
  10116. The @command{guix size} command helps package developers profile the
  10117. disk usage of packages. It is easy to overlook the impact of an
  10118. additional dependency added to a package, or the impact of using a
  10119. single output for a package that could easily be split (@pxref{Packages
  10120. with Multiple Outputs}). Such are the typical issues that
  10121. @command{guix size} can highlight.
  10122. The command can be passed one or more package specifications
  10123. such as @code{gcc@@4.8}
  10124. or @code{guile:debug}, or a file name in the store. Consider this
  10125. example:
  10126. @example
  10127. $ guix size coreutils
  10128. store item total self
  10129. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  10130. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  10131. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  10132. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  10133. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  10134. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  10135. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  10136. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  10137. total: 78.9 MiB
  10138. @end example
  10139. @cindex closure
  10140. The store items listed here constitute the @dfn{transitive closure} of
  10141. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  10142. would be returned by:
  10143. @example
  10144. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  10145. @end example
  10146. Here the output shows three columns next to store items. The first column,
  10147. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  10148. the store item---that is, its own size plus the size of all its
  10149. dependencies. The next column, labeled ``self'', shows the size of the
  10150. item itself. The last column shows the ratio of the size of the item
  10151. itself to the space occupied by all the items listed here.
  10152. In this example, we see that the closure of Coreutils weighs in at
  10153. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  10154. libraries. (That libc and GCC's libraries represent a large fraction of
  10155. the closure is not a problem @i{per se} because they are always available
  10156. on the system anyway.)
  10157. Since the command also accepts store file names, assessing the size of
  10158. a build result is straightforward:
  10159. @example
  10160. guix size $(guix system build config.scm)
  10161. @end example
  10162. When the package(s) passed to @command{guix size} are available in the
  10163. store@footnote{More precisely, @command{guix size} looks for the
  10164. @emph{ungrafted} variant of the given package(s), as returned by
  10165. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  10166. for information on grafts.}, @command{guix size} queries the daemon to determine its
  10167. dependencies, and measures its size in the store, similar to @command{du
  10168. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  10169. Coreutils}).
  10170. When the given packages are @emph{not} in the store, @command{guix size}
  10171. reports information based on the available substitutes
  10172. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  10173. store items that are not even on disk, only available remotely.
  10174. You can also specify several package names:
  10175. @example
  10176. $ guix size coreutils grep sed bash
  10177. store item total self
  10178. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  10179. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  10180. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  10181. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  10182. @dots{}
  10183. total: 102.3 MiB
  10184. @end example
  10185. @noindent
  10186. In this example we see that the combination of the four packages takes
  10187. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  10188. since they have a lot of dependencies in common.
  10189. When looking at the profile returned by @command{guix size}, you may
  10190. find yourself wondering why a given package shows up in the profile at
  10191. all. To understand it, you can use @command{guix graph --path -t
  10192. references} to display the shortest path between the two packages
  10193. (@pxref{Invoking guix graph}).
  10194. The available options are:
  10195. @table @option
  10196. @item --substitute-urls=@var{urls}
  10197. Use substitute information from @var{urls}.
  10198. @xref{client-substitute-urls, the same option for @code{guix build}}.
  10199. @item --sort=@var{key}
  10200. Sort lines according to @var{key}, one of the following options:
  10201. @table @code
  10202. @item self
  10203. the size of each item (the default);
  10204. @item closure
  10205. the total size of the item's closure.
  10206. @end table
  10207. @item --map-file=@var{file}
  10208. Write a graphical map of disk usage in PNG format to @var{file}.
  10209. For the example above, the map looks like this:
  10210. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  10211. produced by @command{guix size}}
  10212. This option requires that
  10213. @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
  10214. installed and visible in Guile's module search path. When that is not
  10215. the case, @command{guix size} fails as it tries to load it.
  10216. @item --system=@var{system}
  10217. @itemx -s @var{system}
  10218. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  10219. @item --load-path=@var{directory}
  10220. @itemx -L @var{directory}
  10221. Add @var{directory} to the front of the package module search path
  10222. (@pxref{Package Modules}).
  10223. This allows users to define their own packages and make them visible to
  10224. the command-line tools.
  10225. @end table
  10226. @node Invoking guix graph
  10227. @section Invoking @command{guix graph}
  10228. @cindex DAG
  10229. @cindex @command{guix graph}
  10230. @cindex package dependencies
  10231. Packages and their dependencies form a @dfn{graph}, specifically a
  10232. directed acyclic graph (DAG). It can quickly become difficult to have a
  10233. mental model of the package DAG, so the @command{guix graph} command
  10234. provides a visual representation of the DAG@. By default,
  10235. @command{guix graph} emits a DAG representation in the input format of
  10236. @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
  10237. directly to the @command{dot} command of Graphviz. It can also emit an
  10238. HTML page with embedded JavaScript code to display a ``chord diagram''
  10239. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  10240. emit Cypher queries to construct a graph in a graph database supporting
  10241. the @uref{https://www.opencypher.org/, openCypher} query language. With
  10242. @option{--path}, it simply displays the shortest path between two
  10243. packages. The general syntax is:
  10244. @example
  10245. guix graph @var{options} @var{package}@dots{}
  10246. @end example
  10247. For example, the following command generates a PDF file representing the
  10248. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  10249. dependencies:
  10250. @example
  10251. guix graph coreutils | dot -Tpdf > dag.pdf
  10252. @end example
  10253. The output looks like this:
  10254. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  10255. Nice little graph, no?
  10256. You may find it more pleasant to navigate the graph interactively with
  10257. @command{xdot} (from the @code{xdot} package):
  10258. @example
  10259. guix graph coreutils | xdot -
  10260. @end example
  10261. But there is more than one graph! The one above is concise: it is the
  10262. graph of package objects, omitting implicit inputs such as GCC, libc,
  10263. grep, etc. It is often useful to have such a concise graph, but
  10264. sometimes one may want to see more details. @command{guix graph} supports
  10265. several types of graphs, allowing you to choose the level of detail:
  10266. @table @code
  10267. @item package
  10268. This is the default type used in the example above. It shows the DAG of
  10269. package objects, excluding implicit dependencies. It is concise, but
  10270. filters out many details.
  10271. @item reverse-package
  10272. This shows the @emph{reverse} DAG of packages. For example:
  10273. @example
  10274. guix graph --type=reverse-package ocaml
  10275. @end example
  10276. ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
  10277. you are also interested in cases where OCaml is an implicit dependency, see
  10278. @code{reverse-bag} below).
  10279. Note that for core packages this can yield huge graphs. If all you want
  10280. is to know the number of packages that depend on a given package, use
  10281. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  10282. @option{--list-dependent}}).
  10283. @item bag-emerged
  10284. This is the package DAG, @emph{including} implicit inputs.
  10285. For instance, the following command:
  10286. @example
  10287. guix graph --type=bag-emerged coreutils
  10288. @end example
  10289. ...@: yields this bigger graph:
  10290. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  10291. At the bottom of the graph, we see all the implicit inputs of
  10292. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  10293. Now, note that the dependencies of these implicit inputs---that is, the
  10294. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  10295. here, for conciseness.
  10296. @item bag
  10297. Similar to @code{bag-emerged}, but this time including all the bootstrap
  10298. dependencies.
  10299. @item bag-with-origins
  10300. Similar to @code{bag}, but also showing origins and their dependencies.
  10301. @item reverse-bag
  10302. This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
  10303. it also takes implicit dependencies into account. For example:
  10304. @example
  10305. guix graph -t reverse-bag dune
  10306. @end example
  10307. @noindent
  10308. ...@: yields the graph of all packages that depend on Dune, directly or
  10309. indirectly. Since Dune is an @emph{implicit} dependency of many packages
  10310. @i{via} @code{dune-build-system}, this shows a large number of packages,
  10311. whereas @code{reverse-package} would show very few if any.
  10312. @item derivation
  10313. This is the most detailed representation: It shows the DAG of
  10314. derivations (@pxref{Derivations}) and plain store items. Compared to
  10315. the above representation, many additional nodes are visible, including
  10316. build scripts, patches, Guile modules, etc.
  10317. For this type of graph, it is also possible to pass a @file{.drv} file
  10318. name instead of a package name, as in:
  10319. @example
  10320. guix graph -t derivation $(guix system build -d my-config.scm)
  10321. @end example
  10322. @item module
  10323. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  10324. For example, the following command shows the graph for the package
  10325. module that defines the @code{guile} package:
  10326. @example
  10327. guix graph -t module guile | xdot -
  10328. @end example
  10329. @end table
  10330. All the types above correspond to @emph{build-time dependencies}. The
  10331. following graph type represents the @emph{run-time dependencies}:
  10332. @table @code
  10333. @item references
  10334. This is the graph of @dfn{references} of a package output, as returned
  10335. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  10336. If the given package output is not available in the store, @command{guix
  10337. graph} attempts to obtain dependency information from substitutes.
  10338. Here you can also pass a store file name instead of a package name. For
  10339. example, the command below produces the reference graph of your profile
  10340. (which can be big!):
  10341. @example
  10342. guix graph -t references $(readlink -f ~/.guix-profile)
  10343. @end example
  10344. @item referrers
  10345. This is the graph of the @dfn{referrers} of a store item, as returned by
  10346. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  10347. This relies exclusively on local information from your store. For
  10348. instance, let us suppose that the current Inkscape is available in 10
  10349. profiles on your machine; @command{guix graph -t referrers inkscape}
  10350. will show a graph rooted at Inkscape and with those 10 profiles linked
  10351. to it.
  10352. It can help determine what is preventing a store item from being garbage
  10353. collected.
  10354. @end table
  10355. @cindex shortest path, between packages
  10356. Often, the graph of the package you are interested in does not fit on
  10357. your screen, and anyway all you want to know is @emph{why} that package
  10358. actually depends on some seemingly unrelated package. The
  10359. @option{--path} option instructs @command{guix graph} to display the
  10360. shortest path between two packages (or derivations, or store items,
  10361. etc.):
  10362. @example
  10363. $ guix graph --path emacs libunistring
  10364. emacs@@26.3
  10365. mailutils@@3.9
  10366. libunistring@@0.9.10
  10367. $ guix graph --path -t derivation emacs libunistring
  10368. /gnu/store/@dots{}-emacs-26.3.drv
  10369. /gnu/store/@dots{}-mailutils-3.9.drv
  10370. /gnu/store/@dots{}-libunistring-0.9.10.drv
  10371. $ guix graph --path -t references emacs libunistring
  10372. /gnu/store/@dots{}-emacs-26.3
  10373. /gnu/store/@dots{}-libidn2-2.2.0
  10374. /gnu/store/@dots{}-libunistring-0.9.10
  10375. @end example
  10376. The available options are the following:
  10377. @table @option
  10378. @item --type=@var{type}
  10379. @itemx -t @var{type}
  10380. Produce a graph output of @var{type}, where @var{type} must be one of
  10381. the values listed above.
  10382. @item --list-types
  10383. List the supported graph types.
  10384. @item --backend=@var{backend}
  10385. @itemx -b @var{backend}
  10386. Produce a graph using the selected @var{backend}.
  10387. @item --list-backends
  10388. List the supported graph backends.
  10389. Currently, the available backends are Graphviz and d3.js.
  10390. @item --path
  10391. Display the shortest path between two nodes of the type specified by
  10392. @option{--type}. The example below shows the shortest path between
  10393. @code{libreoffice} and @code{llvm} according to the references of
  10394. @code{libreoffice}:
  10395. @example
  10396. $ guix graph --path -t references libreoffice llvm
  10397. /gnu/store/@dots{}-libreoffice-6.4.2.2
  10398. /gnu/store/@dots{}-libepoxy-1.5.4
  10399. /gnu/store/@dots{}-mesa-19.3.4
  10400. /gnu/store/@dots{}-llvm-9.0.1
  10401. @end example
  10402. @item --expression=@var{expr}
  10403. @itemx -e @var{expr}
  10404. Consider the package @var{expr} evaluates to.
  10405. This is useful to precisely refer to a package, as in this example:
  10406. @example
  10407. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  10408. @end example
  10409. @item --system=@var{system}
  10410. @itemx -s @var{system}
  10411. Display the graph for @var{system}---e.g., @code{i686-linux}.
  10412. The package dependency graph is largely architecture-independent, but there
  10413. are some architecture-dependent bits that this option allows you to visualize.
  10414. @item --load-path=@var{directory}
  10415. @itemx -L @var{directory}
  10416. Add @var{directory} to the front of the package module search path
  10417. (@pxref{Package Modules}).
  10418. This allows users to define their own packages and make them visible to
  10419. the command-line tools.
  10420. @end table
  10421. On top of that, @command{guix graph} supports all the usual package
  10422. transformation options (@pxref{Package Transformation Options}). This
  10423. makes it easy to view the effect of a graph-rewriting transformation
  10424. such as @option{--with-input}. For example, the command below outputs
  10425. the graph of @code{git} once @code{openssl} has been replaced by
  10426. @code{libressl} everywhere in the graph:
  10427. @example
  10428. guix graph git --with-input=openssl=libressl
  10429. @end example
  10430. So many possibilities, so much fun!
  10431. @node Invoking guix publish
  10432. @section Invoking @command{guix publish}
  10433. @cindex @command{guix publish}
  10434. The purpose of @command{guix publish} is to enable users to easily share
  10435. their store with others, who can then use it as a substitute server
  10436. (@pxref{Substitutes}).
  10437. When @command{guix publish} runs, it spawns an HTTP server which allows
  10438. anyone with network access to obtain substitutes from it. This means
  10439. that any machine running Guix can also act as if it were a build farm,
  10440. since the HTTP interface is compatible with Cuirass, the software behind
  10441. the @code{@value{SUBSTITUTE-SERVER-1}} build farm.
  10442. For security, each substitute is signed, allowing recipients to check
  10443. their authenticity and integrity (@pxref{Substitutes}). Because
  10444. @command{guix publish} uses the signing key of the system, which is only
  10445. readable by the system administrator, it must be started as root; the
  10446. @option{--user} option makes it drop root privileges early on.
  10447. The signing key pair must be generated before @command{guix publish} is
  10448. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  10449. guix archive}).
  10450. When the @option{--advertise} option is passed, the server advertises
  10451. its availability on the local network using multicast DNS (mDNS) and DNS
  10452. service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,,
  10453. guile-avahi, Using Avahi in Guile Scheme Programs}).
  10454. The general syntax is:
  10455. @example
  10456. guix publish @var{options}@dots{}
  10457. @end example
  10458. Running @command{guix publish} without any additional arguments will
  10459. spawn an HTTP server on port 8080:
  10460. @example
  10461. guix publish
  10462. @end example
  10463. Once a publishing server has been authorized, the daemon may download
  10464. substitutes from it. @xref{Getting Substitutes from Other Servers}.
  10465. By default, @command{guix publish} compresses archives on the fly as it
  10466. serves them. This ``on-the-fly'' mode is convenient in that it requires
  10467. no setup and is immediately available. However, when serving lots of
  10468. clients, we recommend using the @option{--cache} option, which enables
  10469. caching of the archives before they are sent to clients---see below for
  10470. details. The @command{guix weather} command provides a handy way to
  10471. check what a server provides (@pxref{Invoking guix weather}).
  10472. As a bonus, @command{guix publish} also serves as a content-addressed
  10473. mirror for source files referenced in @code{origin} records
  10474. (@pxref{origin Reference}). For instance, assuming @command{guix
  10475. publish} is running on @code{example.org}, the following URL returns the
  10476. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  10477. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  10478. @example
  10479. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  10480. @end example
  10481. Obviously, these URLs only work for files that are in the store; in
  10482. other cases, they return 404 (``Not Found'').
  10483. @cindex build logs, publication
  10484. Build logs are available from @code{/log} URLs like:
  10485. @example
  10486. http://example.org/log/gwspk@dots{}-guile-2.2.3
  10487. @end example
  10488. @noindent
  10489. When @command{guix-daemon} is configured to save compressed build logs,
  10490. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  10491. URLs return the compressed log as-is, with an appropriate
  10492. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  10493. running @command{guix-daemon} with @option{--log-compression=gzip} since
  10494. Web browsers can automatically decompress it, which is not the case with
  10495. Bzip2 compression.
  10496. The following options are available:
  10497. @table @code
  10498. @item --port=@var{port}
  10499. @itemx -p @var{port}
  10500. Listen for HTTP requests on @var{port}.
  10501. @item --listen=@var{host}
  10502. Listen on the network interface for @var{host}. The default is to
  10503. accept connections from any interface.
  10504. @item --user=@var{user}
  10505. @itemx -u @var{user}
  10506. Change privileges to @var{user} as soon as possible---i.e., once the
  10507. server socket is open and the signing key has been read.
  10508. @item --compression[=@var{method}[:@var{level}]]
  10509. @itemx -C [@var{method}[:@var{level}]]
  10510. Compress data using the given @var{method} and @var{level}. @var{method} is
  10511. one of @code{lzip}, @code{zstd}, and @code{gzip}; when @var{method} is
  10512. omitted, @code{gzip} is used.
  10513. When @var{level} is zero, disable compression. The range 1 to 9 corresponds
  10514. to different compression levels: 1 is the fastest, and 9 is the best
  10515. (CPU-intensive). The default is 3.
  10516. Usually, @code{lzip} compresses noticeably better than @code{gzip} for a
  10517. small increase in CPU usage; see
  10518. @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip
  10519. Web page}. However, @code{lzip} achieves low decompression throughput
  10520. (on the order of 50@tie{}MiB/s on modern hardware), which can be a
  10521. bottleneck for someone who downloads over a fast network connection.
  10522. The compression ratio of @code{zstd} is between that of @code{lzip} and
  10523. that of @code{gzip}; its main advantage is a
  10524. @uref{https://facebook.github.io/zstd/,high decompression speed}.
  10525. Unless @option{--cache} is used, compression occurs on the fly and
  10526. the compressed streams are not
  10527. cached. Thus, to reduce load on the machine that runs @command{guix
  10528. publish}, it may be a good idea to choose a low compression level, to
  10529. run @command{guix publish} behind a caching proxy, or to use
  10530. @option{--cache}. Using @option{--cache} has the advantage that it
  10531. allows @command{guix publish} to add @code{Content-Length} HTTP header
  10532. to its responses.
  10533. This option can be repeated, in which case every substitute gets compressed
  10534. using all the selected methods, and all of them are advertised. This is
  10535. useful when users may not support all the compression methods: they can select
  10536. the one they support.
  10537. @item --cache=@var{directory}
  10538. @itemx -c @var{directory}
  10539. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  10540. and only serve archives that are in cache.
  10541. When this option is omitted, archives and meta-data are created
  10542. on-the-fly. This can reduce the available bandwidth, especially when
  10543. compression is enabled, since this may become CPU-bound. Another
  10544. drawback of the default mode is that the length of archives is not known
  10545. in advance, so @command{guix publish} does not add a
  10546. @code{Content-Length} HTTP header to its responses, which in turn
  10547. prevents clients from knowing the amount of data being downloaded.
  10548. Conversely, when @option{--cache} is used, the first request for a store
  10549. item (@i{via} a @code{.narinfo} URL) triggers a
  10550. background process to @dfn{bake} the archive---computing its
  10551. @code{.narinfo} and compressing the archive, if needed. Once the
  10552. archive is cached in @var{directory}, subsequent requests succeed and
  10553. are served directly from the cache, which guarantees that clients get
  10554. the best possible bandwidth.
  10555. That first @code{.narinfo} request nonetheless returns 200, provided the
  10556. requested store item is ``small enough'', below the cache bypass
  10557. threshold---see @option{--cache-bypass-threshold} below. That way,
  10558. clients do not have to wait until the archive is baked. For larger
  10559. store items, the first @code{.narinfo} request returns 404, meaning that
  10560. clients have to wait until the archive is baked.
  10561. The ``baking'' process is performed by worker threads. By default, one
  10562. thread per CPU core is created, but this can be customized. See
  10563. @option{--workers} below.
  10564. When @option{--ttl} is used, cached entries are automatically deleted
  10565. when they have expired.
  10566. @item --workers=@var{N}
  10567. When @option{--cache} is used, request the allocation of @var{N} worker
  10568. threads to ``bake'' archives.
  10569. @item --ttl=@var{ttl}
  10570. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  10571. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  10572. days, @code{1m} means 1 month, and so on.
  10573. This allows the user's Guix to keep substitute information in cache for
  10574. @var{ttl}. However, note that @code{guix publish} does not itself
  10575. guarantee that the store items it provides will indeed remain available
  10576. for as long as @var{ttl}.
  10577. Additionally, when @option{--cache} is used, cached entries that have
  10578. not been accessed for @var{ttl} and that no longer have a corresponding
  10579. item in the store, may be deleted.
  10580. @item --negative-ttl=@var{ttl}
  10581. Similarly produce @code{Cache-Control} HTTP headers to advertise the
  10582. time-to-live (TTL) of @emph{negative} lookups---missing store items, for
  10583. which the HTTP 404 code is returned. By default, no negative TTL is
  10584. advertised.
  10585. This parameter can help adjust server load and substitute latency by
  10586. instructing cooperating clients to be more or less patient when a store
  10587. item is missing.
  10588. @item --cache-bypass-threshold=@var{size}
  10589. When used in conjunction with @option{--cache}, store items smaller than
  10590. @var{size} are immediately available, even when they are not yet in
  10591. cache. @var{size} is a size in bytes, or it can be suffixed by @code{M}
  10592. for megabytes and so on. The default is @code{10M}.
  10593. ``Cache bypass'' allows you to reduce the publication delay for clients
  10594. at the expense of possibly additional I/O and CPU use on the server
  10595. side: depending on the client access patterns, those store items can end
  10596. up being baked several times until a copy is available in cache.
  10597. Increasing the threshold may be useful for sites that have few users, or
  10598. to guarantee that users get substitutes even for store items that are
  10599. not popular.
  10600. @item --nar-path=@var{path}
  10601. Use @var{path} as the prefix for the URLs of ``nar'' files
  10602. (@pxref{Invoking guix archive, normalized archives}).
  10603. By default, nars are served at a URL such as
  10604. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  10605. change the @code{/nar} part to @var{path}.
  10606. @item --public-key=@var{file}
  10607. @itemx --private-key=@var{file}
  10608. Use the specific @var{file}s as the public/private key pair used to sign
  10609. the store items being published.
  10610. The files must correspond to the same key pair (the private key is used
  10611. for signing and the public key is merely advertised in the signature
  10612. metadata). They must contain keys in the canonical s-expression format
  10613. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  10614. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  10615. @file{/etc/guix/signing-key.sec} are used.
  10616. @item --repl[=@var{port}]
  10617. @itemx -r [@var{port}]
  10618. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  10619. Reference Manual}) on @var{port} (37146 by default). This is used
  10620. primarily for debugging a running @command{guix publish} server.
  10621. @end table
  10622. Enabling @command{guix publish} on Guix System is a one-liner: just
  10623. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  10624. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  10625. @code{guix-publish-service-type}}).
  10626. If you are instead running Guix on a ``foreign distro'', follow these
  10627. instructions:
  10628. @itemize
  10629. @item
  10630. If your host distro uses the systemd init system:
  10631. @example
  10632. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  10633. /etc/systemd/system/
  10634. # systemctl start guix-publish && systemctl enable guix-publish
  10635. @end example
  10636. @item
  10637. If your host distro uses the Upstart init system:
  10638. @example
  10639. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  10640. # start guix-publish
  10641. @end example
  10642. @item
  10643. Otherwise, proceed similarly with your distro's init system.
  10644. @end itemize
  10645. @node Invoking guix challenge
  10646. @section Invoking @command{guix challenge}
  10647. @cindex reproducible builds
  10648. @cindex verifiable builds
  10649. @cindex @command{guix challenge}
  10650. @cindex challenge
  10651. Do the binaries provided by this server really correspond to the source
  10652. code it claims to build? Is a package build process deterministic?
  10653. These are the questions the @command{guix challenge} command attempts to
  10654. answer.
  10655. The former is obviously an important question: Before using a substitute
  10656. server (@pxref{Substitutes}), one had better @emph{verify} that it
  10657. provides the right binaries, and thus @emph{challenge} it. The latter
  10658. is what enables the former: If package builds are deterministic, then
  10659. independent builds of the package should yield the exact same result,
  10660. bit for bit; if a server provides a binary different from the one
  10661. obtained locally, it may be either corrupt or malicious.
  10662. We know that the hash that shows up in @file{/gnu/store} file names is
  10663. the hash of all the inputs of the process that built the file or
  10664. directory---compilers, libraries, build scripts,
  10665. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  10666. one store file name should map to exactly one build output.
  10667. @command{guix challenge} checks whether there is, indeed, a single
  10668. mapping by comparing the build outputs of several independent builds of
  10669. any given store item.
  10670. The command output looks like this:
  10671. @smallexample
  10672. $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
  10673. updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER-1}'... 100.0%
  10674. updating list of substitutes from 'https://guix.example.org'... 100.0%
  10675. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  10676. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  10677. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  10678. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  10679. differing files:
  10680. /lib/libcrypto.so.1.1
  10681. /lib/libssl.so.1.1
  10682. /gnu/store/@dots{}-git-2.5.0 contents differ:
  10683. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  10684. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  10685. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  10686. differing file:
  10687. /libexec/git-core/git-fsck
  10688. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  10689. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  10690. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  10691. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  10692. differing file:
  10693. /share/man/man1/pius.1.gz
  10694. @dots{}
  10695. 6,406 store items were analyzed:
  10696. - 4,749 (74.1%) were identical
  10697. - 525 (8.2%) differed
  10698. - 1,132 (17.7%) were inconclusive
  10699. @end smallexample
  10700. @noindent
  10701. In this example, @command{guix challenge} first scans the store to
  10702. determine the set of locally-built derivations---as opposed to store
  10703. items that were downloaded from a substitute server---and then queries
  10704. all the substitute servers. It then reports those store items for which
  10705. the servers obtained a result different from the local build.
  10706. @cindex non-determinism, in package builds
  10707. As an example, @code{guix.example.org} always gets a different answer.
  10708. Conversely, @code{@value{SUBSTITUTE-SERVER-1}} agrees with local builds, except in the
  10709. case of Git. This might indicate that the build process of Git is
  10710. non-deterministic, meaning that its output varies as a function of
  10711. various things that Guix does not fully control, in spite of building
  10712. packages in isolated environments (@pxref{Features}). Most common
  10713. sources of non-determinism include the addition of timestamps in build
  10714. results, the inclusion of random numbers, and directory listings sorted
  10715. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  10716. more information.
  10717. To find out what is wrong with this Git binary, the easiest approach is
  10718. to run:
  10719. @example
  10720. guix challenge git \
  10721. --diff=diffoscope \
  10722. --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
  10723. @end example
  10724. This automatically invokes @command{diffoscope}, which displays detailed
  10725. information about files that differ.
  10726. Alternatively, we can do something along these lines (@pxref{Invoking guix
  10727. archive}):
  10728. @example
  10729. $ wget -q -O - https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-git-2.5.0 \
  10730. | lzip -d | guix archive -x /tmp/git
  10731. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  10732. @end example
  10733. This command shows the difference between the files resulting from the
  10734. local build, and the files resulting from the build on
  10735. @code{@value{SUBSTITUTE-SERVER-1}} (@pxref{Overview, Comparing and Merging Files,,
  10736. diffutils, Comparing and Merging Files}). The @command{diff} command
  10737. works great for text files. When binary files differ, a better option
  10738. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  10739. visualize differences for all kinds of files.
  10740. Once you have done that work, you can tell whether the differences are due
  10741. to a non-deterministic build process or to a malicious server. We try
  10742. hard to remove sources of non-determinism in packages to make it easier
  10743. to verify substitutes, but of course, this is a process that
  10744. involves not just Guix, but a large part of the free software community.
  10745. In the meantime, @command{guix challenge} is one tool to help address
  10746. the problem.
  10747. If you are writing packages for Guix, you are encouraged to check
  10748. whether @code{@value{SUBSTITUTE-SERVER-1}} and other substitute servers obtain the
  10749. same build result as you did with:
  10750. @example
  10751. $ guix challenge @var{package}
  10752. @end example
  10753. @noindent
  10754. where @var{package} is a package specification such as
  10755. @code{guile@@2.0} or @code{glibc:debug}.
  10756. The general syntax is:
  10757. @example
  10758. guix challenge @var{options} [@var{packages}@dots{}]
  10759. @end example
  10760. When a difference is found between the hash of a locally-built item and
  10761. that of a server-provided substitute, or among substitutes provided by
  10762. different servers, the command displays it as in the example above and
  10763. its exit code is 2 (other non-zero exit codes denote other kinds of
  10764. errors).
  10765. The one option that matters is:
  10766. @table @code
  10767. @item --substitute-urls=@var{urls}
  10768. Consider @var{urls} the whitespace-separated list of substitute source
  10769. URLs to compare to.
  10770. @item --diff=@var{mode}
  10771. Upon mismatches, show differences according to @var{mode}, one of:
  10772. @table @asis
  10773. @item @code{simple} (the default)
  10774. Show the list of files that differ.
  10775. @item @code{diffoscope}
  10776. @itemx @var{command}
  10777. Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
  10778. two directories whose contents do not match.
  10779. When @var{command} is an absolute file name, run @var{command} instead
  10780. of Diffoscope.
  10781. @item @code{none}
  10782. Do not show further details about the differences.
  10783. @end table
  10784. Thus, unless @option{--diff=none} is passed, @command{guix challenge}
  10785. downloads the store items from the given substitute servers so that it
  10786. can compare them.
  10787. @item --verbose
  10788. @itemx -v
  10789. Show details about matches (identical contents) in addition to
  10790. information about mismatches.
  10791. @end table
  10792. @node Invoking guix copy
  10793. @section Invoking @command{guix copy}
  10794. @cindex copy, of store items, over SSH
  10795. @cindex SSH, copy of store items
  10796. @cindex sharing store items across machines
  10797. @cindex transferring store items across machines
  10798. The @command{guix copy} command copies items from the store of one
  10799. machine to that of another machine over a secure shell (SSH)
  10800. connection@footnote{This command is available only when Guile-SSH was
  10801. found. @xref{Requirements}, for details.}. For example, the following
  10802. command copies the @code{coreutils} package, the user's profile, and all
  10803. their dependencies over to @var{host}, logged in as @var{user}:
  10804. @example
  10805. guix copy --to=@var{user}@@@var{host} \
  10806. coreutils $(readlink -f ~/.guix-profile)
  10807. @end example
  10808. If some of the items to be copied are already present on @var{host},
  10809. they are not actually sent.
  10810. The command below retrieves @code{libreoffice} and @code{gimp} from
  10811. @var{host}, assuming they are available there:
  10812. @example
  10813. guix copy --from=@var{host} libreoffice gimp
  10814. @end example
  10815. The SSH connection is established using the Guile-SSH client, which is
  10816. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  10817. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  10818. The key used to sign items that are sent must be accepted by the remote
  10819. machine. Likewise, the key used by the remote machine to sign items you
  10820. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  10821. own daemon. @xref{Invoking guix archive}, for more information about
  10822. store item authentication.
  10823. The general syntax is:
  10824. @example
  10825. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  10826. @end example
  10827. You must always specify one of the following options:
  10828. @table @code
  10829. @item --to=@var{spec}
  10830. @itemx --from=@var{spec}
  10831. Specify the host to send to or receive from. @var{spec} must be an SSH
  10832. spec such as @code{example.org}, @code{charlie@@example.org}, or
  10833. @code{charlie@@example.org:2222}.
  10834. @end table
  10835. The @var{items} can be either package names, such as @code{gimp}, or
  10836. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  10837. When specifying the name of a package to send, it is first built if
  10838. needed, unless @option{--dry-run} was specified. Common build options
  10839. are supported (@pxref{Common Build Options}).
  10840. @node Invoking guix container
  10841. @section Invoking @command{guix container}
  10842. @cindex container
  10843. @cindex @command{guix container}
  10844. @quotation Note
  10845. As of version @value{VERSION}, this tool is experimental. The interface
  10846. is subject to radical change in the future.
  10847. @end quotation
  10848. The purpose of @command{guix container} is to manipulate processes
  10849. running within an isolated environment, commonly known as a
  10850. ``container'', typically created by the @command{guix environment}
  10851. (@pxref{Invoking guix environment}) and @command{guix system container}
  10852. (@pxref{Invoking guix system}) commands.
  10853. The general syntax is:
  10854. @example
  10855. guix container @var{action} @var{options}@dots{}
  10856. @end example
  10857. @var{action} specifies the operation to perform with a container, and
  10858. @var{options} specifies the context-specific arguments for the action.
  10859. The following actions are available:
  10860. @table @code
  10861. @item exec
  10862. Execute a command within the context of a running container.
  10863. The syntax is:
  10864. @example
  10865. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  10866. @end example
  10867. @var{pid} specifies the process ID of the running container.
  10868. @var{program} specifies an executable file name within the root file
  10869. system of the container. @var{arguments} are the additional options that
  10870. will be passed to @var{program}.
  10871. The following command launches an interactive login shell inside a
  10872. Guix system container, started by @command{guix system container}, and whose
  10873. process ID is 9001:
  10874. @example
  10875. guix container exec 9001 /run/current-system/profile/bin/bash --login
  10876. @end example
  10877. Note that the @var{pid} cannot be the parent process of a container. It
  10878. must be PID 1 of the container or one of its child processes.
  10879. @end table
  10880. @node Invoking guix weather
  10881. @section Invoking @command{guix weather}
  10882. Occasionally you're grumpy because substitutes are lacking and you end
  10883. up building packages by yourself (@pxref{Substitutes}). The
  10884. @command{guix weather} command reports on substitute availability on the
  10885. specified servers so you can have an idea of whether you'll be grumpy
  10886. today. It can sometimes be useful info as a user, but it is primarily
  10887. useful to people running @command{guix publish} (@pxref{Invoking guix
  10888. publish}).
  10889. @cindex statistics, for substitutes
  10890. @cindex availability of substitutes
  10891. @cindex substitute availability
  10892. @cindex weather, substitute availability
  10893. Here's a sample run:
  10894. @example
  10895. $ guix weather --substitute-urls=https://guix.example.org
  10896. computing 5,872 package derivations for x86_64-linux...
  10897. looking for 6,128 store items on https://guix.example.org..
  10898. updating list of substitutes from 'https://guix.example.org'... 100.0%
  10899. https://guix.example.org
  10900. 43.4% substitutes available (2,658 out of 6,128)
  10901. 7,032.5 MiB of nars (compressed)
  10902. 19,824.2 MiB on disk (uncompressed)
  10903. 0.030 seconds per request (182.9 seconds in total)
  10904. 33.5 requests per second
  10905. 9.8% (342 out of 3,470) of the missing items are queued
  10906. 867 queued builds
  10907. x86_64-linux: 518 (59.7%)
  10908. i686-linux: 221 (25.5%)
  10909. aarch64-linux: 128 (14.8%)
  10910. build rate: 23.41 builds per hour
  10911. x86_64-linux: 11.16 builds per hour
  10912. i686-linux: 6.03 builds per hour
  10913. aarch64-linux: 6.41 builds per hour
  10914. @end example
  10915. @cindex continuous integration, statistics
  10916. As you can see, it reports the fraction of all the packages for which
  10917. substitutes are available on the server---regardless of whether
  10918. substitutes are enabled, and regardless of whether this server's signing
  10919. key is authorized. It also reports the size of the compressed archives
  10920. (``nars'') provided by the server, the size the corresponding store
  10921. items occupy in the store (assuming deduplication is turned off), and
  10922. the server's throughput. The second part gives continuous integration
  10923. (CI) statistics, if the server supports it. In addition, using the
  10924. @option{--coverage} option, @command{guix weather} can list ``important''
  10925. package substitutes missing on the server (see below).
  10926. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  10927. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  10928. challenge}, it ignores signatures on those substitutes, which is
  10929. innocuous since the command only gathers statistics and cannot install
  10930. those substitutes.
  10931. The general syntax is:
  10932. @example
  10933. guix weather @var{options}@dots{} [@var{packages}@dots{}]
  10934. @end example
  10935. When @var{packages} is omitted, @command{guix weather} checks the availability
  10936. of substitutes for @emph{all} the packages, or for those specified with
  10937. @option{--manifest}; otherwise it only considers the specified packages. It
  10938. is also possible to query specific system types with @option{--system}.
  10939. @command{guix weather} exits with a non-zero code when the fraction of
  10940. available substitutes is below 100%.
  10941. The available options are listed below.
  10942. @table @code
  10943. @item --substitute-urls=@var{urls}
  10944. @var{urls} is the space-separated list of substitute server URLs to
  10945. query. When this option is omitted, the default set of substitute
  10946. servers is queried.
  10947. @item --system=@var{system}
  10948. @itemx -s @var{system}
  10949. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  10950. option can be repeated, in which case @command{guix weather} will query
  10951. substitutes for several system types.
  10952. @item --manifest=@var{file}
  10953. Instead of querying substitutes for all the packages, only ask for those
  10954. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  10955. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  10956. guix package}).
  10957. This option can be repeated several times, in which case the manifests
  10958. are concatenated.
  10959. @item --coverage[=@var{count}]
  10960. @itemx -c [@var{count}]
  10961. Report on substitute coverage for packages: list packages with at least
  10962. @var{count} dependents (zero by default) for which substitutes are
  10963. unavailable. Dependent packages themselves are not listed: if @var{b} depends
  10964. on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
  10965. @var{b} usually lacks substitutes as well. The result looks like this:
  10966. @example
  10967. $ guix weather --substitute-urls=@value{SUBSTITUTE-URLS} -c 10
  10968. computing 8,983 package derivations for x86_64-linux...
  10969. looking for 9,343 store items on @value{SUBSTITUTE-URLS}...
  10970. updating substitutes from '@value{SUBSTITUTE-URLS}'... 100.0%
  10971. @value{SUBSTITUTE-URLS}
  10972. 64.7% substitutes available (6,047 out of 9,343)
  10973. @dots{}
  10974. 2502 packages are missing from '@value{SUBSTITUTE-URLS}' for 'x86_64-linux', among which:
  10975. 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
  10976. 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
  10977. 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
  10978. @dots{}
  10979. @end example
  10980. What this example shows is that @code{kcoreaddons} and presumably the 58
  10981. packages that depend on it have no substitutes at
  10982. @code{@value{SUBSTITUTE-SERVER-1}}; likewise for @code{qgpgme} and the 46
  10983. packages that depend on it.
  10984. If you are a Guix developer, or if you are taking care of this build farm,
  10985. you'll probably want to have a closer look at these packages: they may simply
  10986. fail to build.
  10987. @item --display-missing
  10988. Display the list of store items for which substitutes are missing.
  10989. @end table
  10990. @node Invoking guix processes
  10991. @section Invoking @command{guix processes}
  10992. The @command{guix processes} command can be useful to developers and system
  10993. administrators, especially on multi-user machines and on build farms: it lists
  10994. the current sessions (connections to the daemon), as well as information about
  10995. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  10996. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  10997. listed.}. Here's an example of the information it returns:
  10998. @example
  10999. $ sudo guix processes
  11000. SessionPID: 19002
  11001. ClientPID: 19090
  11002. ClientCommand: guix environment --ad-hoc python
  11003. SessionPID: 19402
  11004. ClientPID: 19367
  11005. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  11006. SessionPID: 19444
  11007. ClientPID: 19419
  11008. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  11009. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  11010. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  11011. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  11012. ChildPID: 20495
  11013. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11014. ChildPID: 27733
  11015. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11016. ChildPID: 27793
  11017. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11018. @end example
  11019. In this example we see that @command{guix-daemon} has three clients:
  11020. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  11021. integration tool; their process identifier (PID) is given by the
  11022. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  11023. @command{guix-daemon} sub-process of this particular session.
  11024. The @code{LockHeld} fields show which store items are currently locked
  11025. by this session, which corresponds to store items being built or
  11026. substituted (the @code{LockHeld} field is not displayed when
  11027. @command{guix processes} is not running as root). Last, by looking at
  11028. the @code{ChildPID} and @code{ChildCommand} fields, we understand that
  11029. these three builds are being offloaded (@pxref{Daemon Offload Setup}).
  11030. The output is in Recutils format so we can use the handy @command{recsel}
  11031. command to select sessions of interest (@pxref{Selection Expressions,,,
  11032. recutils, GNU recutils manual}). As an example, the command shows the command
  11033. line and PID of the client that triggered the build of a Perl package:
  11034. @example
  11035. $ sudo guix processes | \
  11036. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  11037. ClientPID: 19419
  11038. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  11039. @end example
  11040. Additional options are listed below.
  11041. @table @code
  11042. @item --format=@var{format}
  11043. @itemx -f @var{format}
  11044. Produce output in the specified @var{format}, one of:
  11045. @table @code
  11046. @item recutils
  11047. The default option. It outputs a set of Session recutils records
  11048. that include each @code{ChildProcess} as a field.
  11049. @item normalized
  11050. Normalize the output records into record sets (@pxref{Record Sets,,,
  11051. recutils, GNU recutils manual}). Normalizing into record sets allows
  11052. joins across record types. The example below lists the PID of each
  11053. @code{ChildProcess} and the associated PID for @code{Session} that
  11054. spawned the @code{ChildProcess} where the @code{Session} was started
  11055. using @command{guix build}.
  11056. @example
  11057. $ guix processes --format=normalized | \
  11058. recsel \
  11059. -j Session \
  11060. -t ChildProcess \
  11061. -p Session.PID,PID \
  11062. -e 'Session.ClientCommand ~ "guix build"'
  11063. PID: 4435
  11064. Session_PID: 4278
  11065. PID: 4554
  11066. Session_PID: 4278
  11067. PID: 4646
  11068. Session_PID: 4278
  11069. @end example
  11070. @end table
  11071. @end table
  11072. @node System Configuration
  11073. @chapter System Configuration
  11074. @cindex system configuration
  11075. Guix System supports a consistent whole-system configuration
  11076. mechanism. By that we mean that all aspects of the global system
  11077. configuration---such as the available system services, timezone and
  11078. locale settings, user accounts---are declared in a single place. Such
  11079. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  11080. One of the advantages of putting all the system configuration under the
  11081. control of Guix is that it supports transactional system upgrades, and
  11082. makes it possible to roll back to a previous system instantiation,
  11083. should something go wrong with the new one (@pxref{Features}). Another
  11084. advantage is that it makes it easy to replicate the exact same configuration
  11085. across different machines, or at different points in time, without
  11086. having to resort to additional administration tools layered on top of
  11087. the own tools of the system.
  11088. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  11089. This section describes this mechanism. First we focus on the system
  11090. administrator's viewpoint---explaining how the system is configured and
  11091. instantiated. Then we show how this mechanism can be extended, for
  11092. instance to support new system services.
  11093. @menu
  11094. * Using the Configuration System:: Customizing your GNU system.
  11095. * operating-system Reference:: Detail of operating-system declarations.
  11096. * File Systems:: Configuring file system mounts.
  11097. * Mapped Devices:: Block device extra processing.
  11098. * User Accounts:: Specifying user accounts.
  11099. * Keyboard Layout:: How the system interprets key strokes.
  11100. * Locales:: Language and cultural convention settings.
  11101. * Services:: Specifying system services.
  11102. * Setuid Programs:: Programs running with root privileges.
  11103. * X.509 Certificates:: Authenticating HTTPS servers.
  11104. * Name Service Switch:: Configuring libc's name service switch.
  11105. * Initial RAM Disk:: Linux-Libre bootstrapping.
  11106. * Bootloader Configuration:: Configuring the boot loader.
  11107. * Invoking guix system:: Instantiating a system configuration.
  11108. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  11109. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  11110. * Defining Services:: Adding new service definitions.
  11111. @end menu
  11112. @node Using the Configuration System
  11113. @section Using the Configuration System
  11114. The operating system is configured by providing an
  11115. @code{operating-system} declaration in a file that can then be passed to
  11116. the @command{guix system} command (@pxref{Invoking guix system}). A
  11117. simple setup, with the default system services, the default Linux-Libre
  11118. kernel, initial RAM disk, and boot loader looks like this:
  11119. @findex operating-system
  11120. @lisp
  11121. @include os-config-bare-bones.texi
  11122. @end lisp
  11123. This example should be self-describing. Some of the fields defined
  11124. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  11125. Others, such as @code{packages} and @code{services}, can be omitted, in
  11126. which case they get a default value.
  11127. Below we discuss the effect of some of the most important fields
  11128. (@pxref{operating-system Reference}, for details about all the available
  11129. fields), and how to @dfn{instantiate} the operating system using
  11130. @command{guix system}.
  11131. @unnumberedsubsec Bootloader
  11132. @cindex legacy boot, on Intel machines
  11133. @cindex BIOS boot, on Intel machines
  11134. @cindex UEFI boot
  11135. @cindex EFI boot
  11136. The @code{bootloader} field describes the method that will be used to boot
  11137. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  11138. mode, as in the example above. However, more recent machines rely instead on
  11139. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  11140. the @code{bootloader} field should contain something along these lines:
  11141. @lisp
  11142. (bootloader-configuration
  11143. (bootloader grub-efi-bootloader)
  11144. (targets '("/boot/efi")))
  11145. @end lisp
  11146. @xref{Bootloader Configuration}, for more information on the available
  11147. configuration options.
  11148. @unnumberedsubsec Globally-Visible Packages
  11149. @vindex %base-packages
  11150. The @code{packages} field lists packages that will be globally visible
  11151. on the system, for all user accounts---i.e., in every user's @env{PATH}
  11152. environment variable---in addition to the per-user profiles
  11153. (@pxref{Invoking guix package}). The @code{%base-packages} variable
  11154. provides all the tools one would expect for basic user and administrator
  11155. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  11156. the @command{mg} lightweight text editor, @command{find}, @command{grep},
  11157. etc. The example above adds GNU@tie{}Screen to those,
  11158. taken from the @code{(gnu packages screen)}
  11159. module (@pxref{Package Modules}). The
  11160. @code{(list package output)} syntax can be used to add a specific output
  11161. of a package:
  11162. @lisp
  11163. (use-modules (gnu packages))
  11164. (use-modules (gnu packages dns))
  11165. (operating-system
  11166. ;; ...
  11167. (packages (cons (list isc-bind "utils")
  11168. %base-packages)))
  11169. @end lisp
  11170. @findex specification->package
  11171. Referring to packages by variable name, like @code{isc-bind} above, has
  11172. the advantage of being unambiguous; it also allows typos and such to be
  11173. diagnosed right away as ``unbound variables''. The downside is that one
  11174. needs to know which module defines which package, and to augment the
  11175. @code{use-package-modules} line accordingly. To avoid that, one can use
  11176. the @code{specification->package} procedure of the @code{(gnu packages)}
  11177. module, which returns the best package for a given name or name and
  11178. version:
  11179. @lisp
  11180. (use-modules (gnu packages))
  11181. (operating-system
  11182. ;; ...
  11183. (packages (append (map specification->package
  11184. '("tcpdump" "htop" "gnupg@@2.0"))
  11185. %base-packages)))
  11186. @end lisp
  11187. @unnumberedsubsec System Services
  11188. @cindex services
  11189. @vindex %base-services
  11190. The @code{services} field lists @dfn{system services} to be made
  11191. available when the system starts (@pxref{Services}).
  11192. The @code{operating-system} declaration above specifies that, in
  11193. addition to the basic services, we want the OpenSSH secure shell
  11194. daemon listening on port 2222 (@pxref{Networking Services,
  11195. @code{openssh-service-type}}). Under the hood,
  11196. @code{openssh-service-type} arranges so that @command{sshd} is started with the
  11197. right command-line options, possibly with supporting configuration files
  11198. generated as needed (@pxref{Defining Services}).
  11199. @cindex customization, of services
  11200. @findex modify-services
  11201. Occasionally, instead of using the base services as is, you will want to
  11202. customize them. To do this, use @code{modify-services} (@pxref{Service
  11203. Reference, @code{modify-services}}) to modify the list.
  11204. @anchor{auto-login to TTY} For example, suppose you want to modify
  11205. @code{guix-daemon} and Mingetty (the console log-in) in the
  11206. @code{%base-services} list (@pxref{Base Services,
  11207. @code{%base-services}}). To do that, you can write the following in
  11208. your operating system declaration:
  11209. @lisp
  11210. (define %my-services
  11211. ;; My very own list of services.
  11212. (modify-services %base-services
  11213. (guix-service-type config =>
  11214. (guix-configuration
  11215. (inherit config)
  11216. ;; Fetch substitutes from example.org.
  11217. (substitute-urls
  11218. (list "https://example.org/guix"
  11219. "https://ci.guix.gnu.org"))))
  11220. (mingetty-service-type config =>
  11221. (mingetty-configuration
  11222. (inherit config)
  11223. ;; Automatially log in as "guest".
  11224. (auto-login "guest")))))
  11225. (operating-system
  11226. ;; @dots{}
  11227. (services %my-services))
  11228. @end lisp
  11229. This changes the configuration---i.e., the service parameters---of the
  11230. @code{guix-service-type} instance, and that of all the
  11231. @code{mingetty-service-type} instances in the @code{%base-services} list
  11232. (@pxref{Auto-Login to a Specific TTY, see the cookbook for how to
  11233. auto-login one user to a specific TTY,, guix-cookbook, GNU Guix Cookbook})).
  11234. Observe how this is accomplished: first, we arrange for the original
  11235. configuration to be bound to the identifier @code{config} in the
  11236. @var{body}, and then we write the @var{body} so that it evaluates to the
  11237. desired configuration. In particular, notice how we use @code{inherit}
  11238. to create a new configuration which has the same values as the old
  11239. configuration, but with a few modifications.
  11240. @cindex encrypted disk
  11241. The configuration for a typical ``desktop'' usage, with an encrypted
  11242. root partition, the X11 display
  11243. server, GNOME and Xfce (users can choose which of these desktop
  11244. environments to use at the log-in screen by pressing @kbd{F1}), network
  11245. management, power management, and more, would look like this:
  11246. @lisp
  11247. @include os-config-desktop.texi
  11248. @end lisp
  11249. A graphical system with a choice of lightweight window managers
  11250. instead of full-blown desktop environments would look like this:
  11251. @lisp
  11252. @include os-config-lightweight-desktop.texi
  11253. @end lisp
  11254. This example refers to the @file{/boot/efi} file system by its UUID,
  11255. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  11256. as returned by the @command{blkid} command.
  11257. @xref{Desktop Services}, for the exact list of services provided by
  11258. @code{%desktop-services}. @xref{X.509 Certificates}, for background
  11259. information about the @code{nss-certs} package that is used here.
  11260. Again, @code{%desktop-services} is just a list of service objects. If
  11261. you want to remove services from there, you can do so using the
  11262. procedures for list filtering (@pxref{SRFI-1 Filtering and
  11263. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  11264. following expression returns a list that contains all the services in
  11265. @code{%desktop-services} minus the Avahi service:
  11266. @lisp
  11267. (remove (lambda (service)
  11268. (eq? (service-kind service) avahi-service-type))
  11269. %desktop-services)
  11270. @end lisp
  11271. Alternatively, the @code{modify-services} macro can be used:
  11272. @lisp
  11273. (modify-services %desktop-services
  11274. (delete avahi-service-type))
  11275. @end lisp
  11276. @unnumberedsubsec Instantiating the System
  11277. Assuming the @code{operating-system} declaration
  11278. is stored in the @file{my-system-config.scm}
  11279. file, the @command{guix system reconfigure my-system-config.scm} command
  11280. instantiates that configuration, and makes it the default GRUB boot
  11281. entry (@pxref{Invoking guix system}).
  11282. The normal way to change the system configuration is by updating this
  11283. file and re-running @command{guix system reconfigure}. One should never
  11284. have to touch files in @file{/etc} or to run commands that modify the
  11285. system state such as @command{useradd} or @command{grub-install}. In
  11286. fact, you must avoid that since that would not only void your warranty
  11287. but also prevent you from rolling back to previous versions of your
  11288. system, should you ever need to.
  11289. @cindex roll-back, of the operating system
  11290. Speaking of roll-back, each time you run @command{guix system
  11291. reconfigure}, a new @dfn{generation} of the system is created---without
  11292. modifying or deleting previous generations. Old system generations get
  11293. an entry in the bootloader boot menu, allowing you to boot them in case
  11294. something went wrong with the latest generation. Reassuring, no? The
  11295. @command{guix system list-generations} command lists the system
  11296. generations available on disk. It is also possible to roll back the
  11297. system via the commands @command{guix system roll-back} and
  11298. @command{guix system switch-generation}.
  11299. Although the @command{guix system reconfigure} command will not modify
  11300. previous generations, you must take care when the current generation is not
  11301. the latest (e.g., after invoking @command{guix system roll-back}), since
  11302. the operation might overwrite a later generation (@pxref{Invoking guix
  11303. system}).
  11304. @unnumberedsubsec The Programming Interface
  11305. At the Scheme level, the bulk of an @code{operating-system} declaration
  11306. is instantiated with the following monadic procedure (@pxref{The Store
  11307. Monad}):
  11308. @deffn {Monadic Procedure} operating-system-derivation os
  11309. Return a derivation that builds @var{os}, an @code{operating-system}
  11310. object (@pxref{Derivations}).
  11311. The output of the derivation is a single directory that refers to all
  11312. the packages, configuration files, and other supporting files needed to
  11313. instantiate @var{os}.
  11314. @end deffn
  11315. This procedure is provided by the @code{(gnu system)} module. Along
  11316. with @code{(gnu services)} (@pxref{Services}), this module contains the
  11317. guts of Guix System. Make sure to visit it!
  11318. @node operating-system Reference
  11319. @section @code{operating-system} Reference
  11320. This section summarizes all the options available in
  11321. @code{operating-system} declarations (@pxref{Using the Configuration
  11322. System}).
  11323. @deftp {Data Type} operating-system
  11324. This is the data type representing an operating system configuration.
  11325. By that, we mean all the global system configuration, not per-user
  11326. configuration (@pxref{Using the Configuration System}).
  11327. @table @asis
  11328. @item @code{kernel} (default: @code{linux-libre})
  11329. The package object of the operating system kernel to
  11330. use@footnote{Currently only the Linux-libre kernel is fully supported.
  11331. Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
  11332. available when building a virtual machine disk image.}.
  11333. @cindex hurd
  11334. @item @code{hurd} (default: @code{#f})
  11335. The package object of the Hurd to be started by the kernel. When this
  11336. field is set, produce a GNU/Hurd operating system. In that case,
  11337. @code{kernel} must also be set to the @code{gnumach} package---the
  11338. microkernel the Hurd runs on.
  11339. @quotation Warning
  11340. This feature is experimental and only supported for disk images.
  11341. @end quotation
  11342. @item @code{kernel-loadable-modules} (default: '())
  11343. A list of objects (usually packages) to collect loadable kernel modules
  11344. from--e.g. @code{(list ddcci-driver-linux)}.
  11345. @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
  11346. List of strings or gexps representing additional arguments to pass on
  11347. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  11348. @item @code{bootloader}
  11349. The system bootloader configuration object. @xref{Bootloader Configuration}.
  11350. @item @code{label}
  11351. This is the label (a string) as it appears in the bootloader's menu entry.
  11352. The default label includes the kernel name and version.
  11353. @item @code{keyboard-layout} (default: @code{#f})
  11354. This field specifies the keyboard layout to use in the console. It can be
  11355. either @code{#f}, in which case the default keyboard layout is used (usually
  11356. US English), or a @code{<keyboard-layout>} record. @xref{Keyboard Layout},
  11357. for more information.
  11358. This keyboard layout is in effect as soon as the kernel has booted. For
  11359. instance, it is the keyboard layout in effect when you type a passphrase if
  11360. your root file system is on a @code{luks-device-mapping} mapped device
  11361. (@pxref{Mapped Devices}).
  11362. @quotation Note
  11363. This does @emph{not} specify the keyboard layout used by the bootloader, nor
  11364. that used by the graphical display server. @xref{Bootloader Configuration},
  11365. for information on how to specify the bootloader's keyboard layout. @xref{X
  11366. Window}, for information on how to specify the keyboard layout used by the X
  11367. Window System.
  11368. @end quotation
  11369. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  11370. @cindex initrd
  11371. @cindex initial RAM disk
  11372. The list of Linux kernel modules that need to be available in the
  11373. initial RAM disk. @xref{Initial RAM Disk}.
  11374. @item @code{initrd} (default: @code{base-initrd})
  11375. A procedure that returns an initial RAM disk for the Linux
  11376. kernel. This field is provided to support low-level customization and
  11377. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  11378. @item @code{firmware} (default: @code{%base-firmware})
  11379. @cindex firmware
  11380. List of firmware packages loadable by the operating system kernel.
  11381. The default includes firmware needed for Atheros- and Broadcom-based
  11382. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  11383. respectively). @xref{Hardware Considerations}, for more info on
  11384. supported hardware.
  11385. @item @code{host-name}
  11386. The host name.
  11387. @item @code{hosts-file}
  11388. @cindex hosts file
  11389. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  11390. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  11391. Reference Manual}). The default is a file with entries for
  11392. @code{localhost} and @var{host-name}.
  11393. @item @code{mapped-devices} (default: @code{'()})
  11394. A list of mapped devices. @xref{Mapped Devices}.
  11395. @item @code{file-systems}
  11396. A list of file systems. @xref{File Systems}.
  11397. @cindex swap devices
  11398. @cindex swap space
  11399. @item @code{swap-devices} (default: @code{'()})
  11400. A list of UUIDs, file system labels, or strings identifying devices or
  11401. files to be used for ``swap
  11402. space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
  11403. Manual}). Here are some examples:
  11404. @table @code
  11405. @item (list (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))
  11406. Use the swap partition with the given UUID@. You can learn the UUID of a
  11407. Linux swap partition by running @command{swaplabel @var{device}}, where
  11408. @var{device} is the @file{/dev} file name of that partition.
  11409. @item (list (file-system-label "swap"))
  11410. Use the partition with label @code{swap}. Again, the
  11411. @command{swaplabel} command allows you to view and change the label of a
  11412. Linux swap partition.
  11413. @item (list "/swapfile")
  11414. Use the file @file{/swapfile} as swap space.
  11415. @item (list "/dev/sda3" "/dev/sdb2")
  11416. Use the @file{/dev/sda3} and @file{/dev/sdb2} partitions as swap space.
  11417. We recommend referring to swap devices by UUIDs or labels as shown above
  11418. instead.
  11419. @end table
  11420. It is possible to specify a swap file in a file system on a mapped
  11421. device (under @file{/dev/mapper}), provided that the necessary device
  11422. mapping and file system are also specified. @xref{Mapped Devices} and
  11423. @ref{File Systems}.
  11424. @item @code{users} (default: @code{%base-user-accounts})
  11425. @itemx @code{groups} (default: @code{%base-groups})
  11426. List of user accounts and groups. @xref{User Accounts}.
  11427. If the @code{users} list lacks a user account with UID@tie{}0, a
  11428. ``root'' account with UID@tie{}0 is automatically added.
  11429. @item @code{skeletons} (default: @code{(default-skeletons)})
  11430. A list of target file name/file-like object tuples (@pxref{G-Expressions,
  11431. file-like objects}). These are the skeleton files that will be added to
  11432. the home directory of newly-created user accounts.
  11433. For instance, a valid value may look like this:
  11434. @lisp
  11435. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  11436. (".guile" ,(plain-file "guile"
  11437. "(use-modules (ice-9 readline))
  11438. (activate-readline)")))
  11439. @end lisp
  11440. @item @code{issue} (default: @code{%default-issue})
  11441. A string denoting the contents of the @file{/etc/issue} file, which is
  11442. displayed when users log in on a text console.
  11443. @item @code{packages} (default: @code{%base-packages})
  11444. A list of packages to be installed in the global profile, which is accessible
  11445. at @file{/run/current-system/profile}. Each element is either a package
  11446. variable or a package/output tuple. Here's a simple example of both:
  11447. @lisp
  11448. (cons* git ; the default "out" output
  11449. (list git "send-email") ; another output of git
  11450. %base-packages) ; the default set
  11451. @end lisp
  11452. The default set includes core utilities and it is good practice to
  11453. install non-core utilities in user profiles (@pxref{Invoking guix
  11454. package}).
  11455. @item @code{timezone}
  11456. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  11457. You can run the @command{tzselect} command to find out which timezone
  11458. string corresponds to your region. Choosing an invalid timezone name
  11459. causes @command{guix system} to fail.
  11460. @item @code{locale} (default: @code{"en_US.utf8"})
  11461. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  11462. Library Reference Manual}). @xref{Locales}, for more information.
  11463. @item @code{locale-definitions} (default: @code{%default-locale-definitions})
  11464. The list of locale definitions to be compiled and that may be used at
  11465. run time. @xref{Locales}.
  11466. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  11467. The list of GNU@tie{}libc packages whose locale data and tools are used
  11468. to build the locale definitions. @xref{Locales}, for compatibility
  11469. considerations that justify this option.
  11470. @item @code{name-service-switch} (default: @code{%default-nss})
  11471. Configuration of the libc name service switch (NSS)---a
  11472. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  11473. details.
  11474. @item @code{services} (default: @code{%base-services})
  11475. A list of service objects denoting system services. @xref{Services}.
  11476. @cindex essential services
  11477. @item @code{essential-services} (default: ...)
  11478. The list of ``essential services''---i.e., things like instances of
  11479. @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
  11480. Reference}), which are derived from the operating system definition itself.
  11481. As a user you should @emph{never} need to touch this field.
  11482. @item @code{pam-services} (default: @code{(base-pam-services)})
  11483. @cindex PAM
  11484. @cindex pluggable authentication modules
  11485. Linux @dfn{pluggable authentication module} (PAM) services.
  11486. @c FIXME: Add xref to PAM services section.
  11487. @item @code{setuid-programs} (default: @code{%setuid-programs})
  11488. List of @code{<setuid-program>}. @xref{Setuid Programs}, for more
  11489. information.
  11490. @item @code{sudoers-file} (default: @code{%sudoers-specification})
  11491. @cindex sudoers file
  11492. The contents of the @file{/etc/sudoers} file as a file-like object
  11493. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  11494. This file specifies which users can use the @command{sudo} command, what
  11495. they are allowed to do, and what privileges they may gain. The default
  11496. is that only @code{root} and members of the @code{wheel} group may use
  11497. @code{sudo}.
  11498. @end table
  11499. @deffn {Scheme Syntax} this-operating-system
  11500. When used in the @emph{lexical scope} of an operating system field definition,
  11501. this identifier resolves to the operating system being defined.
  11502. The example below shows how to refer to the operating system being defined in
  11503. the definition of the @code{label} field:
  11504. @lisp
  11505. (use-modules (gnu) (guix))
  11506. (operating-system
  11507. ;; ...
  11508. (label (package-full-name
  11509. (operating-system-kernel this-operating-system))))
  11510. @end lisp
  11511. It is an error to refer to @code{this-operating-system} outside an operating
  11512. system definition.
  11513. @end deffn
  11514. @end deftp
  11515. @node File Systems
  11516. @section File Systems
  11517. The list of file systems to be mounted is specified in the
  11518. @code{file-systems} field of the operating system declaration
  11519. (@pxref{Using the Configuration System}). Each file system is declared
  11520. using the @code{file-system} form, like this:
  11521. @lisp
  11522. (file-system
  11523. (mount-point "/home")
  11524. (device "/dev/sda3")
  11525. (type "ext4"))
  11526. @end lisp
  11527. As usual, some of the fields are mandatory---those shown in the example
  11528. above---while others can be omitted. These are described below.
  11529. @deftp {Data Type} file-system
  11530. Objects of this type represent file systems to be mounted. They
  11531. contain the following members:
  11532. @table @asis
  11533. @item @code{type}
  11534. This is a string specifying the type of the file system---e.g.,
  11535. @code{"ext4"}.
  11536. @item @code{mount-point}
  11537. This designates the place where the file system is to be mounted.
  11538. @item @code{device}
  11539. This names the ``source'' of the file system. It can be one of three
  11540. things: a file system label, a file system UUID, or the name of a
  11541. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  11542. systems without having to hard-code their actual device
  11543. name@footnote{Note that, while it is tempting to use
  11544. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  11545. result, this is not recommended: These special device nodes are created
  11546. by the udev daemon and may be unavailable at the time the device is
  11547. mounted.}.
  11548. @findex file-system-label
  11549. File system labels are created using the @code{file-system-label}
  11550. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  11551. plain strings. Here's an example of a file system referred to by its
  11552. label, as shown by the @command{e2label} command:
  11553. @lisp
  11554. (file-system
  11555. (mount-point "/home")
  11556. (type "ext4")
  11557. (device (file-system-label "my-home")))
  11558. @end lisp
  11559. @findex uuid
  11560. UUIDs are converted from their string representation (as shown by the
  11561. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  11562. @code{uuid} form expects 16-byte UUIDs as defined in
  11563. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  11564. form of UUID used by the ext2 family of file systems and others, but it
  11565. is different from ``UUIDs'' found in FAT file systems, for instance.},
  11566. like this:
  11567. @lisp
  11568. (file-system
  11569. (mount-point "/home")
  11570. (type "ext4")
  11571. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  11572. @end lisp
  11573. When the source of a file system is a mapped device (@pxref{Mapped
  11574. Devices}), its @code{device} field @emph{must} refer to the mapped
  11575. device name---e.g., @file{"/dev/mapper/root-partition"}.
  11576. This is required so that
  11577. the system knows that mounting the file system depends on having the
  11578. corresponding device mapping established.
  11579. @item @code{flags} (default: @code{'()})
  11580. This is a list of symbols denoting mount flags. Recognized flags
  11581. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  11582. access to special files), @code{no-suid} (ignore setuid and setgid
  11583. bits), @code{no-atime} (do not update file access times),
  11584. @code{strict-atime} (update file access time), @code{lazy-time} (only
  11585. update time on the in-memory version of the file inode), and
  11586. @code{no-exec} (disallow program execution).
  11587. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
  11588. Manual}, for more information on these flags.
  11589. @item @code{options} (default: @code{#f})
  11590. This is either @code{#f}, or a string denoting mount options passed to
  11591. the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
  11592. Library Reference Manual}, for details and run @command{man 8 mount} for
  11593. options for various file systems. Note that the
  11594. @code{file-system-options->alist} and @code{alist->file-system-options}
  11595. procedures from @code{(gnu system file-systems)} can be used to convert
  11596. file system options given as an association list to the string
  11597. representation, and vice-versa.
  11598. @item @code{mount?} (default: @code{#t})
  11599. This value indicates whether to automatically mount the file system when
  11600. the system is brought up. When set to @code{#f}, the file system gets
  11601. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  11602. is not automatically mounted.
  11603. @item @code{needed-for-boot?} (default: @code{#f})
  11604. This Boolean value indicates whether the file system is needed when
  11605. booting. If that is true, then the file system is mounted when the
  11606. initial RAM disk (initrd) is loaded. This is always the case, for
  11607. instance, for the root file system.
  11608. @item @code{check?} (default: @code{#t})
  11609. This Boolean indicates whether the file system needs to be checked for
  11610. errors before being mounted.
  11611. @item @code{create-mount-point?} (default: @code{#f})
  11612. When true, the mount point is created if it does not exist yet.
  11613. @item @code{mount-may-fail?} (default: @code{#f})
  11614. When true, this indicates that mounting this file system can fail but
  11615. that should not be considered an error. This is useful in unusual
  11616. cases; an example of this is @code{efivarfs}, a file system that can
  11617. only be mounted on EFI/UEFI systems.
  11618. @item @code{dependencies} (default: @code{'()})
  11619. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  11620. representing file systems that must be mounted or mapped devices that
  11621. must be opened before (and unmounted or closed after) this one.
  11622. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  11623. a dependency of @file{/sys/fs/cgroup/cpu} and
  11624. @file{/sys/fs/cgroup/memory}.
  11625. Another example is a file system that depends on a mapped device, for
  11626. example for an encrypted partition (@pxref{Mapped Devices}).
  11627. @end table
  11628. @end deftp
  11629. @deffn {Scheme Procedure} file-system-label @var{str}
  11630. This procedure returns an opaque file system label from @var{str}, a
  11631. string:
  11632. @lisp
  11633. (file-system-label "home")
  11634. @result{} #<file-system-label "home">
  11635. @end lisp
  11636. File system labels are used to refer to file systems by label rather
  11637. than by device name. See above for examples.
  11638. @end deffn
  11639. The @code{(gnu system file-systems)} exports the following useful
  11640. variables.
  11641. @defvr {Scheme Variable} %base-file-systems
  11642. These are essential file systems that are required on normal systems,
  11643. such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
  11644. below). Operating system declarations should always contain at least
  11645. these.
  11646. @end defvr
  11647. @defvr {Scheme Variable} %pseudo-terminal-file-system
  11648. This is the file system to be mounted as @file{/dev/pts}. It supports
  11649. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  11650. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  11651. Manual}). Pseudo-terminals are used by terminal emulators such as
  11652. @command{xterm}.
  11653. @end defvr
  11654. @defvr {Scheme Variable} %shared-memory-file-system
  11655. This file system is mounted as @file{/dev/shm} and is used to support
  11656. memory sharing across processes (@pxref{Memory-mapped I/O,
  11657. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  11658. @end defvr
  11659. @defvr {Scheme Variable} %immutable-store
  11660. This file system performs a read-only ``bind mount'' of
  11661. @file{/gnu/store}, making it read-only for all the users including
  11662. @code{root}. This prevents against accidental modification by software
  11663. running as @code{root} or by system administrators.
  11664. The daemon itself is still able to write to the store: it remounts it
  11665. read-write in its own ``name space.''
  11666. @end defvr
  11667. @defvr {Scheme Variable} %binary-format-file-system
  11668. The @code{binfmt_misc} file system, which allows handling of arbitrary
  11669. executable file types to be delegated to user space. This requires the
  11670. @code{binfmt.ko} kernel module to be loaded.
  11671. @end defvr
  11672. @defvr {Scheme Variable} %fuse-control-file-system
  11673. The @code{fusectl} file system, which allows unprivileged users to mount
  11674. and unmount user-space FUSE file systems. This requires the
  11675. @code{fuse.ko} kernel module to be loaded.
  11676. @end defvr
  11677. The @code{(gnu system uuid)} module provides tools to deal with file
  11678. system ``unique identifiers'' (UUIDs).
  11679. @deffn {Scheme Procedure} uuid @var{str} [@var{type}]
  11680. Return an opaque UUID (unique identifier) object of the given @var{type}
  11681. (a symbol) by parsing @var{str} (a string):
  11682. @lisp
  11683. (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
  11684. @result{} #<<uuid> type: dce bv: @dots{}>
  11685. (uuid "1234-ABCD" 'fat)
  11686. @result{} #<<uuid> type: fat bv: @dots{}>
  11687. @end lisp
  11688. @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
  11689. @code{ntfs}, or one of the commonly found synonyms for these.
  11690. UUIDs are another way to unambiguously refer to file systems in
  11691. operating system configuration. See the examples above.
  11692. @end deffn
  11693. @node Btrfs file system
  11694. @subsection Btrfs file system
  11695. The Btrfs has special features, such as subvolumes, that merit being
  11696. explained in more details. The following section attempts to cover
  11697. basic as well as complex uses of a Btrfs file system with the Guix
  11698. System.
  11699. In its simplest usage, a Btrfs file system can be described, for
  11700. example, by:
  11701. @lisp
  11702. (file-system
  11703. (mount-point "/home")
  11704. (type "btrfs")
  11705. (device (file-system-label "my-home")))
  11706. @end lisp
  11707. The example below is more complex, as it makes use of a Btrfs
  11708. subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
  11709. @code{my-btrfs-pool}, and is located on an encrypted device (hence the
  11710. dependency on @code{mapped-devices}):
  11711. @lisp
  11712. (file-system
  11713. (device (file-system-label "my-btrfs-pool"))
  11714. (mount-point "/")
  11715. (type "btrfs")
  11716. (options "subvol=rootfs")
  11717. (dependencies mapped-devices))
  11718. @end lisp
  11719. Some bootloaders, for example GRUB, only mount a Btrfs partition at its
  11720. top level during the early boot, and rely on their configuration to
  11721. refer to the correct subvolume path within that top level. The
  11722. bootloaders operating in this way typically produce their configuration
  11723. on a running system where the Btrfs partitions are already mounted and
  11724. where the subvolume information is readily available. As an example,
  11725. @command{grub-mkconfig}, the configuration generator command shipped
  11726. with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
  11727. path of a subvolume.
  11728. The Guix System produces a bootloader configuration using the operating
  11729. system configuration as its sole input; it is therefore necessary to
  11730. extract the subvolume name on which @file{/gnu/store} lives (if any)
  11731. from that operating system configuration. To better illustrate,
  11732. consider a subvolume named 'rootfs' which contains the root file system
  11733. data. In such situation, the GRUB bootloader would only see the top
  11734. level of the root Btrfs partition, e.g.:
  11735. @example
  11736. / (top level)
  11737. ├── rootfs (subvolume directory)
  11738. ├── gnu (normal directory)
  11739. ├── store (normal directory)
  11740. [...]
  11741. @end example
  11742. Thus, the subvolume name must be prepended to the @file{/gnu/store} path
  11743. of the kernel, initrd binaries and any other files referred to in the
  11744. GRUB configuration that must be found during the early boot.
  11745. The next example shows a nested hierarchy of subvolumes and
  11746. directories:
  11747. @example
  11748. / (top level)
  11749. ├── rootfs (subvolume)
  11750. ├── gnu (normal directory)
  11751. ├── store (subvolume)
  11752. [...]
  11753. @end example
  11754. This scenario would work without mounting the 'store' subvolume.
  11755. Mounting 'rootfs' is sufficient, since the subvolume name matches its
  11756. intended mount point in the file system hierarchy. Alternatively, the
  11757. 'store' subvolume could be referred to by setting the @code{subvol}
  11758. option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
  11759. Finally, a more contrived example of nested subvolumes:
  11760. @example
  11761. / (top level)
  11762. ├── root-snapshots (subvolume)
  11763. ├── root-current (subvolume)
  11764. ├── guix-store (subvolume)
  11765. [...]
  11766. @end example
  11767. Here, the 'guix-store' subvolume doesn't match its intended mount point,
  11768. so it is necessary to mount it. The subvolume must be fully specified,
  11769. by passing its file name to the @code{subvol} option. To illustrate,
  11770. the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
  11771. a file system declaration such as:
  11772. @lisp
  11773. (file-system
  11774. (device (file-system-label "btrfs-pool-1"))
  11775. (mount-point "/gnu/store")
  11776. (type "btrfs")
  11777. (options "subvol=root-snapshots/root-current/guix-store,\
  11778. compress-force=zstd,space_cache=v2"))
  11779. @end lisp
  11780. @node Mapped Devices
  11781. @section Mapped Devices
  11782. @cindex device mapping
  11783. @cindex mapped devices
  11784. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  11785. such as a hard disk partition, can be @dfn{mapped} into another device,
  11786. usually in @code{/dev/mapper/},
  11787. with additional processing over the data that flows through
  11788. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  11789. concept of a ``mapped device'' and that of a file system: both boil down
  11790. to @emph{translating} input/output operations made on a file to
  11791. operations on its backing store. Thus, the Hurd implements mapped
  11792. devices, like file systems, using the generic @dfn{translator} mechanism
  11793. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  11794. typical example is encryption device mapping: all writes to the mapped
  11795. device are encrypted, and all reads are deciphered, transparently.
  11796. Guix extends this notion by considering any device or set of devices that
  11797. are @dfn{transformed} in some way to create a new device; for instance,
  11798. RAID devices are obtained by @dfn{assembling} several other devices, such
  11799. as hard disks or partitions, into a new one that behaves as one partition.
  11800. Mapped devices are declared using the @code{mapped-device} form,
  11801. defined as follows; for examples, see below.
  11802. @deftp {Data Type} mapped-device
  11803. Objects of this type represent device mappings that will be made when
  11804. the system boots up.
  11805. @table @code
  11806. @item source
  11807. This is either a string specifying the name of the block device to be mapped,
  11808. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  11809. need to be assembled for creating a new one. In case of LVM this is a
  11810. string specifying name of the volume group to be mapped.
  11811. @item target
  11812. This string specifies the name of the resulting mapped device. For
  11813. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  11814. specifying @code{"my-partition"} leads to the creation of
  11815. the @code{"/dev/mapper/my-partition"} device.
  11816. For RAID devices of type @code{raid-device-mapping}, the full device name
  11817. such as @code{"/dev/md0"} needs to be given.
  11818. LVM logical volumes of type @code{lvm-device-mapping} need to
  11819. be specified as @code{"VGNAME-LVNAME"}.
  11820. @item targets
  11821. This list of strings specifies names of the resulting mapped devices in case
  11822. there are several. The format is identical to @var{target}.
  11823. @item type
  11824. This must be a @code{mapped-device-kind} object, which specifies how
  11825. @var{source} is mapped to @var{target}.
  11826. @end table
  11827. @end deftp
  11828. @defvr {Scheme Variable} luks-device-mapping
  11829. This defines LUKS block device encryption using the @command{cryptsetup}
  11830. command from the package with the same name. It relies on the
  11831. @code{dm-crypt} Linux kernel module.
  11832. @end defvr
  11833. @defvr {Scheme Variable} raid-device-mapping
  11834. This defines a RAID device, which is assembled using the @code{mdadm}
  11835. command from the package with the same name. It requires a Linux kernel
  11836. module for the appropriate RAID level to be loaded, such as @code{raid456}
  11837. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  11838. @end defvr
  11839. @cindex LVM, logical volume manager
  11840. @defvr {Scheme Variable} lvm-device-mapping
  11841. This defines one or more logical volumes for the Linux
  11842. @uref{https://www.sourceware.org/lvm2/, Logical Volume Manager (LVM)}.
  11843. The volume group is activated by the @command{vgchange} command from the
  11844. @code{lvm2} package.
  11845. @end defvr
  11846. @cindex disk encryption
  11847. @cindex LUKS
  11848. The following example specifies a mapping from @file{/dev/sda3} to
  11849. @file{/dev/mapper/home} using LUKS---the
  11850. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  11851. standard mechanism for disk encryption.
  11852. The @file{/dev/mapper/home}
  11853. device can then be used as the @code{device} of a @code{file-system}
  11854. declaration (@pxref{File Systems}).
  11855. @lisp
  11856. (mapped-device
  11857. (source "/dev/sda3")
  11858. (target "home")
  11859. (type luks-device-mapping))
  11860. @end lisp
  11861. Alternatively, to become independent of device numbering, one may obtain
  11862. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  11863. command like:
  11864. @example
  11865. cryptsetup luksUUID /dev/sda3
  11866. @end example
  11867. and use it as follows:
  11868. @lisp
  11869. (mapped-device
  11870. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  11871. (target "home")
  11872. (type luks-device-mapping))
  11873. @end lisp
  11874. @cindex swap encryption
  11875. It is also desirable to encrypt swap space, since swap space may contain
  11876. sensitive data. One way to accomplish that is to use a swap file in a
  11877. file system on a device mapped via LUKS encryption. In this way, the
  11878. swap file is encrypted because the entire device is encrypted.
  11879. @xref{Preparing for Installation,,Disk Partitioning}, for an example.
  11880. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  11881. may be declared as follows:
  11882. @lisp
  11883. (mapped-device
  11884. (source (list "/dev/sda1" "/dev/sdb1"))
  11885. (target "/dev/md0")
  11886. (type raid-device-mapping))
  11887. @end lisp
  11888. The @file{/dev/md0} device can then be used as the @code{device} of a
  11889. @code{file-system} declaration (@pxref{File Systems}).
  11890. Note that the RAID level need not be given; it is chosen during the
  11891. initial creation and formatting of the RAID device and is determined
  11892. automatically later.
  11893. LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
  11894. be declared as follows:
  11895. @lisp
  11896. (mapped-device
  11897. (source "vg0")
  11898. (targets (list "vg0-alpha" "vg0-beta"))
  11899. (type lvm-device-mapping))
  11900. @end lisp
  11901. Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
  11902. then be used as the @code{device} of a @code{file-system} declaration
  11903. (@pxref{File Systems}).
  11904. @node User Accounts
  11905. @section User Accounts
  11906. @cindex users
  11907. @cindex accounts
  11908. @cindex user accounts
  11909. User accounts and groups are entirely managed through the
  11910. @code{operating-system} declaration. They are specified with the
  11911. @code{user-account} and @code{user-group} forms:
  11912. @lisp
  11913. (user-account
  11914. (name "alice")
  11915. (group "users")
  11916. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  11917. "audio" ;sound card
  11918. "video" ;video devices such as webcams
  11919. "cdrom")) ;the good ol' CD-ROM
  11920. (comment "Bob's sister"))
  11921. @end lisp
  11922. Here's a user account that uses a different shell and a custom home
  11923. directory (the default would be @file{"/home/bob"}):
  11924. @lisp
  11925. (user-account
  11926. (name "bob")
  11927. (group "users")
  11928. (comment "Alice's bro")
  11929. (shell (file-append zsh "/bin/zsh"))
  11930. (home-directory "/home/robert"))
  11931. @end lisp
  11932. When booting or upon completion of @command{guix system reconfigure},
  11933. the system ensures that only the user accounts and groups specified in
  11934. the @code{operating-system} declaration exist, and with the specified
  11935. properties. Thus, account or group creations or modifications made by
  11936. directly invoking commands such as @command{useradd} are lost upon
  11937. reconfiguration or reboot. This ensures that the system remains exactly
  11938. as declared.
  11939. @deftp {Data Type} user-account
  11940. Objects of this type represent user accounts. The following members may
  11941. be specified:
  11942. @table @asis
  11943. @item @code{name}
  11944. The name of the user account.
  11945. @item @code{group}
  11946. @cindex groups
  11947. This is the name (a string) or identifier (a number) of the user group
  11948. this account belongs to.
  11949. @item @code{supplementary-groups} (default: @code{'()})
  11950. Optionally, this can be defined as a list of group names that this
  11951. account belongs to.
  11952. @item @code{uid} (default: @code{#f})
  11953. This is the user ID for this account (a number), or @code{#f}. In the
  11954. latter case, a number is automatically chosen by the system when the
  11955. account is created.
  11956. @item @code{comment} (default: @code{""})
  11957. A comment about the account, such as the account owner's full name.
  11958. @item @code{home-directory}
  11959. This is the name of the home directory for the account.
  11960. @item @code{create-home-directory?} (default: @code{#t})
  11961. Indicates whether the home directory of this account should be created
  11962. if it does not exist yet.
  11963. @item @code{shell} (default: Bash)
  11964. This is a G-expression denoting the file name of a program to be used as
  11965. the shell (@pxref{G-Expressions}). For example, you would refer to the
  11966. Bash executable like this:
  11967. @lisp
  11968. (file-append bash "/bin/bash")
  11969. @end lisp
  11970. @noindent
  11971. ... and to the Zsh executable like that:
  11972. @lisp
  11973. (file-append zsh "/bin/zsh")
  11974. @end lisp
  11975. @item @code{system?} (default: @code{#f})
  11976. This Boolean value indicates whether the account is a ``system''
  11977. account. System accounts are sometimes treated specially; for instance,
  11978. graphical login managers do not list them.
  11979. @anchor{user-account-password}
  11980. @cindex password, for user accounts
  11981. @item @code{password} (default: @code{#f})
  11982. You would normally leave this field to @code{#f}, initialize user
  11983. passwords as @code{root} with the @command{passwd} command, and then let
  11984. users change it with @command{passwd}. Passwords set with
  11985. @command{passwd} are of course preserved across reboot and
  11986. reconfiguration.
  11987. If you @emph{do} want to set an initial password for an account, then
  11988. this field must contain the encrypted password, as a string. You can use the
  11989. @code{crypt} procedure for this purpose:
  11990. @lisp
  11991. (user-account
  11992. (name "charlie")
  11993. (group "users")
  11994. ;; Specify a SHA-512-hashed initial password.
  11995. (password (crypt "InitialPassword!" "$6$abc")))
  11996. @end lisp
  11997. @quotation Note
  11998. The hash of this initial password will be available in a file in
  11999. @file{/gnu/store}, readable by all the users, so this method must be used with
  12000. care.
  12001. @end quotation
  12002. @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
  12003. more information on password encryption, and @ref{Encryption,,, guile, GNU
  12004. Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
  12005. @end table
  12006. @end deftp
  12007. @cindex groups
  12008. User group declarations are even simpler:
  12009. @lisp
  12010. (user-group (name "students"))
  12011. @end lisp
  12012. @deftp {Data Type} user-group
  12013. This type is for, well, user groups. There are just a few fields:
  12014. @table @asis
  12015. @item @code{name}
  12016. The name of the group.
  12017. @item @code{id} (default: @code{#f})
  12018. The group identifier (a number). If @code{#f}, a new number is
  12019. automatically allocated when the group is created.
  12020. @item @code{system?} (default: @code{#f})
  12021. This Boolean value indicates whether the group is a ``system'' group.
  12022. System groups have low numerical IDs.
  12023. @item @code{password} (default: @code{#f})
  12024. What, user groups can have a password? Well, apparently yes. Unless
  12025. @code{#f}, this field specifies the password of the group.
  12026. @end table
  12027. @end deftp
  12028. For convenience, a variable lists all the basic user groups one may
  12029. expect:
  12030. @defvr {Scheme Variable} %base-groups
  12031. This is the list of basic user groups that users and/or packages expect
  12032. to be present on the system. This includes groups such as ``root'',
  12033. ``wheel'', and ``users'', as well as groups used to control access to
  12034. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  12035. @end defvr
  12036. @defvr {Scheme Variable} %base-user-accounts
  12037. This is the list of basic system accounts that programs may expect to
  12038. find on a GNU/Linux system, such as the ``nobody'' account.
  12039. Note that the ``root'' account is not included here. It is a
  12040. special-case and is automatically added whether or not it is specified.
  12041. @end defvr
  12042. @node Keyboard Layout
  12043. @section Keyboard Layout
  12044. @cindex keyboard layout
  12045. @cindex keymap
  12046. To specify what each key of your keyboard does, you need to tell the operating
  12047. system what @dfn{keyboard layout} you want to use. The default, when nothing
  12048. is specified, is the US English QWERTY layout for 105-key PC keyboards.
  12049. However, German speakers will usually prefer the German QWERTZ layout, French
  12050. speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
  12051. or bépo, and they might even want to further customize the effect of some of
  12052. the keys. This section explains how to get that done.
  12053. @cindex keyboard layout, definition
  12054. There are three components that will want to know about your keyboard layout:
  12055. @itemize
  12056. @item
  12057. The @emph{bootloader} may want to know what keyboard layout you want to use
  12058. (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
  12059. you want, for instance, to make sure that you can type the passphrase of your
  12060. encrypted root partition using the right layout.
  12061. @item
  12062. The @emph{operating system kernel}, Linux, will need that so that the console
  12063. is properly configured (@pxref{operating-system Reference,
  12064. @code{keyboard-layout}}).
  12065. @item
  12066. The @emph{graphical display server}, usually Xorg, also has its own idea of
  12067. the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
  12068. @end itemize
  12069. Guix allows you to configure all three separately but, fortunately, it allows
  12070. you to share the same keyboard layout for all three components.
  12071. @cindex XKB, keyboard layouts
  12072. Keyboard layouts are represented by records created by the
  12073. @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
  12074. the X Keyboard extension (XKB), each layout has four attributes: a name (often
  12075. a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
  12076. optional variant name, an optional keyboard model name, and a possibly empty
  12077. list of additional options. In most cases the layout name is all you care
  12078. about.
  12079. @deffn {Scheme Procedure} keyboard-layout @var{name} [@var{variant}] @
  12080. [#:model] [#:options '()]
  12081. Return a new keyboard layout with the given @var{name} and @var{variant}.
  12082. @var{name} must be a string such as @code{"fr"}; @var{variant} must be a
  12083. string such as @code{"bepo"} or @code{"nodeadkeys"}. See the
  12084. @code{xkeyboard-config} package for valid options.
  12085. @end deffn
  12086. Here are a few examples:
  12087. @lisp
  12088. ;; The German QWERTZ layout. Here we assume a standard
  12089. ;; "pc105" keyboard model.
  12090. (keyboard-layout "de")
  12091. ;; The bépo variant of the French layout.
  12092. (keyboard-layout "fr" "bepo")
  12093. ;; The Catalan layout.
  12094. (keyboard-layout "es" "cat")
  12095. ;; Arabic layout with "Alt-Shift" to switch to US layout.
  12096. (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
  12097. ;; The Latin American Spanish layout. In addition, the
  12098. ;; "Caps Lock" key is used as an additional "Ctrl" key,
  12099. ;; and the "Menu" key is used as a "Compose" key to enter
  12100. ;; accented letters.
  12101. (keyboard-layout "latam"
  12102. #:options '("ctrl:nocaps" "compose:menu"))
  12103. ;; The Russian layout for a ThinkPad keyboard.
  12104. (keyboard-layout "ru" #:model "thinkpad")
  12105. ;; The "US international" layout, which is the US layout plus
  12106. ;; dead keys to enter accented characters. This is for an
  12107. ;; Apple MacBook keyboard.
  12108. (keyboard-layout "us" "intl" #:model "macbook78")
  12109. @end lisp
  12110. See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
  12111. for a complete list of supported layouts, variants, and models.
  12112. @cindex keyboard layout, configuration
  12113. Let's say you want your system to use the Turkish keyboard layout throughout
  12114. your system---bootloader, console, and Xorg. Here's what your system
  12115. configuration would look like:
  12116. @findex set-xorg-configuration
  12117. @lisp
  12118. ;; Using the Turkish layout for the bootloader, the console,
  12119. ;; and for Xorg.
  12120. (operating-system
  12121. ;; ...
  12122. (keyboard-layout (keyboard-layout "tr")) ;for the console
  12123. (bootloader (bootloader-configuration
  12124. (bootloader grub-efi-bootloader)
  12125. (targets '("/boot/efi"))
  12126. (keyboard-layout keyboard-layout))) ;for GRUB
  12127. (services (cons (set-xorg-configuration
  12128. (xorg-configuration ;for Xorg
  12129. (keyboard-layout keyboard-layout)))
  12130. %desktop-services)))
  12131. @end lisp
  12132. In the example above, for GRUB and for Xorg, we just refer to the
  12133. @code{keyboard-layout} field defined above, but we could just as well refer to
  12134. a different layout. The @code{set-xorg-configuration} procedure communicates
  12135. the desired Xorg configuration to the graphical log-in manager, by default
  12136. GDM.
  12137. We've discussed how to specify the @emph{default} keyboard layout of your
  12138. system when it starts, but you can also adjust it at run time:
  12139. @itemize
  12140. @item
  12141. If you're using GNOME, its settings panel has a ``Region & Language'' entry
  12142. where you can select one or more keyboard layouts.
  12143. @item
  12144. Under Xorg, the @command{setxkbmap} command (from the same-named package)
  12145. allows you to change the current layout. For example, this is how you would
  12146. change the layout to US Dvorak:
  12147. @example
  12148. setxkbmap us dvorak
  12149. @end example
  12150. @item
  12151. The @code{loadkeys} command changes the keyboard layout in effect in the Linux
  12152. console. However, note that @code{loadkeys} does @emph{not} use the XKB
  12153. keyboard layout categorization described above. The command below loads the
  12154. French bépo layout:
  12155. @example
  12156. loadkeys fr-bepo
  12157. @end example
  12158. @end itemize
  12159. @node Locales
  12160. @section Locales
  12161. @cindex locale
  12162. A @dfn{locale} defines cultural conventions for a particular language
  12163. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  12164. Reference Manual}). Each locale has a name that typically has the form
  12165. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  12166. @code{fr_LU.utf8} designates the locale for the French language, with
  12167. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  12168. @cindex locale definition
  12169. Usually, you will want to specify the default locale for the machine
  12170. using the @code{locale} field of the @code{operating-system} declaration
  12171. (@pxref{operating-system Reference, @code{locale}}).
  12172. The selected locale is automatically added to the @dfn{locale
  12173. definitions} known to the system if needed, with its codeset inferred
  12174. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  12175. @code{UTF-8} codeset. Additional locale definitions can be specified in
  12176. the @code{locale-definitions} slot of @code{operating-system}---this is
  12177. useful, for instance, if the codeset could not be inferred from the
  12178. locale name. The default set of locale definitions includes some widely
  12179. used locales, but not all the available locales, in order to save space.
  12180. For instance, to add the North Frisian locale for Germany, the value of
  12181. that field may be:
  12182. @lisp
  12183. (cons (locale-definition
  12184. (name "fy_DE.utf8") (source "fy_DE"))
  12185. %default-locale-definitions)
  12186. @end lisp
  12187. Likewise, to save space, one might want @code{locale-definitions} to
  12188. list only the locales that are actually used, as in:
  12189. @lisp
  12190. (list (locale-definition
  12191. (name "ja_JP.eucjp") (source "ja_JP")
  12192. (charset "EUC-JP")))
  12193. @end lisp
  12194. @vindex LOCPATH
  12195. The compiled locale definitions are available at
  12196. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  12197. version, which is the default location where the GNU@tie{}libc provided
  12198. by Guix looks for locale data. This can be overridden using the
  12199. @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
  12200. @env{LOCPATH} and locale packages}).
  12201. The @code{locale-definition} form is provided by the @code{(gnu system
  12202. locale)} module. Details are given below.
  12203. @deftp {Data Type} locale-definition
  12204. This is the data type of a locale definition.
  12205. @table @asis
  12206. @item @code{name}
  12207. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  12208. Reference Manual}, for more information on locale names.
  12209. @item @code{source}
  12210. The name of the source for that locale. This is typically the
  12211. @code{@var{language}_@var{territory}} part of the locale name.
  12212. @item @code{charset} (default: @code{"UTF-8"})
  12213. The ``character set'' or ``code set'' for that locale,
  12214. @uref{https://www.iana.org/assignments/character-sets, as defined by
  12215. IANA}.
  12216. @end table
  12217. @end deftp
  12218. @defvr {Scheme Variable} %default-locale-definitions
  12219. A list of commonly used UTF-8 locales, used as the default
  12220. value of the @code{locale-definitions} field of @code{operating-system}
  12221. declarations.
  12222. @cindex locale name
  12223. @cindex normalized codeset in locale names
  12224. These locale definitions use the @dfn{normalized codeset} for the part
  12225. that follows the dot in the name (@pxref{Using gettextized software,
  12226. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  12227. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  12228. @code{uk_UA.UTF-8}.
  12229. @end defvr
  12230. @subsection Locale Data Compatibility Considerations
  12231. @cindex incompatibility, of locale data
  12232. @code{operating-system} declarations provide a @code{locale-libcs} field
  12233. to specify the GNU@tie{}libc packages that are used to compile locale
  12234. declarations (@pxref{operating-system Reference}). ``Why would I
  12235. care?'', you may ask. Well, it turns out that the binary format of
  12236. locale data is occasionally incompatible from one libc version to
  12237. another.
  12238. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  12239. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  12240. For instance, a program linked against libc version 2.21 is unable to
  12241. read locale data produced with libc 2.22; worse, that program
  12242. @emph{aborts} instead of simply ignoring the incompatible locale
  12243. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  12244. the incompatible locale data, which is already an improvement.}.
  12245. Similarly, a program linked against libc 2.22 can read most, but not
  12246. all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
  12247. data is incompatible); thus calls to @code{setlocale} may fail, but
  12248. programs will not abort.
  12249. The ``problem'' with Guix is that users have a lot of freedom: They can
  12250. choose whether and when to upgrade software in their profiles, and might
  12251. be using a libc version different from the one the system administrator
  12252. used to build the system-wide locale data.
  12253. Fortunately, unprivileged users can also install their own locale data
  12254. and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  12255. @env{GUIX_LOCPATH} and locale packages}).
  12256. Still, it is best if the system-wide locale data at
  12257. @file{/run/current-system/locale} is built for all the libc versions
  12258. actually in use on the system, so that all the programs can access
  12259. it---this is especially crucial on a multi-user system. To do that, the
  12260. administrator can specify several libc packages in the
  12261. @code{locale-libcs} field of @code{operating-system}:
  12262. @lisp
  12263. (use-package-modules base)
  12264. (operating-system
  12265. ;; @dots{}
  12266. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  12267. @end lisp
  12268. This example would lead to a system containing locale definitions for
  12269. both libc 2.21 and the current version of libc in
  12270. @file{/run/current-system/locale}.
  12271. @node Services
  12272. @section Services
  12273. @cindex system services
  12274. An important part of preparing an @code{operating-system} declaration is
  12275. listing @dfn{system services} and their configuration (@pxref{Using the
  12276. Configuration System}). System services are typically daemons launched
  12277. when the system boots, or other actions needed at that time---e.g.,
  12278. configuring network access.
  12279. Guix has a broad definition of ``service'' (@pxref{Service
  12280. Composition}), but many services are managed by the GNU@tie{}Shepherd
  12281. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  12282. command allows you to list the available services, show their status,
  12283. start and stop them, or do other specific operations (@pxref{Jump
  12284. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  12285. @example
  12286. # herd status
  12287. @end example
  12288. The above command, run as @code{root}, lists the currently defined
  12289. services. The @command{herd doc} command shows a synopsis of the given
  12290. service and its associated actions:
  12291. @example
  12292. # herd doc nscd
  12293. Run libc's name service cache daemon (nscd).
  12294. # herd doc nscd action invalidate
  12295. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  12296. @end example
  12297. The @command{start}, @command{stop}, and @command{restart} sub-commands
  12298. have the effect you would expect. For instance, the commands below stop
  12299. the nscd service and restart the Xorg display server:
  12300. @example
  12301. # herd stop nscd
  12302. Service nscd has been stopped.
  12303. # herd restart xorg-server
  12304. Service xorg-server has been stopped.
  12305. Service xorg-server has been started.
  12306. @end example
  12307. The following sections document the available services, starting with
  12308. the core services, that may be used in an @code{operating-system}
  12309. declaration.
  12310. @menu
  12311. * Base Services:: Essential system services.
  12312. * Scheduled Job Execution:: The mcron service.
  12313. * Log Rotation:: The rottlog service.
  12314. * Networking Services:: Network setup, SSH daemon, etc.
  12315. * Unattended Upgrades:: Automated system upgrades.
  12316. * X Window:: Graphical display.
  12317. * Printing Services:: Local and remote printer support.
  12318. * Desktop Services:: D-Bus and desktop services.
  12319. * Sound Services:: ALSA and Pulseaudio services.
  12320. * Database Services:: SQL databases, key-value stores, etc.
  12321. * Mail Services:: IMAP, POP3, SMTP, and all that.
  12322. * Messaging Services:: Messaging services.
  12323. * Telephony Services:: Telephony services.
  12324. * File-Sharing Services:: File-sharing services.
  12325. * Monitoring Services:: Monitoring services.
  12326. * Kerberos Services:: Kerberos services.
  12327. * LDAP Services:: LDAP services.
  12328. * Web Services:: Web servers.
  12329. * Certificate Services:: TLS certificates via Let's Encrypt.
  12330. * DNS Services:: DNS daemons.
  12331. * VPN Services:: VPN daemons.
  12332. * Network File System:: NFS related services.
  12333. * Continuous Integration:: Cuirass and Laminar services.
  12334. * Power Management Services:: Extending battery life.
  12335. * Audio Services:: The MPD.
  12336. * Virtualization Services:: Virtualization services.
  12337. * Version Control Services:: Providing remote access to Git repositories.
  12338. * Game Services:: Game servers.
  12339. * PAM Mount Service:: Service to mount volumes when logging in.
  12340. * Guix Services:: Services relating specifically to Guix.
  12341. * Linux Services:: Services tied to the Linux kernel.
  12342. * Hurd Services:: Services specific for a Hurd System.
  12343. * Miscellaneous Services:: Other services.
  12344. @end menu
  12345. @node Base Services
  12346. @subsection Base Services
  12347. The @code{(gnu services base)} module provides definitions for the basic
  12348. services that one expects from the system. The services exported by
  12349. this module are listed below.
  12350. @defvr {Scheme Variable} %base-services
  12351. This variable contains a list of basic services (@pxref{Service Types
  12352. and Services}, for more information on service objects) one would
  12353. expect from the system: a login service (mingetty) on each tty, syslogd,
  12354. the libc name service cache daemon (nscd), the udev device manager, and
  12355. more.
  12356. This is the default value of the @code{services} field of
  12357. @code{operating-system} declarations. Usually, when customizing a
  12358. system, you will want to append services to @code{%base-services}, like
  12359. this:
  12360. @lisp
  12361. (append (list (service avahi-service-type)
  12362. (service openssh-service-type))
  12363. %base-services)
  12364. @end lisp
  12365. @end defvr
  12366. @defvr {Scheme Variable} special-files-service-type
  12367. This is the service that sets up ``special files'' such as
  12368. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  12369. The value associated with @code{special-files-service-type} services
  12370. must be a list of tuples where the first element is the ``special file''
  12371. and the second element is its target. By default it is:
  12372. @cindex @file{/bin/sh}
  12373. @cindex @file{sh}, in @file{/bin}
  12374. @lisp
  12375. `(("/bin/sh" ,(file-append bash "/bin/sh")))
  12376. @end lisp
  12377. @cindex @file{/usr/bin/env}
  12378. @cindex @file{env}, in @file{/usr/bin}
  12379. If you want to add, say, @code{/usr/bin/env} to your system, you can
  12380. change it to:
  12381. @lisp
  12382. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  12383. ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
  12384. @end lisp
  12385. Since this is part of @code{%base-services}, you can use
  12386. @code{modify-services} to customize the set of special files
  12387. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  12388. to add a special file is @i{via} the @code{extra-special-file} procedure
  12389. (see below).
  12390. @end defvr
  12391. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  12392. Use @var{target} as the ``special file'' @var{file}.
  12393. For example, adding the following lines to the @code{services} field of
  12394. your operating system declaration leads to a @file{/usr/bin/env}
  12395. symlink:
  12396. @lisp
  12397. (extra-special-file "/usr/bin/env"
  12398. (file-append coreutils "/bin/env"))
  12399. @end lisp
  12400. @end deffn
  12401. @deffn {Scheme Procedure} host-name-service @var{name}
  12402. Return a service that sets the host name to @var{name}.
  12403. @end deffn
  12404. @defvr {Scheme Variable} console-font-service-type
  12405. Install the given fonts on the specified ttys (fonts are per
  12406. virtual console on the kernel Linux). The value of this service is a list of
  12407. tty/font pairs. The font can be the name of a font provided by the @code{kbd}
  12408. package or any valid argument to @command{setfont}, as in this example:
  12409. @lisp
  12410. `(("tty1" . "LatGrkCyr-8x16")
  12411. ("tty2" . ,(file-append
  12412. font-tamzen
  12413. "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  12414. ("tty3" . ,(file-append
  12415. font-terminus
  12416. "/share/consolefonts/ter-132n"))) ; for HDPI
  12417. @end lisp
  12418. @end defvr
  12419. @deffn {Scheme Procedure} login-service @var{config}
  12420. Return a service to run login according to @var{config}, a
  12421. @code{<login-configuration>} object, which specifies the message of the day,
  12422. among other things.
  12423. @end deffn
  12424. @deftp {Data Type} login-configuration
  12425. This is the data type representing the configuration of login.
  12426. @table @asis
  12427. @item @code{motd}
  12428. @cindex message of the day
  12429. A file-like object containing the ``message of the day''.
  12430. @item @code{allow-empty-passwords?} (default: @code{#t})
  12431. Allow empty passwords by default so that first-time users can log in when
  12432. the 'root' account has just been created.
  12433. @end table
  12434. @end deftp
  12435. @deffn {Scheme Procedure} mingetty-service @var{config}
  12436. Return a service to run mingetty according to @var{config}, a
  12437. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  12438. other things.
  12439. @end deffn
  12440. @deftp {Data Type} mingetty-configuration
  12441. This is the data type representing the configuration of Mingetty, which
  12442. provides the default implementation of virtual console log-in.
  12443. @table @asis
  12444. @item @code{tty}
  12445. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  12446. @item @code{auto-login} (default: @code{#f})
  12447. When true, this field must be a string denoting the user name under
  12448. which the system automatically logs in. When it is @code{#f}, a
  12449. user name and password must be entered to log in.
  12450. @item @code{login-program} (default: @code{#f})
  12451. This must be either @code{#f}, in which case the default log-in program
  12452. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  12453. the name of the log-in program.
  12454. @item @code{login-pause?} (default: @code{#f})
  12455. When set to @code{#t} in conjunction with @var{auto-login}, the user
  12456. will have to press a key before the log-in shell is launched.
  12457. @item @code{clear-on-logout?} (default: @code{#t})
  12458. When set to @code{#t}, the screen will be cleared after logout.
  12459. @item @code{mingetty} (default: @var{mingetty})
  12460. The Mingetty package to use.
  12461. @end table
  12462. @end deftp
  12463. @deffn {Scheme Procedure} agetty-service @var{config}
  12464. Return a service to run agetty according to @var{config}, an
  12465. @code{<agetty-configuration>} object, which specifies the tty to run,
  12466. among other things.
  12467. @end deffn
  12468. @deftp {Data Type} agetty-configuration
  12469. This is the data type representing the configuration of agetty, which
  12470. implements virtual and serial console log-in. See the @code{agetty(8)}
  12471. man page for more information.
  12472. @table @asis
  12473. @item @code{tty}
  12474. The name of the console this agetty runs on, as a string---e.g.,
  12475. @code{"ttyS0"}. This argument is optional, it will default to
  12476. a reasonable default serial port used by the kernel Linux.
  12477. For this, if there is a value for an option @code{agetty.tty} in the kernel
  12478. command line, agetty will extract the device name of the serial port
  12479. from it and use that.
  12480. If not and if there is a value for an option @code{console} with a tty in
  12481. the Linux command line, agetty will extract the device name of the
  12482. serial port from it and use that.
  12483. In both cases, agetty will leave the other serial device settings
  12484. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  12485. correct values.
  12486. @item @code{baud-rate} (default: @code{#f})
  12487. A string containing a comma-separated list of one or more baud rates, in
  12488. descending order.
  12489. @item @code{term} (default: @code{#f})
  12490. A string containing the value used for the @env{TERM} environment
  12491. variable.
  12492. @item @code{eight-bits?} (default: @code{#f})
  12493. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  12494. disabled.
  12495. @item @code{auto-login} (default: @code{#f})
  12496. When passed a login name, as a string, the specified user will be logged
  12497. in automatically without prompting for their login name or password.
  12498. @item @code{no-reset?} (default: @code{#f})
  12499. When @code{#t}, don't reset terminal cflags (control modes).
  12500. @item @code{host} (default: @code{#f})
  12501. This accepts a string containing the ``login_host'', which will be written
  12502. into the @file{/var/run/utmpx} file.
  12503. @item @code{remote?} (default: @code{#f})
  12504. When set to @code{#t} in conjunction with @var{host}, this will add an
  12505. @code{-r} fakehost option to the command line of the login program
  12506. specified in @var{login-program}.
  12507. @item @code{flow-control?} (default: @code{#f})
  12508. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  12509. @item @code{no-issue?} (default: @code{#f})
  12510. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  12511. not be displayed before presenting the login prompt.
  12512. @item @code{init-string} (default: @code{#f})
  12513. This accepts a string that will be sent to the tty or modem before
  12514. sending anything else. It can be used to initialize a modem.
  12515. @item @code{no-clear?} (default: @code{#f})
  12516. When set to @code{#t}, agetty will not clear the screen before showing
  12517. the login prompt.
  12518. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  12519. This must be either a gexp denoting the name of a log-in program, or
  12520. unset, in which case the default value is the @command{login} from the
  12521. Shadow tool suite.
  12522. @item @code{local-line} (default: @code{#f})
  12523. Control the CLOCAL line flag. This accepts one of three symbols as
  12524. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  12525. the default value chosen by agetty is @code{'auto}.
  12526. @item @code{extract-baud?} (default: @code{#f})
  12527. When set to @code{#t}, instruct agetty to try to extract the baud rate
  12528. from the status messages produced by certain types of modems.
  12529. @item @code{skip-login?} (default: @code{#f})
  12530. When set to @code{#t}, do not prompt the user for a login name. This
  12531. can be used with @var{login-program} field to use non-standard login
  12532. systems.
  12533. @item @code{no-newline?} (default: @code{#f})
  12534. When set to @code{#t}, do not print a newline before printing the
  12535. @file{/etc/issue} file.
  12536. @c Is this dangerous only when used with login-program, or always?
  12537. @item @code{login-options} (default: @code{#f})
  12538. This option accepts a string containing options that are passed to the
  12539. login program. When used with the @var{login-program}, be aware that a
  12540. malicious user could try to enter a login name containing embedded
  12541. options that could be parsed by the login program.
  12542. @item @code{login-pause} (default: @code{#f})
  12543. When set to @code{#t}, wait for any key before showing the login prompt.
  12544. This can be used in conjunction with @var{auto-login} to save memory by
  12545. lazily spawning shells.
  12546. @item @code{chroot} (default: @code{#f})
  12547. Change root to the specified directory. This option accepts a directory
  12548. path as a string.
  12549. @item @code{hangup?} (default: @code{#f})
  12550. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  12551. specified terminal.
  12552. @item @code{keep-baud?} (default: @code{#f})
  12553. When set to @code{#t}, try to keep the existing baud rate. The baud
  12554. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  12555. character.
  12556. @item @code{timeout} (default: @code{#f})
  12557. When set to an integer value, terminate if no user name could be read
  12558. within @var{timeout} seconds.
  12559. @item @code{detect-case?} (default: @code{#f})
  12560. When set to @code{#t}, turn on support for detecting an uppercase-only
  12561. terminal. This setting will detect a login name containing only
  12562. uppercase letters as indicating an uppercase-only terminal and turn on
  12563. some upper-to-lower case conversions. Note that this will not support
  12564. Unicode characters.
  12565. @item @code{wait-cr?} (default: @code{#f})
  12566. When set to @code{#t}, wait for the user or modem to send a
  12567. carriage-return or linefeed character before displaying
  12568. @file{/etc/issue} or login prompt. This is typically used with the
  12569. @var{init-string} option.
  12570. @item @code{no-hints?} (default: @code{#f})
  12571. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  12572. locks.
  12573. @item @code{no-hostname?} (default: @code{#f})
  12574. By default, the hostname is printed. When this option is set to
  12575. @code{#t}, no hostname will be shown at all.
  12576. @item @code{long-hostname?} (default: @code{#f})
  12577. By default, the hostname is only printed until the first dot. When this
  12578. option is set to @code{#t}, the fully qualified hostname by
  12579. @code{gethostname} or @code{getaddrinfo} is shown.
  12580. @item @code{erase-characters} (default: @code{#f})
  12581. This option accepts a string of additional characters that should be
  12582. interpreted as backspace when the user types their login name.
  12583. @item @code{kill-characters} (default: @code{#f})
  12584. This option accepts a string that should be interpreted to mean ``ignore
  12585. all previous characters'' (also called a ``kill'' character) when the user
  12586. types their login name.
  12587. @item @code{chdir} (default: @code{#f})
  12588. This option accepts, as a string, a directory path that will be changed
  12589. to before login.
  12590. @item @code{delay} (default: @code{#f})
  12591. This options accepts, as an integer, the number of seconds to sleep
  12592. before opening the tty and displaying the login prompt.
  12593. @item @code{nice} (default: @code{#f})
  12594. This option accepts, as an integer, the nice value with which to run the
  12595. @command{login} program.
  12596. @item @code{extra-options} (default: @code{'()})
  12597. This option provides an ``escape hatch'' for the user to provide arbitrary
  12598. command-line arguments to @command{agetty} as a list of strings.
  12599. @end table
  12600. @end deftp
  12601. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  12602. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  12603. according to @var{config}, a @code{<kmscon-configuration>} object, which
  12604. specifies the tty to run, among other things.
  12605. @end deffn
  12606. @deftp {Data Type} kmscon-configuration
  12607. This is the data type representing the configuration of Kmscon, which
  12608. implements virtual console log-in.
  12609. @table @asis
  12610. @item @code{virtual-terminal}
  12611. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  12612. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  12613. A gexp denoting the name of the log-in program. The default log-in program is
  12614. @command{login} from the Shadow tool suite.
  12615. @item @code{login-arguments} (default: @code{'("-p")})
  12616. A list of arguments to pass to @command{login}.
  12617. @item @code{auto-login} (default: @code{#f})
  12618. When passed a login name, as a string, the specified user will be logged
  12619. in automatically without prompting for their login name or password.
  12620. @item @code{hardware-acceleration?} (default: #f)
  12621. Whether to use hardware acceleration.
  12622. @item @code{font-engine} (default: @code{"pango"})
  12623. Font engine used in Kmscon.
  12624. @item @code{font-size} (default: @code{12})
  12625. Font size used in Kmscon.
  12626. @item @code{keyboard-layout} (default: @code{#f})
  12627. If this is @code{#f}, Kmscon uses the default keyboard layout---usually US
  12628. English (``qwerty'') for a 105-key PC keyboard.
  12629. Otherwise this must be a @code{keyboard-layout} object specifying the
  12630. keyboard layout. @xref{Keyboard Layout}, for more information on how to
  12631. specify the keyboard layout.
  12632. @item @code{kmscon} (default: @var{kmscon})
  12633. The Kmscon package to use.
  12634. @end table
  12635. @end deftp
  12636. @cindex name service cache daemon
  12637. @cindex nscd
  12638. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  12639. [#:name-services '()]
  12640. Return a service that runs the libc name service cache daemon (nscd) with the
  12641. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  12642. Service Switch}, for an example.
  12643. For convenience, the Shepherd service for nscd provides the following actions:
  12644. @table @code
  12645. @item invalidate
  12646. @cindex cache invalidation, nscd
  12647. @cindex nscd, cache invalidation
  12648. This invalidate the given cache. For instance, running:
  12649. @example
  12650. herd invalidate nscd hosts
  12651. @end example
  12652. @noindent
  12653. invalidates the host name lookup cache of nscd.
  12654. @item statistics
  12655. Running @command{herd statistics nscd} displays information about nscd usage
  12656. and caches.
  12657. @end table
  12658. @end deffn
  12659. @defvr {Scheme Variable} %nscd-default-configuration
  12660. This is the default @code{<nscd-configuration>} value (see below) used
  12661. by @code{nscd-service}. It uses the caches defined by
  12662. @code{%nscd-default-caches}; see below.
  12663. @end defvr
  12664. @deftp {Data Type} nscd-configuration
  12665. This is the data type representing the name service cache daemon (nscd)
  12666. configuration.
  12667. @table @asis
  12668. @item @code{name-services} (default: @code{'()})
  12669. List of packages denoting @dfn{name services} that must be visible to
  12670. the nscd---e.g., @code{(list @var{nss-mdns})}.
  12671. @item @code{glibc} (default: @var{glibc})
  12672. Package object denoting the GNU C Library providing the @command{nscd}
  12673. command.
  12674. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  12675. Name of the nscd log file. This is where debugging output goes when
  12676. @code{debug-level} is strictly positive.
  12677. @item @code{debug-level} (default: @code{0})
  12678. Integer denoting the debugging levels. Higher numbers mean that more
  12679. debugging output is logged.
  12680. @item @code{caches} (default: @code{%nscd-default-caches})
  12681. List of @code{<nscd-cache>} objects denoting things to be cached; see
  12682. below.
  12683. @end table
  12684. @end deftp
  12685. @deftp {Data Type} nscd-cache
  12686. Data type representing a cache database of nscd and its parameters.
  12687. @table @asis
  12688. @item @code{database}
  12689. This is a symbol representing the name of the database to be cached.
  12690. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  12691. @code{services}, which designate the corresponding NSS database
  12692. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  12693. @item @code{positive-time-to-live}
  12694. @itemx @code{negative-time-to-live} (default: @code{20})
  12695. A number representing the number of seconds during which a positive or
  12696. negative lookup result remains in cache.
  12697. @item @code{check-files?} (default: @code{#t})
  12698. Whether to check for updates of the files corresponding to
  12699. @var{database}.
  12700. For instance, when @var{database} is @code{hosts}, setting this flag
  12701. instructs nscd to check for updates in @file{/etc/hosts} and to take
  12702. them into account.
  12703. @item @code{persistent?} (default: @code{#t})
  12704. Whether the cache should be stored persistently on disk.
  12705. @item @code{shared?} (default: @code{#t})
  12706. Whether the cache should be shared among users.
  12707. @item @code{max-database-size} (default: 32@tie{}MiB)
  12708. Maximum size in bytes of the database cache.
  12709. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  12710. @c settings, so leave them out.
  12711. @end table
  12712. @end deftp
  12713. @defvr {Scheme Variable} %nscd-default-caches
  12714. List of @code{<nscd-cache>} objects used by default by
  12715. @code{nscd-configuration} (see above).
  12716. It enables persistent and aggressive caching of service and host name
  12717. lookups. The latter provides better host name lookup performance,
  12718. resilience in the face of unreliable name servers, and also better
  12719. privacy---often the result of host name lookups is in local cache, so
  12720. external name servers do not even need to be queried.
  12721. @end defvr
  12722. @anchor{syslog-configuration-type}
  12723. @cindex syslog
  12724. @cindex logging
  12725. @deftp {Data Type} syslog-configuration
  12726. This data type represents the configuration of the syslog daemon.
  12727. @table @asis
  12728. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  12729. The syslog daemon to use.
  12730. @item @code{config-file} (default: @code{%default-syslog.conf})
  12731. The syslog configuration file to use.
  12732. @end table
  12733. @end deftp
  12734. @anchor{syslog-service}
  12735. @cindex syslog
  12736. @deffn {Scheme Procedure} syslog-service @var{config}
  12737. Return a service that runs a syslog daemon according to @var{config}.
  12738. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  12739. information on the configuration file syntax.
  12740. @end deffn
  12741. @defvr {Scheme Variable} guix-service-type
  12742. This is the type of the service that runs the build daemon,
  12743. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  12744. @code{guix-configuration} record as described below.
  12745. @end defvr
  12746. @anchor{guix-configuration-type}
  12747. @deftp {Data Type} guix-configuration
  12748. This data type represents the configuration of the Guix build daemon.
  12749. @xref{Invoking guix-daemon}, for more information.
  12750. @table @asis
  12751. @item @code{guix} (default: @var{guix})
  12752. The Guix package to use.
  12753. @item @code{build-group} (default: @code{"guixbuild"})
  12754. Name of the group for build user accounts.
  12755. @item @code{build-accounts} (default: @code{10})
  12756. Number of build user accounts to create.
  12757. @item @code{authorize-key?} (default: @code{#t})
  12758. @cindex substitutes, authorization thereof
  12759. Whether to authorize the substitute keys listed in
  12760. @code{authorized-keys}---by default that of
  12761. @code{@value{SUBSTITUTE-SERVER-1}} and
  12762. @code{@value{SUBSTITUTE-SERVER-2}}
  12763. (@pxref{Substitutes}).
  12764. When @code{authorize-key?} is true, @file{/etc/guix/acl} cannot be
  12765. changed by invoking @command{guix archive --authorize}. You must
  12766. instead adjust @code{guix-configuration} as you wish and reconfigure the
  12767. system. This ensures that your operating system configuration file is
  12768. self-contained.
  12769. @quotation Note
  12770. When booting or reconfiguring to a system where @code{authorize-key?}
  12771. is true, the existing @file{/etc/guix/acl} file is backed up as
  12772. @file{/etc/guix/acl.bak} if it was determined to be a manually modified
  12773. file. This is to facilitate migration from earlier versions, which
  12774. allowed for in-place modifications to @file{/etc/guix/acl}.
  12775. @end quotation
  12776. @vindex %default-authorized-guix-keys
  12777. @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
  12778. The list of authorized key files for archive imports, as a list of
  12779. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  12780. contains that of @code{@value{SUBSTITUTE-SERVER-1}} and
  12781. @code{@value{SUBSTITUTE-SERVER-2}} (@pxref{Substitutes}). See
  12782. @code{substitute-urls} below for an example on how to change it.
  12783. @item @code{use-substitutes?} (default: @code{#t})
  12784. Whether to use substitutes.
  12785. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  12786. The list of URLs where to look for substitutes by default.
  12787. Suppose you would like to fetch substitutes from @code{guix.example.org}
  12788. in addition to @code{@value{SUBSTITUTE-SERVER-1}}. You will need to do
  12789. two things: (1) add @code{guix.example.org} to @code{substitute-urls},
  12790. and (2) authorize its signing key, having done appropriate checks
  12791. (@pxref{Substitute Server Authorization}). The configuration below does
  12792. exactly that:
  12793. @lisp
  12794. (guix-configuration
  12795. (substitute-urls
  12796. (append (list "https://guix.example.org")
  12797. %default-substitute-urls))
  12798. (authorized-keys
  12799. (append (list (local-file "./guix.example.org-key.pub"))
  12800. %default-authorized-guix-keys)))
  12801. @end lisp
  12802. This example assumes that the file @file{./guix.example.org-key.pub}
  12803. contains the public key that @code{guix.example.org} uses to sign
  12804. substitutes.
  12805. @item @code{max-silent-time} (default: @code{0})
  12806. @itemx @code{timeout} (default: @code{0})
  12807. The number of seconds of silence and the number of seconds of activity,
  12808. respectively, after which a build process times out. A value of zero
  12809. disables the timeout.
  12810. @item @code{log-compression} (default: @code{'bzip2})
  12811. The type of compression used for build logs---one of @code{gzip},
  12812. @code{bzip2}, or @code{none}.
  12813. @item @code{discover?} (default: @code{#f})
  12814. Whether to discover substitute servers on the local network using mDNS
  12815. and DNS-SD.
  12816. @item @code{extra-options} (default: @code{'()})
  12817. List of extra command-line options for @command{guix-daemon}.
  12818. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  12819. File where @command{guix-daemon}'s standard output and standard error
  12820. are written.
  12821. @cindex HTTP proxy, for @code{guix-daemon}
  12822. @cindex proxy, for @code{guix-daemon} HTTP access
  12823. @item @code{http-proxy} (default: @code{#f})
  12824. The URL of the HTTP and HTTPS proxy used for downloading fixed-output
  12825. derivations and substitutes.
  12826. It is also possible to change the daemon's proxy at run time through the
  12827. @code{set-http-proxy} action, which restarts it:
  12828. @example
  12829. herd set-http-proxy guix-daemon http://localhost:8118
  12830. @end example
  12831. To clear the proxy settings, run:
  12832. @example
  12833. herd set-http-proxy guix-daemon
  12834. @end example
  12835. @item @code{tmpdir} (default: @code{#f})
  12836. A directory path where the @command{guix-daemon} will perform builds.
  12837. @end table
  12838. @end deftp
  12839. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  12840. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  12841. udev rules can be provided as a list of files through the @var{rules}
  12842. variable. The procedures @code{udev-rule}, @code{udev-rules-service}
  12843. and @code{file->udev-rule} from @code{(gnu services base)} simplify the
  12844. creation of such rule files.
  12845. The @command{herd rules udev} command, as root, returns the name of the
  12846. directory containing all the active udev rules.
  12847. @end deffn
  12848. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  12849. Return a udev-rule file named @var{file-name} containing the rules
  12850. defined by the @var{contents} literal.
  12851. In the following example, a rule for a USB device is defined to be
  12852. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  12853. upon detecting a USB device with a given product identifier.
  12854. @lisp
  12855. (define %example-udev-rule
  12856. (udev-rule
  12857. "90-usb-thing.rules"
  12858. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  12859. "ATTR@{product@}==\"Example\", "
  12860. "RUN+=\"/path/to/script\"")))
  12861. @end lisp
  12862. @end deffn
  12863. @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
  12864. [#:groups @var{groups}]
  12865. Return a service that extends @code{udev-service-type } with @var{rules}
  12866. and @code{account-service-type} with @var{groups} as system groups.
  12867. This works by creating a singleton service type
  12868. @code{@var{name}-udev-rules}, of which the returned service is an
  12869. instance.
  12870. Here we show how it can be used to extend @code{udev-service-type} with the
  12871. previously defined rule @code{%example-udev-rule}.
  12872. @lisp
  12873. (operating-system
  12874. ;; @dots{}
  12875. (services
  12876. (cons (udev-rules-service 'usb-thing %example-udev-rule)
  12877. %desktop-services)))
  12878. @end lisp
  12879. @end deffn
  12880. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  12881. Return a udev file named @var{file-name} containing the rules defined
  12882. within @var{file}, a file-like object.
  12883. The following example showcases how we can use an existing rule file.
  12884. @lisp
  12885. (use-modules (guix download) ;for url-fetch
  12886. (guix packages) ;for origin
  12887. @dots{})
  12888. (define %android-udev-rules
  12889. (file->udev-rule
  12890. "51-android-udev.rules"
  12891. (let ((version "20170910"))
  12892. (origin
  12893. (method url-fetch)
  12894. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  12895. "android-udev-rules/" version "/51-android.rules"))
  12896. (sha256
  12897. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  12898. @end lisp
  12899. @end deffn
  12900. Additionally, Guix package definitions can be included in @var{rules} in
  12901. order to extend the udev rules with the definitions found under their
  12902. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  12903. @var{file->udev-rule} example, we could have used the
  12904. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  12905. packages android)} module.
  12906. The following example shows how to use the @var{android-udev-rules}
  12907. package so that the Android tool @command{adb} can detect devices
  12908. without root privileges. It also details how to create the
  12909. @code{adbusers} group, which is required for the proper functioning of
  12910. the rules defined within the @code{android-udev-rules} package. To
  12911. create such a group, we must define it both as part of the
  12912. @code{supplementary-groups} of our @code{user-account} declaration, as
  12913. well as in the @var{groups} of the @code{udev-rules-service} procedure.
  12914. @lisp
  12915. (use-modules (gnu packages android) ;for android-udev-rules
  12916. (gnu system shadow) ;for user-group
  12917. @dots{})
  12918. (operating-system
  12919. ;; @dots{}
  12920. (users (cons (user-account
  12921. ;; @dots{}
  12922. (supplementary-groups
  12923. '("adbusers" ;for adb
  12924. "wheel" "netdev" "audio" "video")))))
  12925. ;; @dots{}
  12926. (services
  12927. (cons (udev-rules-service 'android android-udev-rules
  12928. #:groups '("adbusers"))
  12929. %desktop-services)))
  12930. @end lisp
  12931. @defvr {Scheme Variable} urandom-seed-service-type
  12932. Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
  12933. when rebooting. It also tries to seed @file{/dev/urandom} from
  12934. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  12935. readable.
  12936. @end defvr
  12937. @defvr {Scheme Variable} %random-seed-file
  12938. This is the name of the file where some random bytes are saved by
  12939. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  12940. It defaults to @file{/var/lib/random-seed}.
  12941. @end defvr
  12942. @cindex mouse
  12943. @cindex gpm
  12944. @defvr {Scheme Variable} gpm-service-type
  12945. This is the type of the service that runs GPM, the @dfn{general-purpose
  12946. mouse daemon}, which provides mouse support to the Linux console. GPM
  12947. allows users to use the mouse in the console, notably to select, copy,
  12948. and paste text.
  12949. The value for services of this type must be a @code{gpm-configuration}
  12950. (see below). This service is not part of @code{%base-services}.
  12951. @end defvr
  12952. @deftp {Data Type} gpm-configuration
  12953. Data type representing the configuration of GPM.
  12954. @table @asis
  12955. @item @code{options} (default: @code{%default-gpm-options})
  12956. Command-line options passed to @command{gpm}. The default set of
  12957. options instruct @command{gpm} to listen to mouse events on
  12958. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  12959. more information.
  12960. @item @code{gpm} (default: @code{gpm})
  12961. The GPM package to use.
  12962. @end table
  12963. @end deftp
  12964. @anchor{guix-publish-service-type}
  12965. @deffn {Scheme Variable} guix-publish-service-type
  12966. This is the service type for @command{guix publish} (@pxref{Invoking
  12967. guix publish}). Its value must be a @code{guix-publish-configuration}
  12968. object, as described below.
  12969. This assumes that @file{/etc/guix} already contains a signing key pair as
  12970. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  12971. archive}). If that is not the case, the service will fail to start.
  12972. @end deffn
  12973. @deftp {Data Type} guix-publish-configuration
  12974. Data type representing the configuration of the @code{guix publish}
  12975. service.
  12976. @table @asis
  12977. @item @code{guix} (default: @code{guix})
  12978. The Guix package to use.
  12979. @item @code{port} (default: @code{80})
  12980. The TCP port to listen for connections.
  12981. @item @code{host} (default: @code{"localhost"})
  12982. The host (and thus, network interface) to listen to. Use
  12983. @code{"0.0.0.0"} to listen on all the network interfaces.
  12984. @item @code{advertise?} (default: @code{#f})
  12985. When true, advertise the service on the local network @i{via} the DNS-SD
  12986. protocol, using Avahi.
  12987. This allows neighboring Guix devices with discovery on (see
  12988. @code{guix-configuration} above) to discover this @command{guix publish}
  12989. instance and to automatically download substitutes from it.
  12990. @item @code{compression} (default: @code{'(("gzip" 3) ("zstd" 3))})
  12991. This is a list of compression method/level tuple used when compressing
  12992. substitutes. For example, to compress all substitutes with @emph{both} lzip
  12993. at level 7 and gzip at level 9, write:
  12994. @lisp
  12995. '(("lzip" 7) ("gzip" 9))
  12996. @end lisp
  12997. Level 9 achieves the best compression ratio at the expense of increased CPU
  12998. usage, whereas level 1 achieves fast compression. @xref{Invoking guix
  12999. publish}, for more information on the available compression methods and
  13000. the tradeoffs involved.
  13001. An empty list disables compression altogether.
  13002. @item @code{nar-path} (default: @code{"nar"})
  13003. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  13004. publish, @option{--nar-path}}, for details.
  13005. @item @code{cache} (default: @code{#f})
  13006. When it is @code{#f}, disable caching and instead generate archives on
  13007. demand. Otherwise, this should be the name of a directory---e.g.,
  13008. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  13009. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  13010. @option{--cache}}, for more information on the tradeoffs involved.
  13011. @item @code{workers} (default: @code{#f})
  13012. When it is an integer, this is the number of worker threads used for
  13013. caching; when @code{#f}, the number of processors is used.
  13014. @xref{Invoking guix publish, @option{--workers}}, for more information.
  13015. @item @code{cache-bypass-threshold} (default: 10 MiB)
  13016. When @code{cache} is true, this is the maximum size in bytes of a store
  13017. item for which @command{guix publish} may bypass its cache in case of a
  13018. cache miss. @xref{Invoking guix publish,
  13019. @option{--cache-bypass-threshold}}, for more information.
  13020. @item @code{ttl} (default: @code{#f})
  13021. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  13022. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  13023. for more information.
  13024. @end table
  13025. @end deftp
  13026. @anchor{rngd-service}
  13027. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  13028. [#:device "/dev/hwrng"]
  13029. Return a service that runs the @command{rngd} program from @var{rng-tools}
  13030. to add @var{device} to the kernel's entropy pool. The service will fail if
  13031. @var{device} does not exist.
  13032. @end deffn
  13033. @anchor{pam-limits-service}
  13034. @cindex session limits
  13035. @cindex ulimit
  13036. @cindex priority
  13037. @cindex realtime
  13038. @cindex jackd
  13039. @cindex nofile
  13040. @cindex open file descriptors
  13041. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  13042. Return a service that installs a configuration file for the
  13043. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  13044. @code{pam_limits} module}. The procedure optionally takes a list of
  13045. @code{pam-limits-entry} values, which can be used to specify
  13046. @code{ulimit} limits and @code{nice} priority limits to user sessions.
  13047. The following limits definition sets two hard and soft limits for all
  13048. login sessions of users in the @code{realtime} group:
  13049. @lisp
  13050. (pam-limits-service
  13051. (list
  13052. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  13053. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  13054. @end lisp
  13055. The first entry increases the maximum realtime priority for
  13056. non-privileged processes; the second entry lifts any restriction of the
  13057. maximum address space that can be locked in memory. These settings are
  13058. commonly used for real-time audio systems.
  13059. Another useful example is raising the maximum number of open file
  13060. descriptors that can be used:
  13061. @lisp
  13062. (pam-limits-service
  13063. (list
  13064. (pam-limits-entry "*" 'both 'nofile 100000)))
  13065. @end lisp
  13066. In the above example, the asterisk means the limit should apply to any
  13067. user. It is important to ensure the chosen value doesn't exceed the
  13068. maximum system value visible in the @file{/proc/sys/fs/file-max} file,
  13069. else the users would be prevented from login in. For more information
  13070. about the Pluggable Authentication Module (PAM) limits, refer to the
  13071. @samp{pam_limits} man page from the @code{linux-pam} package.
  13072. @end deffn
  13073. @node Scheduled Job Execution
  13074. @subsection Scheduled Job Execution
  13075. @cindex cron
  13076. @cindex mcron
  13077. @cindex scheduling jobs
  13078. The @code{(gnu services mcron)} module provides an interface to
  13079. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  13080. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  13081. Unix @command{cron} daemon; the main difference is that it is
  13082. implemented in Guile Scheme, which provides a lot of flexibility when
  13083. specifying the scheduling of jobs and their actions.
  13084. The example below defines an operating system that runs the
  13085. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  13086. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  13087. well as the @command{mkid} command on behalf of an unprivileged user
  13088. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  13089. gexps to introduce job definitions that are passed to mcron
  13090. (@pxref{G-Expressions}).
  13091. @lisp
  13092. (use-modules (guix) (gnu) (gnu services mcron))
  13093. (use-package-modules base idutils)
  13094. (define updatedb-job
  13095. ;; Run 'updatedb' at 3AM every day. Here we write the
  13096. ;; job's action as a Scheme procedure.
  13097. #~(job '(next-hour '(3))
  13098. (lambda ()
  13099. (execl (string-append #$findutils "/bin/updatedb")
  13100. "updatedb"
  13101. "--prunepaths=/tmp /var/tmp /gnu/store"))
  13102. "updatedb"))
  13103. (define garbage-collector-job
  13104. ;; Collect garbage 5 minutes after midnight every day.
  13105. ;; The job's action is a shell command.
  13106. #~(job "5 0 * * *" ;Vixie cron syntax
  13107. "guix gc -F 1G"))
  13108. (define idutils-job
  13109. ;; Update the index database as user "charlie" at 12:15PM
  13110. ;; and 19:15PM. This runs from the user's home directory.
  13111. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  13112. (string-append #$idutils "/bin/mkid src")
  13113. #:user "charlie"))
  13114. (operating-system
  13115. ;; @dots{}
  13116. ;; %BASE-SERVICES already includes an instance of
  13117. ;; 'mcron-service-type', which we extend with additional
  13118. ;; jobs using 'simple-service'.
  13119. (services (cons (simple-service 'my-cron-jobs
  13120. mcron-service-type
  13121. (list garbage-collector-job
  13122. updatedb-job
  13123. idutils-job))
  13124. %base-services)))
  13125. @end lisp
  13126. @quotation Tip
  13127. When providing the action of a job specification as a procedure, you
  13128. should provide an explicit name for the job via the optional 3rd
  13129. argument as done in the @code{updatedb-job} example above. Otherwise,
  13130. the job would appear as ``Lambda function'' in the output of
  13131. @command{herd schedule mcron}, which is not nearly descriptive enough!
  13132. @end quotation
  13133. For more complex jobs defined in Scheme where you need control over the top
  13134. level, for instance to introduce a @code{use-modules} form, you can move your
  13135. code to a separate program using the @code{program-file} procedure of the
  13136. @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
  13137. illustrates that.
  13138. @lisp
  13139. (define %battery-alert-job
  13140. ;; Beep when the battery percentage falls below %MIN-LEVEL.
  13141. #~(job
  13142. '(next-minute (range 0 60 1))
  13143. #$(program-file
  13144. "battery-alert.scm"
  13145. (with-imported-modules (source-module-closure
  13146. '((guix build utils)))
  13147. #~(begin
  13148. (use-modules (guix build utils)
  13149. (ice-9 popen)
  13150. (ice-9 regex)
  13151. (ice-9 textual-ports)
  13152. (srfi srfi-2))
  13153. (define %min-level 20)
  13154. (setenv "LC_ALL" "C") ;ensure English output
  13155. (and-let* ((input-pipe (open-pipe*
  13156. OPEN_READ
  13157. #$(file-append acpi "/bin/acpi")))
  13158. (output (get-string-all input-pipe))
  13159. (m (string-match "Discharging, ([0-9]+)%" output))
  13160. (level (string->number (match:substring m 1)))
  13161. ((< level %min-level)))
  13162. (format #t "warning: Battery level is low (~a%)~%" level)
  13163. (invoke #$(file-append beep "/bin/beep") "-r5")))))))
  13164. @end lisp
  13165. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  13166. for more information on mcron job specifications. Below is the
  13167. reference of the mcron service.
  13168. On a running system, you can use the @code{schedule} action of the service to
  13169. visualize the mcron jobs that will be executed next:
  13170. @example
  13171. # herd schedule mcron
  13172. @end example
  13173. @noindent
  13174. The example above lists the next five tasks that will be executed, but you can
  13175. also specify the number of tasks to display:
  13176. @example
  13177. # herd schedule mcron 10
  13178. @end example
  13179. @defvr {Scheme Variable} mcron-service-type
  13180. This is the type of the @code{mcron} service, whose value is an
  13181. @code{mcron-configuration} object.
  13182. This service type can be the target of a service extension that provides
  13183. it additional job specifications (@pxref{Service Composition}). In
  13184. other words, it is possible to define services that provide additional
  13185. mcron jobs to run.
  13186. @end defvr
  13187. @deftp {Data Type} mcron-configuration
  13188. Data type representing the configuration of mcron.
  13189. @table @asis
  13190. @item @code{mcron} (default: @var{mcron})
  13191. The mcron package to use.
  13192. @item @code{jobs}
  13193. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  13194. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  13195. specifications,, mcron, GNU@tie{}mcron}).
  13196. @end table
  13197. @end deftp
  13198. @node Log Rotation
  13199. @subsection Log Rotation
  13200. @cindex rottlog
  13201. @cindex log rotation
  13202. @cindex logging
  13203. Log files such as those found in @file{/var/log} tend to grow endlessly,
  13204. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  13205. their contents in separate files, possibly compressed. The @code{(gnu
  13206. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  13207. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  13208. This service is part of @code{%base-services}, and thus enabled by
  13209. default, with the default settings, for commonly encountered log files.
  13210. The example below shows how to extend it with an additional
  13211. @dfn{rotation}, should you need to do that (usually, services that
  13212. produce log files already take care of that):
  13213. @lisp
  13214. (use-modules (guix) (gnu))
  13215. (use-service-modules admin)
  13216. (define my-log-files
  13217. ;; Log files that I want to rotate.
  13218. '("/var/log/something.log" "/var/log/another.log"))
  13219. (operating-system
  13220. ;; @dots{}
  13221. (services (cons (simple-service 'rotate-my-stuff
  13222. rottlog-service-type
  13223. (list (log-rotation
  13224. (frequency 'daily)
  13225. (files my-log-files))))
  13226. %base-services)))
  13227. @end lisp
  13228. @defvr {Scheme Variable} rottlog-service-type
  13229. This is the type of the Rottlog service, whose value is a
  13230. @code{rottlog-configuration} object.
  13231. Other services can extend this one with new @code{log-rotation} objects
  13232. (see below), thereby augmenting the set of files to be rotated.
  13233. This service type can define mcron jobs (@pxref{Scheduled Job
  13234. Execution}) to run the rottlog service.
  13235. @end defvr
  13236. @deftp {Data Type} rottlog-configuration
  13237. Data type representing the configuration of rottlog.
  13238. @table @asis
  13239. @item @code{rottlog} (default: @code{rottlog})
  13240. The Rottlog package to use.
  13241. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  13242. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  13243. rottlog, GNU Rot[t]log Manual}).
  13244. @item @code{rotations} (default: @code{%default-rotations})
  13245. A list of @code{log-rotation} objects as defined below.
  13246. @item @code{jobs}
  13247. This is a list of gexps where each gexp corresponds to an mcron job
  13248. specification (@pxref{Scheduled Job Execution}).
  13249. @end table
  13250. @end deftp
  13251. @deftp {Data Type} log-rotation
  13252. Data type representing the rotation of a group of log files.
  13253. Taking an example from the Rottlog manual (@pxref{Period Related File
  13254. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  13255. defined like this:
  13256. @lisp
  13257. (log-rotation
  13258. (frequency 'daily)
  13259. (files '("/var/log/apache/*"))
  13260. (options '("storedir apache-archives"
  13261. "rotate 6"
  13262. "notifempty"
  13263. "nocompress")))
  13264. @end lisp
  13265. The list of fields is as follows:
  13266. @table @asis
  13267. @item @code{frequency} (default: @code{'weekly})
  13268. The log rotation frequency, a symbol.
  13269. @item @code{files}
  13270. The list of files or file glob patterns to rotate.
  13271. @item @code{options} (default: @code{'()})
  13272. The list of rottlog options for this rotation (@pxref{Configuration
  13273. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  13274. @item @code{post-rotate} (default: @code{#f})
  13275. Either @code{#f} or a gexp to execute once the rotation has completed.
  13276. @end table
  13277. @end deftp
  13278. @defvr {Scheme Variable} %default-rotations
  13279. Specifies weekly rotation of @code{%rotated-files} and of
  13280. @file{/var/log/guix-daemon.log}.
  13281. @end defvr
  13282. @defvr {Scheme Variable} %rotated-files
  13283. The list of syslog-controlled files to be rotated. By default it is:
  13284. @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
  13285. "/var/log/maillog")}.
  13286. @end defvr
  13287. @node Networking Services
  13288. @subsection Networking Services
  13289. The @code{(gnu services networking)} module provides services to configure
  13290. the network interface.
  13291. @cindex DHCP, networking service
  13292. @defvr {Scheme Variable} dhcp-client-service-type
  13293. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  13294. Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
  13295. is the DHCP client package to use, @code{isc-dhcp} by default.
  13296. @end defvr
  13297. @deffn {Scheme Procedure} dhcpd-service-type
  13298. This type defines a service that runs a DHCP daemon. To create a
  13299. service of this type, you must supply a @code{<dhcpd-configuration>}.
  13300. For example:
  13301. @lisp
  13302. (service dhcpd-service-type
  13303. (dhcpd-configuration
  13304. (config-file (local-file "my-dhcpd.conf"))
  13305. (interfaces '("enp0s25"))))
  13306. @end lisp
  13307. @end deffn
  13308. @deftp {Data Type} dhcpd-configuration
  13309. @table @asis
  13310. @item @code{package} (default: @code{isc-dhcp})
  13311. The package that provides the DHCP daemon. This package is expected to
  13312. provide the daemon at @file{sbin/dhcpd} relative to its output
  13313. directory. The default package is the
  13314. @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
  13315. @item @code{config-file} (default: @code{#f})
  13316. The configuration file to use. This is required. It will be passed to
  13317. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  13318. object (@pxref{G-Expressions, file-like objects}). See @code{man
  13319. dhcpd.conf} for details on the configuration file syntax.
  13320. @item @code{version} (default: @code{"4"})
  13321. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  13322. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  13323. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  13324. details.
  13325. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  13326. The run directory to use. At service activation time, this directory
  13327. will be created if it does not exist.
  13328. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  13329. The PID file to use. This corresponds to the @code{-pf} option of
  13330. @code{dhcpd}. See @code{man dhcpd} for details.
  13331. @item @code{interfaces} (default: @code{'()})
  13332. The names of the network interfaces on which dhcpd should listen for
  13333. broadcasts. If this list is not empty, then its elements (which must be
  13334. strings) will be appended to the @code{dhcpd} invocation when starting
  13335. the daemon. It may not be necessary to explicitly specify any
  13336. interfaces here; see @code{man dhcpd} for details.
  13337. @end table
  13338. @end deftp
  13339. @defvr {Scheme Variable} static-networking-service-type
  13340. This is the type for statically-configured network interfaces.
  13341. @c TODO Document <static-networking> data structures.
  13342. @end defvr
  13343. @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
  13344. [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
  13345. [#:requirement @code{'(udev)}]
  13346. Return a service that starts @var{interface} with address @var{ip}. If
  13347. @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
  13348. it must be a string specifying the default network gateway. @var{requirement}
  13349. can be used to declare a dependency on another service before configuring the
  13350. interface.
  13351. This procedure can be called several times, one for each network
  13352. interface of interest. Behind the scenes what it does is extend
  13353. @code{static-networking-service-type} with additional network interfaces
  13354. to handle.
  13355. For example:
  13356. @lisp
  13357. (static-networking-service "eno1" "192.168.1.82"
  13358. #:gateway "192.168.1.2"
  13359. #:name-servers '("192.168.1.2"))
  13360. @end lisp
  13361. @end deffn
  13362. @cindex wicd
  13363. @cindex wireless
  13364. @cindex WiFi
  13365. @cindex network management
  13366. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  13367. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  13368. management daemon that aims to simplify wired and wireless networking.
  13369. This service adds the @var{wicd} package to the global profile, providing
  13370. several commands to interact with the daemon and configure networking:
  13371. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  13372. and @command{wicd-curses} user interfaces.
  13373. @end deffn
  13374. @cindex ModemManager
  13375. @defvr {Scheme Variable} modem-manager-service-type
  13376. This is the service type for the
  13377. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  13378. service. The value for this service type is a
  13379. @code{modem-manager-configuration} record.
  13380. This service is part of @code{%desktop-services} (@pxref{Desktop
  13381. Services}).
  13382. @end defvr
  13383. @deftp {Data Type} modem-manager-configuration
  13384. Data type representing the configuration of ModemManager.
  13385. @table @asis
  13386. @item @code{modem-manager} (default: @code{modem-manager})
  13387. The ModemManager package to use.
  13388. @end table
  13389. @end deftp
  13390. @cindex USB_ModeSwitch
  13391. @cindex Modeswitching
  13392. @defvr {Scheme Variable} usb-modeswitch-service-type
  13393. This is the service type for the
  13394. @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch}
  13395. service. The value for this service type is
  13396. a @code{usb-modeswitch-configuration} record.
  13397. When plugged in, some USB modems (and other USB devices) initially present
  13398. themselves as a read-only storage medium and not as a modem. They need to be
  13399. @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
  13400. installs udev rules to automatically modeswitch these devices when they are
  13401. plugged in.
  13402. This service is part of @code{%desktop-services} (@pxref{Desktop
  13403. Services}).
  13404. @end defvr
  13405. @deftp {Data Type} usb-modeswitch-configuration
  13406. Data type representing the configuration of USB_ModeSwitch.
  13407. @table @asis
  13408. @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
  13409. The USB_ModeSwitch package providing the binaries for modeswitching.
  13410. @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
  13411. The package providing the device data and udev rules file used by
  13412. USB_ModeSwitch.
  13413. @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
  13414. Which config file to use for the USB_ModeSwitch dispatcher. By default the
  13415. config file shipped with USB_ModeSwitch is used which disables logging to
  13416. @file{/var/log} among other default settings. If set to @code{#f}, no config
  13417. file is used.
  13418. @end table
  13419. @end deftp
  13420. @cindex NetworkManager
  13421. @defvr {Scheme Variable} network-manager-service-type
  13422. This is the service type for the
  13423. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  13424. service. The value for this service type is a
  13425. @code{network-manager-configuration} record.
  13426. This service is part of @code{%desktop-services} (@pxref{Desktop
  13427. Services}).
  13428. @end defvr
  13429. @deftp {Data Type} network-manager-configuration
  13430. Data type representing the configuration of NetworkManager.
  13431. @table @asis
  13432. @item @code{network-manager} (default: @code{network-manager})
  13433. The NetworkManager package to use.
  13434. @item @code{dns} (default: @code{"default"})
  13435. Processing mode for DNS, which affects how NetworkManager uses the
  13436. @code{resolv.conf} configuration file.
  13437. @table @samp
  13438. @item default
  13439. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  13440. provided by currently active connections.
  13441. @item dnsmasq
  13442. NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
  13443. @dfn{conditional forwarding} configuration if you are connected to a VPN, and
  13444. then update @code{resolv.conf} to point to the local nameserver.
  13445. With this setting, you can share your network connection. For example when
  13446. you want to share your network connection to another laptop @i{via} an
  13447. Ethernet cable, you can open @command{nm-connection-editor} and configure the
  13448. Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
  13449. and reestablish the connection (or reboot).
  13450. You can also set up a @dfn{host-to-guest connection} to QEMU VMs
  13451. (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
  13452. e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
  13453. browser on your host system, or connect to the VM @i{via} SSH
  13454. (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
  13455. host-to-guest connection, run this command once:
  13456. @example
  13457. nmcli connection add type tun \
  13458. connection.interface-name tap0 \
  13459. tun.mode tap tun.owner $(id -u) \
  13460. ipv4.method shared \
  13461. ipv4.addresses 172.28.112.1/24
  13462. @end example
  13463. Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
  13464. @option{-nic tap,ifname=tap0,script=no,downscript=no} to
  13465. @command{qemu-system-...}.
  13466. @item none
  13467. NetworkManager will not modify @code{resolv.conf}.
  13468. @end table
  13469. @item @code{vpn-plugins} (default: @code{'()})
  13470. This is the list of available plugins for virtual private networks
  13471. (VPNs). An example of this is the @code{network-manager-openvpn}
  13472. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  13473. @end table
  13474. @end deftp
  13475. @cindex Connman
  13476. @deffn {Scheme Variable} connman-service-type
  13477. This is the service type to run @url{https://01.org/connman,Connman},
  13478. a network connection manager.
  13479. Its value must be an
  13480. @code{connman-configuration} record as in this example:
  13481. @lisp
  13482. (service connman-service-type
  13483. (connman-configuration
  13484. (disable-vpn? #t)))
  13485. @end lisp
  13486. See below for details about @code{connman-configuration}.
  13487. @end deffn
  13488. @deftp {Data Type} connman-configuration
  13489. Data Type representing the configuration of connman.
  13490. @table @asis
  13491. @item @code{connman} (default: @var{connman})
  13492. The connman package to use.
  13493. @item @code{disable-vpn?} (default: @code{#f})
  13494. When true, disable connman's vpn plugin.
  13495. @end table
  13496. @end deftp
  13497. @cindex WPA Supplicant
  13498. @defvr {Scheme Variable} wpa-supplicant-service-type
  13499. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  13500. supplicant}, an authentication daemon required to authenticate against
  13501. encrypted WiFi or ethernet networks.
  13502. @end defvr
  13503. @deftp {Data Type} wpa-supplicant-configuration
  13504. Data type representing the configuration of WPA Supplicant.
  13505. It takes the following parameters:
  13506. @table @asis
  13507. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  13508. The WPA Supplicant package to use.
  13509. @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
  13510. List of services that should be started before WPA Supplicant starts.
  13511. @item @code{dbus?} (default: @code{#t})
  13512. Whether to listen for requests on D-Bus.
  13513. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  13514. Where to store the PID file.
  13515. @item @code{interface} (default: @code{#f})
  13516. If this is set, it must specify the name of a network interface that
  13517. WPA supplicant will control.
  13518. @item @code{config-file} (default: @code{#f})
  13519. Optional configuration file to use.
  13520. @item @code{extra-options} (default: @code{'()})
  13521. List of additional command-line arguments to pass to the daemon.
  13522. @end table
  13523. @end deftp
  13524. @cindex hostapd service, for Wi-Fi access points
  13525. @cindex Wi-Fi access points, hostapd service
  13526. @defvr {Scheme Variable} hostapd-service-type
  13527. This is the service type to run the @uref{https://w1.fi/hostapd/,
  13528. hostapd} daemon to set up WiFi (IEEE 802.11) access points and
  13529. authentication servers. Its associated value must be a
  13530. @code{hostapd-configuration} as shown below:
  13531. @lisp
  13532. ;; Use wlan1 to run the access point for "My Network".
  13533. (service hostapd-service-type
  13534. (hostapd-configuration
  13535. (interface "wlan1")
  13536. (ssid "My Network")
  13537. (channel 12)))
  13538. @end lisp
  13539. @end defvr
  13540. @deftp {Data Type} hostapd-configuration
  13541. This data type represents the configuration of the hostapd service, with
  13542. the following fields:
  13543. @table @asis
  13544. @item @code{package} (default: @code{hostapd})
  13545. The hostapd package to use.
  13546. @item @code{interface} (default: @code{"wlan0"})
  13547. The network interface to run the WiFi access point.
  13548. @item @code{ssid}
  13549. The SSID (@dfn{service set identifier}), a string that identifies this
  13550. network.
  13551. @item @code{broadcast-ssid?} (default: @code{#t})
  13552. Whether to broadcast this SSID.
  13553. @item @code{channel} (default: @code{1})
  13554. The WiFi channel to use.
  13555. @item @code{driver} (default: @code{"nl80211"})
  13556. The driver interface type. @code{"nl80211"} is used with all Linux
  13557. mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
  13558. RADIUS server that does # not control any wireless/wired driver.
  13559. @item @code{extra-settings} (default: @code{""})
  13560. Extra settings to append as-is to the hostapd configuration file. See
  13561. @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
  13562. configuration file reference.
  13563. @end table
  13564. @end deftp
  13565. @defvr {Scheme Variable} simulated-wifi-service-type
  13566. This is the type of a service to simulate WiFi networking, which can be
  13567. useful in virtual machines for testing purposes. The service loads the
  13568. Linux kernel
  13569. @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
  13570. @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
  13571. network that can be seen on @code{wlan0}, by default.
  13572. The service's value is a @code{hostapd-configuration} record.
  13573. @end defvr
  13574. @cindex iptables
  13575. @defvr {Scheme Variable} iptables-service-type
  13576. This is the service type to set up an iptables configuration. iptables is a
  13577. packet filtering framework supported by the Linux kernel. This service
  13578. supports configuring iptables for both IPv4 and IPv6. A simple example
  13579. configuration rejecting all incoming connections except those to the ssh port
  13580. 22 is shown below.
  13581. @lisp
  13582. (service iptables-service-type
  13583. (iptables-configuration
  13584. (ipv4-rules (plain-file "iptables.rules" "*filter
  13585. :INPUT ACCEPT
  13586. :FORWARD ACCEPT
  13587. :OUTPUT ACCEPT
  13588. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  13589. -A INPUT -p tcp --dport 22 -j ACCEPT
  13590. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  13591. COMMIT
  13592. "))
  13593. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  13594. :INPUT ACCEPT
  13595. :FORWARD ACCEPT
  13596. :OUTPUT ACCEPT
  13597. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  13598. -A INPUT -p tcp --dport 22 -j ACCEPT
  13599. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  13600. COMMIT
  13601. "))))
  13602. @end lisp
  13603. @end defvr
  13604. @deftp {Data Type} iptables-configuration
  13605. The data type representing the configuration of iptables.
  13606. @table @asis
  13607. @item @code{iptables} (default: @code{iptables})
  13608. The iptables package that provides @code{iptables-restore} and
  13609. @code{ip6tables-restore}.
  13610. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  13611. The iptables rules to use. It will be passed to @code{iptables-restore}.
  13612. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  13613. objects}).
  13614. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  13615. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  13616. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  13617. objects}).
  13618. @end table
  13619. @end deftp
  13620. @cindex nftables
  13621. @defvr {Scheme Variable} nftables-service-type
  13622. This is the service type to set up a nftables configuration. nftables is a
  13623. netfilter project that aims to replace the existing iptables, ip6tables,
  13624. arptables and ebtables framework. It provides a new packet filtering
  13625. framework, a new user-space utility @command{nft}, and a compatibility layer
  13626. for iptables. This service comes with a default ruleset
  13627. @code{%default-nftables-ruleset} that rejecting all incoming connections
  13628. except those to the ssh port 22. To use it, simply write:
  13629. @lisp
  13630. (service nftables-service-type)
  13631. @end lisp
  13632. @end defvr
  13633. @deftp {Data Type} nftables-configuration
  13634. The data type representing the configuration of nftables.
  13635. @table @asis
  13636. @item @code{package} (default: @code{nftables})
  13637. The nftables package that provides @command{nft}.
  13638. @item @code{ruleset} (default: @code{%default-nftables-ruleset})
  13639. The nftables ruleset to use. This may be any ``file-like'' object
  13640. (@pxref{G-Expressions, file-like objects}).
  13641. @end table
  13642. @end deftp
  13643. @cindex NTP (Network Time Protocol), service
  13644. @cindex ntpd, service for the Network Time Protocol daemon
  13645. @cindex real time clock
  13646. @defvr {Scheme Variable} ntp-service-type
  13647. This is the type of the service running the @uref{https://www.ntp.org,
  13648. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  13649. system clock synchronized with that of the specified NTP servers.
  13650. The value of this service is an @code{ntpd-configuration} object, as described
  13651. below.
  13652. @end defvr
  13653. @deftp {Data Type} ntp-configuration
  13654. This is the data type for the NTP service configuration.
  13655. @table @asis
  13656. @item @code{servers} (default: @code{%ntp-servers})
  13657. This is the list of servers (@code{<ntp-server>} records) with which
  13658. @command{ntpd} will be synchronized. See the @code{ntp-server} data type
  13659. definition below.
  13660. @item @code{allow-large-adjustment?} (default: @code{#t})
  13661. This determines whether @command{ntpd} is allowed to make an initial
  13662. adjustment of more than 1,000 seconds.
  13663. @item @code{ntp} (default: @code{ntp})
  13664. The NTP package to use.
  13665. @end table
  13666. @end deftp
  13667. @defvr {Scheme Variable} %ntp-servers
  13668. List of host names used as the default NTP servers. These are servers of the
  13669. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  13670. @end defvr
  13671. @deftp {Data Type} ntp-server
  13672. The data type representing the configuration of a NTP server.
  13673. @table @asis
  13674. @item @code{type} (default: @code{'server})
  13675. The type of the NTP server, given as a symbol. One of @code{'pool},
  13676. @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
  13677. @item @code{address}
  13678. The address of the server, as a string.
  13679. @item @code{options}
  13680. NTPD options to use with that specific server, given as a list of option names
  13681. and/or of option names and values tuples. The following example define a server
  13682. to use with the options @option{iburst} and @option{prefer}, as well as
  13683. @option{version} 3 and a @option{maxpoll} time of 16 seconds.
  13684. @example
  13685. (ntp-server
  13686. (type 'server)
  13687. (address "some.ntp.server.org")
  13688. (options `(iburst (version 3) (maxpoll 16) prefer))))
  13689. @end example
  13690. @end table
  13691. @end deftp
  13692. @cindex OpenNTPD
  13693. @deffn {Scheme Procedure} openntpd-service-type
  13694. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  13695. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  13696. clock synchronized with that of the given servers.
  13697. @lisp
  13698. (service
  13699. openntpd-service-type
  13700. (openntpd-configuration
  13701. (listen-on '("127.0.0.1" "::1"))
  13702. (sensor '("udcf0 correction 70000"))
  13703. (constraint-from '("www.gnu.org"))
  13704. (constraints-from '("https://www.google.com/"))))
  13705. @end lisp
  13706. @end deffn
  13707. @defvr {Scheme Variable} %openntpd-servers
  13708. This variable is a list of the server addresses defined in
  13709. @code{%ntp-servers}.
  13710. @end defvr
  13711. @deftp {Data Type} openntpd-configuration
  13712. @table @asis
  13713. @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
  13714. The openntpd executable to use.
  13715. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  13716. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  13717. @item @code{query-from} (default: @code{'()})
  13718. A list of local IP address the ntpd daemon should use for outgoing queries.
  13719. @item @code{sensor} (default: @code{'()})
  13720. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  13721. will listen to each sensor that actually exists and ignore non-existent ones.
  13722. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  13723. information.
  13724. @item @code{server} (default: @code{'()})
  13725. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  13726. @item @code{servers} (default: @code{%openntp-servers})
  13727. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  13728. @item @code{constraint-from} (default: @code{'()})
  13729. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  13730. This time information is not used for precision but acts as an authenticated
  13731. constraint, thereby reducing the impact of unauthenticated NTP
  13732. man-in-the-middle attacks.
  13733. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  13734. a constraint.
  13735. @item @code{constraints-from} (default: @code{'()})
  13736. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  13737. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  13738. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  13739. @end table
  13740. @end deftp
  13741. @cindex inetd
  13742. @deffn {Scheme variable} inetd-service-type
  13743. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  13744. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  13745. connections on internet sockets, and lazily starts the specified server
  13746. program when a connection is made on one of these sockets.
  13747. The value of this service is an @code{inetd-configuration} object. The
  13748. following example configures the @command{inetd} daemon to provide the
  13749. built-in @command{echo} service, as well as an smtp service which
  13750. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  13751. gateway @code{hostname}:
  13752. @lisp
  13753. (service
  13754. inetd-service-type
  13755. (inetd-configuration
  13756. (entries (list
  13757. (inetd-entry
  13758. (name "echo")
  13759. (socket-type 'stream)
  13760. (protocol "tcp")
  13761. (wait? #f)
  13762. (user "root"))
  13763. (inetd-entry
  13764. (node "127.0.0.1")
  13765. (name "smtp")
  13766. (socket-type 'stream)
  13767. (protocol "tcp")
  13768. (wait? #f)
  13769. (user "root")
  13770. (program (file-append openssh "/bin/ssh"))
  13771. (arguments
  13772. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  13773. "-W" "smtp-server:25" "user@@hostname")))))))
  13774. @end lisp
  13775. See below for more details about @code{inetd-configuration}.
  13776. @end deffn
  13777. @deftp {Data Type} inetd-configuration
  13778. Data type representing the configuration of @command{inetd}.
  13779. @table @asis
  13780. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  13781. The @command{inetd} executable to use.
  13782. @item @code{entries} (default: @code{'()})
  13783. A list of @command{inetd} service entries. Each entry should be created
  13784. by the @code{inetd-entry} constructor.
  13785. @end table
  13786. @end deftp
  13787. @deftp {Data Type} inetd-entry
  13788. Data type representing an entry in the @command{inetd} configuration.
  13789. Each entry corresponds to a socket where @command{inetd} will listen for
  13790. requests.
  13791. @table @asis
  13792. @item @code{node} (default: @code{#f})
  13793. Optional string, a comma-separated list of local addresses
  13794. @command{inetd} should use when listening for this service.
  13795. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  13796. description of all options.
  13797. @item @code{name}
  13798. A string, the name must correspond to an entry in @code{/etc/services}.
  13799. @item @code{socket-type}
  13800. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  13801. @code{'seqpacket}.
  13802. @item @code{protocol}
  13803. A string, must correspond to an entry in @code{/etc/protocols}.
  13804. @item @code{wait?} (default: @code{#t})
  13805. Whether @command{inetd} should wait for the server to exit before
  13806. listening to new service requests.
  13807. @item @code{user}
  13808. A string containing the user (and, optionally, group) name of the user
  13809. as whom the server should run. The group name can be specified in a
  13810. suffix, separated by a colon or period, i.e.@: @code{"user"},
  13811. @code{"user:group"} or @code{"user.group"}.
  13812. @item @code{program} (default: @code{"internal"})
  13813. The server program which will serve the requests, or @code{"internal"}
  13814. if @command{inetd} should use a built-in service.
  13815. @item @code{arguments} (default: @code{'()})
  13816. A list strings or file-like objects, which are the server program's
  13817. arguments, starting with the zeroth argument, i.e.@: the name of the
  13818. program itself. For @command{inetd}'s internal services, this entry
  13819. must be @code{'()} or @code{'("internal")}.
  13820. @end table
  13821. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  13822. detailed discussion of each configuration field.
  13823. @end deftp
  13824. @cindex opendht, distributed hash table network service
  13825. @cindex dhtproxy, for use with jami
  13826. @defvr {Scheme Variable} opendht-service-type
  13827. This is the type of the service running a @uref{https://opendht.net,
  13828. OpenDHT} node, @command{dhtnode}. The daemon can be used to host your
  13829. own proxy service to the distributed hash table (DHT), for example to
  13830. connect to with Jami, among other applications.
  13831. @quotation Important
  13832. When using the OpenDHT proxy server, the IP addresses it ``sees'' from
  13833. the clients should be addresses reachable from other peers. In practice
  13834. this means that a publicly reachable address is best suited for a proxy
  13835. server, outside of your private network. For example, hosting the proxy
  13836. server on a IPv4 private local network and exposing it via port
  13837. forwarding could work for external peers, but peers local to the proxy
  13838. would have their private addresses shared with the external peers,
  13839. leading to connectivity problems.
  13840. @end quotation
  13841. The value of this service is a @code{opendht-configuration} object, as
  13842. described below.
  13843. @end defvr
  13844. @deftp {Data Type} opendht-configuration
  13845. This is the data type for the OpenDHT service configuration.
  13846. @c The fields documentation has been auto-generated using the
  13847. @c configuration->documentation procedure from
  13848. @c (gnu services configuration).
  13849. Available @code{opendht-configuration} fields are:
  13850. @deftypevr {@code{opendht-configuration} parameter} package opendht
  13851. The @code{opendht} package to use.
  13852. @end deftypevr
  13853. @deftypevr {@code{opendht-configuration} parameter} boolean peer-discovery?
  13854. Whether to enable the multicast local peer discovery mechanism.
  13855. Defaults to @samp{#f}.
  13856. @end deftypevr
  13857. @deftypevr {@code{opendht-configuration} parameter} boolean enable-logging?
  13858. Whether to enable logging messages to syslog. It is disabled by default
  13859. as it is rather verbose.
  13860. Defaults to @samp{#f}.
  13861. @end deftypevr
  13862. @deftypevr {@code{opendht-configuration} parameter} boolean debug?
  13863. Whether to enable debug-level logging messages. This has no effect if
  13864. logging is disabled.
  13865. Defaults to @samp{#f}.
  13866. @end deftypevr
  13867. @deftypevr {@code{opendht-configuration} parameter} maybe-string bootstrap-host
  13868. The node host name that is used to make the first connection to the
  13869. network. A specific port value can be provided by appending the
  13870. @code{:PORT} suffix. By default, it uses the Jami bootstrap nodes, but
  13871. any host can be specified here. It's also possible to disable
  13872. bootsrapping by setting this to the @code{'disabled} symbol.
  13873. Defaults to @samp{"bootstrap.jami.net:4222"}.
  13874. @end deftypevr
  13875. @deftypevr {@code{opendht-configuration} parameter} maybe-number port
  13876. The UDP port to bind to. When set to @code{'disabled}, an available
  13877. port is automatically selected.
  13878. Defaults to @samp{4222}.
  13879. @end deftypevr
  13880. @deftypevr {@code{opendht-configuration} parameter} maybe-number proxy-server-port
  13881. Spawn a proxy server listening on the specified port.
  13882. Defaults to @samp{disabled}.
  13883. @end deftypevr
  13884. @deftypevr {@code{opendht-configuration} parameter} maybe-number proxy-server-port-tls
  13885. Spawn a proxy server listening to TLS connections on the specified port.
  13886. Defaults to @samp{disabled}.
  13887. @end deftypevr
  13888. @end deftp
  13889. @cindex Tor
  13890. @defvr {Scheme Variable} tor-service-type
  13891. This is the type for a service that runs the @uref{https://torproject.org,
  13892. Tor} anonymous networking daemon. The service is configured using a
  13893. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  13894. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  13895. @end defvr
  13896. @deftp {Data Type} tor-configuration
  13897. @table @asis
  13898. @item @code{tor} (default: @code{tor})
  13899. The package that provides the Tor daemon. This package is expected to provide
  13900. the daemon at @file{bin/tor} relative to its output directory. The default
  13901. package is the @uref{https://www.torproject.org, Tor Project's}
  13902. implementation.
  13903. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  13904. The configuration file to use. It will be appended to a default configuration
  13905. file, and the final configuration file will be passed to @code{tor} via its
  13906. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  13907. file-like objects}). See @code{man tor} for details on the configuration file
  13908. syntax.
  13909. @item @code{hidden-services} (default: @code{'()})
  13910. The list of @code{<hidden-service>} records to use. For any hidden service
  13911. you include in this list, appropriate configuration to enable the hidden
  13912. service will be automatically added to the default configuration file. You
  13913. may conveniently create @code{<hidden-service>} records using the
  13914. @code{tor-hidden-service} procedure described below.
  13915. @item @code{socks-socket-type} (default: @code{'tcp})
  13916. The default socket type that Tor should use for its SOCKS socket. This must
  13917. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  13918. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  13919. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  13920. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  13921. @code{tor} group.
  13922. If you want to customize the SOCKS socket in more detail, leave
  13923. @code{socks-socket-type} at its default value of @code{'tcp} and use
  13924. @code{config-file} to override the default by providing your own
  13925. @code{SocksPort} option.
  13926. @item @code{control-socket?} (default: @code{#f})
  13927. Whether or not to provide a ``control socket'' by which Tor can be
  13928. controlled to, for instance, dynamically instantiate tor onion services.
  13929. If @code{#t}, Tor will listen for control commands on the UNIX domain socket
  13930. @file{/var/run/tor/control-sock}, which will be made writable by members of the
  13931. @code{tor} group.
  13932. @end table
  13933. @end deftp
  13934. @cindex hidden service
  13935. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  13936. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  13937. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  13938. @example
  13939. '((22 "127.0.0.1:22")
  13940. (80 "127.0.0.1:8080"))
  13941. @end example
  13942. In this example, port 22 of the hidden service is mapped to local port 22, and
  13943. port 80 is mapped to local port 8080.
  13944. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  13945. the @file{hostname} file contains the @code{.onion} host name for the hidden
  13946. service.
  13947. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  13948. project's documentation} for more information.
  13949. @end deffn
  13950. The @code{(gnu services rsync)} module provides the following services:
  13951. You might want an rsync daemon if you have files that you want available
  13952. so anyone (or just yourself) can download existing files or upload new
  13953. files.
  13954. @deffn {Scheme Variable} rsync-service-type
  13955. This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
  13956. The value for this service type is a
  13957. @command{rsync-configuration} record as in this example:
  13958. @lisp
  13959. (service rsync-service-type)
  13960. @end lisp
  13961. See below for details about @code{rsync-configuration}.
  13962. @end deffn
  13963. @deftp {Data Type} rsync-configuration
  13964. Data type representing the configuration for @code{rsync-service}.
  13965. @table @asis
  13966. @item @code{package} (default: @var{rsync})
  13967. @code{rsync} package to use.
  13968. @item @code{port-number} (default: @code{873})
  13969. TCP port on which @command{rsync} listens for incoming connections. If port
  13970. is less than @code{1024} @command{rsync} needs to be started as the
  13971. @code{root} user and group.
  13972. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  13973. Name of the file where @command{rsync} writes its PID.
  13974. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  13975. Name of the file where @command{rsync} writes its lock file.
  13976. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  13977. Name of the file where @command{rsync} writes its log file.
  13978. @item @code{use-chroot?} (default: @var{#t})
  13979. Whether to use chroot for @command{rsync} shared directory.
  13980. @item @code{share-path} (default: @file{/srv/rsync})
  13981. Location of the @command{rsync} shared directory.
  13982. @item @code{share-comment} (default: @code{"Rsync share"})
  13983. Comment of the @command{rsync} shared directory.
  13984. @item @code{read-only?} (default: @var{#f})
  13985. Read-write permissions to shared directory.
  13986. @item @code{timeout} (default: @code{300})
  13987. I/O timeout in seconds.
  13988. @item @code{user} (default: @var{"root"})
  13989. Owner of the @code{rsync} process.
  13990. @item @code{group} (default: @var{"root"})
  13991. Group of the @code{rsync} process.
  13992. @item @code{uid} (default: @var{"rsyncd"})
  13993. User name or user ID that file transfers to and from that module should take
  13994. place as when the daemon was run as @code{root}.
  13995. @item @code{gid} (default: @var{"rsyncd"})
  13996. Group name or group ID that will be used when accessing the module.
  13997. @end table
  13998. @end deftp
  13999. The @code{(gnu services syncthing)} module provides the following services:
  14000. @cindex syncthing
  14001. You might want a syncthing daemon if you have files between two or more
  14002. computers and want to sync them in real time, safely protected from
  14003. prying eyes.
  14004. @deffn {Scheme Variable} syncthing-service-type
  14005. This is the service type for the @uref{https://syncthing.net/,
  14006. syncthing} daemon, The value for this service type is a
  14007. @command{syncthing-configuration} record as in this example:
  14008. @lisp
  14009. (service syncthing-service-type
  14010. (syncthing-configuration (user "alice")))
  14011. @end lisp
  14012. See below for details about @code{syncthing-configuration}.
  14013. @deftp {Data Type} syncthing-configuration
  14014. Data type representing the configuration for @code{syncthing-service-type}.
  14015. @table @asis
  14016. @item @code{syncthing} (default: @var{syncthing})
  14017. @code{syncthing} package to use.
  14018. @item @code{arguments} (default: @var{'()})
  14019. List of command-line arguments passing to @code{syncthing} binary.
  14020. @item @code{logflags} (default: @var{0})
  14021. Sum of logging flags, see
  14022. @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}.
  14023. @item @code{user} (default: @var{#f})
  14024. The user as which the Syncthing service is to be run.
  14025. This assumes that the specified user exists.
  14026. @item @code{group} (default: @var{"users"})
  14027. The group as which the Syncthing service is to be run.
  14028. This assumes that the specified group exists.
  14029. @item @code{home} (default: @var{#f})
  14030. Common configuration and data directory. The default configuration
  14031. directory is @file{$HOME} of the specified Syncthing @code{user}.
  14032. @end table
  14033. @end deftp
  14034. @end deffn
  14035. Furthermore, @code{(gnu services ssh)} provides the following services.
  14036. @cindex SSH
  14037. @cindex SSH server
  14038. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  14039. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  14040. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  14041. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  14042. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  14043. [#:public-key-authentication? #t] [#:initialize? #t]
  14044. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  14045. @var{host-key} must designate a file containing the host key, and readable
  14046. only by root.
  14047. When @var{daemonic?} is true, @command{lshd} will detach from the
  14048. controlling terminal and log its output to syslogd, unless one sets
  14049. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  14050. depend on existence of syslogd service. When @var{pid-file?} is true,
  14051. @command{lshd} writes its PID to the file called @var{pid-file}.
  14052. When @var{initialize?} is true, automatically create the seed and host key
  14053. upon service activation if they do not exist yet. This may take long and
  14054. require interaction.
  14055. When @var{initialize?} is false, it is up to the user to initialize the
  14056. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  14057. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  14058. basics,,, lsh, LSH Manual}).
  14059. When @var{interfaces} is empty, lshd listens for connections on all the
  14060. network interfaces; otherwise, @var{interfaces} must be a list of host names
  14061. or addresses.
  14062. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  14063. passwords, and @var{root-login?} specifies whether to accept log-ins as
  14064. root.
  14065. The other options should be self-descriptive.
  14066. @end deffn
  14067. @cindex SSH
  14068. @cindex SSH server
  14069. @deffn {Scheme Variable} openssh-service-type
  14070. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  14071. shell daemon, @command{sshd}. Its value must be an
  14072. @code{openssh-configuration} record as in this example:
  14073. @lisp
  14074. (service openssh-service-type
  14075. (openssh-configuration
  14076. (x11-forwarding? #t)
  14077. (permit-root-login 'prohibit-password)
  14078. (authorized-keys
  14079. `(("alice" ,(local-file "alice.pub"))
  14080. ("bob" ,(local-file "bob.pub"))))))
  14081. @end lisp
  14082. See below for details about @code{openssh-configuration}.
  14083. This service can be extended with extra authorized keys, as in this
  14084. example:
  14085. @lisp
  14086. (service-extension openssh-service-type
  14087. (const `(("charlie"
  14088. ,(local-file "charlie.pub")))))
  14089. @end lisp
  14090. @end deffn
  14091. @deftp {Data Type} openssh-configuration
  14092. This is the configuration record for OpenSSH's @command{sshd}.
  14093. @table @asis
  14094. @item @code{openssh} (default @var{openssh})
  14095. The Openssh package to use.
  14096. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  14097. Name of the file where @command{sshd} writes its PID.
  14098. @item @code{port-number} (default: @code{22})
  14099. TCP port on which @command{sshd} listens for incoming connections.
  14100. @item @code{permit-root-login} (default: @code{#f})
  14101. This field determines whether and when to allow logins as root. If
  14102. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  14103. If it's the symbol @code{'prohibit-password}, then root logins are
  14104. permitted but not with password-based authentication.
  14105. @item @code{allow-empty-passwords?} (default: @code{#f})
  14106. When true, users with empty passwords may log in. When false, they may
  14107. not.
  14108. @item @code{password-authentication?} (default: @code{#t})
  14109. When true, users may log in with their password. When false, they have
  14110. other authentication methods.
  14111. @item @code{public-key-authentication?} (default: @code{#t})
  14112. When true, users may log in using public key authentication. When
  14113. false, users have to use other authentication method.
  14114. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  14115. This is used only by protocol version 2.
  14116. @item @code{x11-forwarding?} (default: @code{#f})
  14117. When true, forwarding of X11 graphical client connections is
  14118. enabled---in other words, @command{ssh} options @option{-X} and
  14119. @option{-Y} will work.
  14120. @item @code{allow-agent-forwarding?} (default: @code{#t})
  14121. Whether to allow agent forwarding.
  14122. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  14123. Whether to allow TCP forwarding.
  14124. @item @code{gateway-ports?} (default: @code{#f})
  14125. Whether to allow gateway ports.
  14126. @item @code{challenge-response-authentication?} (default: @code{#f})
  14127. Specifies whether challenge response authentication is allowed (e.g.@: via
  14128. PAM).
  14129. @item @code{use-pam?} (default: @code{#t})
  14130. Enables the Pluggable Authentication Module interface. If set to
  14131. @code{#t}, this will enable PAM authentication using
  14132. @code{challenge-response-authentication?} and
  14133. @code{password-authentication?}, in addition to PAM account and session
  14134. module processing for all authentication types.
  14135. Because PAM challenge response authentication usually serves an
  14136. equivalent role to password authentication, you should disable either
  14137. @code{challenge-response-authentication?} or
  14138. @code{password-authentication?}.
  14139. @item @code{print-last-log?} (default: @code{#t})
  14140. Specifies whether @command{sshd} should print the date and time of the
  14141. last user login when a user logs in interactively.
  14142. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  14143. Configures external subsystems (e.g.@: file transfer daemon).
  14144. This is a list of two-element lists, each of which containing the
  14145. subsystem name and a command (with optional arguments) to execute upon
  14146. subsystem request.
  14147. The command @command{internal-sftp} implements an in-process SFTP
  14148. server. Alternatively, one can specify the @command{sftp-server} command:
  14149. @lisp
  14150. (service openssh-service-type
  14151. (openssh-configuration
  14152. (subsystems
  14153. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  14154. @end lisp
  14155. @item @code{accepted-environment} (default: @code{'()})
  14156. List of strings describing which environment variables may be exported.
  14157. Each string gets on its own line. See the @code{AcceptEnv} option in
  14158. @code{man sshd_config}.
  14159. This example allows ssh-clients to export the @env{COLORTERM} variable.
  14160. It is set by terminal emulators, which support colors. You can use it in
  14161. your shell's resource file to enable colors for the prompt and commands
  14162. if this variable is set.
  14163. @lisp
  14164. (service openssh-service-type
  14165. (openssh-configuration
  14166. (accepted-environment '("COLORTERM"))))
  14167. @end lisp
  14168. @item @code{authorized-keys} (default: @code{'()})
  14169. @cindex authorized keys, SSH
  14170. @cindex SSH authorized keys
  14171. This is the list of authorized keys. Each element of the list is a user
  14172. name followed by one or more file-like objects that represent SSH public
  14173. keys. For example:
  14174. @lisp
  14175. (openssh-configuration
  14176. (authorized-keys
  14177. `(("rekado" ,(local-file "rekado.pub"))
  14178. ("chris" ,(local-file "chris.pub"))
  14179. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  14180. @end lisp
  14181. @noindent
  14182. registers the specified public keys for user accounts @code{rekado},
  14183. @code{chris}, and @code{root}.
  14184. Additional authorized keys can be specified @i{via}
  14185. @code{service-extension}.
  14186. Note that this does @emph{not} interfere with the use of
  14187. @file{~/.ssh/authorized_keys}.
  14188. @item @code{log-level} (default: @code{'info})
  14189. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  14190. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  14191. page for @file{sshd_config} for the full list of level names.
  14192. @item @code{extra-content} (default: @code{""})
  14193. This field can be used to append arbitrary text to the configuration file. It
  14194. is especially useful for elaborate configurations that cannot be expressed
  14195. otherwise. This configuration, for example, would generally disable root
  14196. logins, but permit them from one specific IP address:
  14197. @lisp
  14198. (openssh-configuration
  14199. (extra-content "\
  14200. Match Address 192.168.0.1
  14201. PermitRootLogin yes"))
  14202. @end lisp
  14203. @end table
  14204. @end deftp
  14205. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  14206. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  14207. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  14208. object.
  14209. For example, to specify a Dropbear service listening on port 1234, add
  14210. this call to the operating system's @code{services} field:
  14211. @lisp
  14212. (dropbear-service (dropbear-configuration
  14213. (port-number 1234)))
  14214. @end lisp
  14215. @end deffn
  14216. @deftp {Data Type} dropbear-configuration
  14217. This data type represents the configuration of a Dropbear SSH daemon.
  14218. @table @asis
  14219. @item @code{dropbear} (default: @var{dropbear})
  14220. The Dropbear package to use.
  14221. @item @code{port-number} (default: 22)
  14222. The TCP port where the daemon waits for incoming connections.
  14223. @item @code{syslog-output?} (default: @code{#t})
  14224. Whether to enable syslog output.
  14225. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  14226. File name of the daemon's PID file.
  14227. @item @code{root-login?} (default: @code{#f})
  14228. Whether to allow @code{root} logins.
  14229. @item @code{allow-empty-passwords?} (default: @code{#f})
  14230. Whether to allow empty passwords.
  14231. @item @code{password-authentication?} (default: @code{#t})
  14232. Whether to enable password-based authentication.
  14233. @end table
  14234. @end deftp
  14235. @cindex AutoSSH
  14236. @deffn {Scheme Variable} autossh-service-type
  14237. This is the type for the @uref{https://www.harding.motd.ca/autossh,
  14238. AutoSSH} program that runs a copy of @command{ssh} and monitors it,
  14239. restarting it as necessary should it die or stop passing traffic.
  14240. AutoSSH can be run manually from the command-line by passing arguments
  14241. to the binary @command{autossh} from the package @code{autossh}, but it
  14242. can also be run as a Guix service. This latter use case is documented
  14243. here.
  14244. AutoSSH can be used to forward local traffic to a remote machine using
  14245. an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
  14246. is run as.
  14247. For example, to specify a service running autossh as the user
  14248. @code{pino} and forwarding all local connections to port @code{8081} to
  14249. @code{remote:8081} using an SSH tunnel, add this call to the operating
  14250. system's @code{services} field:
  14251. @lisp
  14252. (service autossh-service-type
  14253. (autossh-configuration
  14254. (user "pino")
  14255. (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
  14256. @end lisp
  14257. @end deffn
  14258. @deftp {Data Type} autossh-configuration
  14259. This data type represents the configuration of an AutoSSH service.
  14260. @table @asis
  14261. @item @code{user} (default @code{"autossh"})
  14262. The user as which the AutoSSH service is to be run.
  14263. This assumes that the specified user exists.
  14264. @item @code{poll} (default @code{600})
  14265. Specifies the connection poll time in seconds.
  14266. @item @code{first-poll} (default @code{#f})
  14267. Specifies how many seconds AutoSSH waits before the first connection
  14268. test. After this first test, polling is resumed at the pace defined in
  14269. @code{poll}. When set to @code{#f}, the first poll is not treated
  14270. specially and will also use the connection poll specified in
  14271. @code{poll}.
  14272. @item @code{gate-time} (default @code{30})
  14273. Specifies how many seconds an SSH connection must be active before it is
  14274. considered successful.
  14275. @item @code{log-level} (default @code{1})
  14276. The log level, corresponding to the levels used by syslog---so @code{0}
  14277. is the most silent while @code{7} is the chattiest.
  14278. @item @code{max-start} (default @code{#f})
  14279. The maximum number of times SSH may be (re)started before AutoSSH exits.
  14280. When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
  14281. @item @code{message} (default @code{""})
  14282. The message to append to the echo message sent when testing connections.
  14283. @item @code{port} (default @code{"0"})
  14284. The ports used for monitoring the connection. When set to @code{"0"},
  14285. monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
  14286. a positive integer, ports @var{n} and @var{n}+1 are used for
  14287. monitoring the connection, such that port @var{n} is the base
  14288. monitoring port and @code{n+1} is the echo port. When set to
  14289. @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
  14290. integers, the ports @var{n} and @var{m} are used for monitoring the
  14291. connection, such that port @var{n} is the base monitoring port and
  14292. @var{m} is the echo port.
  14293. @item @code{ssh-options} (default @code{'()})
  14294. The list of command-line arguments to pass to @command{ssh} when it is
  14295. run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
  14296. may cause undefined behaviour.
  14297. @end table
  14298. @end deftp
  14299. @cindex WebSSH
  14300. @deffn {Scheme Variable} webssh-service-type
  14301. This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
  14302. program that runs a web SSH client. WebSSH can be run manually from the
  14303. command-line by passing arguments to the binary @command{wssh} from the
  14304. package @code{webssh}, but it can also be run as a Guix service. This
  14305. latter use case is documented here.
  14306. For example, to specify a service running WebSSH on loopback interface
  14307. on port @code{8888} with reject policy with a list of allowed to
  14308. connection hosts, and NGINX as a reverse-proxy to this service listening
  14309. for HTTPS connection, add this call to the operating system's
  14310. @code{services} field:
  14311. @lisp
  14312. (service webssh-service-type
  14313. (webssh-configuration (address "127.0.0.1")
  14314. (port 8888)
  14315. (policy 'reject)
  14316. (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
  14317. "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
  14318. (service nginx-service-type
  14319. (nginx-configuration
  14320. (server-blocks
  14321. (list
  14322. (nginx-server-configuration
  14323. (inherit %webssh-configuration-nginx)
  14324. (server-name '("webssh.example.com"))
  14325. (listen '("443 ssl"))
  14326. (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
  14327. (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
  14328. (locations
  14329. (cons (nginx-location-configuration
  14330. (uri "/.well-known")
  14331. (body '("root /var/www;")))
  14332. (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
  14333. @end lisp
  14334. @end deffn
  14335. @deftp {Data Type} webssh-configuration
  14336. Data type representing the configuration for @code{webssh-service}.
  14337. @table @asis
  14338. @item @code{package} (default: @var{webssh})
  14339. @code{webssh} package to use.
  14340. @item @code{user-name} (default: @var{"webssh"})
  14341. User name or user ID that file transfers to and from that module should take
  14342. place.
  14343. @item @code{group-name} (default: @var{"webssh"})
  14344. Group name or group ID that will be used when accessing the module.
  14345. @item @code{address} (default: @var{#f})
  14346. IP address on which @command{webssh} listens for incoming connections.
  14347. @item @code{port} (default: @var{8888})
  14348. TCP port on which @command{webssh} listens for incoming connections.
  14349. @item @code{policy} (default: @var{#f})
  14350. Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
  14351. @item @code{known-hosts} (default: @var{'()})
  14352. List of hosts which allowed for SSH connection from @command{webssh}.
  14353. @item @code{log-file} (default: @file{"/var/log/webssh.log"})
  14354. Name of the file where @command{webssh} writes its log file.
  14355. @item @code{log-level} (default: @var{#f})
  14356. Logging level.
  14357. @end table
  14358. @end deftp
  14359. @defvr {Scheme Variable} %facebook-host-aliases
  14360. This variable contains a string for use in @file{/etc/hosts}
  14361. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  14362. line contains a entry that maps a known server name of the Facebook
  14363. on-line service---e.g., @code{www.facebook.com}---to the local
  14364. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  14365. This variable is typically used in the @code{hosts-file} field of an
  14366. @code{operating-system} declaration (@pxref{operating-system Reference,
  14367. @file{/etc/hosts}}):
  14368. @lisp
  14369. (use-modules (gnu) (guix))
  14370. (operating-system
  14371. (host-name "mymachine")
  14372. ;; ...
  14373. (hosts-file
  14374. ;; Create a /etc/hosts file with aliases for "localhost"
  14375. ;; and "mymachine", as well as for Facebook servers.
  14376. (plain-file "hosts"
  14377. (string-append (local-host-aliases host-name)
  14378. %facebook-host-aliases))))
  14379. @end lisp
  14380. This mechanism can prevent programs running locally, such as Web
  14381. browsers, from accessing Facebook.
  14382. @end defvr
  14383. The @code{(gnu services avahi)} provides the following definition.
  14384. @defvr {Scheme Variable} avahi-service-type
  14385. This is the service that runs @command{avahi-daemon}, a system-wide
  14386. mDNS/DNS-SD responder that allows for service discovery and
  14387. ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
  14388. Its value must be an @code{avahi-configuration} record---see below.
  14389. This service extends the name service cache daemon (nscd) so that it can
  14390. resolve @code{.local} host names using
  14391. @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
  14392. Service Switch}, for information on host name resolution.
  14393. Additionally, add the @var{avahi} package to the system profile so that
  14394. commands such as @command{avahi-browse} are directly usable.
  14395. @end defvr
  14396. @deftp {Data Type} avahi-configuration
  14397. Data type representation the configuration for Avahi.
  14398. @table @asis
  14399. @item @code{host-name} (default: @code{#f})
  14400. If different from @code{#f}, use that as the host name to
  14401. publish for this machine; otherwise, use the machine's actual host name.
  14402. @item @code{publish?} (default: @code{#t})
  14403. When true, allow host names and services to be published (broadcast) over the
  14404. network.
  14405. @item @code{publish-workstation?} (default: @code{#t})
  14406. When true, @command{avahi-daemon} publishes the machine's host name and IP
  14407. address via mDNS on the local network. To view the host names published on
  14408. your local network, you can run:
  14409. @example
  14410. avahi-browse _workstation._tcp
  14411. @end example
  14412. @item @code{wide-area?} (default: @code{#f})
  14413. When true, DNS-SD over unicast DNS is enabled.
  14414. @item @code{ipv4?} (default: @code{#t})
  14415. @itemx @code{ipv6?} (default: @code{#t})
  14416. These fields determine whether to use IPv4/IPv6 sockets.
  14417. @item @code{domains-to-browse} (default: @code{'()})
  14418. This is a list of domains to browse.
  14419. @end table
  14420. @end deftp
  14421. @deffn {Scheme Variable} openvswitch-service-type
  14422. This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
  14423. service, whose value should be an @code{openvswitch-configuration}
  14424. object.
  14425. @end deffn
  14426. @deftp {Data Type} openvswitch-configuration
  14427. Data type representing the configuration of Open vSwitch, a multilayer
  14428. virtual switch which is designed to enable massive network automation
  14429. through programmatic extension.
  14430. @table @asis
  14431. @item @code{package} (default: @var{openvswitch})
  14432. Package object of the Open vSwitch.
  14433. @end table
  14434. @end deftp
  14435. @defvr {Scheme Variable} pagekite-service-type
  14436. This is the service type for the @uref{https://pagekite.net, PageKite} service,
  14437. a tunneling solution for making localhost servers publicly visible, even from
  14438. behind restrictive firewalls or NAT without forwarded ports. The value for
  14439. this service type is a @code{pagekite-configuration} record.
  14440. Here's an example exposing the local HTTP and SSH daemons:
  14441. @lisp
  14442. (service pagekite-service-type
  14443. (pagekite-configuration
  14444. (kites '("http:@@kitename:localhost:80:@@kitesecret"
  14445. "raw/22:@@kitename:localhost:22:@@kitesecret"))
  14446. (extra-file "/etc/pagekite.rc")))
  14447. @end lisp
  14448. @end defvr
  14449. @deftp {Data Type} pagekite-configuration
  14450. Data type representing the configuration of PageKite.
  14451. @table @asis
  14452. @item @code{package} (default: @var{pagekite})
  14453. Package object of PageKite.
  14454. @item @code{kitename} (default: @code{#f})
  14455. PageKite name for authenticating to the frontend server.
  14456. @item @code{kitesecret} (default: @code{#f})
  14457. Shared secret for authenticating to the frontend server. You should probably
  14458. put this inside @code{extra-file} instead.
  14459. @item @code{frontend} (default: @code{#f})
  14460. Connect to the named PageKite frontend server instead of the
  14461. @uref{https://pagekite.net,,pagekite.net} service.
  14462. @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
  14463. List of service kites to use. Exposes HTTP on port 80 by default. The format
  14464. is @code{proto:kitename:host:port:secret}.
  14465. @item @code{extra-file} (default: @code{#f})
  14466. Extra configuration file to read, which you are expected to create manually.
  14467. Use this to add additional options and manage shared secrets out-of-band.
  14468. @end table
  14469. @end deftp
  14470. @defvr {Scheme Variable} yggdrasil-service-type
  14471. The service type for connecting to the @uref{https://yggdrasil-network.github.io/,
  14472. Yggdrasil network}, an early-stage implementation of a fully end-to-end
  14473. encrypted IPv6 network.
  14474. @quotation
  14475. Yggdrasil provides name-independent routing with cryptographically generated
  14476. addresses. Static addressing means you can keep the same address as long as
  14477. you want, even if you move to a new location, or generate a new address (by
  14478. generating new keys) whenever you want.
  14479. @uref{https://yggdrasil-network.github.io/2018/07/28/addressing.html}
  14480. @end quotation
  14481. Pass it a value of @code{yggdrasil-configuration} to connect it to public
  14482. peers and/or local peers.
  14483. Here is an example using public peers and a static address. The static
  14484. signing and encryption keys are defined in @file{/etc/yggdrasil-private.conf}
  14485. (the default value for @code{config-file}).
  14486. @lisp
  14487. ;; part of the operating-system declaration
  14488. (service yggdrasil-service-type
  14489. (yggdrasil-configuration
  14490. (autoconf? #f) ;; use only the public peers
  14491. (json-config
  14492. ;; choose one from
  14493. ;; https://github.com/yggdrasil-network/public-peers
  14494. '((peers . #("tcp://1.2.3.4:1337"))))
  14495. ;; /etc/yggdrasil-private.conf is the default value for config-file
  14496. ))
  14497. @end lisp
  14498. @example
  14499. # sample content for /etc/yggdrasil-private.conf
  14500. @{
  14501. # Your public encryption key. Your peers may ask you for this to put
  14502. # into their AllowedEncryptionPublicKeys configuration.
  14503. EncryptionPublicKey: 378dc5...
  14504. # Your private encryption key. DO NOT share this with anyone!
  14505. EncryptionPrivateKey: 0777...
  14506. # Your public signing key. You should not ordinarily need to share
  14507. # this with anyone.
  14508. SigningPublicKey: e1664...
  14509. # Your private signing key. DO NOT share this with anyone!
  14510. SigningPrivateKey: 0589d...
  14511. @}
  14512. @end example
  14513. @end defvr
  14514. @deftp {Data Type} yggdrasil-configuration
  14515. Data type representing the configuration of Yggdrasil.
  14516. @table @asis
  14517. @item @code{package} (default: @code{yggdrasil})
  14518. Package object of Yggdrasil.
  14519. @item @code{json-config} (default: @code{'()})
  14520. Contents of @file{/etc/yggdrasil.conf}. Will be merged with
  14521. @file{/etc/yggdrasil-private.conf}. Note that these settings are stored in
  14522. the Guix store, which is readable to all users. @strong{Do not store your
  14523. private keys in it}. See the output of @code{yggdrasil -genconf} for a
  14524. quick overview of valid keys and their default values.
  14525. @item @code{autoconf?} (default: @code{#f})
  14526. Whether to use automatic mode. Enabling it makes Yggdrasil use adynamic IP
  14527. and peer with IPv6 neighbors.
  14528. @item @code{log-level} (default: @code{'info})
  14529. How much detail to include in logs. Use @code{'debug} for more detail.
  14530. @item @code{log-to} (default: @code{'stdout})
  14531. Where to send logs. By default, the service logs standard output to
  14532. @file{/var/log/yggdrasil.log}. The alternative is @code{'syslog}, which
  14533. sends output to the running syslog service.
  14534. @item @code{config-file} (default: @code{"/etc/yggdrasil-private.conf"})
  14535. What HJSON file to load sensitive data from. This is where private keys
  14536. should be stored, which are necessary to specify if you don't want a
  14537. randomized address after each restart. Use @code{#f} to disable. Options
  14538. defined in this file take precedence over @code{json-config}. Use the output
  14539. of @code{yggdrasil -genconf} as a starting point. To configure a static
  14540. address, delete everything except these options:
  14541. @itemize
  14542. @item @code{EncryptionPublicKey}
  14543. @item @code{EncryptionPrivateKey}
  14544. @item @code{SigningPublicKey}
  14545. @item @code{SigningPrivateKey}
  14546. @end itemize
  14547. @end table
  14548. @end deftp
  14549. @cindex IPFS
  14550. @defvr {Scheme Variable} ipfs-service-type
  14551. The service type for connecting to the @uref{https://ipfs.io,IPFS network},
  14552. a global, versioned, peer-to-peer file system. Pass it a
  14553. @code{ipfs-configuration} to change the ports used for the gateway and API.
  14554. Here's an example configuration, using some non-standard ports:
  14555. @lisp
  14556. (service ipfs-service-type
  14557. (ipfs-configuration
  14558. (gateway "/ip4/127.0.0.1/tcp/8880")
  14559. (api "/ip4/127.0.0.1/tcp/8881")))
  14560. @end lisp
  14561. @end defvr
  14562. @deftp {Data Type} ipfs-configuration
  14563. Data type representing the configuration of IPFS.
  14564. @table @asis
  14565. @item @code{package} (default: @code{go-ipfs})
  14566. Package object of IPFS.
  14567. @item @code{gateway} (default: @code{"/ip4/127.0.0.1/tcp/8082"})
  14568. Address of the gateway, in ‘multiaddress’ format.
  14569. @item @code{api} (default: @code{"/ip4/127.0.0.1/tcp/5001"})
  14570. Address of the API endpoint, in ‘multiaddress’ format.
  14571. @end table
  14572. @end deftp
  14573. @cindex keepalived
  14574. @deffn {Scheme Variable} keepalived-service-type
  14575. This is the type for the @uref{https://www.keepalived.org/, Keepalived}
  14576. routing software, @command{keepalived}. Its value must be an
  14577. @code{keepalived-configuration} record as in this example for master
  14578. machine:
  14579. @lisp
  14580. (service keepalived-service-type
  14581. (keepalived-configuration
  14582. (config-file (local-file "keepalived-master.conf"))))
  14583. @end lisp
  14584. where @file{keepalived-master.conf}:
  14585. @example
  14586. vrrp_instance my-group @{
  14587. state MASTER
  14588. interface enp9s0
  14589. virtual_router_id 100
  14590. priority 100
  14591. unicast_peer @{ 10.0.0.2 @}
  14592. virtual_ipaddress @{
  14593. 10.0.0.4/24
  14594. @}
  14595. @}
  14596. @end example
  14597. and for backup machine:
  14598. @lisp
  14599. (service keepalived-service-type
  14600. (keepalived-configuration
  14601. (config-file (local-file "keepalived-backup.conf"))))
  14602. @end lisp
  14603. where @file{keepalived-backup.conf}:
  14604. @example
  14605. vrrp_instance my-group @{
  14606. state BACKUP
  14607. interface enp9s0
  14608. virtual_router_id 100
  14609. priority 99
  14610. unicast_peer @{ 10.0.0.3 @}
  14611. virtual_ipaddress @{
  14612. 10.0.0.4/24
  14613. @}
  14614. @}
  14615. @end example
  14616. @end deffn
  14617. @node Unattended Upgrades
  14618. @subsection Unattended Upgrades
  14619. @cindex unattended upgrades
  14620. @cindex upgrades, unattended
  14621. Guix provides a service to perform @emph{unattended upgrades}:
  14622. periodically, the system automatically reconfigures itself from the
  14623. latest Guix. Guix System has several properties that make unattended
  14624. upgrades safe:
  14625. @itemize
  14626. @item
  14627. upgrades are transactional (either the upgrade succeeds or it fails, but
  14628. you cannot end up with an ``in-between'' system state);
  14629. @item
  14630. the upgrade log is kept---you can view it with @command{guix system
  14631. list-generations}---and you can roll back to any previous generation,
  14632. should the upgraded system fail to behave as intended;
  14633. @item
  14634. channel code is authenticated so you know you can only run genuine code
  14635. (@pxref{Channels});
  14636. @item
  14637. @command{guix system reconfigure} prevents downgrades, which makes it
  14638. immune to @dfn{downgrade attacks}.
  14639. @end itemize
  14640. To set up unattended upgrades, add an instance of
  14641. @code{unattended-upgrade-service-type} like the one below to the list of
  14642. your operating system services:
  14643. @lisp
  14644. (service unattended-upgrade-service-type)
  14645. @end lisp
  14646. The defaults above set up weekly upgrades: every Sunday at midnight.
  14647. You do not need to provide the operating system configuration file: it
  14648. uses @file{/run/current-system/configuration.scm}, which ensures it
  14649. always uses your latest configuration---@pxref{provenance-service-type},
  14650. for more information about this file.
  14651. There are several things that can be configured, in particular the
  14652. periodicity and services (daemons) to be restarted upon completion.
  14653. When the upgrade is successful, the service takes care of deleting
  14654. system generations older that some threshold, as per @command{guix
  14655. system delete-generations}. See the reference below for details.
  14656. To ensure that upgrades are actually happening, you can run
  14657. @command{guix system describe}. To investigate upgrade failures, visit
  14658. the unattended upgrade log file (see below).
  14659. @defvr {Scheme Variable} unattended-upgrade-service-type
  14660. This is the service type for unattended upgrades. It sets up an mcron
  14661. job (@pxref{Scheduled Job Execution}) that runs @command{guix system
  14662. reconfigure} from the latest version of the specified channels.
  14663. Its value must be a @code{unattended-upgrade-configuration} record (see
  14664. below).
  14665. @end defvr
  14666. @deftp {Data Type} unattended-upgrade-configuration
  14667. This data type represents the configuration of the unattended upgrade
  14668. service. The following fields are available:
  14669. @table @asis
  14670. @item @code{schedule} (default: @code{"30 01 * * 0"})
  14671. This is the schedule of upgrades, expressed as a gexp containing an
  14672. mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
  14673. mcron, GNU@tie{}mcron}).
  14674. @item @code{channels} (default: @code{#~%default-channels})
  14675. This gexp specifies the channels to use for the upgrade
  14676. (@pxref{Channels}). By default, the tip of the official @code{guix}
  14677. channel is used.
  14678. @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
  14679. This field specifies the operating system configuration file to use.
  14680. The default is to reuse the config file of the current configuration.
  14681. There are cases, though, where referring to
  14682. @file{/run/current-system/configuration.scm} is not enough, for instance
  14683. because that file refers to extra files (SSH public keys, extra
  14684. configuration files, etc.) @i{via} @code{local-file} and similar
  14685. constructs. For those cases, we recommend something along these lines:
  14686. @lisp
  14687. (unattended-upgrade-configuration
  14688. (operating-system-file
  14689. (file-append (local-file "." "config-dir" #:recursive? #t)
  14690. "/config.scm")))
  14691. @end lisp
  14692. The effect here is to import all of the current directory into the
  14693. store, and to refer to @file{config.scm} within that directory.
  14694. Therefore, uses of @code{local-file} within @file{config.scm} will work
  14695. as expected. @xref{G-Expressions}, for information about
  14696. @code{local-file} and @code{file-append}.
  14697. @item @code{services-to-restart} (default: @code{'(mcron)})
  14698. This field specifies the Shepherd services to restart when the upgrade
  14699. completes.
  14700. Those services are restarted right away upon completion, as with
  14701. @command{herd restart}, which ensures that the latest version is
  14702. running---remember that by default @command{guix system reconfigure}
  14703. only restarts services that are not currently running, which is
  14704. conservative: it minimizes disruption but leaves outdated services
  14705. running.
  14706. Use @command{herd status} to find out candidates for restarting.
  14707. @xref{Services}, for general information about services. Common
  14708. services to restart would include @code{ntpd} and @code{ssh-daemon}.
  14709. By default, the @code{mcron} service is restarted. This ensures that
  14710. the latest version of the unattended upgrade job will be used next time.
  14711. @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
  14712. This is the expiration time in seconds for system generations. System
  14713. generations older that this amount of time are deleted with
  14714. @command{guix system delete-generations} when an upgrade completes.
  14715. @quotation Note
  14716. The unattended upgrade service does not run the garbage collector. You
  14717. will probably want to set up your own mcron job to run @command{guix gc}
  14718. periodically.
  14719. @end quotation
  14720. @item @code{maximum-duration} (default: @code{3600})
  14721. Maximum duration in seconds for the upgrade; past that time, the upgrade
  14722. aborts.
  14723. This is primarily useful to ensure the upgrade does not end up
  14724. rebuilding or re-downloading ``the world''.
  14725. @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
  14726. File where unattended upgrades are logged.
  14727. @end table
  14728. @end deftp
  14729. @node X Window
  14730. @subsection X Window
  14731. @cindex X11
  14732. @cindex X Window System
  14733. @cindex login manager
  14734. Support for the X Window graphical display system---specifically
  14735. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  14736. there is no @code{xorg-service} procedure. Instead, the X server is
  14737. started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
  14738. @cindex GDM
  14739. @cindex GNOME, login manager
  14740. GDM of course allows users to log in into window managers and desktop
  14741. environments other than GNOME; for those using GNOME, GDM is required for
  14742. features such as automatic screen locking.
  14743. @cindex window manager
  14744. To use X11, you must install at least one @dfn{window manager}---for
  14745. example the @code{windowmaker} or @code{openbox} packages---preferably
  14746. by adding it to the @code{packages} field of your operating system
  14747. definition (@pxref{operating-system Reference, system-wide packages}).
  14748. @anchor{wayland-gdm}
  14749. GDM also supports Wayland: it can itself use Wayland instead of X11 for
  14750. its user interface, and it can also start Wayland sessions. The former is
  14751. required for the latter, to enable, set @code{wayland?} to @code{#t} in
  14752. @code{gdm-configuration}.
  14753. @defvr {Scheme Variable} gdm-service-type
  14754. This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
  14755. Desktop Manager} (GDM), a program that manages graphical display servers and
  14756. handles graphical user logins. Its value must be a @code{gdm-configuration}
  14757. (see below).
  14758. @cindex session types
  14759. GDM looks for @dfn{session types} described by the @file{.desktop} files in
  14760. @file{/run/current-system/profile/share/xsessions} (for X11 sessions) and
  14761. @file{/run/current-system/profile/share/wayland-sessions} (for Wayland
  14762. sessions) and allows users to choose a session from the log-in screen.
  14763. Packages such as @code{gnome}, @code{xfce}, @code{i3} and @code{sway} provide
  14764. @file{.desktop} files; adding them to the system-wide set of packages
  14765. automatically makes them available at the log-in screen.
  14766. In addition, @file{~/.xsession} files are honored. When available,
  14767. @file{~/.xsession} must be an executable that starts a window manager
  14768. and/or other X clients.
  14769. @end defvr
  14770. @deftp {Data Type} gdm-configuration
  14771. @table @asis
  14772. @item @code{auto-login?} (default: @code{#f})
  14773. @itemx @code{default-user} (default: @code{#f})
  14774. When @code{auto-login?} is false, GDM presents a log-in screen.
  14775. When @code{auto-login?} is true, GDM logs in directly as
  14776. @code{default-user}.
  14777. @item @code{debug?} (default: @code{#f})
  14778. When true, GDM writes debug messages to its log.
  14779. @item @code{gnome-shell-assets} (default: ...)
  14780. List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
  14781. @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
  14782. Configuration of the Xorg graphical server.
  14783. @item @code{xsession} (default: @code{(xinitrc)})
  14784. Script to run before starting a X session.
  14785. @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
  14786. File name of the @code{dbus-daemon} executable.
  14787. @item @code{gdm} (default: @code{gdm})
  14788. The GDM package to use.
  14789. @item @code{wayland?} (default: @code{#f})
  14790. When true, enables Wayland in GDM, necessary to use Wayland sessions.
  14791. @item @code{wayland-session} (default: @code{gdm-wayland-session-wrapper})
  14792. The Wayland session wrapper to use, needed to setup the
  14793. environment.
  14794. @end table
  14795. @end deftp
  14796. @defvr {Scheme Variable} slim-service-type
  14797. This is the type for the SLiM graphical login manager for X11.
  14798. Like GDM, SLiM looks for session types described by @file{.desktop} files and
  14799. allows users to choose a session from the log-in screen using @kbd{F1}. It
  14800. also honors @file{~/.xsession} files.
  14801. Unlike GDM, SLiM does not spawn the user session on a different VT after
  14802. logging in, which means that you can only start one graphical session. If you
  14803. want to be able to run multiple graphical sessions at the same time you have
  14804. to add multiple SLiM services to your system services. The following example
  14805. shows how to replace the default GDM service with two SLiM services on tty7
  14806. and tty8.
  14807. @lisp
  14808. (use-modules (gnu services)
  14809. (gnu services desktop)
  14810. (gnu services xorg)
  14811. (srfi srfi-1)) ;for 'remove'
  14812. (operating-system
  14813. ;; ...
  14814. (services (cons* (service slim-service-type (slim-configuration
  14815. (display ":0")
  14816. (vt "vt7")))
  14817. (service slim-service-type (slim-configuration
  14818. (display ":1")
  14819. (vt "vt8")))
  14820. (modify-services %desktop-services
  14821. (delete gdm-service-type)))))
  14822. @end lisp
  14823. @end defvr
  14824. @deftp {Data Type} slim-configuration
  14825. Data type representing the configuration of @code{slim-service-type}.
  14826. @table @asis
  14827. @item @code{allow-empty-passwords?} (default: @code{#t})
  14828. Whether to allow logins with empty passwords.
  14829. @item @code{gnupg?} (default: @code{#f})
  14830. If enabled, @code{pam-gnupg} will attempt to automatically unlock the
  14831. user's GPG keys with the login password via @code{gpg-agent}. The
  14832. keygrips of all keys to be unlocked should be written to
  14833. @file{~/.pam-gnupg}, and can be queried with @code{gpg -K
  14834. --with-keygrip}. Presetting passphrases must be enabled by adding
  14835. @code{allow-preset-passphrase} in @file{~/.gnupg/gpg-agent.conf}.
  14836. @item @code{auto-login?} (default: @code{#f})
  14837. @itemx @code{default-user} (default: @code{""})
  14838. When @code{auto-login?} is false, SLiM presents a log-in screen.
  14839. When @code{auto-login?} is true, SLiM logs in directly as
  14840. @code{default-user}.
  14841. @item @code{theme} (default: @code{%default-slim-theme})
  14842. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  14843. The graphical theme to use and its name.
  14844. @item @code{auto-login-session} (default: @code{#f})
  14845. If true, this must be the name of the executable to start as the default
  14846. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  14847. If false, a session described by one of the available @file{.desktop}
  14848. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  14849. will be used.
  14850. @quotation Note
  14851. You must install at least one window manager in the system profile or in
  14852. your user profile. Failing to do that, if @code{auto-login-session} is
  14853. false, you will be unable to log in.
  14854. @end quotation
  14855. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  14856. Configuration of the Xorg graphical server.
  14857. @item @code{display} (default @code{":0"})
  14858. The display on which to start the Xorg graphical server.
  14859. @item @code{vt} (default @code{"vt7"})
  14860. The VT on which to start the Xorg graphical server.
  14861. @item @code{xauth} (default: @code{xauth})
  14862. The XAuth package to use.
  14863. @item @code{shepherd} (default: @code{shepherd})
  14864. The Shepherd package used when invoking @command{halt} and
  14865. @command{reboot}.
  14866. @item @code{sessreg} (default: @code{sessreg})
  14867. The sessreg package used in order to register the session.
  14868. @item @code{slim} (default: @code{slim})
  14869. The SLiM package to use.
  14870. @end table
  14871. @end deftp
  14872. @defvr {Scheme Variable} %default-theme
  14873. @defvrx {Scheme Variable} %default-theme-name
  14874. The default SLiM theme and its name.
  14875. @end defvr
  14876. @deftp {Data Type} sddm-configuration
  14877. This is the data type representing the SDDM service configuration.
  14878. @table @asis
  14879. @item @code{display-server} (default: "x11")
  14880. Select display server to use for the greeter. Valid values are
  14881. @samp{"x11"} or @samp{"wayland"}.
  14882. @item @code{numlock} (default: "on")
  14883. Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
  14884. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  14885. Command to run when halting.
  14886. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  14887. Command to run when rebooting.
  14888. @item @code{theme} (default "maldives")
  14889. Theme to use. Default themes provided by SDDM are @samp{"elarun"},
  14890. @samp{"maldives"} or @samp{"maya"}.
  14891. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  14892. Directory to look for themes.
  14893. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  14894. Directory to look for faces.
  14895. @item @code{default-path} (default "/run/current-system/profile/bin")
  14896. Default PATH to use.
  14897. @item @code{minimum-uid} (default: 1000)
  14898. Minimum UID displayed in SDDM and allowed for log-in.
  14899. @item @code{maximum-uid} (default: 2000)
  14900. Maximum UID to display in SDDM.
  14901. @item @code{remember-last-user?} (default #t)
  14902. Remember last user.
  14903. @item @code{remember-last-session?} (default #t)
  14904. Remember last session.
  14905. @item @code{hide-users} (default "")
  14906. Usernames to hide from SDDM greeter.
  14907. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  14908. Users with shells listed will be hidden from the SDDM greeter.
  14909. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  14910. Script to run before starting a wayland session.
  14911. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  14912. Directory to look for desktop files starting wayland sessions.
  14913. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  14914. Configuration of the Xorg graphical server.
  14915. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  14916. Path to xauth.
  14917. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  14918. Path to Xephyr.
  14919. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  14920. Script to run after starting xorg-server.
  14921. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  14922. Script to run before stopping xorg-server.
  14923. @item @code{xsession-command} (default: @code{xinitrc})
  14924. Script to run before starting a X session.
  14925. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  14926. Directory to look for desktop files starting X sessions.
  14927. @item @code{minimum-vt} (default: 7)
  14928. Minimum VT to use.
  14929. @item @code{auto-login-user} (default "")
  14930. User to use for auto-login.
  14931. @item @code{auto-login-session} (default "")
  14932. Desktop file to use for auto-login.
  14933. @item @code{relogin?} (default #f)
  14934. Relogin after logout.
  14935. @end table
  14936. @end deftp
  14937. @cindex login manager
  14938. @cindex X11 login
  14939. @defvr {Scheme Variable} sddm-service-type
  14940. This is the type of the service to run the
  14941. @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
  14942. must be a @code{sddm-configuration} record (see below).
  14943. Here's an example use:
  14944. @lisp
  14945. (service sddm-service-type
  14946. (sddm-configuration
  14947. (auto-login-user "alice")
  14948. (auto-login-session "xfce.desktop")))
  14949. @end lisp
  14950. @end defvr
  14951. @deftp {Data Type} sddm-configuration
  14952. This data type represents the configuration of the SDDM login manager.
  14953. The available fields are:
  14954. @table @asis
  14955. @item @code{sddm} (default: @code{sddm})
  14956. The SDDM package to use.
  14957. @item @code{display-server} (default: @code{"x11"})
  14958. This must be either @code{"x11"} or @code{"wayland"}.
  14959. @c FIXME: Add more fields.
  14960. @item @code{auto-login-user} (default: @code{""})
  14961. If non-empty, this is the user account under which to log in
  14962. automatically.
  14963. @item @code{auto-login-session} (default: @code{""})
  14964. If non-empty, this is the @file{.desktop} file name to use as the
  14965. auto-login session.
  14966. @end table
  14967. @end deftp
  14968. @cindex Xorg, configuration
  14969. @deftp {Data Type} xorg-configuration
  14970. This data type represents the configuration of the Xorg graphical display
  14971. server. Note that there is no Xorg service; instead, the X server is started
  14972. by a ``display manager'' such as GDM, SDDM, and SLiM@. Thus, the configuration
  14973. of these display managers aggregates an @code{xorg-configuration} record.
  14974. @table @asis
  14975. @item @code{modules} (default: @code{%default-xorg-modules})
  14976. This is a list of @dfn{module packages} loaded by the Xorg
  14977. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  14978. @item @code{fonts} (default: @code{%default-xorg-fonts})
  14979. This is a list of font directories to add to the server's @dfn{font path}.
  14980. @item @code{drivers} (default: @code{'()})
  14981. This must be either the empty list, in which case Xorg chooses a graphics
  14982. driver automatically, or a list of driver names that will be tried in this
  14983. order---e.g., @code{("modesetting" "vesa")}.
  14984. @item @code{resolutions} (default: @code{'()})
  14985. When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
  14986. resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
  14987. 768) (640 480))}.
  14988. @cindex keyboard layout, for Xorg
  14989. @cindex keymap, for Xorg
  14990. @item @code{keyboard-layout} (default: @code{#f})
  14991. If this is @code{#f}, Xorg uses the default keyboard layout---usually US
  14992. English (``qwerty'') for a 105-key PC keyboard.
  14993. Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
  14994. layout in use when Xorg is running. @xref{Keyboard Layout}, for more
  14995. information on how to specify the keyboard layout.
  14996. @item @code{extra-config} (default: @code{'()})
  14997. This is a list of strings or objects appended to the configuration file. It
  14998. is used to pass extra text to be added verbatim to the configuration file.
  14999. @item @code{server} (default: @code{xorg-server})
  15000. This is the package providing the Xorg server.
  15001. @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
  15002. This is the list of command-line arguments to pass to the X server. The
  15003. default is @code{-nolisten tcp}.
  15004. @end table
  15005. @end deftp
  15006. @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
  15007. [@var{login-manager-service-type}]
  15008. Tell the log-in manager (of type @var{login-manager-service-type}) to use
  15009. @var{config}, an @code{<xorg-configuration>} record.
  15010. Since the Xorg configuration is embedded in the log-in manager's
  15011. configuration---e.g., @code{gdm-configuration}---this procedure provides a
  15012. shorthand to set the Xorg configuration.
  15013. @end deffn
  15014. @deffn {Scheme Procedure} xorg-start-command [@var{config}]
  15015. Return a @code{startx} script in which the modules, fonts, etc. specified
  15016. in @var{config}, are available. The result should be used in place of
  15017. @code{startx}.
  15018. Usually the X server is started by a login manager.
  15019. @end deffn
  15020. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
  15021. Add @var{package}, a package for a screen locker or screen saver whose
  15022. command is @var{program}, to the set of setuid programs and add a PAM entry
  15023. for it. For example:
  15024. @lisp
  15025. (screen-locker-service xlockmore "xlock")
  15026. @end lisp
  15027. makes the good ol' XlockMore usable.
  15028. @end deffn
  15029. @node Printing Services
  15030. @subsection Printing Services
  15031. @cindex printer support with CUPS
  15032. The @code{(gnu services cups)} module provides a Guix service definition
  15033. for the CUPS printing service. To add printer support to a Guix
  15034. system, add a @code{cups-service} to the operating system definition:
  15035. @deffn {Scheme Variable} cups-service-type
  15036. The service type for the CUPS print server. Its value should be a valid
  15037. CUPS configuration (see below). To use the default settings, simply
  15038. write:
  15039. @lisp
  15040. (service cups-service-type)
  15041. @end lisp
  15042. @end deffn
  15043. The CUPS configuration controls the basic things about your CUPS
  15044. installation: what interfaces it listens on, what to do if a print job
  15045. fails, how much logging to do, and so on. To actually add a printer,
  15046. you have to visit the @url{http://localhost:631} URL, or use a tool such
  15047. as GNOME's printer configuration services. By default, configuring a
  15048. CUPS service will generate a self-signed certificate if needed, for
  15049. secure connections to the print server.
  15050. Suppose you want to enable the Web interface of CUPS and also add
  15051. support for Epson printers @i{via} the @code{epson-inkjet-printer-escpr}
  15052. package and for HP printers @i{via} the @code{hplip-minimal} package.
  15053. You can do that directly, like this (you need to use the
  15054. @code{(gnu packages cups)} module):
  15055. @lisp
  15056. (service cups-service-type
  15057. (cups-configuration
  15058. (web-interface? #t)
  15059. (extensions
  15060. (list cups-filters epson-inkjet-printer-escpr hplip-minimal))))
  15061. @end lisp
  15062. Note: If you wish to use the Qt5 based GUI which comes with the hplip
  15063. package then it is suggested that you install the @code{hplip} package,
  15064. either in your OS configuration file or as your user.
  15065. The available configuration parameters follow. Each parameter
  15066. definition is preceded by its type; for example, @samp{string-list foo}
  15067. indicates that the @code{foo} parameter should be specified as a list of
  15068. strings. There is also a way to specify the configuration as a string,
  15069. if you have an old @code{cupsd.conf} file that you want to port over
  15070. from some other system; see the end for more details.
  15071. @c The following documentation was initially generated by
  15072. @c (generate-documentation) in (gnu services cups). Manually maintained
  15073. @c documentation is better, so we shouldn't hesitate to edit below as
  15074. @c needed. However if the change you want to make to this documentation
  15075. @c can be done in an automated way, it's probably easier to change
  15076. @c (generate-documentation) than to make it below and have to deal with
  15077. @c the churn as CUPS updates.
  15078. Available @code{cups-configuration} fields are:
  15079. @deftypevr {@code{cups-configuration} parameter} package cups
  15080. The CUPS package.
  15081. @end deftypevr
  15082. @deftypevr {@code{cups-configuration} parameter} package-list extensions (default: @code{(list brlaser cups-filters epson-inkjet-printer-escpr foomatic-filters hplip-minimal splix)})
  15083. Drivers and other extensions to the CUPS package.
  15084. @end deftypevr
  15085. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  15086. Configuration of where to write logs, what directories to use for print
  15087. spools, and related privileged configuration parameters.
  15088. Available @code{files-configuration} fields are:
  15089. @deftypevr {@code{files-configuration} parameter} log-location access-log
  15090. Defines the access log filename. Specifying a blank filename disables
  15091. access log generation. The value @code{stderr} causes log entries to be
  15092. sent to the standard error file when the scheduler is running in the
  15093. foreground, or to the system log daemon when run in the background. The
  15094. value @code{syslog} causes log entries to be sent to the system log
  15095. daemon. The server name may be included in filenames using the string
  15096. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  15097. Defaults to @samp{"/var/log/cups/access_log"}.
  15098. @end deftypevr
  15099. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  15100. Where CUPS should cache data.
  15101. Defaults to @samp{"/var/cache/cups"}.
  15102. @end deftypevr
  15103. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  15104. Specifies the permissions for all configuration files that the scheduler
  15105. writes.
  15106. Note that the permissions for the printers.conf file are currently
  15107. masked to only allow access from the scheduler user (typically root).
  15108. This is done because printer device URIs sometimes contain sensitive
  15109. authentication information that should not be generally known on the
  15110. system. There is no way to disable this security feature.
  15111. Defaults to @samp{"0640"}.
  15112. @end deftypevr
  15113. @deftypevr {@code{files-configuration} parameter} log-location error-log
  15114. Defines the error log filename. Specifying a blank filename disables
  15115. error log generation. The value @code{stderr} causes log entries to be
  15116. sent to the standard error file when the scheduler is running in the
  15117. foreground, or to the system log daemon when run in the background. The
  15118. value @code{syslog} causes log entries to be sent to the system log
  15119. daemon. The server name may be included in filenames using the string
  15120. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  15121. Defaults to @samp{"/var/log/cups/error_log"}.
  15122. @end deftypevr
  15123. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  15124. Specifies which errors are fatal, causing the scheduler to exit. The
  15125. kind strings are:
  15126. @table @code
  15127. @item none
  15128. No errors are fatal.
  15129. @item all
  15130. All of the errors below are fatal.
  15131. @item browse
  15132. Browsing initialization errors are fatal, for example failed connections
  15133. to the DNS-SD daemon.
  15134. @item config
  15135. Configuration file syntax errors are fatal.
  15136. @item listen
  15137. Listen or Port errors are fatal, except for IPv6 failures on the
  15138. loopback or @code{any} addresses.
  15139. @item log
  15140. Log file creation or write errors are fatal.
  15141. @item permissions
  15142. Bad startup file permissions are fatal, for example shared TLS
  15143. certificate and key files with world-read permissions.
  15144. @end table
  15145. Defaults to @samp{"all -browse"}.
  15146. @end deftypevr
  15147. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  15148. Specifies whether the file pseudo-device can be used for new printer
  15149. queues. The URI @uref{file:///dev/null} is always allowed.
  15150. Defaults to @samp{#f}.
  15151. @end deftypevr
  15152. @deftypevr {@code{files-configuration} parameter} string group
  15153. Specifies the group name or ID that will be used when executing external
  15154. programs.
  15155. Defaults to @samp{"lp"}.
  15156. @end deftypevr
  15157. @deftypevr {@code{files-configuration} parameter} string log-file-group
  15158. Specifies the group name or ID that will be used for log files.
  15159. Defaults to @samp{"lpadmin"}.
  15160. @end deftypevr
  15161. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  15162. Specifies the permissions for all log files that the scheduler writes.
  15163. Defaults to @samp{"0644"}.
  15164. @end deftypevr
  15165. @deftypevr {@code{files-configuration} parameter} log-location page-log
  15166. Defines the page log filename. Specifying a blank filename disables
  15167. page log generation. The value @code{stderr} causes log entries to be
  15168. sent to the standard error file when the scheduler is running in the
  15169. foreground, or to the system log daemon when run in the background. The
  15170. value @code{syslog} causes log entries to be sent to the system log
  15171. daemon. The server name may be included in filenames using the string
  15172. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  15173. Defaults to @samp{"/var/log/cups/page_log"}.
  15174. @end deftypevr
  15175. @deftypevr {@code{files-configuration} parameter} string remote-root
  15176. Specifies the username that is associated with unauthenticated accesses
  15177. by clients claiming to be the root user. The default is @code{remroot}.
  15178. Defaults to @samp{"remroot"}.
  15179. @end deftypevr
  15180. @deftypevr {@code{files-configuration} parameter} file-name request-root
  15181. Specifies the directory that contains print jobs and other HTTP request
  15182. data.
  15183. Defaults to @samp{"/var/spool/cups"}.
  15184. @end deftypevr
  15185. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  15186. Specifies the level of security sandboxing that is applied to print
  15187. filters, backends, and other child processes of the scheduler; either
  15188. @code{relaxed} or @code{strict}. This directive is currently only
  15189. used/supported on macOS.
  15190. Defaults to @samp{strict}.
  15191. @end deftypevr
  15192. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  15193. Specifies the location of TLS certificates and private keys. CUPS will
  15194. look for public and private keys in this directory: @file{.crt} files
  15195. for PEM-encoded certificates and corresponding @file{.key} files for
  15196. PEM-encoded private keys.
  15197. Defaults to @samp{"/etc/cups/ssl"}.
  15198. @end deftypevr
  15199. @deftypevr {@code{files-configuration} parameter} file-name server-root
  15200. Specifies the directory containing the server configuration files.
  15201. Defaults to @samp{"/etc/cups"}.
  15202. @end deftypevr
  15203. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  15204. Specifies whether the scheduler calls fsync(2) after writing
  15205. configuration or state files.
  15206. Defaults to @samp{#f}.
  15207. @end deftypevr
  15208. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  15209. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  15210. @end deftypevr
  15211. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  15212. Specifies the directory where temporary files are stored.
  15213. Defaults to @samp{"/var/spool/cups/tmp"}.
  15214. @end deftypevr
  15215. @deftypevr {@code{files-configuration} parameter} string user
  15216. Specifies the user name or ID that is used when running external
  15217. programs.
  15218. Defaults to @samp{"lp"}.
  15219. @end deftypevr
  15220. @deftypevr {@code{files-configuration} parameter} string set-env
  15221. Set the specified environment variable to be passed to child processes.
  15222. Defaults to @samp{"variable value"}.
  15223. @end deftypevr
  15224. @end deftypevr
  15225. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  15226. Specifies the logging level for the AccessLog file. The @code{config}
  15227. level logs when printers and classes are added, deleted, or modified and
  15228. when configuration files are accessed or updated. The @code{actions}
  15229. level logs when print jobs are submitted, held, released, modified, or
  15230. canceled, and any of the conditions for @code{config}. The @code{all}
  15231. level logs all requests.
  15232. Defaults to @samp{actions}.
  15233. @end deftypevr
  15234. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  15235. Specifies whether to purge job history data automatically when it is no
  15236. longer required for quotas.
  15237. Defaults to @samp{#f}.
  15238. @end deftypevr
  15239. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
  15240. Specifies a list of DNS-SD sub-types to advertise for each shared printer.
  15241. For example, @samp{"_cups" "_print"} will tell network clients that both
  15242. CUPS sharing and IPP Everywhere are supported.
  15243. Defaults to @samp{"_cups"}.
  15244. @end deftypevr
  15245. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  15246. Specifies which protocols to use for local printer sharing.
  15247. Defaults to @samp{dnssd}.
  15248. @end deftypevr
  15249. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  15250. Specifies whether the CUPS web interface is advertised.
  15251. Defaults to @samp{#f}.
  15252. @end deftypevr
  15253. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  15254. Specifies whether shared printers are advertised.
  15255. Defaults to @samp{#f}.
  15256. @end deftypevr
  15257. @deftypevr {@code{cups-configuration} parameter} string classification
  15258. Specifies the security classification of the server. Any valid banner
  15259. name can be used, including @samp{"classified"}, @samp{"confidential"},
  15260. @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
  15261. banner can be omitted to disable secure printing functions.
  15262. Defaults to @samp{""}.
  15263. @end deftypevr
  15264. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  15265. Specifies whether users may override the classification (cover page) of
  15266. individual print jobs using the @code{job-sheets} option.
  15267. Defaults to @samp{#f}.
  15268. @end deftypevr
  15269. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  15270. Specifies the default type of authentication to use.
  15271. Defaults to @samp{Basic}.
  15272. @end deftypevr
  15273. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  15274. Specifies whether encryption will be used for authenticated requests.
  15275. Defaults to @samp{Required}.
  15276. @end deftypevr
  15277. @deftypevr {@code{cups-configuration} parameter} string default-language
  15278. Specifies the default language to use for text and web content.
  15279. Defaults to @samp{"en"}.
  15280. @end deftypevr
  15281. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  15282. Specifies the default paper size for new print queues. @samp{"Auto"}
  15283. uses a locale-specific default, while @samp{"None"} specifies there is
  15284. no default paper size. Specific size names are typically
  15285. @samp{"Letter"} or @samp{"A4"}.
  15286. Defaults to @samp{"Auto"}.
  15287. @end deftypevr
  15288. @deftypevr {@code{cups-configuration} parameter} string default-policy
  15289. Specifies the default access policy to use.
  15290. Defaults to @samp{"default"}.
  15291. @end deftypevr
  15292. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  15293. Specifies whether local printers are shared by default.
  15294. Defaults to @samp{#t}.
  15295. @end deftypevr
  15296. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  15297. Specifies the delay for updating of configuration and state files, in
  15298. seconds. A value of 0 causes the update to happen as soon as possible,
  15299. typically within a few milliseconds.
  15300. Defaults to @samp{30}.
  15301. @end deftypevr
  15302. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  15303. Specifies what to do when an error occurs. Possible values are
  15304. @code{abort-job}, which will discard the failed print job;
  15305. @code{retry-job}, which will retry the job at a later time;
  15306. @code{retry-current-job}, which retries the failed job immediately; and
  15307. @code{stop-printer}, which stops the printer.
  15308. Defaults to @samp{stop-printer}.
  15309. @end deftypevr
  15310. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  15311. Specifies the maximum cost of filters that are run concurrently, which
  15312. can be used to minimize disk, memory, and CPU resource problems. A
  15313. limit of 0 disables filter limiting. An average print to a
  15314. non-PostScript printer needs a filter limit of about 200. A PostScript
  15315. printer needs about half that (100). Setting the limit below these
  15316. thresholds will effectively limit the scheduler to printing a single job
  15317. at any time.
  15318. Defaults to @samp{0}.
  15319. @end deftypevr
  15320. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  15321. Specifies the scheduling priority of filters that are run to print a
  15322. job. The nice value ranges from 0, the highest priority, to 19, the
  15323. lowest priority.
  15324. Defaults to @samp{0}.
  15325. @end deftypevr
  15326. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  15327. Specifies whether to do reverse lookups on connecting clients. The
  15328. @code{double} setting causes @code{cupsd} to verify that the hostname
  15329. resolved from the address matches one of the addresses returned for that
  15330. hostname. Double lookups also prevent clients with unregistered
  15331. addresses from connecting to your server. Only set this option to
  15332. @code{#t} or @code{double} if absolutely required.
  15333. Defaults to @samp{#f}.
  15334. @end deftypevr
  15335. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  15336. Specifies the number of seconds to wait before killing the filters and
  15337. backend associated with a canceled or held job.
  15338. Defaults to @samp{30}.
  15339. @end deftypevr
  15340. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  15341. Specifies the interval between retries of jobs in seconds. This is
  15342. typically used for fax queues but can also be used with normal print
  15343. queues whose error policy is @code{retry-job} or
  15344. @code{retry-current-job}.
  15345. Defaults to @samp{30}.
  15346. @end deftypevr
  15347. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  15348. Specifies the number of retries that are done for jobs. This is
  15349. typically used for fax queues but can also be used with normal print
  15350. queues whose error policy is @code{retry-job} or
  15351. @code{retry-current-job}.
  15352. Defaults to @samp{5}.
  15353. @end deftypevr
  15354. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  15355. Specifies whether to support HTTP keep-alive connections.
  15356. Defaults to @samp{#t}.
  15357. @end deftypevr
  15358. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  15359. Specifies the maximum size of print files, IPP requests, and HTML form
  15360. data. A limit of 0 disables the limit check.
  15361. Defaults to @samp{0}.
  15362. @end deftypevr
  15363. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  15364. Listens on the specified interfaces for connections. Valid values are
  15365. of the form @var{address}:@var{port}, where @var{address} is either an
  15366. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  15367. indicate all addresses. Values can also be file names of local UNIX
  15368. domain sockets. The Listen directive is similar to the Port directive
  15369. but allows you to restrict access to specific interfaces or networks.
  15370. @end deftypevr
  15371. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  15372. Specifies the number of pending connections that will be allowed. This
  15373. normally only affects very busy servers that have reached the MaxClients
  15374. limit, but can also be triggered by large numbers of simultaneous
  15375. connections. When the limit is reached, the operating system will
  15376. refuse additional connections until the scheduler can accept the pending
  15377. ones.
  15378. Defaults to @samp{128}.
  15379. @end deftypevr
  15380. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  15381. Specifies a set of additional access controls.
  15382. Available @code{location-access-controls} fields are:
  15383. @deftypevr {@code{location-access-controls} parameter} file-name path
  15384. Specifies the URI path to which the access control applies.
  15385. @end deftypevr
  15386. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  15387. Access controls for all access to this path, in the same format as the
  15388. @code{access-controls} of @code{operation-access-control}.
  15389. Defaults to @samp{()}.
  15390. @end deftypevr
  15391. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  15392. Access controls for method-specific access to this path.
  15393. Defaults to @samp{()}.
  15394. Available @code{method-access-controls} fields are:
  15395. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  15396. If @code{#t}, apply access controls to all methods except the listed
  15397. methods. Otherwise apply to only the listed methods.
  15398. Defaults to @samp{#f}.
  15399. @end deftypevr
  15400. @deftypevr {@code{method-access-controls} parameter} method-list methods
  15401. Methods to which this access control applies.
  15402. Defaults to @samp{()}.
  15403. @end deftypevr
  15404. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  15405. Access control directives, as a list of strings. Each string should be
  15406. one directive, such as @samp{"Order allow,deny"}.
  15407. Defaults to @samp{()}.
  15408. @end deftypevr
  15409. @end deftypevr
  15410. @end deftypevr
  15411. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  15412. Specifies the number of debugging messages that are retained for logging
  15413. if an error occurs in a print job. Debug messages are logged regardless
  15414. of the LogLevel setting.
  15415. Defaults to @samp{100}.
  15416. @end deftypevr
  15417. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  15418. Specifies the level of logging for the ErrorLog file. The value
  15419. @code{none} stops all logging while @code{debug2} logs everything.
  15420. Defaults to @samp{info}.
  15421. @end deftypevr
  15422. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  15423. Specifies the format of the date and time in the log files. The value
  15424. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  15425. Defaults to @samp{standard}.
  15426. @end deftypevr
  15427. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  15428. Specifies the maximum number of simultaneous clients that are allowed by
  15429. the scheduler.
  15430. Defaults to @samp{100}.
  15431. @end deftypevr
  15432. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  15433. Specifies the maximum number of simultaneous clients that are allowed
  15434. from a single address.
  15435. Defaults to @samp{100}.
  15436. @end deftypevr
  15437. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  15438. Specifies the maximum number of copies that a user can print of each
  15439. job.
  15440. Defaults to @samp{9999}.
  15441. @end deftypevr
  15442. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  15443. Specifies the maximum time a job may remain in the @code{indefinite}
  15444. hold state before it is canceled. A value of 0 disables cancellation of
  15445. held jobs.
  15446. Defaults to @samp{0}.
  15447. @end deftypevr
  15448. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  15449. Specifies the maximum number of simultaneous jobs that are allowed. Set
  15450. to 0 to allow an unlimited number of jobs.
  15451. Defaults to @samp{500}.
  15452. @end deftypevr
  15453. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  15454. Specifies the maximum number of simultaneous jobs that are allowed per
  15455. printer. A value of 0 allows up to MaxJobs jobs per printer.
  15456. Defaults to @samp{0}.
  15457. @end deftypevr
  15458. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  15459. Specifies the maximum number of simultaneous jobs that are allowed per
  15460. user. A value of 0 allows up to MaxJobs jobs per user.
  15461. Defaults to @samp{0}.
  15462. @end deftypevr
  15463. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  15464. Specifies the maximum time a job may take to print before it is
  15465. canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
  15466. Defaults to @samp{10800}.
  15467. @end deftypevr
  15468. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  15469. Specifies the maximum size of the log files before they are rotated, in
  15470. bytes. The value 0 disables log rotation.
  15471. Defaults to @samp{1048576}.
  15472. @end deftypevr
  15473. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  15474. Specifies the maximum amount of time to allow between files in a
  15475. multiple file print job, in seconds.
  15476. Defaults to @samp{300}.
  15477. @end deftypevr
  15478. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  15479. Specifies the format of PageLog lines. Sequences beginning with percent
  15480. (@samp{%}) characters are replaced with the corresponding information,
  15481. while all other characters are copied literally. The following percent
  15482. sequences are recognized:
  15483. @table @samp
  15484. @item %%
  15485. insert a single percent character
  15486. @item %@{name@}
  15487. insert the value of the specified IPP attribute
  15488. @item %C
  15489. insert the number of copies for the current page
  15490. @item %P
  15491. insert the current page number
  15492. @item %T
  15493. insert the current date and time in common log format
  15494. @item %j
  15495. insert the job ID
  15496. @item %p
  15497. insert the printer name
  15498. @item %u
  15499. insert the username
  15500. @end table
  15501. A value of the empty string disables page logging. The string @code{%p
  15502. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  15503. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  15504. standard items.
  15505. Defaults to @samp{""}.
  15506. @end deftypevr
  15507. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  15508. Passes the specified environment variable(s) to child processes; a list
  15509. of strings.
  15510. Defaults to @samp{()}.
  15511. @end deftypevr
  15512. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  15513. Specifies named access control policies.
  15514. Available @code{policy-configuration} fields are:
  15515. @deftypevr {@code{policy-configuration} parameter} string name
  15516. Name of the policy.
  15517. @end deftypevr
  15518. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  15519. Specifies an access list for a job's private values. @code{@@ACL} maps
  15520. to the printer's requesting-user-name-allowed or
  15521. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  15522. owner. @code{@@SYSTEM} maps to the groups listed for the
  15523. @code{system-group} field of the @code{files-configuration},
  15524. which is reified into the @code{cups-files.conf(5)} file. Other
  15525. possible elements of the access list include specific user names, and
  15526. @code{@@@var{group}} to indicate members of a specific group. The
  15527. access list may also be simply @code{all} or @code{default}.
  15528. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  15529. @end deftypevr
  15530. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  15531. Specifies the list of job values to make private, or @code{all},
  15532. @code{default}, or @code{none}.
  15533. Defaults to @samp{"job-name job-originating-host-name
  15534. job-originating-user-name phone"}.
  15535. @end deftypevr
  15536. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  15537. Specifies an access list for a subscription's private values.
  15538. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  15539. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  15540. owner. @code{@@SYSTEM} maps to the groups listed for the
  15541. @code{system-group} field of the @code{files-configuration},
  15542. which is reified into the @code{cups-files.conf(5)} file. Other
  15543. possible elements of the access list include specific user names, and
  15544. @code{@@@var{group}} to indicate members of a specific group. The
  15545. access list may also be simply @code{all} or @code{default}.
  15546. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  15547. @end deftypevr
  15548. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  15549. Specifies the list of job values to make private, or @code{all},
  15550. @code{default}, or @code{none}.
  15551. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  15552. notify-subscriber-user-name notify-user-data"}.
  15553. @end deftypevr
  15554. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  15555. Access control by IPP operation.
  15556. Defaults to @samp{()}.
  15557. @end deftypevr
  15558. @end deftypevr
  15559. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  15560. Specifies whether job files (documents) are preserved after a job is
  15561. printed. If a numeric value is specified, job files are preserved for
  15562. the indicated number of seconds after printing. Otherwise a boolean
  15563. value applies indefinitely.
  15564. Defaults to @samp{86400}.
  15565. @end deftypevr
  15566. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  15567. Specifies whether the job history is preserved after a job is printed.
  15568. If a numeric value is specified, the job history is preserved for the
  15569. indicated number of seconds after printing. If @code{#t}, the job
  15570. history is preserved until the MaxJobs limit is reached.
  15571. Defaults to @samp{#t}.
  15572. @end deftypevr
  15573. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  15574. Specifies the amount of time to wait for job completion before
  15575. restarting the scheduler.
  15576. Defaults to @samp{30}.
  15577. @end deftypevr
  15578. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  15579. Specifies the maximum amount of memory to use when converting documents
  15580. into bitmaps for a printer.
  15581. Defaults to @samp{"128m"}.
  15582. @end deftypevr
  15583. @deftypevr {@code{cups-configuration} parameter} string server-admin
  15584. Specifies the email address of the server administrator.
  15585. Defaults to @samp{"root@@localhost.localdomain"}.
  15586. @end deftypevr
  15587. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  15588. The ServerAlias directive is used for HTTP Host header validation when
  15589. clients connect to the scheduler from external interfaces. Using the
  15590. special name @code{*} can expose your system to known browser-based DNS
  15591. rebinding attacks, even when accessing sites through a firewall. If the
  15592. auto-discovery of alternate names does not work, we recommend listing
  15593. each alternate name with a ServerAlias directive instead of using
  15594. @code{*}.
  15595. Defaults to @samp{*}.
  15596. @end deftypevr
  15597. @deftypevr {@code{cups-configuration} parameter} string server-name
  15598. Specifies the fully-qualified host name of the server.
  15599. Defaults to @samp{"localhost"}.
  15600. @end deftypevr
  15601. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  15602. Specifies what information is included in the Server header of HTTP
  15603. responses. @code{None} disables the Server header. @code{ProductOnly}
  15604. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  15605. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  15606. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  15607. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  15608. 2.0.0 (@var{uname}) IPP/2.0}.
  15609. Defaults to @samp{Minimal}.
  15610. @end deftypevr
  15611. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  15612. Listens on the specified interfaces for encrypted connections. Valid
  15613. values are of the form @var{address}:@var{port}, where @var{address} is
  15614. either an IPv6 address enclosed in brackets, an IPv4 address, or
  15615. @code{*} to indicate all addresses.
  15616. Defaults to @samp{()}.
  15617. @end deftypevr
  15618. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  15619. Sets encryption options. By default, CUPS only supports encryption
  15620. using TLS v1.0 or higher using known secure cipher suites. Security is
  15621. reduced when @code{Allow} options are used, and enhanced when @code{Deny}
  15622. options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
  15623. suites, which are required for some older clients. The @code{AllowSSL3} option
  15624. enables SSL v3.0, which is required for some older clients that do not support
  15625. TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
  15626. @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
  15627. protocol version to TLS v1.1.
  15628. Defaults to @samp{()}.
  15629. @end deftypevr
  15630. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  15631. Specifies whether the scheduler requires clients to strictly adhere to
  15632. the IPP specifications.
  15633. Defaults to @samp{#f}.
  15634. @end deftypevr
  15635. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  15636. Specifies the HTTP request timeout, in seconds.
  15637. Defaults to @samp{300}.
  15638. @end deftypevr
  15639. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  15640. Specifies whether the web interface is enabled.
  15641. Defaults to @samp{#f}.
  15642. @end deftypevr
  15643. At this point you're probably thinking ``oh dear, Guix manual, I like
  15644. you but you can stop already with the configuration options''. Indeed.
  15645. However, one more point: it could be that you have an existing
  15646. @code{cupsd.conf} that you want to use. In that case, you can pass an
  15647. @code{opaque-cups-configuration} as the configuration of a
  15648. @code{cups-service-type}.
  15649. Available @code{opaque-cups-configuration} fields are:
  15650. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  15651. The CUPS package.
  15652. @end deftypevr
  15653. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  15654. The contents of the @code{cupsd.conf}, as a string.
  15655. @end deftypevr
  15656. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  15657. The contents of the @code{cups-files.conf} file, as a string.
  15658. @end deftypevr
  15659. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  15660. strings of the same name, you could instantiate a CUPS service like
  15661. this:
  15662. @lisp
  15663. (service cups-service-type
  15664. (opaque-cups-configuration
  15665. (cupsd.conf cupsd.conf)
  15666. (cups-files.conf cups-files.conf)))
  15667. @end lisp
  15668. @node Desktop Services
  15669. @subsection Desktop Services
  15670. The @code{(gnu services desktop)} module provides services that are
  15671. usually useful in the context of a ``desktop'' setup---that is, on a
  15672. machine running a graphical display server, possibly with graphical user
  15673. interfaces, etc. It also defines services that provide specific desktop
  15674. environments like GNOME, Xfce or MATE.
  15675. To simplify things, the module defines a variable containing the set of
  15676. services that users typically expect on a machine with a graphical
  15677. environment and networking:
  15678. @defvr {Scheme Variable} %desktop-services
  15679. This is a list of services that builds upon @code{%base-services} and
  15680. adds or adjusts services for a typical ``desktop'' setup.
  15681. In particular, it adds a graphical login manager (@pxref{X Window,
  15682. @code{gdm-service-type}}), screen lockers, a network management tool
  15683. (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
  15684. support (@pxref{Networking Services, @code{modem-manager-service-type}}),
  15685. energy and color management services, the @code{elogind} login and seat
  15686. manager, the Polkit privilege service, the GeoClue location service, the
  15687. AccountsService daemon that allows authorized users change system passwords,
  15688. an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
  15689. name service switch service configured to be able to use @code{nss-mdns}
  15690. (@pxref{Name Service Switch, mDNS}).
  15691. @end defvr
  15692. The @code{%desktop-services} variable can be used as the @code{services}
  15693. field of an @code{operating-system} declaration (@pxref{operating-system
  15694. Reference, @code{services}}).
  15695. Additionally, the @code{gnome-desktop-service-type},
  15696. @code{xfce-desktop-service}, @code{mate-desktop-service-type},
  15697. @code{lxqt-desktop-service-type} and @code{enlightenment-desktop-service-type}
  15698. procedures can add GNOME, Xfce, MATE and/or Enlightenment to a system. To
  15699. ``add GNOME'' means that system-level services like the backlight adjustment
  15700. helpers and the power management utilities are added to the system, extending
  15701. @code{polkit} and @code{dbus} appropriately, allowing GNOME to operate with
  15702. elevated privileges on a limited number of special-purpose system interfaces.
  15703. Additionally, adding a service made by @code{gnome-desktop-service-type} adds
  15704. the GNOME metapackage to the system profile. Likewise, adding the Xfce
  15705. service not only adds the @code{xfce} metapackage to the system profile, but
  15706. it also gives the Thunar file manager the ability to open a ``root-mode'' file
  15707. management window, if the user authenticates using the administrator's
  15708. password via the standard polkit graphical interface. To ``add MATE'' means
  15709. that @code{polkit} and @code{dbus} are extended appropriately, allowing MATE
  15710. to operate with elevated privileges on a limited number of special-purpose
  15711. system interfaces. Additionally, adding a service of type
  15712. @code{mate-desktop-service-type} adds the MATE metapackage to the system
  15713. profile. ``Adding Enlightenment'' means that @code{dbus} is extended
  15714. appropriately, and several of Enlightenment's binaries are set as setuid,
  15715. allowing Enlightenment's screen locker and other functionality to work as
  15716. expected.
  15717. The desktop environments in Guix use the Xorg display server by
  15718. default. If you'd like to use the newer display server protocol
  15719. called Wayland, you need to enable Wayland support in GDM
  15720. (@pxref{wayland-gdm}). Another solution is to use the
  15721. @code{sddm-service} instead of GDM as the graphical login manager.
  15722. You should then select the ``GNOME (Wayland)'' session in SDDM@.
  15723. Alternatively you can also try starting GNOME on Wayland manually from a
  15724. TTY with the command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  15725. gnome-session``. Currently only GNOME has support for Wayland.
  15726. @defvr {Scheme Variable} gnome-desktop-service-type
  15727. This is the type of the service that adds the @uref{https://www.gnome.org,
  15728. GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
  15729. object (see below).
  15730. This service adds the @code{gnome} package to the system profile, and extends
  15731. polkit with the actions from @code{gnome-settings-daemon}.
  15732. @end defvr
  15733. @deftp {Data Type} gnome-desktop-configuration
  15734. Configuration record for the GNOME desktop environment.
  15735. @table @asis
  15736. @item @code{gnome} (default: @code{gnome})
  15737. The GNOME package to use.
  15738. @end table
  15739. @end deftp
  15740. @defvr {Scheme Variable} xfce-desktop-service-type
  15741. This is the type of a service to run the @uref{Xfce, https://xfce.org/}
  15742. desktop environment. Its value is an @code{xfce-desktop-configuration} object
  15743. (see below).
  15744. This service adds the @code{xfce} package to the system profile, and
  15745. extends polkit with the ability for @code{thunar} to manipulate the file
  15746. system as root from within a user session, after the user has authenticated
  15747. with the administrator's password.
  15748. Note that @code{xfce4-panel} and its plugin packages should be installed in
  15749. the same profile to ensure compatibility. When using this service, you should
  15750. add extra plugins (@code{xfce4-whiskermenu-plugin},
  15751. @code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your
  15752. @code{operating-system}.
  15753. @end defvr
  15754. @deftp {Data Type} xfce-desktop-configuration
  15755. Configuration record for the Xfce desktop environment.
  15756. @table @asis
  15757. @item @code{xfce} (default: @code{xfce})
  15758. The Xfce package to use.
  15759. @end table
  15760. @end deftp
  15761. @deffn {Scheme Variable} mate-desktop-service-type
  15762. This is the type of the service that runs the @uref{https://mate-desktop.org/,
  15763. MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
  15764. object (see below).
  15765. This service adds the @code{mate} package to the system
  15766. profile, and extends polkit with the actions from
  15767. @code{mate-settings-daemon}.
  15768. @end deffn
  15769. @deftp {Data Type} mate-desktop-configuration
  15770. Configuration record for the MATE desktop environment.
  15771. @table @asis
  15772. @item @code{mate} (default: @code{mate})
  15773. The MATE package to use.
  15774. @end table
  15775. @end deftp
  15776. @deffn {Scheme Variable} lxqt-desktop-service-type
  15777. This is the type of the service that runs the @uref{https://lxqt-project.org,
  15778. LXQt desktop environment}. Its value is a @code{lxqt-desktop-configuration}
  15779. object (see below).
  15780. This service adds the @code{lxqt} package to the system
  15781. profile.
  15782. @end deffn
  15783. @deftp {Data Type} lxqt-desktop-configuration
  15784. Configuration record for the LXQt desktop environment.
  15785. @table @asis
  15786. @item @code{lxqt} (default: @code{lxqt})
  15787. The LXQT package to use.
  15788. @end table
  15789. @end deftp
  15790. @deffn {Scheme Variable} enlightenment-desktop-service-type
  15791. Return a service that adds the @code{enlightenment} package to the system
  15792. profile, and extends dbus with actions from @code{efl}.
  15793. @end deffn
  15794. @deftp {Data Type} enlightenment-desktop-service-configuration
  15795. @table @asis
  15796. @item @code{enlightenment} (default: @code{enlightenment})
  15797. The enlightenment package to use.
  15798. @end table
  15799. @end deftp
  15800. Because the GNOME, Xfce and MATE desktop services pull in so many packages,
  15801. the default @code{%desktop-services} variable doesn't include any of
  15802. them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
  15803. @code{%desktop-services} in the @code{services} field of your
  15804. @code{operating-system}:
  15805. @lisp
  15806. (use-modules (gnu))
  15807. (use-service-modules desktop)
  15808. (operating-system
  15809. ...
  15810. ;; cons* adds items to the list given as its last argument.
  15811. (services (cons* (service gnome-desktop-service-type)
  15812. (service xfce-desktop-service)
  15813. %desktop-services))
  15814. ...)
  15815. @end lisp
  15816. These desktop environments will then be available as options in the
  15817. graphical login window.
  15818. The actual service definitions included in @code{%desktop-services} and
  15819. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  15820. are described below.
  15821. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  15822. Return a service that runs the ``system bus'', using @var{dbus}, with
  15823. support for @var{services}.
  15824. @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  15825. facility. Its system bus is used to allow system services to communicate
  15826. and to be notified of system-wide events.
  15827. @var{services} must be a list of packages that provide an
  15828. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  15829. and policy files. For example, to allow avahi-daemon to use the system bus,
  15830. @var{services} must be equal to @code{(list avahi)}.
  15831. @end deffn
  15832. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  15833. Return a service that runs the @code{elogind} login and
  15834. seat management daemon. @uref{https://github.com/elogind/elogind,
  15835. Elogind} exposes a D-Bus interface that can be used to know which users
  15836. are logged in, know what kind of sessions they have open, suspend the
  15837. system, inhibit system suspend, reboot the system, and other tasks.
  15838. Elogind handles most system-level power events for a computer, for
  15839. example suspending the system when a lid is closed, or shutting it down
  15840. when the power button is pressed.
  15841. The @var{config} keyword argument specifies the configuration for
  15842. elogind, and should be the result of an @code{(elogind-configuration
  15843. (@var{parameter} @var{value})...)} invocation. Available parameters and
  15844. their default values are:
  15845. @table @code
  15846. @item kill-user-processes?
  15847. @code{#f}
  15848. @item kill-only-users
  15849. @code{()}
  15850. @item kill-exclude-users
  15851. @code{("root")}
  15852. @item inhibit-delay-max-seconds
  15853. @code{5}
  15854. @item handle-power-key
  15855. @code{poweroff}
  15856. @item handle-suspend-key
  15857. @code{suspend}
  15858. @item handle-hibernate-key
  15859. @code{hibernate}
  15860. @item handle-lid-switch
  15861. @code{suspend}
  15862. @item handle-lid-switch-docked
  15863. @code{ignore}
  15864. @item handle-lid-switch-external-power
  15865. @code{ignore}
  15866. @item power-key-ignore-inhibited?
  15867. @code{#f}
  15868. @item suspend-key-ignore-inhibited?
  15869. @code{#f}
  15870. @item hibernate-key-ignore-inhibited?
  15871. @code{#f}
  15872. @item lid-switch-ignore-inhibited?
  15873. @code{#t}
  15874. @item holdoff-timeout-seconds
  15875. @code{30}
  15876. @item idle-action
  15877. @code{ignore}
  15878. @item idle-action-seconds
  15879. @code{(* 30 60)}
  15880. @item runtime-directory-size-percent
  15881. @code{10}
  15882. @item runtime-directory-size
  15883. @code{#f}
  15884. @item remove-ipc?
  15885. @code{#t}
  15886. @item suspend-state
  15887. @code{("mem" "standby" "freeze")}
  15888. @item suspend-mode
  15889. @code{()}
  15890. @item hibernate-state
  15891. @code{("disk")}
  15892. @item hibernate-mode
  15893. @code{("platform" "shutdown")}
  15894. @item hybrid-sleep-state
  15895. @code{("disk")}
  15896. @item hybrid-sleep-mode
  15897. @code{("suspend" "platform" "shutdown")}
  15898. @end table
  15899. @end deffn
  15900. @deffn {Scheme Procedure} accountsservice-service @
  15901. [#:accountsservice @var{accountsservice}]
  15902. Return a service that runs AccountsService, a system service that can
  15903. list available accounts, change their passwords, and so on.
  15904. AccountsService integrates with PolicyKit to enable unprivileged users
  15905. to acquire the capability to modify their system configuration.
  15906. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  15907. accountsservice web site} for more information.
  15908. The @var{accountsservice} keyword argument is the @code{accountsservice}
  15909. package to expose as a service.
  15910. @end deffn
  15911. @deffn {Scheme Procedure} polkit-service @
  15912. [#:polkit @var{polkit}]
  15913. Return a service that runs the
  15914. @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  15915. management service}, which allows system administrators to grant access to
  15916. privileged operations in a structured way. By querying the Polkit service, a
  15917. privileged system component can know when it should grant additional
  15918. capabilities to ordinary users. For example, an ordinary user can be granted
  15919. the capability to suspend the system if the user is logged in locally.
  15920. @end deffn
  15921. @defvr {Scheme Variable} polkit-wheel-service
  15922. Service that adds the @code{wheel} group as admins to the Polkit
  15923. service. This makes it so that users in the @code{wheel} group are queried
  15924. for their own passwords when performing administrative actions instead of
  15925. @code{root}'s, similar to the behaviour used by @code{sudo}.
  15926. @end defvr
  15927. @defvr {Scheme Variable} upower-service-type
  15928. Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
  15929. system-wide monitor for power consumption and battery levels, with the given
  15930. configuration settings.
  15931. It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
  15932. notably used by GNOME.
  15933. @end defvr
  15934. @deftp {Data Type} upower-configuration
  15935. Data type representation the configuration for UPower.
  15936. @table @asis
  15937. @item @code{upower} (default: @var{upower})
  15938. Package to use for @code{upower}.
  15939. @item @code{watts-up-pro?} (default: @code{#f})
  15940. Enable the Watts Up Pro device.
  15941. @item @code{poll-batteries?} (default: @code{#t})
  15942. Enable polling the kernel for battery level changes.
  15943. @item @code{ignore-lid?} (default: @code{#f})
  15944. Ignore the lid state, this can be useful if it's incorrect on a device.
  15945. @item @code{use-percentage-for-policy?} (default: @code{#f})
  15946. Whether battery percentage based policy should be used. The default is to use
  15947. the time left, change to @code{#t} to use the percentage.
  15948. @item @code{percentage-low} (default: @code{10})
  15949. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15950. at which the battery is considered low.
  15951. @item @code{percentage-critical} (default: @code{3})
  15952. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15953. at which the battery is considered critical.
  15954. @item @code{percentage-action} (default: @code{2})
  15955. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15956. at which action will be taken.
  15957. @item @code{time-low} (default: @code{1200})
  15958. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15959. seconds at which the battery is considered low.
  15960. @item @code{time-critical} (default: @code{300})
  15961. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15962. seconds at which the battery is considered critical.
  15963. @item @code{time-action} (default: @code{120})
  15964. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15965. seconds at which action will be taken.
  15966. @item @code{critical-power-action} (default: @code{'hybrid-sleep})
  15967. The action taken when @code{percentage-action} or @code{time-action} is
  15968. reached (depending on the configuration of @code{use-percentage-for-policy?}).
  15969. Possible values are:
  15970. @itemize @bullet
  15971. @item
  15972. @code{'power-off}
  15973. @item
  15974. @code{'hibernate}
  15975. @item
  15976. @code{'hybrid-sleep}.
  15977. @end itemize
  15978. @end table
  15979. @end deftp
  15980. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  15981. Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
  15982. UDisks}, a @dfn{disk management} daemon that provides user interfaces
  15983. with notifications and ways to mount/unmount disks. Programs that talk
  15984. to UDisks include the @command{udisksctl} command, part of UDisks, and
  15985. GNOME Disks. Note that Udisks relies on the @command{mount} command, so
  15986. it will only be able to use the file-system utilities installed in the
  15987. system profile. For example if you want to be able to mount NTFS
  15988. file-systems in read and write fashion, you'll need to have
  15989. @code{ntfs-3g} installed system-wide.
  15990. @end deffn
  15991. @deffn {Scheme Variable} colord-service-type
  15992. This is the type of the service that runs @command{colord}, a system
  15993. service with a D-Bus
  15994. interface to manage the color profiles of input and output devices such as
  15995. screens and scanners. It is notably used by the GNOME Color Manager graphical
  15996. tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
  15997. site} for more information.
  15998. @end deffn
  15999. @cindex scanner access
  16000. @defvr {Scheme Variable} sane-service-type
  16001. This service provides access to scanners @i{via}
  16002. @uref{http://www.sane-project.org, SANE} by installing the necessary
  16003. udev rules. It is included in @code{%desktop-services} (@pxref{Desktop
  16004. Services}) and relies by default on @code{sane-backends-minimal} package
  16005. (see below) for hardware support.
  16006. @end defvr
  16007. @defvr {Scheme Variable} sane-backends-minimal
  16008. The default package which the @code{sane-service-type} installs. It
  16009. supports many recent scanners.
  16010. @end defvr
  16011. @defvr {Scheme Variable} sane-backends
  16012. This package includes support for all scanners that
  16013. @code{sane-backends-minimal} supports, plus older Hewlett-Packard
  16014. scanners supported by @code{hplip} package. In order to use this on
  16015. a system which relies on @code{%desktop-services}, you may use
  16016. @code{modify-services} (@pxref{Service Reference,
  16017. @code{modify-services}}) as illustrated below:
  16018. @lisp
  16019. (use-modules (gnu))
  16020. (use-service-modules
  16021. @dots{}
  16022. desktop)
  16023. (use-package-modules
  16024. @dots{}
  16025. scanner)
  16026. (define %my-desktop-services
  16027. ;; List of desktop services that supports a broader range of scanners.
  16028. (modify-services %desktop-services
  16029. (sane-service-type _ => sane-backends)))
  16030. (operating-system
  16031. @dots{}
  16032. (services %my-desktop-services)
  16033. @end lisp
  16034. @end defvr
  16035. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  16036. Return a configuration allowing an application to access GeoClue
  16037. location data. @var{name} is the Desktop ID of the application, without
  16038. the @code{.desktop} part. If @var{allowed?} is true, the application
  16039. will have access to location information by default. The boolean
  16040. @var{system?} value indicates whether an application is a system component
  16041. or not. Finally @var{users} is a list of UIDs of all users for which
  16042. this application is allowed location info access. An empty users list
  16043. means that all users are allowed.
  16044. @end deffn
  16045. @defvr {Scheme Variable} %standard-geoclue-applications
  16046. The standard list of well-known GeoClue application configurations,
  16047. granting authority to the GNOME date-and-time utility to ask for the
  16048. current location in order to set the time zone, and allowing the
  16049. IceCat and Epiphany web browsers to request location information.
  16050. IceCat and Epiphany both query the user before allowing a web page to
  16051. know the user's location.
  16052. @end defvr
  16053. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  16054. [#:whitelist '()] @
  16055. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  16056. [#:submit-data? #f]
  16057. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  16058. [#:submission-nick "geoclue"] @
  16059. [#:applications %standard-geoclue-applications]
  16060. Return a service that runs the GeoClue location service. This service
  16061. provides a D-Bus interface to allow applications to request access to a
  16062. user's physical location, and optionally to add information to online
  16063. location databases. See
  16064. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  16065. web site} for more information.
  16066. @end deffn
  16067. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  16068. [@w{#:auto-enable? #f}]
  16069. Return a service that runs the @command{bluetoothd} daemon, which
  16070. manages all the Bluetooth devices and provides a number of D-Bus
  16071. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  16072. powered automatically at boot, which can be useful when using a
  16073. bluetooth keyboard or mouse.
  16074. Users need to be in the @code{lp} group to access the D-Bus service.
  16075. @end deffn
  16076. @defvr {Scheme Variable} gnome-keyring-service-type
  16077. This is the type of the service that adds the
  16078. @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
  16079. value is a @code{gnome-keyring-configuration} object (see below).
  16080. This service adds the @code{gnome-keyring} package to the system profile
  16081. and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
  16082. a user's login keyring when they log in or setting its password with passwd.
  16083. @end defvr
  16084. @deftp {Data Type} gnome-keyring-configuration
  16085. Configuration record for the GNOME Keyring service.
  16086. @table @asis
  16087. @item @code{keyring} (default: @code{gnome-keyring})
  16088. The GNOME keyring package to use.
  16089. @item @code{pam-services}
  16090. A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
  16091. services to extend, where @var{service} is the name of an existing
  16092. service to extend and @var{kind} is one of @code{login} or
  16093. @code{passwd}.
  16094. If @code{login} is given, it adds an optional
  16095. @code{pam_gnome_keyring.so} to the auth block without arguments and to
  16096. the session block with @code{auto_start}. If @code{passwd} is given, it
  16097. adds an optional @code{pam_gnome_keyring.so} to the password block
  16098. without arguments.
  16099. By default, this field contains ``gdm-password'' with the value @code{login}
  16100. and ``passwd'' is with the value @code{passwd}.
  16101. @end table
  16102. @end deftp
  16103. @node Sound Services
  16104. @subsection Sound Services
  16105. @cindex sound support
  16106. @cindex ALSA
  16107. @cindex PulseAudio, sound support
  16108. The @code{(gnu services sound)} module provides a service to configure the
  16109. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  16110. preferred ALSA output driver.
  16111. @deffn {Scheme Variable} alsa-service-type
  16112. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  16113. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  16114. configuration file. The value for this type is a @command{alsa-configuration}
  16115. record as in this example:
  16116. @lisp
  16117. (service alsa-service-type)
  16118. @end lisp
  16119. See below for details about @code{alsa-configuration}.
  16120. @end deffn
  16121. @deftp {Data Type} alsa-configuration
  16122. Data type representing the configuration for @code{alsa-service}.
  16123. @table @asis
  16124. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  16125. @code{alsa-plugins} package to use.
  16126. @item @code{pulseaudio?} (default: @var{#t})
  16127. Whether ALSA applications should transparently be made to use the
  16128. @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
  16129. Using PulseAudio allows you to run several sound-producing applications
  16130. at the same time and to individual control them @i{via}
  16131. @command{pavucontrol}, among other things.
  16132. @item @code{extra-options} (default: @var{""})
  16133. String to append to the @file{/etc/asound.conf} file.
  16134. @end table
  16135. @end deftp
  16136. Individual users who want to override the system configuration of ALSA can do
  16137. it with the @file{~/.asoundrc} file:
  16138. @example
  16139. # In guix, we have to specify the absolute path for plugins.
  16140. pcm_type.jack @{
  16141. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  16142. @}
  16143. # Routing ALSA to jack:
  16144. # <http://jackaudio.org/faq/routing_alsa.html>.
  16145. pcm.rawjack @{
  16146. type jack
  16147. playback_ports @{
  16148. 0 system:playback_1
  16149. 1 system:playback_2
  16150. @}
  16151. capture_ports @{
  16152. 0 system:capture_1
  16153. 1 system:capture_2
  16154. @}
  16155. @}
  16156. pcm.!default @{
  16157. type plug
  16158. slave @{
  16159. pcm "rawjack"
  16160. @}
  16161. @}
  16162. @end example
  16163. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  16164. details.
  16165. @deffn {Scheme Variable} pulseaudio-service-type
  16166. This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
  16167. sound server. It exists to allow system overrides of the default settings
  16168. via @code{pulseaudio-configuration}, see below.
  16169. @quotation Warning
  16170. This service overrides per-user configuration files. If you want
  16171. PulseAudio to honor configuration files in @file{~/.config/pulse} you
  16172. have to unset the environment variables @env{PULSE_CONFIG} and
  16173. @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
  16174. @end quotation
  16175. @quotation Warning
  16176. This service on its own does not ensure, that the @code{pulseaudio} package
  16177. exists on your machine. It merely adds configuration files for it, as
  16178. detailed below. In the (admittedly unlikely) case, that you find yourself
  16179. without a @code{pulseaudio} package, consider enabling it through the
  16180. @code{alsa-service-type} above.
  16181. @end quotation
  16182. @end deffn
  16183. @deftp {Data Type} pulseaudio-configuration
  16184. Data type representing the configuration for @code{pulseaudio-service}.
  16185. @table @asis
  16186. @item @code{client-conf} (default: @code{'()})
  16187. List of settings to set in @file{client.conf}.
  16188. Accepts a list of strings or a symbol-value pairs. A string will be
  16189. inserted as-is with a newline added. A pair will be formatted as
  16190. ``key = value'', again with a newline added.
  16191. @item @code{daemon-conf} (default: @code{'((flat-volumes . no))})
  16192. List of settings to set in @file{daemon.conf}, formatted just like
  16193. @var{client-conf}.
  16194. @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
  16195. Script file to use as @file{default.pa}.
  16196. @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
  16197. Script file to use as @file{system.pa}.
  16198. @end table
  16199. @end deftp
  16200. @deffn {Scheme Variable} ladspa-service-type
  16201. This service sets the @var{LADSPA_PATH} variable, so that programs, which
  16202. respect it, e.g. PulseAudio, can load LADSPA plugins.
  16203. The following example will setup the service to enable modules from the
  16204. @code{swh-plugins} package:
  16205. @lisp
  16206. (service ladspa-service-type
  16207. (ladspa-configuration (plugins (list swh-plugins))))
  16208. @end lisp
  16209. See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
  16210. details.
  16211. @end deffn
  16212. @node Database Services
  16213. @subsection Database Services
  16214. @cindex database
  16215. @cindex SQL
  16216. The @code{(gnu services databases)} module provides the following services.
  16217. @subsubheading PostgreSQL
  16218. The following example describes a PostgreSQL service with the default
  16219. configuration.
  16220. @lisp
  16221. (service postgresql-service-type
  16222. (postgresql-configuration
  16223. (postgresql postgresql-10)))
  16224. @end lisp
  16225. If the services fails to start, it may be due to an incompatible
  16226. cluster already present in @var{data-directory}. Adjust it (or, if you
  16227. don't need the cluster anymore, delete @var{data-directory}), then
  16228. restart the service.
  16229. Peer authentication is used by default and the @code{postgres} user
  16230. account has no shell, which prevents the direct execution of @code{psql}
  16231. commands as this user. To use @code{psql}, you can temporarily log in
  16232. as @code{postgres} using a shell, create a PostgreSQL superuser with the
  16233. same name as one of the system users and then create the associated
  16234. database.
  16235. @example
  16236. sudo -u postgres -s /bin/sh
  16237. createuser --interactive
  16238. createdb $MY_USER_LOGIN # Replace appropriately.
  16239. @end example
  16240. @deftp {Data Type} postgresql-configuration
  16241. Data type representing the configuration for the
  16242. @code{postgresql-service-type}.
  16243. @table @asis
  16244. @item @code{postgresql}
  16245. PostgreSQL package to use for the service.
  16246. @item @code{port} (default: @code{5432})
  16247. Port on which PostgreSQL should listen.
  16248. @item @code{locale} (default: @code{"en_US.utf8"})
  16249. Locale to use as the default when creating the database cluster.
  16250. @item @code{config-file} (default: @code{(postgresql-config-file)})
  16251. The configuration file to use when running PostgreSQL@. The default
  16252. behaviour uses the postgresql-config-file record with the default values
  16253. for the fields.
  16254. @item @code{log-directory} (default: @code{"/var/log/postgresql"})
  16255. The directory where @command{pg_ctl} output will be written in a file
  16256. named @code{"pg_ctl.log"}. This file can be useful to debug PostgreSQL
  16257. configuration errors for instance.
  16258. @item @code{data-directory} (default: @code{"/var/lib/postgresql/data"})
  16259. Directory in which to store the data.
  16260. @item @code{extension-packages} (default: @code{'()})
  16261. @cindex postgresql extension-packages
  16262. Additional extensions are loaded from packages listed in
  16263. @var{extension-packages}. Extensions are available at runtime. For instance,
  16264. to create a geographic database using the @code{postgis} extension, a user can
  16265. configure the postgresql-service as in this example:
  16266. @cindex postgis
  16267. @lisp
  16268. (use-package-modules databases geo)
  16269. (operating-system
  16270. ...
  16271. ;; postgresql is required to run `psql' but postgis is not required for
  16272. ;; proper operation.
  16273. (packages (cons* postgresql %base-packages))
  16274. (services
  16275. (cons*
  16276. (service postgresql-service-type
  16277. (postgresql-configuration
  16278. (postgresql postgresql-10)
  16279. (extension-packages (list postgis))))
  16280. %base-services)))
  16281. @end lisp
  16282. Then the extension becomes visible and you can initialise an empty geographic
  16283. database in this way:
  16284. @example
  16285. psql -U postgres
  16286. > create database postgistest;
  16287. > \connect postgistest;
  16288. > create extension postgis;
  16289. > create extension postgis_topology;
  16290. @end example
  16291. There is no need to add this field for contrib extensions such as hstore or
  16292. dblink as they are already loadable by postgresql. This field is only
  16293. required to add extensions provided by other packages.
  16294. @end table
  16295. @end deftp
  16296. @deftp {Data Type} postgresql-config-file
  16297. Data type representing the PostgreSQL configuration file. As shown in
  16298. the following example, this can be used to customize the configuration
  16299. of PostgreSQL@. Note that you can use any G-expression or filename in
  16300. place of this record, if you already have a configuration file you'd
  16301. like to use for example.
  16302. @lisp
  16303. (service postgresql-service-type
  16304. (postgresql-configuration
  16305. (config-file
  16306. (postgresql-config-file
  16307. (log-destination "stderr")
  16308. (hba-file
  16309. (plain-file "pg_hba.conf"
  16310. "
  16311. local all all trust
  16312. host all all 127.0.0.1/32 md5
  16313. host all all ::1/128 md5"))
  16314. (extra-config
  16315. '(("session_preload_libraries" "auto_explain")
  16316. ("random_page_cost" 2)
  16317. ("auto_explain.log_min_duration" "100 ms")
  16318. ("work_mem" "500 MB")
  16319. ("logging_collector" #t)
  16320. ("log_directory" "/var/log/postgresql")))))))
  16321. @end lisp
  16322. @table @asis
  16323. @item @code{log-destination} (default: @code{"syslog"})
  16324. The logging method to use for PostgreSQL@. Multiple values are accepted,
  16325. separated by commas.
  16326. @item @code{hba-file} (default: @code{%default-postgres-hba})
  16327. Filename or G-expression for the host-based authentication
  16328. configuration.
  16329. @item @code{ident-file} (default: @code{%default-postgres-ident})
  16330. Filename or G-expression for the user name mapping configuration.
  16331. @item @code{socket-directory} (default: @code{"/var/run/postgresql"})
  16332. Specifies the directory of the Unix-domain socket(s) on which PostgreSQL
  16333. is to listen for connections from client applications. If set to
  16334. @code{""} PostgreSQL does not listen on any Unix-domain sockets, in
  16335. which case only TCP/IP sockets can be used to connect to the server.
  16336. By default, the @code{#false} value means the PostgreSQL default value
  16337. will be used, which is currently @samp{/tmp}.
  16338. @item @code{extra-config} (default: @code{'()})
  16339. List of additional keys and values to include in the PostgreSQL config
  16340. file. Each entry in the list should be a list where the first element
  16341. is the key, and the remaining elements are the values.
  16342. The values can be numbers, booleans or strings and will be mapped to
  16343. PostgreSQL parameters types @code{Boolean}, @code{String},
  16344. @code{Numeric}, @code{Numeric with Unit} and @code{Enumerated} described
  16345. @uref{https://www.postgresql.org/docs/current/config-setting.html,
  16346. here}.
  16347. @end table
  16348. @end deftp
  16349. @deffn {Scheme Variable} postgresql-role-service-type
  16350. This service allows to create PostgreSQL roles and databases after
  16351. PostgreSQL service start. Here is an example of its use.
  16352. @lisp
  16353. (service postgresql-role-service-type
  16354. (postgresql-role-configuration
  16355. (roles
  16356. (list (postgresql-role
  16357. (name "test")
  16358. (create-database? #t))))))
  16359. @end lisp
  16360. This service can be extended with extra roles, as in this
  16361. example:
  16362. @lisp
  16363. (service-extension postgresql-role-service-type
  16364. (const (postgresql-role
  16365. (name "alice")
  16366. (create-database? #t))))
  16367. @end lisp
  16368. @end deffn
  16369. @deftp {Data Type} postgresql-role
  16370. PostgreSQL manages database access permissions using the concept of
  16371. roles. A role can be thought of as either a database user, or a group
  16372. of database users, depending on how the role is set up. Roles can own
  16373. database objects (for example, tables) and can assign privileges on
  16374. those objects to other roles to control who has access to which objects.
  16375. @table @asis
  16376. @item @code{name}
  16377. The role name.
  16378. @item @code{permissions} (default: @code{'(createdb login)})
  16379. The role permissions list. Supported permissions are @code{bypassrls},
  16380. @code{createdb}, @code{createrole}, @code{login}, @code{replication} and
  16381. @code{superuser}.
  16382. @item @code{create-database?} (default: @code{#f})
  16383. Whether to create a database with the same name as the role.
  16384. @end table
  16385. @end deftp
  16386. @deftp {Data Type} postgresql-role-configuration
  16387. Data type representing the configuration of
  16388. @var{postgresql-role-service-type}.
  16389. @table @asis
  16390. @item @code{host} (default: @code{"/var/run/postgresql"})
  16391. The PostgreSQL host to connect to.
  16392. @item @code{log} (default: @code{"/var/log/postgresql_roles.log"})
  16393. File name of the log file.
  16394. @item @code{roles} (default: @code{'()})
  16395. The initial PostgreSQL roles to create.
  16396. @end table
  16397. @end deftp
  16398. @subsubheading MariaDB/MySQL
  16399. @defvr {Scheme Variable} mysql-service-type
  16400. This is the service type for a MySQL or MariaDB database server. Its value
  16401. is a @code{mysql-configuration} object that specifies which package to use,
  16402. as well as various settings for the @command{mysqld} daemon.
  16403. @end defvr
  16404. @deftp {Data Type} mysql-configuration
  16405. Data type representing the configuration of @var{mysql-service-type}.
  16406. @table @asis
  16407. @item @code{mysql} (default: @var{mariadb})
  16408. Package object of the MySQL database server, can be either @var{mariadb}
  16409. or @var{mysql}.
  16410. For MySQL, a temporary root password will be displayed at activation time.
  16411. For MariaDB, the root password is empty.
  16412. @item @code{bind-address} (default: @code{"127.0.0.1"})
  16413. The IP on which to listen for network connections. Use @code{"0.0.0.0"}
  16414. to bind to all available network interfaces.
  16415. @item @code{port} (default: @code{3306})
  16416. TCP port on which the database server listens for incoming connections.
  16417. @item @code{socket} (default: @code{"/run/mysqld/mysqld.sock"})
  16418. Socket file to use for local (non-network) connections.
  16419. @item @code{extra-content} (default: @code{""})
  16420. Additional settings for the @file{my.cnf} configuration file.
  16421. @item @code{extra-environment} (default: @code{#~'()})
  16422. List of environment variables passed to the @command{mysqld} process.
  16423. @item @code{auto-upgrade?} (default: @code{#t})
  16424. Whether to automatically run @command{mysql_upgrade} after starting the
  16425. service. This is necessary to upgrade the @dfn{system schema} after
  16426. ``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can
  16427. be disabled if you would rather do that manually.
  16428. @end table
  16429. @end deftp
  16430. @subsubheading Memcached
  16431. @defvr {Scheme Variable} memcached-service-type
  16432. This is the service type for the @uref{https://memcached.org/,
  16433. Memcached} service, which provides a distributed in memory cache. The
  16434. value for the service type is a @code{memcached-configuration} object.
  16435. @end defvr
  16436. @lisp
  16437. (service memcached-service-type)
  16438. @end lisp
  16439. @deftp {Data Type} memcached-configuration
  16440. Data type representing the configuration of memcached.
  16441. @table @asis
  16442. @item @code{memcached} (default: @code{memcached})
  16443. The Memcached package to use.
  16444. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  16445. Network interfaces on which to listen.
  16446. @item @code{tcp-port} (default: @code{11211})
  16447. Port on which to accept connections.
  16448. @item @code{udp-port} (default: @code{11211})
  16449. Port on which to accept UDP connections on, a value of 0 will disable
  16450. listening on a UDP socket.
  16451. @item @code{additional-options} (default: @code{'()})
  16452. Additional command line options to pass to @code{memcached}.
  16453. @end table
  16454. @end deftp
  16455. @subsubheading Redis
  16456. @defvr {Scheme Variable} redis-service-type
  16457. This is the service type for the @uref{https://redis.io/, Redis}
  16458. key/value store, whose value is a @code{redis-configuration} object.
  16459. @end defvr
  16460. @deftp {Data Type} redis-configuration
  16461. Data type representing the configuration of redis.
  16462. @table @asis
  16463. @item @code{redis} (default: @code{redis})
  16464. The Redis package to use.
  16465. @item @code{bind} (default: @code{"127.0.0.1"})
  16466. Network interface on which to listen.
  16467. @item @code{port} (default: @code{6379})
  16468. Port on which to accept connections on, a value of 0 will disable
  16469. listening on a TCP socket.
  16470. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  16471. Directory in which to store the database and related files.
  16472. @end table
  16473. @end deftp
  16474. @node Mail Services
  16475. @subsection Mail Services
  16476. @cindex mail
  16477. @cindex email
  16478. The @code{(gnu services mail)} module provides Guix service definitions
  16479. for email services: IMAP, POP3, and LMTP servers, as well as mail
  16480. transport agents (MTAs). Lots of acronyms! These services are detailed
  16481. in the subsections below.
  16482. @subsubheading Dovecot Service
  16483. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  16484. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  16485. @end deffn
  16486. By default, Dovecot does not need much configuration; the default
  16487. configuration object created by @code{(dovecot-configuration)} will
  16488. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  16489. certificate will be generated for TLS-protected connections, though
  16490. Dovecot will also listen on cleartext ports by default. There are a
  16491. number of options, though, which mail administrators might need to change,
  16492. and as is the case with other services, Guix allows the system
  16493. administrator to specify these parameters via a uniform Scheme interface.
  16494. For example, to specify that mail is located at @code{maildir~/.mail},
  16495. one would instantiate the Dovecot service like this:
  16496. @lisp
  16497. (dovecot-service #:config
  16498. (dovecot-configuration
  16499. (mail-location "maildir:~/.mail")))
  16500. @end lisp
  16501. The available configuration parameters follow. Each parameter
  16502. definition is preceded by its type; for example, @samp{string-list foo}
  16503. indicates that the @code{foo} parameter should be specified as a list of
  16504. strings. There is also a way to specify the configuration as a string,
  16505. if you have an old @code{dovecot.conf} file that you want to port over
  16506. from some other system; see the end for more details.
  16507. @c The following documentation was initially generated by
  16508. @c (generate-documentation) in (gnu services mail). Manually maintained
  16509. @c documentation is better, so we shouldn't hesitate to edit below as
  16510. @c needed. However if the change you want to make to this documentation
  16511. @c can be done in an automated way, it's probably easier to change
  16512. @c (generate-documentation) than to make it below and have to deal with
  16513. @c the churn as dovecot updates.
  16514. Available @code{dovecot-configuration} fields are:
  16515. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  16516. The dovecot package.
  16517. @end deftypevr
  16518. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  16519. A list of IPs or hosts where to listen for connections. @samp{*}
  16520. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  16521. interfaces. If you want to specify non-default ports or anything more
  16522. complex, customize the address and port fields of the
  16523. @samp{inet-listener} of the specific services you are interested in.
  16524. @end deftypevr
  16525. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  16526. List of protocols we want to serve. Available protocols include
  16527. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  16528. Available @code{protocol-configuration} fields are:
  16529. @deftypevr {@code{protocol-configuration} parameter} string name
  16530. The name of the protocol.
  16531. @end deftypevr
  16532. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  16533. UNIX socket path to the master authentication server to find users.
  16534. This is used by imap (for shared users) and lda.
  16535. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  16536. @end deftypevr
  16537. @deftypevr {@code{protocol-configuration} parameter} boolean imap-metadata?
  16538. Whether to enable the @code{IMAP METADATA} extension as defined in
  16539. @uref{https://tools.ietf.org/html/rfc5464,RFC@tie{}5464}, which provides
  16540. a means for clients to set and retrieve per-mailbox, per-user metadata
  16541. and annotations over IMAP.
  16542. If this is @samp{#t}, you must also specify a dictionary @i{via} the
  16543. @code{mail-attribute-dict} setting.
  16544. Defaults to @samp{#f}.
  16545. @end deftypevr
  16546. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-notify-capabilities
  16547. Which NOTIFY capabilities to report to clients that first connect to
  16548. the ManageSieve service, before authentication. These may differ from the
  16549. capabilities offered to authenticated users. If this field is left empty,
  16550. report what the Sieve interpreter supports by default.
  16551. Defaults to @samp{()}.
  16552. @end deftypevr
  16553. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-sieve-capability
  16554. Which SIEVE capabilities to report to clients that first connect to
  16555. the ManageSieve service, before authentication. These may differ from the
  16556. capabilities offered to authenticated users. If this field is left empty,
  16557. report what the Sieve interpreter supports by default.
  16558. Defaults to @samp{()}.
  16559. @end deftypevr
  16560. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  16561. Space separated list of plugins to load.
  16562. @end deftypevr
  16563. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  16564. Maximum number of IMAP connections allowed for a user from each IP
  16565. address. NOTE: The username is compared case-sensitively.
  16566. Defaults to @samp{10}.
  16567. @end deftypevr
  16568. @end deftypevr
  16569. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  16570. List of services to enable. Available services include @samp{imap},
  16571. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  16572. @samp{lmtp}.
  16573. Available @code{service-configuration} fields are:
  16574. @deftypevr {@code{service-configuration} parameter} string kind
  16575. The service kind. Valid values include @code{director},
  16576. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  16577. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  16578. @code{tcpwrap}, @code{quota-warning}, or anything else.
  16579. @end deftypevr
  16580. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  16581. Listeners for the service. A listener is either a
  16582. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  16583. an @code{inet-listener-configuration}.
  16584. Defaults to @samp{()}.
  16585. Available @code{unix-listener-configuration} fields are:
  16586. @deftypevr {@code{unix-listener-configuration} parameter} string path
  16587. Path to the file, relative to @code{base-dir} field. This is also used as
  16588. the section name.
  16589. @end deftypevr
  16590. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  16591. The access mode for the socket.
  16592. Defaults to @samp{"0600"}.
  16593. @end deftypevr
  16594. @deftypevr {@code{unix-listener-configuration} parameter} string user
  16595. The user to own the socket.
  16596. Defaults to @samp{""}.
  16597. @end deftypevr
  16598. @deftypevr {@code{unix-listener-configuration} parameter} string group
  16599. The group to own the socket.
  16600. Defaults to @samp{""}.
  16601. @end deftypevr
  16602. Available @code{fifo-listener-configuration} fields are:
  16603. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  16604. Path to the file, relative to @code{base-dir} field. This is also used as
  16605. the section name.
  16606. @end deftypevr
  16607. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  16608. The access mode for the socket.
  16609. Defaults to @samp{"0600"}.
  16610. @end deftypevr
  16611. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  16612. The user to own the socket.
  16613. Defaults to @samp{""}.
  16614. @end deftypevr
  16615. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  16616. The group to own the socket.
  16617. Defaults to @samp{""}.
  16618. @end deftypevr
  16619. Available @code{inet-listener-configuration} fields are:
  16620. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  16621. The protocol to listen for.
  16622. @end deftypevr
  16623. @deftypevr {@code{inet-listener-configuration} parameter} string address
  16624. The address on which to listen, or empty for all addresses.
  16625. Defaults to @samp{""}.
  16626. @end deftypevr
  16627. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  16628. The port on which to listen.
  16629. @end deftypevr
  16630. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  16631. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  16632. @samp{required}.
  16633. Defaults to @samp{#t}.
  16634. @end deftypevr
  16635. @end deftypevr
  16636. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  16637. Maximum number of simultaneous client connections per process. Once
  16638. this number of connections is received, the next incoming connection
  16639. will prompt Dovecot to spawn another process. If set to 0,
  16640. @code{default-client-limit} is used instead.
  16641. Defaults to @samp{0}.
  16642. @end deftypevr
  16643. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  16644. Number of connections to handle before starting a new process.
  16645. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  16646. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  16647. Defaults to @samp{1}.
  16648. @end deftypevr
  16649. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  16650. Maximum number of processes that can exist for this service. If set to
  16651. 0, @code{default-process-limit} is used instead.
  16652. Defaults to @samp{0}.
  16653. @end deftypevr
  16654. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  16655. Number of processes to always keep waiting for more connections.
  16656. Defaults to @samp{0}.
  16657. @end deftypevr
  16658. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  16659. If you set @samp{service-count 0}, you probably need to grow
  16660. this.
  16661. Defaults to @samp{256000000}.
  16662. @end deftypevr
  16663. @end deftypevr
  16664. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  16665. Dict configuration, as created by the @code{dict-configuration}
  16666. constructor.
  16667. Available @code{dict-configuration} fields are:
  16668. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  16669. A list of key-value pairs that this dict should hold.
  16670. Defaults to @samp{()}.
  16671. @end deftypevr
  16672. @end deftypevr
  16673. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  16674. A list of passdb configurations, each one created by the
  16675. @code{passdb-configuration} constructor.
  16676. Available @code{passdb-configuration} fields are:
  16677. @deftypevr {@code{passdb-configuration} parameter} string driver
  16678. The driver that the passdb should use. Valid values include
  16679. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  16680. @samp{static}.
  16681. Defaults to @samp{"pam"}.
  16682. @end deftypevr
  16683. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  16684. Space separated list of arguments to the passdb driver.
  16685. Defaults to @samp{""}.
  16686. @end deftypevr
  16687. @end deftypevr
  16688. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  16689. List of userdb configurations, each one created by the
  16690. @code{userdb-configuration} constructor.
  16691. Available @code{userdb-configuration} fields are:
  16692. @deftypevr {@code{userdb-configuration} parameter} string driver
  16693. The driver that the userdb should use. Valid values include
  16694. @samp{passwd} and @samp{static}.
  16695. Defaults to @samp{"passwd"}.
  16696. @end deftypevr
  16697. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  16698. Space separated list of arguments to the userdb driver.
  16699. Defaults to @samp{""}.
  16700. @end deftypevr
  16701. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  16702. Override fields from passwd.
  16703. Defaults to @samp{()}.
  16704. @end deftypevr
  16705. @end deftypevr
  16706. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  16707. Plug-in configuration, created by the @code{plugin-configuration}
  16708. constructor.
  16709. @end deftypevr
  16710. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  16711. List of namespaces. Each item in the list is created by the
  16712. @code{namespace-configuration} constructor.
  16713. Available @code{namespace-configuration} fields are:
  16714. @deftypevr {@code{namespace-configuration} parameter} string name
  16715. Name for this namespace.
  16716. @end deftypevr
  16717. @deftypevr {@code{namespace-configuration} parameter} string type
  16718. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  16719. Defaults to @samp{"private"}.
  16720. @end deftypevr
  16721. @deftypevr {@code{namespace-configuration} parameter} string separator
  16722. Hierarchy separator to use. You should use the same separator for
  16723. all namespaces or some clients get confused. @samp{/} is usually a good
  16724. one. The default however depends on the underlying mail storage
  16725. format.
  16726. Defaults to @samp{""}.
  16727. @end deftypevr
  16728. @deftypevr {@code{namespace-configuration} parameter} string prefix
  16729. Prefix required to access this namespace. This needs to be
  16730. different for all namespaces. For example @samp{Public/}.
  16731. Defaults to @samp{""}.
  16732. @end deftypevr
  16733. @deftypevr {@code{namespace-configuration} parameter} string location
  16734. Physical location of the mailbox. This is in the same format as
  16735. mail_location, which is also the default for it.
  16736. Defaults to @samp{""}.
  16737. @end deftypevr
  16738. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  16739. There can be only one INBOX, and this setting defines which
  16740. namespace has it.
  16741. Defaults to @samp{#f}.
  16742. @end deftypevr
  16743. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  16744. If namespace is hidden, it's not advertised to clients via NAMESPACE
  16745. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  16746. useful when converting from another server with different namespaces
  16747. which you want to deprecate but still keep working. For example you can
  16748. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  16749. and @samp{mail/}.
  16750. Defaults to @samp{#f}.
  16751. @end deftypevr
  16752. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  16753. Show the mailboxes under this namespace with the LIST command. This
  16754. makes the namespace visible for clients that do not support the NAMESPACE
  16755. extension. The special @code{children} value lists child mailboxes, but
  16756. hides the namespace prefix.
  16757. Defaults to @samp{#t}.
  16758. @end deftypevr
  16759. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  16760. Namespace handles its own subscriptions. If set to @code{#f}, the
  16761. parent namespace handles them. The empty prefix should always have this
  16762. as @code{#t}).
  16763. Defaults to @samp{#t}.
  16764. @end deftypevr
  16765. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  16766. List of predefined mailboxes in this namespace.
  16767. Defaults to @samp{()}.
  16768. Available @code{mailbox-configuration} fields are:
  16769. @deftypevr {@code{mailbox-configuration} parameter} string name
  16770. Name for this mailbox.
  16771. @end deftypevr
  16772. @deftypevr {@code{mailbox-configuration} parameter} string auto
  16773. @samp{create} will automatically create this mailbox.
  16774. @samp{subscribe} will both create and subscribe to the mailbox.
  16775. Defaults to @samp{"no"}.
  16776. @end deftypevr
  16777. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  16778. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  16779. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  16780. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  16781. Defaults to @samp{()}.
  16782. @end deftypevr
  16783. @end deftypevr
  16784. @end deftypevr
  16785. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  16786. Base directory where to store runtime data.
  16787. Defaults to @samp{"/var/run/dovecot/"}.
  16788. @end deftypevr
  16789. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  16790. Greeting message for clients.
  16791. Defaults to @samp{"Dovecot ready."}.
  16792. @end deftypevr
  16793. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  16794. List of trusted network ranges. Connections from these IPs are
  16795. allowed to override their IP addresses and ports (for logging and for
  16796. authentication checks). @samp{disable-plaintext-auth} is also ignored
  16797. for these networks. Typically you would specify your IMAP proxy servers
  16798. here.
  16799. Defaults to @samp{()}.
  16800. @end deftypevr
  16801. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  16802. List of login access check sockets (e.g.@: tcpwrap).
  16803. Defaults to @samp{()}.
  16804. @end deftypevr
  16805. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  16806. Show more verbose process titles (in ps). Currently shows user name
  16807. and IP address. Useful for seeing who is actually using the IMAP
  16808. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  16809. accounts).
  16810. Defaults to @samp{#f}.
  16811. @end deftypevr
  16812. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  16813. Should all processes be killed when Dovecot master process shuts down.
  16814. Setting this to @code{#f} means that Dovecot can be upgraded without
  16815. forcing existing client connections to close (although that could also
  16816. be a problem if the upgrade is e.g.@: due to a security fix).
  16817. Defaults to @samp{#t}.
  16818. @end deftypevr
  16819. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  16820. If non-zero, run mail commands via this many connections to doveadm
  16821. server, instead of running them directly in the same process.
  16822. Defaults to @samp{0}.
  16823. @end deftypevr
  16824. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  16825. UNIX socket or host:port used for connecting to doveadm server.
  16826. Defaults to @samp{"doveadm-server"}.
  16827. @end deftypevr
  16828. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  16829. List of environment variables that are preserved on Dovecot startup
  16830. and passed down to all of its child processes. You can also give
  16831. key=value pairs to always set specific settings.
  16832. @end deftypevr
  16833. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  16834. Disable LOGIN command and all other plaintext authentications unless
  16835. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  16836. matches the local IP (i.e.@: you're connecting from the same computer),
  16837. the connection is considered secure and plaintext authentication is
  16838. allowed. See also ssl=required setting.
  16839. Defaults to @samp{#t}.
  16840. @end deftypevr
  16841. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  16842. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  16843. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  16844. for caching to be used.
  16845. Defaults to @samp{0}.
  16846. @end deftypevr
  16847. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  16848. Time to live for cached data. After TTL expires the cached record
  16849. is no longer used, *except* if the main database lookup returns internal
  16850. failure. We also try to handle password changes automatically: If
  16851. user's previous authentication was successful, but this one wasn't, the
  16852. cache isn't used. For now this works only with plaintext
  16853. authentication.
  16854. Defaults to @samp{"1 hour"}.
  16855. @end deftypevr
  16856. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  16857. TTL for negative hits (user not found, password mismatch).
  16858. 0 disables caching them completely.
  16859. Defaults to @samp{"1 hour"}.
  16860. @end deftypevr
  16861. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  16862. List of realms for SASL authentication mechanisms that need them.
  16863. You can leave it empty if you don't want to support multiple realms.
  16864. Many clients simply use the first one listed here, so keep the default
  16865. realm first.
  16866. Defaults to @samp{()}.
  16867. @end deftypevr
  16868. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  16869. Default realm/domain to use if none was specified. This is used for
  16870. both SASL realms and appending @@domain to username in plaintext
  16871. logins.
  16872. Defaults to @samp{""}.
  16873. @end deftypevr
  16874. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  16875. List of allowed characters in username. If the user-given username
  16876. contains a character not listed in here, the login automatically fails.
  16877. This is just an extra check to make sure user can't exploit any
  16878. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  16879. you want to allow all characters, set this value to empty.
  16880. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  16881. @end deftypevr
  16882. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  16883. Username character translations before it's looked up from
  16884. databases. The value contains series of from -> to characters. For
  16885. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  16886. translated to @samp{@@}.
  16887. Defaults to @samp{""}.
  16888. @end deftypevr
  16889. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  16890. Username formatting before it's looked up from databases. You can
  16891. use the standard variables here, e.g.@: %Lu would lowercase the username,
  16892. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  16893. change the @samp{@@} into @samp{-AT-}. This translation is done after
  16894. @samp{auth-username-translation} changes.
  16895. Defaults to @samp{"%Lu"}.
  16896. @end deftypevr
  16897. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  16898. If you want to allow master users to log in by specifying the master
  16899. username within the normal username string (i.e.@: not using SASL
  16900. mechanism's support for it), you can specify the separator character
  16901. here. The format is then <username><separator><master username>.
  16902. UW-IMAP uses @samp{*} as the separator, so that could be a good
  16903. choice.
  16904. Defaults to @samp{""}.
  16905. @end deftypevr
  16906. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  16907. Username to use for users logging in with ANONYMOUS SASL
  16908. mechanism.
  16909. Defaults to @samp{"anonymous"}.
  16910. @end deftypevr
  16911. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  16912. Maximum number of dovecot-auth worker processes. They're used to
  16913. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  16914. They're automatically created and destroyed as needed.
  16915. Defaults to @samp{30}.
  16916. @end deftypevr
  16917. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  16918. Host name to use in GSSAPI principal names. The default is to use
  16919. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  16920. allow all keytab entries.
  16921. Defaults to @samp{""}.
  16922. @end deftypevr
  16923. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  16924. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  16925. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  16926. need to change the auth service to run as root to be able to read this
  16927. file.
  16928. Defaults to @samp{""}.
  16929. @end deftypevr
  16930. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  16931. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  16932. and @samp{ntlm-auth} helper.
  16933. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  16934. Defaults to @samp{#f}.
  16935. @end deftypevr
  16936. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  16937. Path for Samba's @samp{ntlm-auth} helper binary.
  16938. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  16939. @end deftypevr
  16940. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  16941. Time to delay before replying to failed authentications.
  16942. Defaults to @samp{"2 secs"}.
  16943. @end deftypevr
  16944. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  16945. Require a valid SSL client certificate or the authentication
  16946. fails.
  16947. Defaults to @samp{#f}.
  16948. @end deftypevr
  16949. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  16950. Take the username from client's SSL certificate, using
  16951. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  16952. CommonName.
  16953. Defaults to @samp{#f}.
  16954. @end deftypevr
  16955. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  16956. List of wanted authentication mechanisms. Supported mechanisms are:
  16957. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  16958. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  16959. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  16960. @samp{disable-plaintext-auth} setting.
  16961. @end deftypevr
  16962. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  16963. List of IPs or hostnames to all director servers, including ourself.
  16964. Ports can be specified as ip:port. The default port is the same as what
  16965. director service's @samp{inet-listener} is using.
  16966. Defaults to @samp{()}.
  16967. @end deftypevr
  16968. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  16969. List of IPs or hostnames to all backend mail servers. Ranges are
  16970. allowed too, like 10.0.0.10-10.0.0.30.
  16971. Defaults to @samp{()}.
  16972. @end deftypevr
  16973. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  16974. How long to redirect users to a specific server after it no longer
  16975. has any connections.
  16976. Defaults to @samp{"15 min"}.
  16977. @end deftypevr
  16978. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  16979. How the username is translated before being hashed. Useful values
  16980. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  16981. are shared within domain.
  16982. Defaults to @samp{"%Lu"}.
  16983. @end deftypevr
  16984. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  16985. Log file to use for error messages. @samp{syslog} logs to syslog,
  16986. @samp{/dev/stderr} logs to stderr.
  16987. Defaults to @samp{"syslog"}.
  16988. @end deftypevr
  16989. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  16990. Log file to use for informational messages. Defaults to
  16991. @samp{log-path}.
  16992. Defaults to @samp{""}.
  16993. @end deftypevr
  16994. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  16995. Log file to use for debug messages. Defaults to
  16996. @samp{info-log-path}.
  16997. Defaults to @samp{""}.
  16998. @end deftypevr
  16999. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  17000. Syslog facility to use if you're logging to syslog. Usually if you
  17001. don't want to use @samp{mail}, you'll use local0..local7. Also other
  17002. standard facilities are supported.
  17003. Defaults to @samp{"mail"}.
  17004. @end deftypevr
  17005. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  17006. Log unsuccessful authentication attempts and the reasons why they
  17007. failed.
  17008. Defaults to @samp{#f}.
  17009. @end deftypevr
  17010. @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
  17011. In case of password mismatches, log the attempted password. Valid
  17012. values are no, plain and sha1. sha1 can be useful for detecting brute
  17013. force password attempts vs. user simply trying the same password over
  17014. and over again. You can also truncate the value to n chars by appending
  17015. ":n" (e.g.@: sha1:6).
  17016. Defaults to @samp{"no"}.
  17017. @end deftypevr
  17018. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  17019. Even more verbose logging for debugging purposes. Shows for example
  17020. SQL queries.
  17021. Defaults to @samp{#f}.
  17022. @end deftypevr
  17023. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  17024. In case of password mismatches, log the passwords and used scheme so
  17025. the problem can be debugged. Enabling this also enables
  17026. @samp{auth-debug}.
  17027. Defaults to @samp{#f}.
  17028. @end deftypevr
  17029. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  17030. Enable mail process debugging. This can help you figure out why
  17031. Dovecot isn't finding your mails.
  17032. Defaults to @samp{#f}.
  17033. @end deftypevr
  17034. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  17035. Show protocol level SSL errors.
  17036. Defaults to @samp{#f}.
  17037. @end deftypevr
  17038. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  17039. Prefix for each line written to log file. % codes are in
  17040. strftime(3) format.
  17041. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  17042. @end deftypevr
  17043. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  17044. List of elements we want to log. The elements which have a
  17045. non-empty variable value are joined together to form a comma-separated
  17046. string.
  17047. @end deftypevr
  17048. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  17049. Login log format. %s contains @samp{login-log-format-elements}
  17050. string, %$ contains the data we want to log.
  17051. Defaults to @samp{"%$: %s"}.
  17052. @end deftypevr
  17053. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  17054. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  17055. of possible variables you can use.
  17056. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  17057. @end deftypevr
  17058. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  17059. Format to use for logging mail deliveries. You can use variables:
  17060. @table @code
  17061. @item %$
  17062. Delivery status message (e.g.@: @samp{saved to INBOX})
  17063. @item %m
  17064. Message-ID
  17065. @item %s
  17066. Subject
  17067. @item %f
  17068. From address
  17069. @item %p
  17070. Physical size
  17071. @item %w
  17072. Virtual size.
  17073. @end table
  17074. Defaults to @samp{"msgid=%m: %$"}.
  17075. @end deftypevr
  17076. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  17077. Location for users' mailboxes. The default is empty, which means
  17078. that Dovecot tries to find the mailboxes automatically. This won't work
  17079. if the user doesn't yet have any mail, so you should explicitly tell
  17080. Dovecot the full location.
  17081. If you're using mbox, giving a path to the INBOX
  17082. file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
  17083. where the other mailboxes are kept. This is called the @emph{root mail
  17084. directory}, and it must be the first path given in the
  17085. @samp{mail-location} setting.
  17086. There are a few special variables you can use, e.g.:
  17087. @table @samp
  17088. @item %u
  17089. username
  17090. @item %n
  17091. user part in user@@domain, same as %u if there's no domain
  17092. @item %d
  17093. domain part in user@@domain, empty if there's no domain
  17094. @item %h
  17095. home director
  17096. @end table
  17097. See doc/wiki/Variables.txt for full list. Some examples:
  17098. @table @samp
  17099. @item maildir:~/Maildir
  17100. @item mbox:~/mail:INBOX=/var/mail/%u
  17101. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  17102. @end table
  17103. Defaults to @samp{""}.
  17104. @end deftypevr
  17105. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  17106. System user and group used to access mails. If you use multiple,
  17107. userdb can override these by returning uid or gid fields. You can use
  17108. either numbers or names. <doc/wiki/UserIds.txt>.
  17109. Defaults to @samp{""}.
  17110. @end deftypevr
  17111. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  17112. Defaults to @samp{""}.
  17113. @end deftypevr
  17114. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  17115. Group to enable temporarily for privileged operations. Currently
  17116. this is used only with INBOX when either its initial creation or
  17117. dotlocking fails. Typically this is set to @samp{"mail"} to give access to
  17118. @file{/var/mail}.
  17119. Defaults to @samp{""}.
  17120. @end deftypevr
  17121. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  17122. Grant access to these supplementary groups for mail processes.
  17123. Typically these are used to set up access to shared mailboxes. Note
  17124. that it may be dangerous to set these if users can create symlinks
  17125. (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
  17126. could allow a user to delete others' mailboxes, or @code{ln -s
  17127. /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
  17128. @samp{""}.
  17129. @end deftypevr
  17130. @deftypevr {@code{dovecot-configuration} parameter} string mail-attribute-dict
  17131. The location of a dictionary used to store @code{IMAP METADATA}
  17132. as defined by @uref{https://tools.ietf.org/html/rfc5464, RFC@tie{}5464}.
  17133. The IMAP METADATA commands are available only if the ``imap''
  17134. protocol configuration's @code{imap-metadata?} field is @samp{#t}.
  17135. Defaults to @samp{""}.
  17136. @end deftypevr
  17137. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  17138. Allow full file system access to clients. There's no access checks
  17139. other than what the operating system does for the active UID/GID@. It
  17140. works with both maildir and mboxes, allowing you to prefix mailboxes
  17141. names with e.g.@: @file{/path/} or @file{~user/}.
  17142. Defaults to @samp{#f}.
  17143. @end deftypevr
  17144. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  17145. Don't use @code{mmap()} at all. This is required if you store indexes to
  17146. shared file systems (NFS or clustered file system).
  17147. Defaults to @samp{#f}.
  17148. @end deftypevr
  17149. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  17150. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  17151. supports @samp{O_EXCL} since version 3, so this should be safe to use
  17152. nowadays by default.
  17153. Defaults to @samp{#t}.
  17154. @end deftypevr
  17155. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  17156. When to use fsync() or fdatasync() calls:
  17157. @table @code
  17158. @item optimized
  17159. Whenever necessary to avoid losing important data
  17160. @item always
  17161. Useful with e.g.@: NFS when @code{write()}s are delayed
  17162. @item never
  17163. Never use it (best performance, but crashes can lose data).
  17164. @end table
  17165. Defaults to @samp{"optimized"}.
  17166. @end deftypevr
  17167. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  17168. Mail storage exists in NFS@. Set this to yes to make Dovecot flush
  17169. NFS caches whenever needed. If you're using only a single mail server
  17170. this isn't needed.
  17171. Defaults to @samp{#f}.
  17172. @end deftypevr
  17173. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  17174. Mail index files also exist in NFS@. Setting this to yes requires
  17175. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  17176. Defaults to @samp{#f}.
  17177. @end deftypevr
  17178. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  17179. Locking method for index files. Alternatives are fcntl, flock and
  17180. dotlock. Dotlocking uses some tricks which may create more disk I/O
  17181. than other locking methods. NFS users: flock doesn't work, remember to
  17182. change @samp{mmap-disable}.
  17183. Defaults to @samp{"fcntl"}.
  17184. @end deftypevr
  17185. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  17186. Directory in which LDA/LMTP temporarily stores incoming mails >128
  17187. kB.
  17188. Defaults to @samp{"/tmp"}.
  17189. @end deftypevr
  17190. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  17191. Valid UID range for users. This is mostly to make sure that users can't
  17192. log in as daemons or other system users. Note that denying root logins is
  17193. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  17194. is set to 0.
  17195. Defaults to @samp{500}.
  17196. @end deftypevr
  17197. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  17198. Defaults to @samp{0}.
  17199. @end deftypevr
  17200. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  17201. Valid GID range for users. Users having non-valid GID as primary group ID
  17202. aren't allowed to log in. If user belongs to supplementary groups with
  17203. non-valid GIDs, those groups are not set.
  17204. Defaults to @samp{1}.
  17205. @end deftypevr
  17206. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  17207. Defaults to @samp{0}.
  17208. @end deftypevr
  17209. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  17210. Maximum allowed length for mail keyword name. It's only forced when
  17211. trying to create new keywords.
  17212. Defaults to @samp{50}.
  17213. @end deftypevr
  17214. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  17215. List of directories under which chrooting is allowed for mail
  17216. processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
  17217. too). This setting doesn't affect @samp{login-chroot}
  17218. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  17219. @samp{/./} in home dirs are ignored. WARNING: Never add directories here
  17220. which local users can modify, that may lead to root exploit. Usually
  17221. this should be done only if you don't allow shell access for users.
  17222. <doc/wiki/Chrooting.txt>.
  17223. Defaults to @samp{()}.
  17224. @end deftypevr
  17225. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  17226. Default chroot directory for mail processes. This can be overridden
  17227. for specific users in user database by giving @samp{/./} in user's home
  17228. directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
  17229. there is no real need to do chrooting, Dovecot doesn't allow users to
  17230. access files outside their mail directory anyway. If your home
  17231. directories are prefixed with the chroot directory, append @samp{/.} to
  17232. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  17233. Defaults to @samp{""}.
  17234. @end deftypevr
  17235. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  17236. UNIX socket path to master authentication server to find users.
  17237. This is used by imap (for shared users) and lda.
  17238. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  17239. @end deftypevr
  17240. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  17241. Directory where to look up mail plugins.
  17242. Defaults to @samp{"/usr/lib/dovecot"}.
  17243. @end deftypevr
  17244. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  17245. List of plugins to load for all services. Plugins specific to IMAP,
  17246. LDA, etc.@: are added to this list in their own .conf files.
  17247. Defaults to @samp{()}.
  17248. @end deftypevr
  17249. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  17250. The minimum number of mails in a mailbox before updates are done to
  17251. cache file. This allows optimizing Dovecot's behavior to do less disk
  17252. writes at the cost of more disk reads.
  17253. Defaults to @samp{0}.
  17254. @end deftypevr
  17255. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  17256. When IDLE command is running, mailbox is checked once in a while to
  17257. see if there are any new mails or other changes. This setting defines
  17258. the minimum time to wait between those checks. Dovecot can also use
  17259. dnotify, inotify and kqueue to find out immediately when changes
  17260. occur.
  17261. Defaults to @samp{"30 secs"}.
  17262. @end deftypevr
  17263. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  17264. Save mails with CR+LF instead of plain LF@. This makes sending those
  17265. mails take less CPU, especially with sendfile() syscall with Linux and
  17266. FreeBSD@. But it also creates a bit more disk I/O which may just make it
  17267. slower. Also note that if other software reads the mboxes/maildirs,
  17268. they may handle the extra CRs wrong and cause problems.
  17269. Defaults to @samp{#f}.
  17270. @end deftypevr
  17271. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  17272. By default LIST command returns all entries in maildir beginning
  17273. with a dot. Enabling this option makes Dovecot return only entries
  17274. which are directories. This is done by stat()ing each entry, so it
  17275. causes more disk I/O.
  17276. (For systems setting struct @samp{dirent->d_type} this check is free
  17277. and it's done always regardless of this setting).
  17278. Defaults to @samp{#f}.
  17279. @end deftypevr
  17280. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  17281. When copying a message, do it with hard links whenever possible.
  17282. This makes the performance much better, and it's unlikely to have any
  17283. side effects.
  17284. Defaults to @samp{#t}.
  17285. @end deftypevr
  17286. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  17287. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  17288. directory only when its mtime changes unexpectedly or when we can't find
  17289. the mail otherwise.
  17290. Defaults to @samp{#f}.
  17291. @end deftypevr
  17292. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  17293. Which locking methods to use for locking mbox. There are four
  17294. available:
  17295. @table @code
  17296. @item dotlock
  17297. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  17298. solution. If you want to use /var/mail/ like directory, the users will
  17299. need write access to that directory.
  17300. @item dotlock-try
  17301. Same as dotlock, but if it fails because of permissions or because there
  17302. isn't enough disk space, just skip it.
  17303. @item fcntl
  17304. Use this if possible. Works with NFS too if lockd is used.
  17305. @item flock
  17306. May not exist in all systems. Doesn't work with NFS.
  17307. @item lockf
  17308. May not exist in all systems. Doesn't work with NFS.
  17309. @end table
  17310. You can use multiple locking methods; if you do the order they're declared
  17311. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  17312. locking methods as well. Some operating systems don't allow using some of
  17313. them simultaneously.
  17314. @end deftypevr
  17315. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  17316. @end deftypevr
  17317. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  17318. Maximum time to wait for lock (all of them) before aborting.
  17319. Defaults to @samp{"5 mins"}.
  17320. @end deftypevr
  17321. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  17322. If dotlock exists but the mailbox isn't modified in any way,
  17323. override the lock file after this much time.
  17324. Defaults to @samp{"2 mins"}.
  17325. @end deftypevr
  17326. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  17327. When mbox changes unexpectedly we have to fully read it to find out
  17328. what changed. If the mbox is large this can take a long time. Since
  17329. the change is usually just a newly appended mail, it'd be faster to
  17330. simply read the new mails. If this setting is enabled, Dovecot does
  17331. this but still safely fallbacks to re-reading the whole mbox file
  17332. whenever something in mbox isn't how it's expected to be. The only real
  17333. downside to this setting is that if some other MUA changes message
  17334. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  17335. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  17336. Defaults to @samp{#t}.
  17337. @end deftypevr
  17338. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  17339. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  17340. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  17341. @samp{mbox-dirty-syncs} is ignored.
  17342. Defaults to @samp{#f}.
  17343. @end deftypevr
  17344. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  17345. Delay writing mbox headers until doing a full write sync (EXPUNGE
  17346. and CHECK commands and when closing the mailbox). This is especially
  17347. useful for POP3 where clients often delete all mails. The downside is
  17348. that our changes aren't immediately visible to other MUAs.
  17349. Defaults to @samp{#t}.
  17350. @end deftypevr
  17351. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  17352. If mbox size is smaller than this (e.g.@: 100k), don't write index
  17353. files. If an index file already exists it's still read, just not
  17354. updated.
  17355. Defaults to @samp{0}.
  17356. @end deftypevr
  17357. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  17358. Maximum dbox file size until it's rotated.
  17359. Defaults to @samp{10000000}.
  17360. @end deftypevr
  17361. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  17362. Maximum dbox file age until it's rotated. Typically in days. Day
  17363. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  17364. disabled.
  17365. Defaults to @samp{"1d"}.
  17366. @end deftypevr
  17367. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  17368. When creating new mdbox files, immediately preallocate their size to
  17369. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  17370. with some file systems (ext4, xfs).
  17371. Defaults to @samp{#f}.
  17372. @end deftypevr
  17373. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  17374. sdbox and mdbox support saving mail attachments to external files,
  17375. which also allows single instance storage for them. Other backends
  17376. don't support this for now.
  17377. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  17378. Directory root where to store mail attachments. Disabled, if empty.
  17379. Defaults to @samp{""}.
  17380. @end deftypevr
  17381. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  17382. Attachments smaller than this aren't saved externally. It's also
  17383. possible to write a plugin to disable saving specific attachments
  17384. externally.
  17385. Defaults to @samp{128000}.
  17386. @end deftypevr
  17387. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  17388. File system backend to use for saving attachments:
  17389. @table @code
  17390. @item posix
  17391. No SiS done by Dovecot (but this might help FS's own deduplication)
  17392. @item sis posix
  17393. SiS with immediate byte-by-byte comparison during saving
  17394. @item sis-queue posix
  17395. SiS with delayed comparison and deduplication.
  17396. @end table
  17397. Defaults to @samp{"sis posix"}.
  17398. @end deftypevr
  17399. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  17400. Hash format to use in attachment filenames. You can add any text and
  17401. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  17402. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  17403. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  17404. Defaults to @samp{"%@{sha1@}"}.
  17405. @end deftypevr
  17406. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  17407. Defaults to @samp{100}.
  17408. @end deftypevr
  17409. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  17410. Defaults to @samp{1000}.
  17411. @end deftypevr
  17412. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  17413. Default VSZ (virtual memory size) limit for service processes.
  17414. This is mainly intended to catch and kill processes that leak memory
  17415. before they eat up everything.
  17416. Defaults to @samp{256000000}.
  17417. @end deftypevr
  17418. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  17419. Login user is internally used by login processes. This is the most
  17420. untrusted user in Dovecot system. It shouldn't have access to anything
  17421. at all.
  17422. Defaults to @samp{"dovenull"}.
  17423. @end deftypevr
  17424. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  17425. Internal user is used by unprivileged processes. It should be
  17426. separate from login user, so that login processes can't disturb other
  17427. processes.
  17428. Defaults to @samp{"dovecot"}.
  17429. @end deftypevr
  17430. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  17431. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  17432. Defaults to @samp{"required"}.
  17433. @end deftypevr
  17434. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  17435. PEM encoded X.509 SSL/TLS certificate (public key).
  17436. Defaults to @samp{"</etc/dovecot/default.pem"}.
  17437. @end deftypevr
  17438. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  17439. PEM encoded SSL/TLS private key. The key is opened before
  17440. dropping root privileges, so keep the key file unreadable by anyone but
  17441. root.
  17442. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  17443. @end deftypevr
  17444. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  17445. If key file is password protected, give the password here.
  17446. Alternatively give it when starting dovecot with -p parameter. Since
  17447. this file is often world-readable, you may want to place this setting
  17448. instead to a different.
  17449. Defaults to @samp{""}.
  17450. @end deftypevr
  17451. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  17452. PEM encoded trusted certificate authority. Set this only if you
  17453. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  17454. contain the CA certificate(s) followed by the matching
  17455. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  17456. Defaults to @samp{""}.
  17457. @end deftypevr
  17458. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  17459. Require that CRL check succeeds for client certificates.
  17460. Defaults to @samp{#t}.
  17461. @end deftypevr
  17462. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  17463. Request client to send a certificate. If you also want to require
  17464. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  17465. Defaults to @samp{#f}.
  17466. @end deftypevr
  17467. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  17468. Which field from certificate to use for username. commonName and
  17469. x500UniqueIdentifier are the usual choices. You'll also need to set
  17470. @samp{auth-ssl-username-from-cert? #t}.
  17471. Defaults to @samp{"commonName"}.
  17472. @end deftypevr
  17473. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  17474. Minimum SSL protocol version to accept.
  17475. Defaults to @samp{"TLSv1"}.
  17476. @end deftypevr
  17477. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  17478. SSL ciphers to use.
  17479. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  17480. @end deftypevr
  17481. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  17482. SSL crypto device to use, for valid values run "openssl engine".
  17483. Defaults to @samp{""}.
  17484. @end deftypevr
  17485. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  17486. Address to use when sending rejection mails.
  17487. %d expands to recipient domain.
  17488. Defaults to @samp{"postmaster@@%d"}.
  17489. @end deftypevr
  17490. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  17491. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  17492. and in LMTP replies. Default is the system's real hostname@@domain.
  17493. Defaults to @samp{""}.
  17494. @end deftypevr
  17495. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  17496. If user is over quota, return with temporary failure instead of
  17497. bouncing the mail.
  17498. Defaults to @samp{#f}.
  17499. @end deftypevr
  17500. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  17501. Binary to use for sending mails.
  17502. Defaults to @samp{"/usr/sbin/sendmail"}.
  17503. @end deftypevr
  17504. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  17505. If non-empty, send mails via this SMTP host[:port] instead of
  17506. sendmail.
  17507. Defaults to @samp{""}.
  17508. @end deftypevr
  17509. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  17510. Subject: header to use for rejection mails. You can use the same
  17511. variables as for @samp{rejection-reason} below.
  17512. Defaults to @samp{"Rejected: %s"}.
  17513. @end deftypevr
  17514. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  17515. Human readable error message for rejection mails. You can use
  17516. variables:
  17517. @table @code
  17518. @item %n
  17519. CRLF
  17520. @item %r
  17521. reason
  17522. @item %s
  17523. original subject
  17524. @item %t
  17525. recipient
  17526. @end table
  17527. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  17528. @end deftypevr
  17529. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  17530. Delimiter character between local-part and detail in email
  17531. address.
  17532. Defaults to @samp{"+"}.
  17533. @end deftypevr
  17534. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  17535. Header where the original recipient address (SMTP's RCPT TO:
  17536. address) is taken from if not available elsewhere. With dovecot-lda -a
  17537. parameter overrides this. A commonly used header for this is
  17538. X-Original-To.
  17539. Defaults to @samp{""}.
  17540. @end deftypevr
  17541. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  17542. Should saving a mail to a nonexistent mailbox automatically create
  17543. it?.
  17544. Defaults to @samp{#f}.
  17545. @end deftypevr
  17546. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  17547. Should automatically created mailboxes be also automatically
  17548. subscribed?.
  17549. Defaults to @samp{#f}.
  17550. @end deftypevr
  17551. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  17552. Maximum IMAP command line length. Some clients generate very long
  17553. command lines with huge mailboxes, so you may need to raise this if you
  17554. get "Too long argument" or "IMAP command line too large" errors
  17555. often.
  17556. Defaults to @samp{64000}.
  17557. @end deftypevr
  17558. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  17559. IMAP logout format string:
  17560. @table @code
  17561. @item %i
  17562. total number of bytes read from client
  17563. @item %o
  17564. total number of bytes sent to client.
  17565. @end table
  17566. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  17567. 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@}"}.
  17568. @end deftypevr
  17569. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  17570. Override the IMAP CAPABILITY response. If the value begins with '+',
  17571. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  17572. Defaults to @samp{""}.
  17573. @end deftypevr
  17574. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  17575. How long to wait between "OK Still here" notifications when client
  17576. is IDLEing.
  17577. Defaults to @samp{"2 mins"}.
  17578. @end deftypevr
  17579. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  17580. ID field names and values to send to clients. Using * as the value
  17581. makes Dovecot use the default value. The following fields have default
  17582. values currently: name, version, os, os-version, support-url,
  17583. support-email.
  17584. Defaults to @samp{""}.
  17585. @end deftypevr
  17586. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  17587. ID fields sent by client to log. * means everything.
  17588. Defaults to @samp{""}.
  17589. @end deftypevr
  17590. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  17591. Workarounds for various client bugs:
  17592. @table @code
  17593. @item delay-newmail
  17594. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  17595. CHECK commands. Some clients ignore them otherwise, for example OSX
  17596. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  17597. may show user "Message no longer in server" errors. Note that OE6
  17598. still breaks even with this workaround if synchronization is set to
  17599. "Headers Only".
  17600. @item tb-extra-mailbox-sep
  17601. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  17602. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  17603. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  17604. @item tb-lsub-flags
  17605. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  17606. This makes Thunderbird realize they aren't selectable and show them
  17607. greyed out, instead of only later giving "not selectable" popup error.
  17608. @end table
  17609. Defaults to @samp{()}.
  17610. @end deftypevr
  17611. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  17612. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  17613. Defaults to @samp{""}.
  17614. @end deftypevr
  17615. Whew! Lots of configuration options. The nice thing about it though is
  17616. that Guix has a complete interface to Dovecot's configuration
  17617. language. This allows not only a nice way to declare configurations,
  17618. but also offers reflective capabilities as well: users can write code to
  17619. inspect and transform configurations from within Scheme.
  17620. However, it could be that you just want to get a @code{dovecot.conf} up
  17621. and running. In that case, you can pass an
  17622. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  17623. @code{dovecot-service}. As its name indicates, an opaque configuration
  17624. does not have easy reflective capabilities.
  17625. Available @code{opaque-dovecot-configuration} fields are:
  17626. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  17627. The dovecot package.
  17628. @end deftypevr
  17629. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  17630. The contents of the @code{dovecot.conf}, as a string.
  17631. @end deftypevr
  17632. For example, if your @code{dovecot.conf} is just the empty string, you
  17633. could instantiate a dovecot service like this:
  17634. @lisp
  17635. (dovecot-service #:config
  17636. (opaque-dovecot-configuration
  17637. (string "")))
  17638. @end lisp
  17639. @subsubheading OpenSMTPD Service
  17640. @deffn {Scheme Variable} opensmtpd-service-type
  17641. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  17642. service, whose value should be an @code{opensmtpd-configuration} object
  17643. as in this example:
  17644. @lisp
  17645. (service opensmtpd-service-type
  17646. (opensmtpd-configuration
  17647. (config-file (local-file "./my-smtpd.conf"))))
  17648. @end lisp
  17649. @end deffn
  17650. @deftp {Data Type} opensmtpd-configuration
  17651. Data type representing the configuration of opensmtpd.
  17652. @table @asis
  17653. @item @code{package} (default: @var{opensmtpd})
  17654. Package object of the OpenSMTPD SMTP server.
  17655. @item @code{config-file} (default: @code{%default-opensmtpd-file})
  17656. File-like object of the OpenSMTPD configuration file to use. By default
  17657. it listens on the loopback network interface, and allows for mail from
  17658. users and daemons on the local machine, as well as permitting email to
  17659. remote servers. Run @command{man smtpd.conf} for more information.
  17660. @end table
  17661. @end deftp
  17662. @subsubheading Exim Service
  17663. @cindex mail transfer agent (MTA)
  17664. @cindex MTA (mail transfer agent)
  17665. @cindex SMTP
  17666. @deffn {Scheme Variable} exim-service-type
  17667. This is the type of the @uref{https://exim.org, Exim} mail transfer
  17668. agent (MTA), whose value should be an @code{exim-configuration} object
  17669. as in this example:
  17670. @lisp
  17671. (service exim-service-type
  17672. (exim-configuration
  17673. (config-file (local-file "./my-exim.conf"))))
  17674. @end lisp
  17675. @end deffn
  17676. In order to use an @code{exim-service-type} service you must also have a
  17677. @code{mail-aliases-service-type} service present in your
  17678. @code{operating-system} (even if it has no aliases).
  17679. @deftp {Data Type} exim-configuration
  17680. Data type representing the configuration of exim.
  17681. @table @asis
  17682. @item @code{package} (default: @var{exim})
  17683. Package object of the Exim server.
  17684. @item @code{config-file} (default: @code{#f})
  17685. File-like object of the Exim configuration file to use. If its value is
  17686. @code{#f} then use the default configuration file from the package
  17687. provided in @code{package}. The resulting configuration file is loaded
  17688. after setting the @code{exim_user} and @code{exim_group} configuration
  17689. variables.
  17690. @end table
  17691. @end deftp
  17692. @subsubheading Getmail service
  17693. @cindex IMAP
  17694. @cindex POP
  17695. @deffn {Scheme Variable} getmail-service-type
  17696. This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
  17697. mail retriever, whose value should be an @code{getmail-configuration}.
  17698. @end deffn
  17699. Available @code{getmail-configuration} fields are:
  17700. @deftypevr {@code{getmail-configuration} parameter} symbol name
  17701. A symbol to identify the getmail service.
  17702. Defaults to @samp{"unset"}.
  17703. @end deftypevr
  17704. @deftypevr {@code{getmail-configuration} parameter} package package
  17705. The getmail package to use.
  17706. @end deftypevr
  17707. @deftypevr {@code{getmail-configuration} parameter} string user
  17708. The user to run getmail as.
  17709. Defaults to @samp{"getmail"}.
  17710. @end deftypevr
  17711. @deftypevr {@code{getmail-configuration} parameter} string group
  17712. The group to run getmail as.
  17713. Defaults to @samp{"getmail"}.
  17714. @end deftypevr
  17715. @deftypevr {@code{getmail-configuration} parameter} string directory
  17716. The getmail directory to use.
  17717. Defaults to @samp{"/var/lib/getmail/default"}.
  17718. @end deftypevr
  17719. @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
  17720. The getmail configuration file to use.
  17721. Available @code{getmail-configuration-file} fields are:
  17722. @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
  17723. What mail account to retrieve mail from, and how to access that account.
  17724. Available @code{getmail-retriever-configuration} fields are:
  17725. @deftypevr {@code{getmail-retriever-configuration} parameter} string type
  17726. The type of mail retriever to use. Valid values include @samp{passwd}
  17727. and @samp{static}.
  17728. Defaults to @samp{"SimpleIMAPSSLRetriever"}.
  17729. @end deftypevr
  17730. @deftypevr {@code{getmail-retriever-configuration} parameter} string server
  17731. Username to login to the mail server with.
  17732. Defaults to @samp{unset}.
  17733. @end deftypevr
  17734. @deftypevr {@code{getmail-retriever-configuration} parameter} string username
  17735. Username to login to the mail server with.
  17736. Defaults to @samp{unset}.
  17737. @end deftypevr
  17738. @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
  17739. Port number to connect to.
  17740. Defaults to @samp{#f}.
  17741. @end deftypevr
  17742. @deftypevr {@code{getmail-retriever-configuration} parameter} string password
  17743. Override fields from passwd.
  17744. Defaults to @samp{""}.
  17745. @end deftypevr
  17746. @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
  17747. Override fields from passwd.
  17748. Defaults to @samp{()}.
  17749. @end deftypevr
  17750. @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
  17751. PEM-formatted key file to use for the TLS negotiation.
  17752. Defaults to @samp{""}.
  17753. @end deftypevr
  17754. @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
  17755. PEM-formatted certificate file to use for the TLS negotiation.
  17756. Defaults to @samp{""}.
  17757. @end deftypevr
  17758. @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
  17759. CA certificates to use.
  17760. Defaults to @samp{""}.
  17761. @end deftypevr
  17762. @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
  17763. Extra retriever parameters.
  17764. Defaults to @samp{()}.
  17765. @end deftypevr
  17766. @end deftypevr
  17767. @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
  17768. What to do with retrieved messages.
  17769. Available @code{getmail-destination-configuration} fields are:
  17770. @deftypevr {@code{getmail-destination-configuration} parameter} string type
  17771. The type of mail destination. Valid values include @samp{Maildir},
  17772. @samp{Mboxrd} and @samp{MDA_external}.
  17773. Defaults to @samp{unset}.
  17774. @end deftypevr
  17775. @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
  17776. The path option for the mail destination. The behaviour depends on the
  17777. chosen type.
  17778. Defaults to @samp{""}.
  17779. @end deftypevr
  17780. @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
  17781. Extra destination parameters
  17782. Defaults to @samp{()}.
  17783. @end deftypevr
  17784. @end deftypevr
  17785. @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
  17786. Configure getmail.
  17787. Available @code{getmail-options-configuration} fields are:
  17788. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
  17789. If set to @samp{0}, getmail will only print warnings and errors. A
  17790. value of @samp{1} means that messages will be printed about retrieving
  17791. and deleting messages. If set to @samp{2}, getmail will print messages
  17792. about each of its actions.
  17793. Defaults to @samp{1}.
  17794. @end deftypevr
  17795. @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
  17796. If true, getmail will retrieve all available messages. Otherwise it
  17797. will only retrieve messages it hasn't seen previously.
  17798. Defaults to @samp{#t}.
  17799. @end deftypevr
  17800. @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
  17801. If set to true, messages will be deleted from the server after
  17802. retrieving and successfully delivering them. Otherwise, messages will
  17803. be left on the server.
  17804. Defaults to @samp{#f}.
  17805. @end deftypevr
  17806. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
  17807. Getmail will delete messages this number of days after seeing them, if
  17808. they have been delivered. This means messages will be left on the
  17809. server this number of days after delivering them. A value of @samp{0}
  17810. disabled this feature.
  17811. Defaults to @samp{0}.
  17812. @end deftypevr
  17813. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
  17814. Delete messages larger than this of bytes after retrieving them, even if
  17815. the delete and delete-after options are disabled. A value of @samp{0}
  17816. disables this feature.
  17817. Defaults to @samp{0}.
  17818. @end deftypevr
  17819. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
  17820. Retrieve messages totalling up to this number of bytes before closing
  17821. the session with the server. A value of @samp{0} disables this feature.
  17822. Defaults to @samp{0}.
  17823. @end deftypevr
  17824. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
  17825. Don't retrieve messages larger than this number of bytes. A value of
  17826. @samp{0} disables this feature.
  17827. Defaults to @samp{0}.
  17828. @end deftypevr
  17829. @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
  17830. If true, getmail will add a Delivered-To header to messages.
  17831. Defaults to @samp{#t}.
  17832. @end deftypevr
  17833. @deftypevr {@code{getmail-options-configuration} parameter} boolean received
  17834. If set, getmail adds a Received header to the messages.
  17835. Defaults to @samp{#t}.
  17836. @end deftypevr
  17837. @deftypevr {@code{getmail-options-configuration} parameter} string message-log
  17838. Getmail will record a log of its actions to the named file. A value of
  17839. @samp{""} disables this feature.
  17840. Defaults to @samp{""}.
  17841. @end deftypevr
  17842. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
  17843. If true, getmail will record a log of its actions using the system
  17844. logger.
  17845. Defaults to @samp{#f}.
  17846. @end deftypevr
  17847. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
  17848. If true, getmail will log information about messages not retrieved and
  17849. the reason for not retrieving them, as well as starting and ending
  17850. information lines.
  17851. Defaults to @samp{#f}.
  17852. @end deftypevr
  17853. @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
  17854. Extra options to include.
  17855. Defaults to @samp{()}.
  17856. @end deftypevr
  17857. @end deftypevr
  17858. @end deftypevr
  17859. @deftypevr {@code{getmail-configuration} parameter} list idle
  17860. A list of mailboxes that getmail should wait on the server for new mail
  17861. notifications. This depends on the server supporting the IDLE
  17862. extension.
  17863. Defaults to @samp{()}.
  17864. @end deftypevr
  17865. @deftypevr {@code{getmail-configuration} parameter} list environment-variables
  17866. Environment variables to set for getmail.
  17867. Defaults to @samp{()}.
  17868. @end deftypevr
  17869. @subsubheading Mail Aliases Service
  17870. @cindex email aliases
  17871. @cindex aliases, for email addresses
  17872. @deffn {Scheme Variable} mail-aliases-service-type
  17873. This is the type of the service which provides @code{/etc/aliases},
  17874. specifying how to deliver mail to users on this system.
  17875. @lisp
  17876. (service mail-aliases-service-type
  17877. '(("postmaster" "bob")
  17878. ("bob" "bob@@example.com" "bob@@example2.com")))
  17879. @end lisp
  17880. @end deffn
  17881. The configuration for a @code{mail-aliases-service-type} service is an
  17882. association list denoting how to deliver mail that comes to this
  17883. system. Each entry is of the form @code{(alias addresses ...)}, with
  17884. @code{alias} specifying the local alias and @code{addresses} specifying
  17885. where to deliver this user's mail.
  17886. The aliases aren't required to exist as users on the local system. In
  17887. the above example, there doesn't need to be a @code{postmaster} entry in
  17888. the @code{operating-system}'s @code{user-accounts} in order to deliver
  17889. the @code{postmaster} mail to @code{bob} (which subsequently would
  17890. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  17891. @subsubheading GNU Mailutils IMAP4 Daemon
  17892. @cindex GNU Mailutils IMAP4 Daemon
  17893. @deffn {Scheme Variable} imap4d-service-type
  17894. This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
  17895. mailutils, GNU Mailutils Manual}), whose value should be an
  17896. @code{imap4d-configuration} object as in this example:
  17897. @lisp
  17898. (service imap4d-service-type
  17899. (imap4d-configuration
  17900. (config-file (local-file "imap4d.conf"))))
  17901. @end lisp
  17902. @end deffn
  17903. @deftp {Data Type} imap4d-configuration
  17904. Data type representing the configuration of @command{imap4d}.
  17905. @table @asis
  17906. @item @code{package} (default: @code{mailutils})
  17907. The package that provides @command{imap4d}.
  17908. @item @code{config-file} (default: @code{%default-imap4d-config-file})
  17909. File-like object of the configuration file to use, by default it will listen
  17910. on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
  17911. Mailutils Manual}, for details.
  17912. @end table
  17913. @end deftp
  17914. @subsubheading Radicale Service
  17915. @cindex CalDAV
  17916. @cindex CardDAV
  17917. @deffn {Scheme Variable} radicale-service-type
  17918. This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV
  17919. server whose value should be a @code{radicale-configuration}.
  17920. @end deffn
  17921. @deftp {Data Type} radicale-configuration
  17922. Data type representing the configuration of @command{radicale}.
  17923. @table @asis
  17924. @item @code{package} (default: @code{radicale})
  17925. The package that provides @command{radicale}.
  17926. @item @code{config-file} (default: @code{%default-radicale-config-file})
  17927. File-like object of the configuration file to use, by default it will listen
  17928. on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at
  17929. @file{/var/lib/radicale/users} with no (@code{plain}) encryption.
  17930. @end table
  17931. @end deftp
  17932. @node Messaging Services
  17933. @subsection Messaging Services
  17934. @cindex messaging
  17935. @cindex jabber
  17936. @cindex XMPP
  17937. The @code{(gnu services messaging)} module provides Guix service
  17938. definitions for messaging services. Currently it provides the following
  17939. services:
  17940. @subsubheading Prosody Service
  17941. @deffn {Scheme Variable} prosody-service-type
  17942. This is the type for the @uref{https://prosody.im, Prosody XMPP
  17943. communication server}. Its value must be a @code{prosody-configuration}
  17944. record as in this example:
  17945. @lisp
  17946. (service prosody-service-type
  17947. (prosody-configuration
  17948. (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
  17949. (int-components
  17950. (list
  17951. (int-component-configuration
  17952. (hostname "conference.example.net")
  17953. (plugin "muc")
  17954. (mod-muc (mod-muc-configuration)))))
  17955. (virtualhosts
  17956. (list
  17957. (virtualhost-configuration
  17958. (domain "example.net"))))))
  17959. @end lisp
  17960. See below for details about @code{prosody-configuration}.
  17961. @end deffn
  17962. By default, Prosody does not need much configuration. Only one
  17963. @code{virtualhosts} field is needed: it specifies the domain you wish
  17964. Prosody to serve.
  17965. You can perform various sanity checks on the generated configuration
  17966. with the @code{prosodyctl check} command.
  17967. Prosodyctl will also help you to import certificates from the
  17968. @code{letsencrypt} directory so that the @code{prosody} user can access
  17969. them. See @url{https://prosody.im/doc/letsencrypt}.
  17970. @example
  17971. prosodyctl --root cert import /etc/letsencrypt/live
  17972. @end example
  17973. The available configuration parameters follow. Each parameter
  17974. definition is preceded by its type; for example, @samp{string-list foo}
  17975. indicates that the @code{foo} parameter should be specified as a list of
  17976. strings. Types starting with @code{maybe-} denote parameters that won't
  17977. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  17978. There is also a way to specify the configuration as a string, if you
  17979. have an old @code{prosody.cfg.lua} file that you want to port over from
  17980. some other system; see the end for more details.
  17981. The @code{file-object} type designates either a file-like object
  17982. (@pxref{G-Expressions, file-like objects}) or a file name.
  17983. @c The following documentation was initially generated by
  17984. @c (generate-documentation) in (gnu services messaging). Manually maintained
  17985. @c documentation is better, so we shouldn't hesitate to edit below as
  17986. @c needed. However if the change you want to make to this documentation
  17987. @c can be done in an automated way, it's probably easier to change
  17988. @c (generate-documentation) than to make it below and have to deal with
  17989. @c the churn as Prosody updates.
  17990. Available @code{prosody-configuration} fields are:
  17991. @deftypevr {@code{prosody-configuration} parameter} package prosody
  17992. The Prosody package.
  17993. @end deftypevr
  17994. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  17995. Location of the Prosody data storage directory. See
  17996. @url{https://prosody.im/doc/configure}.
  17997. Defaults to @samp{"/var/lib/prosody"}.
  17998. @end deftypevr
  17999. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  18000. Additional plugin directories. They are searched in all the specified
  18001. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  18002. Defaults to @samp{()}.
  18003. @end deftypevr
  18004. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  18005. Every virtual host and component needs a certificate so that clients and
  18006. servers can securely verify its identity. Prosody will automatically load
  18007. certificates/keys from the directory specified here.
  18008. Defaults to @samp{"/etc/prosody/certs"}.
  18009. @end deftypevr
  18010. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  18011. This is a list of accounts that are admins for the server. Note that you
  18012. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  18013. @url{https://prosody.im/doc/creating_accounts}.
  18014. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  18015. Defaults to @samp{()}.
  18016. @end deftypevr
  18017. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  18018. Enable use of libevent for better performance under high load. See
  18019. @url{https://prosody.im/doc/libevent}.
  18020. Defaults to @samp{#f}.
  18021. @end deftypevr
  18022. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  18023. This is the list of modules Prosody will load on startup. It looks for
  18024. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  18025. Documentation on modules can be found at:
  18026. @url{https://prosody.im/doc/modules}.
  18027. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  18028. @end deftypevr
  18029. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  18030. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  18031. should you want to disable them then add them to this list.
  18032. Defaults to @samp{()}.
  18033. @end deftypevr
  18034. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  18035. Path to a text file where the shared groups are defined. If this path is
  18036. empty then @samp{mod_groups} does nothing. See
  18037. @url{https://prosody.im/doc/modules/mod_groups}.
  18038. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  18039. @end deftypevr
  18040. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  18041. Disable account creation by default, for security. See
  18042. @url{https://prosody.im/doc/creating_accounts}.
  18043. Defaults to @samp{#f}.
  18044. @end deftypevr
  18045. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  18046. These are the SSL/TLS-related settings. Most of them are disabled so to
  18047. use Prosody's defaults. If you do not completely understand these options, do
  18048. not add them to your config, it is easy to lower the security of your server
  18049. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  18050. Available @code{ssl-configuration} fields are:
  18051. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  18052. This determines what handshake to use.
  18053. @end deftypevr
  18054. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  18055. Path to your private key file.
  18056. @end deftypevr
  18057. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  18058. Path to your certificate file.
  18059. @end deftypevr
  18060. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  18061. Path to directory containing root certificates that you wish Prosody to
  18062. trust when verifying the certificates of remote servers.
  18063. Defaults to @samp{"/etc/ssl/certs"}.
  18064. @end deftypevr
  18065. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  18066. Path to a file containing root certificates that you wish Prosody to trust.
  18067. Similar to @code{capath} but with all certificates concatenated together.
  18068. @end deftypevr
  18069. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  18070. A list of verification options (these mostly map to OpenSSL's
  18071. @code{set_verify()} flags).
  18072. @end deftypevr
  18073. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  18074. A list of general options relating to SSL/TLS@. These map to OpenSSL's
  18075. @code{set_options()}. For a full list of options available in LuaSec, see the
  18076. LuaSec source.
  18077. @end deftypevr
  18078. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  18079. How long a chain of certificate authorities to check when looking for a
  18080. trusted root certificate.
  18081. @end deftypevr
  18082. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  18083. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  18084. clients, and in what order.
  18085. @end deftypevr
  18086. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  18087. A path to a file containing parameters for Diffie-Hellman key exchange. You
  18088. can create such a file with:
  18089. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  18090. @end deftypevr
  18091. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  18092. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  18093. @samp{"secp384r1"}.
  18094. @end deftypevr
  18095. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  18096. A list of ``extra'' verification options.
  18097. @end deftypevr
  18098. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  18099. Password for encrypted private keys.
  18100. @end deftypevr
  18101. @end deftypevr
  18102. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  18103. Whether to force all client-to-server connections to be encrypted or not.
  18104. See @url{https://prosody.im/doc/modules/mod_tls}.
  18105. Defaults to @samp{#f}.
  18106. @end deftypevr
  18107. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  18108. Set of mechanisms that will never be offered. See
  18109. @url{https://prosody.im/doc/modules/mod_saslauth}.
  18110. Defaults to @samp{("DIGEST-MD5")}.
  18111. @end deftypevr
  18112. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  18113. Whether to force all server-to-server connections to be encrypted or not.
  18114. See @url{https://prosody.im/doc/modules/mod_tls}.
  18115. Defaults to @samp{#f}.
  18116. @end deftypevr
  18117. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  18118. Whether to require encryption and certificate authentication. This
  18119. provides ideal security, but requires servers you communicate with to support
  18120. encryption AND present valid, trusted certificates. See
  18121. @url{https://prosody.im/doc/s2s#security}.
  18122. Defaults to @samp{#f}.
  18123. @end deftypevr
  18124. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  18125. Many servers don't support encryption or have invalid or self-signed
  18126. certificates. You can list domains here that will not be required to
  18127. authenticate using certificates. They will be authenticated using DNS@. See
  18128. @url{https://prosody.im/doc/s2s#security}.
  18129. Defaults to @samp{()}.
  18130. @end deftypevr
  18131. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  18132. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  18133. valid certificates for some domains by specifying a list here. See
  18134. @url{https://prosody.im/doc/s2s#security}.
  18135. Defaults to @samp{()}.
  18136. @end deftypevr
  18137. @deftypevr {@code{prosody-configuration} parameter} string authentication
  18138. Select the authentication backend to use. The default provider stores
  18139. passwords in plaintext and uses Prosody's configured data storage to store the
  18140. authentication data. If you do not trust your server please see
  18141. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  18142. about using the hashed backend. See also
  18143. @url{https://prosody.im/doc/authentication}
  18144. Defaults to @samp{"internal_plain"}.
  18145. @end deftypevr
  18146. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  18147. Set logging options. Advanced logging configuration is not yet supported
  18148. by the Prosody service. See @url{https://prosody.im/doc/logging}.
  18149. Defaults to @samp{"*syslog"}.
  18150. @end deftypevr
  18151. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  18152. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  18153. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  18154. @end deftypevr
  18155. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  18156. Maximum allowed size of the HTTP body (in bytes).
  18157. @end deftypevr
  18158. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  18159. Some modules expose their own URL in various ways. This URL is built
  18160. from the protocol, host and port used. If Prosody sits behind a proxy, the
  18161. public URL will be @code{http-external-url} instead. See
  18162. @url{https://prosody.im/doc/http#external_url}.
  18163. @end deftypevr
  18164. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  18165. A host in Prosody is a domain on which user accounts can be created. For
  18166. example if you want your users to have addresses like
  18167. @samp{"john.smith@@example.com"} then you need to add a host
  18168. @samp{"example.com"}. All options in this list will apply only to this host.
  18169. Note: the name @emph{virtual} host is used in configuration to avoid confusion with
  18170. the actual physical host that Prosody is installed on. A single Prosody
  18171. instance can serve many domains, each one defined as a VirtualHost entry in
  18172. Prosody's configuration. Conversely a server that hosts a single domain would
  18173. have just one VirtualHost entry.
  18174. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  18175. Available @code{virtualhost-configuration} fields are:
  18176. 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:
  18177. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  18178. Domain you wish Prosody to serve.
  18179. @end deftypevr
  18180. @end deftypevr
  18181. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  18182. Components are extra services on a server which are available to clients,
  18183. usually on a subdomain of the main server (such as
  18184. @samp{"mycomponent.example.com"}). Example components might be chatroom
  18185. servers, user directories, or gateways to other protocols.
  18186. Internal components are implemented with Prosody-specific plugins. To add an
  18187. internal component, you simply fill the hostname field, and the plugin you wish
  18188. to use for the component.
  18189. See @url{https://prosody.im/doc/components}.
  18190. Defaults to @samp{()}.
  18191. Available @code{int-component-configuration} fields are:
  18192. 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:
  18193. @deftypevr {@code{int-component-configuration} parameter} string hostname
  18194. Hostname of the component.
  18195. @end deftypevr
  18196. @deftypevr {@code{int-component-configuration} parameter} string plugin
  18197. Plugin you wish to use for the component.
  18198. @end deftypevr
  18199. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  18200. Multi-user chat (MUC) is Prosody's module for allowing you to create
  18201. hosted chatrooms/conferences for XMPP users.
  18202. General information on setting up and using multi-user chatrooms can be found
  18203. in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
  18204. which you should read if you are new to XMPP chatrooms.
  18205. See also @url{https://prosody.im/doc/modules/mod_muc}.
  18206. Available @code{mod-muc-configuration} fields are:
  18207. @deftypevr {@code{mod-muc-configuration} parameter} string name
  18208. The name to return in service discovery responses.
  18209. Defaults to @samp{"Prosody Chatrooms"}.
  18210. @end deftypevr
  18211. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  18212. If @samp{#t}, this will only allow admins to create new chatrooms.
  18213. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  18214. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  18215. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  18216. restricts to service administrators only.
  18217. Defaults to @samp{#f}.
  18218. @end deftypevr
  18219. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  18220. Maximum number of history messages that will be sent to the member that has
  18221. just joined the room.
  18222. Defaults to @samp{20}.
  18223. @end deftypevr
  18224. @end deftypevr
  18225. @end deftypevr
  18226. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  18227. External components use XEP-0114, which most standalone components
  18228. support. To add an external component, you simply fill the hostname field. See
  18229. @url{https://prosody.im/doc/components}.
  18230. Defaults to @samp{()}.
  18231. Available @code{ext-component-configuration} fields are:
  18232. 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:
  18233. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  18234. Password which the component will use to log in.
  18235. @end deftypevr
  18236. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  18237. Hostname of the component.
  18238. @end deftypevr
  18239. @end deftypevr
  18240. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  18241. Port(s) Prosody listens on for component connections.
  18242. Defaults to @samp{(5347)}.
  18243. @end deftypevr
  18244. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  18245. Interface Prosody listens on for component connections.
  18246. Defaults to @samp{"127.0.0.1"}.
  18247. @end deftypevr
  18248. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  18249. Raw content that will be added to the configuration file.
  18250. @end deftypevr
  18251. It could be that you just want to get a @code{prosody.cfg.lua}
  18252. up and running. In that case, you can pass an
  18253. @code{opaque-prosody-configuration} record as the value of
  18254. @code{prosody-service-type}. As its name indicates, an opaque configuration
  18255. does not have easy reflective capabilities.
  18256. Available @code{opaque-prosody-configuration} fields are:
  18257. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  18258. The prosody package.
  18259. @end deftypevr
  18260. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  18261. The contents of the @code{prosody.cfg.lua} to use.
  18262. @end deftypevr
  18263. For example, if your @code{prosody.cfg.lua} is just the empty
  18264. string, you could instantiate a prosody service like this:
  18265. @lisp
  18266. (service prosody-service-type
  18267. (opaque-prosody-configuration
  18268. (prosody.cfg.lua "")))
  18269. @end lisp
  18270. @c end of Prosody auto-generated documentation
  18271. @subsubheading BitlBee Service
  18272. @cindex IRC (Internet Relay Chat)
  18273. @cindex IRC gateway
  18274. @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
  18275. interface to a variety of messaging protocols such as XMPP.
  18276. @defvr {Scheme Variable} bitlbee-service-type
  18277. This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
  18278. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  18279. below).
  18280. To have BitlBee listen on port 6667 on localhost, add this line to your
  18281. services:
  18282. @lisp
  18283. (service bitlbee-service-type)
  18284. @end lisp
  18285. @end defvr
  18286. @deftp {Data Type} bitlbee-configuration
  18287. This is the configuration for BitlBee, with the following fields:
  18288. @table @asis
  18289. @item @code{interface} (default: @code{"127.0.0.1"})
  18290. @itemx @code{port} (default: @code{6667})
  18291. Listen on the network interface corresponding to the IP address
  18292. specified in @var{interface}, on @var{port}.
  18293. When @var{interface} is @code{127.0.0.1}, only local clients can
  18294. connect; when it is @code{0.0.0.0}, connections can come from any
  18295. networking interface.
  18296. @item @code{bitlbee} (default: @code{bitlbee})
  18297. The BitlBee package to use.
  18298. @item @code{plugins} (default: @code{'()})
  18299. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  18300. @item @code{extra-settings} (default: @code{""})
  18301. Configuration snippet added as-is to the BitlBee configuration file.
  18302. @end table
  18303. @end deftp
  18304. @subsubheading Quassel Service
  18305. @cindex IRC (Internet Relay Chat)
  18306. @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
  18307. meaning that one or more clients can attach to and detach from the
  18308. central core.
  18309. @defvr {Scheme Variable} quassel-service-type
  18310. This is the service type for the @url{https://quassel-irc.org/,Quassel}
  18311. IRC backend daemon. Its value is a @code{quassel-configuration}
  18312. (see below).
  18313. @end defvr
  18314. @deftp {Data Type} quassel-configuration
  18315. This is the configuration for Quassel, with the following fields:
  18316. @table @asis
  18317. @item @code{quassel} (default: @code{quassel})
  18318. The Quassel package to use.
  18319. @item @code{interface} (default: @code{"::,0.0.0.0"})
  18320. @item @code{port} (default: @code{4242})
  18321. Listen on the network interface(s) corresponding to the IPv4 or IPv6
  18322. interfaces specified in the comma delimited @var{interface}, on
  18323. @var{port}.
  18324. @item @code{loglevel} (default: @code{"Info"})
  18325. The level of logging desired. Accepted values are Debug, Info, Warning
  18326. and Error.
  18327. @end table
  18328. @end deftp
  18329. @node Telephony Services
  18330. @subsection Telephony Services
  18331. @cindex telephony, services
  18332. The @code{(gnu services telephony)} module contains Guix service
  18333. definitions for telephony services. Currently it provides the following
  18334. services:
  18335. @subsubheading Jami
  18336. @cindex jami, service
  18337. This section describes how to configure a Jami server that can be used
  18338. to host video (or audio) conferences, among other uses. The following
  18339. example demonstrates how to specify Jami account archives (backups) to
  18340. be provisioned automatically:
  18341. @lisp
  18342. (service jami-service-type
  18343. (jami-configuration
  18344. (accounts
  18345. (list (jami-account
  18346. (archive "/etc/jami/unencrypted-account-1.gz"))
  18347. (jami-account
  18348. (archive "/etc/jami/unencrypted-account-2.gz"))))))
  18349. @end lisp
  18350. When the accounts field is specified, the Jami account files of the
  18351. service found under @file{/var/lib/jami} are recreated every time the
  18352. service starts.
  18353. Jami accounts and their corresponding backup archives can be generated
  18354. using either the @code{jami-qt} or @code{jami-gnome} Jami clients. The
  18355. accounts should not be password-protected, but it is wise to ensure
  18356. their files are only readable by @samp{root}.
  18357. The next example shows how to declare that only some contacts should be
  18358. allowed to communicate with a given account:
  18359. @lisp
  18360. (service jami-service-type
  18361. (jami-configuration
  18362. (accounts
  18363. (list (jami-account
  18364. (archive "/etc/jami/unencrypted-account-1.gz")
  18365. (peer-discovery? #t)
  18366. (rendezvous-point? #t)
  18367. (allowed-contacts
  18368. '("1dbcb0f5f37324228235564b79f2b9737e9a008f"
  18369. "2dbcb0f5f37324228235564b79f2b9737e9a008f")))))))
  18370. @end lisp
  18371. In this mode, only the declared @code{allowed-contacts} can initiate
  18372. communication with the Jami account. This can be used, for example,
  18373. with rendezvous point accounts to create a private video conferencing
  18374. space.
  18375. To put the system administrator in full control of the conferences
  18376. hosted on their system, the Jami service supports the following actions:
  18377. @example sh
  18378. # herd doc jami list-actions
  18379. (list-accounts
  18380. list-account-details
  18381. list-banned-contacts
  18382. list-contacts
  18383. list-moderators
  18384. add-moderator
  18385. ban-contact
  18386. enable-account
  18387. disable-account)
  18388. @end example
  18389. The above actions aim to provide the most valuable actions for
  18390. moderation purposes, not to cover the whole Jami API. Users wanting to
  18391. interact with the Jami daemon from Guile may be interested in
  18392. experimenting with the @code{(gnu build jami-service)} module, which
  18393. powers the above Shepherd actions.
  18394. @c TODO: This should be auto-generated from the doc already defined on
  18395. @c the shepherd-actions themselves in (gnu services telephony).
  18396. The @code{add-moderator} and @code{ban-contact} actions accept a contact
  18397. @emph{fingerprint} (40 characters long hash) as first argument and an
  18398. account fingerprint or username as second argument:
  18399. @example sh
  18400. # herd add-moderator jami 1dbcb0f5f37324228235564b79f2b9737e9a008f \
  18401. f3345f2775ddfe07a4b0d95daea111d15fbc1199
  18402. # herd list-moderators jami
  18403. Moderators for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
  18404. - 1dbcb0f5f37324228235564b79f2b9737e9a008f
  18405. @end example
  18406. In the case of @code{ban-contact}, the second username argument is
  18407. optional; when omitted, the account is banned from all Jami accounts:
  18408. @example sh
  18409. # herd ban-contact jami 1dbcb0f5f37324228235564b79f2b9737e9a008f
  18410. # herd list-banned-contacts jami
  18411. Banned contacts for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
  18412. - 1dbcb0f5f37324228235564b79f2b9737e9a008f
  18413. @end example
  18414. Banned contacts are also stripped from their moderation privileges.
  18415. The @code{disable-account} action allows to completely disconnect an
  18416. account from the network, making it unreachable, while
  18417. @code{enable-account} does the inverse. They accept a single account
  18418. username or fingerprint as first argument:
  18419. @example sh
  18420. # herd disable-account jami f3345f2775ddfe07a4b0d95daea111d15fbc1199
  18421. # herd list-accounts jami
  18422. The following Jami accounts are available:
  18423. - f3345f2775ddfe07a4b0d95daea111d15fbc1199 (dummy) [disabled]
  18424. @end example
  18425. The @code{list-account-details} action prints the detailed parameters of
  18426. each accounts in the Recutils format, which means the @command{recsel}
  18427. command can be used to select accounts of interest (@pxref{Selection
  18428. Expressions,,,recutils, GNU recutils manual}). Note that period
  18429. characters (@samp{.}) found in the account parameter keys are mapped to
  18430. underscores (@samp{_}) in the output, to meet the requirements of the
  18431. Recutils format. The following example shows how to print the account
  18432. fingerprints for all accounts operating in the rendezvous point mode:
  18433. @example sh
  18434. # herd list-account-details jami | \
  18435. recsel -p Account.username -e 'Account.rendezVous ~ "true"'
  18436. Account_username: f3345f2775ddfe07a4b0d95daea111d15fbc1199
  18437. @end example
  18438. The remaining actions should be self-explanatory.
  18439. The complete set of available configuration options is detailed below.
  18440. @c TODO: Ideally, the following fragments would be auto-generated at
  18441. @c build time, so that they needn't be manually duplicated.
  18442. @c Auto-generated via (configuration->documentation 'jami-configuration)
  18443. @deftp {Data Type} jami-configuration
  18444. Available @code{jami-configuration} fields are:
  18445. @table @asis
  18446. @item @code{jamid} (default: @code{libring}) (type: package)
  18447. The Jami daemon package to use.
  18448. @item @code{dbus} (default: @code{dbus}) (type: package)
  18449. The D-Bus package to use to start the required D-Bus session.
  18450. @item @code{nss-certs} (default: @code{nss-certs}) (type: package)
  18451. The nss-certs package to use to provide TLS certificates.
  18452. @item @code{enable-logging?} (default: @code{#t}) (type: boolean)
  18453. Whether to enable logging to syslog.
  18454. @item @code{debug?} (default: @code{#f}) (type: boolean)
  18455. Whether to enable debug level messages.
  18456. @item @code{auto-answer?} (default: @code{#f}) (type: boolean)
  18457. Whether to force automatic answer to incoming calls.
  18458. @item @code{accounts} (default: @code{disabled}) (type: maybe-jami-account-list)
  18459. A list of Jami accounts to be (re-)provisioned every time the Jami
  18460. daemon service starts. When providing this field, the account
  18461. directories under @file{/var/lib/jami/} are recreated every time the
  18462. service starts, ensuring a consistent state.
  18463. @end table
  18464. @end deftp
  18465. @c Auto-generated via (configuration->documentation 'jami-account)
  18466. @deftp {Data Type} jami-account
  18467. Available @code{jami-account} fields are:
  18468. @table @asis
  18469. @item @code{archive} (type: string-or-computed-file)
  18470. The account archive (backup) file name of the account. This is used to
  18471. provision the account when the service starts. The account archive
  18472. should @emph{not} be encrypted. It is highly recommended to make it
  18473. readable only to the @samp{root} user (i.e., not in the store), to guard
  18474. against leaking the secret key material of the Jami account it contains.
  18475. @item @code{allowed-contacts} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
  18476. The list of allowed contacts for the account, entered as their 40
  18477. characters long fingerprint. Messages or calls from accounts not in
  18478. that list will be rejected. When unspecified, the configuration of the
  18479. account archive is used as-is with respect to contacts and public
  18480. inbound calls/messaging allowance, which typically defaults to allow any
  18481. contact to communicate with the account.
  18482. @item @code{moderators} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
  18483. The list of contacts that should have moderation privileges (to ban,
  18484. mute, etc. other users) in rendezvous conferences, entered as their 40
  18485. characters long fingerprint. When unspecified, the configuration of the
  18486. account archive is used as-is with respect to moderation, which
  18487. typically defaults to allow anyone to moderate.
  18488. @item @code{rendezvous-point?} (default: @code{disabled}) (type: maybe-boolean)
  18489. Whether the account should operate in the rendezvous mode. In this
  18490. mode, all the incoming audio/video calls are mixed into a conference.
  18491. When left unspecified, the value from the account archive prevails.
  18492. @item @code{peer-discovery?} (default: @code{disabled}) (type: maybe-boolean)
  18493. Whether peer discovery should be enabled. Peer discovery is used to
  18494. discover other OpenDHT nodes on the local network, which can be useful
  18495. to maintain communication between devices on such network even when the
  18496. connection to the the Internet has been lost. When left unspecified,
  18497. the value from the account archive prevails.
  18498. @item @code{bootstrap-hostnames} (default: @code{disabled}) (type: maybe-string-list)
  18499. A list of hostnames or IPs pointing to OpenDHT nodes, that should be
  18500. used to initially join the OpenDHT network. When left unspecified, the
  18501. value from the account archive prevails.
  18502. @item @code{name-server-uri} (default: @code{disabled}) (type: maybe-string)
  18503. The URI of the name server to use, that can be used to retrieve the
  18504. account fingerprint for a registered username.
  18505. @end table
  18506. @end deftp
  18507. @subsubheading Murmur (VoIP server)
  18508. @cindex Murmur (VoIP server)
  18509. @cindex VoIP server
  18510. This section describes how to set up and run a Murmur server. Murmur is
  18511. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  18512. (VoIP) suite.
  18513. @deftp {Data Type} murmur-configuration
  18514. The service type for the Murmur server. An example configuration can
  18515. look like this:
  18516. @lisp
  18517. (service murmur-service-type
  18518. (murmur-configuration
  18519. (welcome-text
  18520. "Welcome to this Mumble server running on Guix!")
  18521. (cert-required? #t) ;disallow text password logins
  18522. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  18523. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  18524. @end lisp
  18525. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  18526. password with the command that is printed during the activation phase.
  18527. It is recommended to register a normal Mumble user account
  18528. and grant it admin or moderator rights.
  18529. You can use the @code{mumble} client to
  18530. login as new normal user, register yourself, and log out.
  18531. For the next step login with the name @code{SuperUser} use
  18532. the @code{SuperUser} password that you set previously,
  18533. and grant your newly registered mumble user administrator or moderator
  18534. rights and create some channels.
  18535. Available @code{murmur-configuration} fields are:
  18536. @table @asis
  18537. @item @code{package} (default: @code{mumble})
  18538. Package that contains @code{bin/murmurd}.
  18539. @item @code{user} (default: @code{"murmur"})
  18540. User who will run the Murmur server.
  18541. @item @code{group} (default: @code{"murmur"})
  18542. Group of the user who will run the murmur server.
  18543. @item @code{port} (default: @code{64738})
  18544. Port on which the server will listen.
  18545. @item @code{welcome-text} (default: @code{""})
  18546. Welcome text sent to clients when they connect.
  18547. @item @code{server-password} (default: @code{""})
  18548. Password the clients have to enter in order to connect.
  18549. @item @code{max-users} (default: @code{100})
  18550. Maximum of users that can be connected to the server at once.
  18551. @item @code{max-user-bandwidth} (default: @code{#f})
  18552. Maximum voice traffic a user can send per second.
  18553. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  18554. File name of the sqlite database.
  18555. The service's user will become the owner of the directory.
  18556. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  18557. File name of the log file.
  18558. The service's user will become the owner of the directory.
  18559. @item @code{autoban-attempts} (default: @code{10})
  18560. Maximum number of logins a user can make in @code{autoban-timeframe}
  18561. without getting auto banned for @code{autoban-time}.
  18562. @item @code{autoban-timeframe} (default: @code{120})
  18563. Timeframe for autoban in seconds.
  18564. @item @code{autoban-time} (default: @code{300})
  18565. Amount of time in seconds for which a client gets banned
  18566. when violating the autoban limits.
  18567. @item @code{opus-threshold} (default: @code{100})
  18568. Percentage of clients that need to support opus
  18569. before switching over to opus audio codec.
  18570. @item @code{channel-nesting-limit} (default: @code{10})
  18571. How deep channels can be nested at maximum.
  18572. @item @code{channelname-regex} (default: @code{#f})
  18573. A string in form of a Qt regular expression that channel names must conform to.
  18574. @item @code{username-regex} (default: @code{#f})
  18575. A string in form of a Qt regular expression that user names must conform to.
  18576. @item @code{text-message-length} (default: @code{5000})
  18577. Maximum size in bytes that a user can send in one text chat message.
  18578. @item @code{image-message-length} (default: @code{(* 128 1024)})
  18579. Maximum size in bytes that a user can send in one image message.
  18580. @item @code{cert-required?} (default: @code{#f})
  18581. If it is set to @code{#t} clients that use weak password authentication
  18582. will not be accepted. Users must have completed the certificate wizard to join.
  18583. @item @code{remember-channel?} (default: @code{#f})
  18584. Should murmur remember the last channel each user was in when they disconnected
  18585. and put them into the remembered channel when they rejoin.
  18586. @item @code{allow-html?} (default: @code{#f})
  18587. Should html be allowed in text messages, user comments, and channel descriptions.
  18588. @item @code{allow-ping?} (default: @code{#f})
  18589. Setting to true exposes the current user count, the maximum user count, and
  18590. the server's maximum bandwidth per client to unauthenticated users. In the
  18591. Mumble client, this information is shown in the Connect dialog.
  18592. Disabling this setting will prevent public listing of the server.
  18593. @item @code{bonjour?} (default: @code{#f})
  18594. Should the server advertise itself in the local network through the bonjour protocol.
  18595. @item @code{send-version?} (default: @code{#f})
  18596. Should the murmur server version be exposed in ping requests.
  18597. @item @code{log-days} (default: @code{31})
  18598. Murmur also stores logs in the database, which are accessible via RPC.
  18599. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  18600. or -1 to disable logging to the database.
  18601. @item @code{obfuscate-ips?} (default: @code{#t})
  18602. Should logged ips be obfuscated to protect the privacy of users.
  18603. @item @code{ssl-cert} (default: @code{#f})
  18604. File name of the SSL/TLS certificate used for encrypted connections.
  18605. @lisp
  18606. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  18607. @end lisp
  18608. @item @code{ssl-key} (default: @code{#f})
  18609. Filepath to the ssl private key used for encrypted connections.
  18610. @lisp
  18611. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  18612. @end lisp
  18613. @item @code{ssl-dh-params} (default: @code{#f})
  18614. File name of a PEM-encoded file with Diffie-Hellman parameters
  18615. for the SSL/TLS encryption. Alternatively you set it to
  18616. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  18617. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  18618. @item @code{ssl-ciphers} (default: @code{#f})
  18619. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  18620. in SSL/TLS.
  18621. This option is specified using
  18622. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  18623. OpenSSL cipher list notation}.
  18624. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  18625. before setting it here, to get a feel for which cipher suites you will get.
  18626. After setting this option, it is recommend that you inspect your Murmur log
  18627. to ensure that Murmur is using the cipher suites that you expected it to.
  18628. Note: Changing this option may impact the backwards compatibility of your
  18629. Murmur server, and can remove the ability for older Mumble clients to be able
  18630. to connect to it.
  18631. @item @code{public-registration} (default: @code{#f})
  18632. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  18633. You can optionally register your server in the public server list that the
  18634. @code{mumble} client shows on startup.
  18635. You cannot register your server if you have set a @code{server-password},
  18636. or set @code{allow-ping} to @code{#f}.
  18637. It might take a few hours until it shows up in the public list.
  18638. @item @code{file} (default: @code{#f})
  18639. Optional alternative override for this configuration.
  18640. @end table
  18641. @end deftp
  18642. @deftp {Data Type} murmur-public-registration-configuration
  18643. Configuration for public registration of a murmur service.
  18644. @table @asis
  18645. @item @code{name}
  18646. This is a display name for your server. Not to be confused with the hostname.
  18647. @item @code{password}
  18648. A password to identify your registration.
  18649. Subsequent updates will need the same password. Don't lose your password.
  18650. @item @code{url}
  18651. This should be a @code{http://} or @code{https://} link to your web
  18652. site.
  18653. @item @code{hostname} (default: @code{#f})
  18654. By default your server will be listed by its IP address.
  18655. If it is set your server will be linked by this host name instead.
  18656. @end table
  18657. @end deftp
  18658. @node File-Sharing Services
  18659. @subsection File-Sharing Services
  18660. The @code{(gnu services file-sharing)} module provides services that
  18661. assist with transferring files over peer-to-peer file-sharing networks.
  18662. @subsubheading Transmission Daemon Service
  18663. @uref{https://transmissionbt.com/, Transmission} is a flexible
  18664. BitTorrent client that offers a variety of graphical and command-line
  18665. interfaces. A @code{transmission-daemon-service-type} service provides
  18666. Transmission's headless variant, @command{transmission-daemon}, as a
  18667. system service, allowing users to share files via BitTorrent even when
  18668. they are not logged in.
  18669. @deffn {Scheme Variable} transmission-daemon-service-type
  18670. The service type for the Transmission Daemon BitTorrent client. Its
  18671. value must be a @code{transmission-daemon-configuration} object as in
  18672. this example:
  18673. @lisp
  18674. (service transmission-daemon-service-type
  18675. (transmission-daemon-configuration
  18676. ;; Restrict access to the RPC ("control") interface
  18677. (rpc-authentication-required? #t)
  18678. (rpc-username "transmission")
  18679. (rpc-password
  18680. (transmission-password-hash
  18681. "transmission" ; desired password
  18682. "uKd1uMs9")) ; arbitrary salt value
  18683. ;; Accept requests from this and other hosts on the
  18684. ;; local network
  18685. (rpc-whitelist-enabled? #t)
  18686. (rpc-whitelist '("::1" "127.0.0.1" "192.168.0.*"))
  18687. ;; Limit bandwidth use during work hours
  18688. (alt-speed-down (* 1024 2)) ; 2 MB/s
  18689. (alt-speed-up 512) ; 512 kB/s
  18690. (alt-speed-time-enabled? #t)
  18691. (alt-speed-time-day 'weekdays)
  18692. (alt-speed-time-begin
  18693. (+ (* 60 8) 30)) ; 8:30 am
  18694. (alt-speed-time-end
  18695. (+ (* 60 (+ 12 5)) 30)))) ; 5:30 pm
  18696. @end lisp
  18697. @end deffn
  18698. Once the service is started, users can interact with the daemon through
  18699. its Web interface (at @code{http://localhost:9091/}) or by using the
  18700. @command{transmission-remote} command-line tool, available in the
  18701. @code{transmission} package. (Emacs users may want to also consider the
  18702. @code{emacs-transmission} package.) Both communicate with the daemon
  18703. through its remote procedure call (RPC) interface, which by default is
  18704. available to all users on the system; you may wish to change this by
  18705. assigning values to the @code{rpc-authentication-required?},
  18706. @code{rpc-username} and @code{rpc-password} settings, as shown in the
  18707. example above and documented further below.
  18708. The value for @code{rpc-password} must be a password hash of the type
  18709. generated and used by Transmission clients. This can be copied verbatim
  18710. from an existing @file{settings.json} file, if another Transmission
  18711. client is already being used. Otherwise, the
  18712. @code{transmission-password-hash} and @code{transmission-random-salt}
  18713. procedures provided by this module can be used to obtain a suitable hash
  18714. value.
  18715. @deffn {Scheme Procedure} transmission-password-hash @var{password} @var{salt}
  18716. Returns a string containing the result of hashing @var{password}
  18717. together with @var{salt}, in the format recognized by Transmission
  18718. clients for their @code{rpc-password} configuration setting.
  18719. @var{salt} must be an eight-character string. The
  18720. @code{transmission-random-salt} procedure can be used to generate a
  18721. suitable salt value at random.
  18722. @end deffn
  18723. @deffn {Scheme Procedure} transmission-random-salt
  18724. Returns a string containing a random, eight-character salt value of the
  18725. type generated and used by Transmission clients, suitable for passing to
  18726. the @code{transmission-password-hash} procedure.
  18727. @end deffn
  18728. These procedures are accessible from within a Guile REPL started with
  18729. the @command{guix repl} command (@pxref{Invoking guix repl}). This is
  18730. useful for obtaining a random salt value to provide as the second
  18731. parameter to `transmission-password-hash`, as in this example session:
  18732. @example
  18733. $ guix repl
  18734. scheme@@(guix-user)> ,use (gnu services file-sharing)
  18735. scheme@@(guix-user)> (transmission-random-salt)
  18736. $1 = "uKd1uMs9"
  18737. @end example
  18738. Alternatively, a complete password hash can generated in a single step:
  18739. @example
  18740. scheme@@(guix-user)> (transmission-password-hash "transmission"
  18741. (transmission-random-salt))
  18742. $2 = "@{c8bbc6d1740cd8dc819a6e25563b67812c1c19c9VtFPfdsX"
  18743. @end example
  18744. The resulting string can be used as-is for the value of
  18745. @code{rpc-password}, allowing the password to be kept hidden even in the
  18746. operating-system configuration.
  18747. Torrent files downloaded by the daemon are directly accessible only to
  18748. users in the ``transmission'' user group, who receive read-only access
  18749. to the directory specified by the @code{download-dir} configuration
  18750. setting (and also the directory specified by @code{incomplete-dir}, if
  18751. @code{incomplete-dir-enabled?} is @code{#t}). Downloaded files can be
  18752. moved to another directory or deleted altogether using
  18753. @command{transmission-remote} with its @code{--move} and
  18754. @code{--remove-and-delete} options.
  18755. If the @code{watch-dir-enabled?} setting is set to @code{#t}, users in
  18756. the ``transmission'' group are able also to place @file{.torrent} files
  18757. in the directory specified by @code{watch-dir} to have the corresponding
  18758. torrents added by the daemon. (The @code{trash-original-torrent-files?}
  18759. setting controls whether the daemon deletes these files after processing
  18760. them.)
  18761. Some of the daemon's configuration settings can be changed temporarily
  18762. by @command{transmission-remote} and similar tools. To undo these
  18763. changes, use the service's @code{reload} action to have the daemon
  18764. reload its settings from disk:
  18765. @example
  18766. # herd reload transmission-daemon
  18767. @end example
  18768. The full set of available configuration settings is defined by the
  18769. @code{transmission-daemon-configuration} data type.
  18770. @deftp {Data Type} transmission-daemon-configuration
  18771. The data type representing configuration settings for Transmission
  18772. Daemon. These correspond directly to the settings recognized by
  18773. Transmission clients in their @file{settings.json} file.
  18774. @end deftp
  18775. @c The following documentation was initially generated by
  18776. @c (generate-transmission-daemon-documentation) in (gnu services
  18777. @c file-sharing). Manually maintained documentation is better, so we
  18778. @c shouldn't hesitate to edit below as needed. However if the change
  18779. @c you want to make to this documentation can be done in an automated
  18780. @c way, it's probably easier to change (generate-documentation) than to
  18781. @c make it below and have to deal with the churn as Transmission Daemon
  18782. @c updates.
  18783. @c %start of fragment
  18784. Available @code{transmission-daemon-configuration} fields are:
  18785. @deftypevr {@code{transmission-daemon-configuration} parameter} package transmission
  18786. The Transmission package to use.
  18787. @end deftypevr
  18788. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer stop-wait-period
  18789. The period, in seconds, to wait when stopping the service for
  18790. @command{transmission-daemon} to exit before killing its process. This
  18791. allows the daemon time to complete its housekeeping and send a final
  18792. update to trackers as it shuts down. On slow hosts, or hosts with a
  18793. slow network connection, this value may need to be increased.
  18794. Defaults to @samp{10}.
  18795. @end deftypevr
  18796. @deftypevr {@code{transmission-daemon-configuration} parameter} string download-dir
  18797. The directory to which torrent files are downloaded.
  18798. Defaults to @samp{"/var/lib/transmission-daemon/downloads"}.
  18799. @end deftypevr
  18800. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean incomplete-dir-enabled?
  18801. If @code{#t}, files will be held in @code{incomplete-dir} while their
  18802. torrent is being downloaded, then moved to @code{download-dir} once the
  18803. torrent is complete. Otherwise, files for all torrents (including those
  18804. still being downloaded) will be placed in @code{download-dir}.
  18805. Defaults to @samp{#f}.
  18806. @end deftypevr
  18807. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string incomplete-dir
  18808. The directory in which files from incompletely downloaded torrents will
  18809. be held when @code{incomplete-dir-enabled?} is @code{#t}.
  18810. Defaults to @samp{disabled}.
  18811. @end deftypevr
  18812. @deftypevr {@code{transmission-daemon-configuration} parameter} umask umask
  18813. The file mode creation mask used for downloaded files. (See the
  18814. @command{umask} man page for more information.)
  18815. Defaults to @samp{18}.
  18816. @end deftypevr
  18817. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rename-partial-files?
  18818. When @code{#t}, ``.part'' is appended to the name of partially
  18819. downloaded files.
  18820. Defaults to @samp{#t}.
  18821. @end deftypevr
  18822. @deftypevr {@code{transmission-daemon-configuration} parameter} preallocation-mode preallocation
  18823. The mode by which space should be preallocated for downloaded files, one
  18824. of @code{none}, @code{fast} (or @code{sparse}) and @code{full}.
  18825. Specifying @code{full} will minimize disk fragmentation at a cost to
  18826. file-creation speed.
  18827. Defaults to @samp{fast}.
  18828. @end deftypevr
  18829. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean watch-dir-enabled?
  18830. If @code{#t}, the directory specified by @code{watch-dir} will be
  18831. watched for new @file{.torrent} files and the torrents they describe
  18832. added automatically (and the original files removed, if
  18833. @code{trash-original-torrent-files?} is @code{#t}).
  18834. Defaults to @samp{#f}.
  18835. @end deftypevr
  18836. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string watch-dir
  18837. The directory to be watched for @file{.torrent} files indicating new
  18838. torrents to be added, when @code{watch-dir-enabled} is @code{#t}.
  18839. Defaults to @samp{disabled}.
  18840. @end deftypevr
  18841. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean trash-original-torrent-files?
  18842. When @code{#t}, @file{.torrent} files will be deleted from the watch
  18843. directory once their torrent has been added (see
  18844. @code{watch-directory-enabled?}).
  18845. Defaults to @samp{#f}.
  18846. @end deftypevr
  18847. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-down-enabled?
  18848. When @code{#t}, the daemon's download speed will be limited to the rate
  18849. specified by @code{speed-limit-down}.
  18850. Defaults to @samp{#f}.
  18851. @end deftypevr
  18852. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-down
  18853. The default global-maximum download speed, in kilobytes per second.
  18854. Defaults to @samp{100}.
  18855. @end deftypevr
  18856. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-up-enabled?
  18857. When @code{#t}, the daemon's upload speed will be limited to the rate
  18858. specified by @code{speed-limit-up}.
  18859. Defaults to @samp{#f}.
  18860. @end deftypevr
  18861. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-up
  18862. The default global-maximum upload speed, in kilobytes per second.
  18863. Defaults to @samp{100}.
  18864. @end deftypevr
  18865. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-enabled?
  18866. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  18867. @code{alt-speed-up} are used (in place of @code{speed-limit-down} and
  18868. @code{speed-limit-up}, if they are enabled) to constrain the daemon's
  18869. bandwidth usage. This can be scheduled to occur automatically at
  18870. certain times during the week; see @code{alt-speed-time-enabled?}.
  18871. Defaults to @samp{#f}.
  18872. @end deftypevr
  18873. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-down
  18874. The alternate global-maximum download speed, in kilobytes per second.
  18875. Defaults to @samp{50}.
  18876. @end deftypevr
  18877. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-up
  18878. The alternate global-maximum upload speed, in kilobytes per second.
  18879. Defaults to @samp{50}.
  18880. @end deftypevr
  18881. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-time-enabled?
  18882. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  18883. @code{alt-speed-up} will be enabled automatically during the periods
  18884. specified by @code{alt-speed-time-day}, @code{alt-speed-time-begin} and
  18885. @code{alt-time-speed-end}.
  18886. Defaults to @samp{#f}.
  18887. @end deftypevr
  18888. @deftypevr {@code{transmission-daemon-configuration} parameter} day-list alt-speed-time-day
  18889. The days of the week on which the alternate-speed schedule should be
  18890. used, specified either as a list of days (@code{sunday}, @code{monday},
  18891. and so on) or using one of the symbols @code{weekdays}, @code{weekends}
  18892. or @code{all}.
  18893. Defaults to @samp{all}.
  18894. @end deftypevr
  18895. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-begin
  18896. The time of day at which to enable the alternate speed limits, expressed
  18897. as a number of minutes since midnight.
  18898. Defaults to @samp{540}.
  18899. @end deftypevr
  18900. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-end
  18901. The time of day at which to disable the alternate speed limits,
  18902. expressed as a number of minutes since midnight.
  18903. Defaults to @samp{1020}.
  18904. @end deftypevr
  18905. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv4
  18906. The IP address at which to listen for peer connections, or ``0.0.0.0''
  18907. to listen at all available IP addresses.
  18908. Defaults to @samp{"0.0.0.0"}.
  18909. @end deftypevr
  18910. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv6
  18911. The IPv6 address at which to listen for peer connections, or ``::'' to
  18912. listen at all available IPv6 addresses.
  18913. Defaults to @samp{"::"}.
  18914. @end deftypevr
  18915. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean peer-port-random-on-start?
  18916. If @code{#t}, when the daemon starts it will select a port at random on
  18917. which to listen for peer connections, from the range specified
  18918. (inclusively) by @code{peer-port-random-low} and
  18919. @code{peer-port-random-high}. Otherwise, it listens on the port
  18920. specified by @code{peer-port}.
  18921. Defaults to @samp{#f}.
  18922. @end deftypevr
  18923. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-low
  18924. The lowest selectable port number when @code{peer-port-random-on-start?}
  18925. is @code{#t}.
  18926. Defaults to @samp{49152}.
  18927. @end deftypevr
  18928. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-high
  18929. The highest selectable port number when @code{peer-port-random-on-start}
  18930. is @code{#t}.
  18931. Defaults to @samp{65535}.
  18932. @end deftypevr
  18933. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port
  18934. The port on which to listen for peer connections when
  18935. @code{peer-port-random-on-start?} is @code{#f}.
  18936. Defaults to @samp{51413}.
  18937. @end deftypevr
  18938. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean port-forwarding-enabled?
  18939. If @code{#t}, the daemon will attempt to configure port-forwarding on an
  18940. upstream gateway automatically using @acronym{UPnP} and
  18941. @acronym{NAT-PMP}.
  18942. Defaults to @samp{#t}.
  18943. @end deftypevr
  18944. @deftypevr {@code{transmission-daemon-configuration} parameter} encryption-mode encryption
  18945. The encryption preference for peer connections, one of
  18946. @code{prefer-unencrypted-connections},
  18947. @code{prefer-encrypted-connections} or
  18948. @code{require-encrypted-connections}.
  18949. Defaults to @samp{prefer-encrypted-connections}.
  18950. @end deftypevr
  18951. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
  18952. The TCP congestion-control algorithm to use for peer connections,
  18953. specified using a string recognized by the operating system in calls to
  18954. @code{setsockopt} (or set to @code{disabled}, in which case the
  18955. operating-system default is used).
  18956. Note that on GNU/Linux systems, the kernel must be configured to allow
  18957. processes to use a congestion-control algorithm not in the default set;
  18958. otherwise, it will deny these requests with ``Operation not permitted''.
  18959. To see which algorithms are available on your system and which are
  18960. currently permitted for use, look at the contents of the files
  18961. @file{tcp_available_congestion_control} and
  18962. @file{tcp_allowed_congestion_control} in the @file{/proc/sys/net/ipv4}
  18963. directory.
  18964. As an example, to have Transmission Daemon use
  18965. @uref{http://www-ece.rice.edu/networks/TCP-LP/,the TCP Low Priority
  18966. congestion-control algorithm}, you'll need to modify your kernel
  18967. configuration to build in support for the algorithm, then update your
  18968. operating-system configuration to allow its use by adding a
  18969. @code{sysctl-service-type} service (or updating the existing one's
  18970. configuration) with lines like the following:
  18971. @lisp
  18972. (service sysctl-service-type
  18973. (sysctl-configuration
  18974. (settings
  18975. ("net.ipv4.tcp_allowed_congestion_control" .
  18976. "reno cubic lp"))))
  18977. @end lisp
  18978. The Transmission Daemon configuration can then be updated with
  18979. @lisp
  18980. (peer-congestion-algorithm "lp")
  18981. @end lisp
  18982. and the system reconfigured to have the changes take effect.
  18983. Defaults to @samp{disabled}.
  18984. @end deftypevr
  18985. @deftypevr {@code{transmission-daemon-configuration} parameter} tcp-type-of-service peer-socket-tos
  18986. The type of service to request in outgoing @acronym{TCP} packets, one of
  18987. @code{default}, @code{low-cost}, @code{throughput}, @code{low-delay} and
  18988. @code{reliability}.
  18989. Defaults to @samp{default}.
  18990. @end deftypevr
  18991. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-global
  18992. The global limit on the number of connected peers.
  18993. Defaults to @samp{200}.
  18994. @end deftypevr
  18995. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-per-torrent
  18996. The per-torrent limit on the number of connected peers.
  18997. Defaults to @samp{50}.
  18998. @end deftypevr
  18999. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer upload-slots-per-torrent
  19000. The maximum number of peers to which the daemon will upload data
  19001. simultaneously for each torrent.
  19002. Defaults to @samp{14}.
  19003. @end deftypevr
  19004. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-id-ttl-hours
  19005. The maximum lifespan, in hours, of the peer ID associated with each
  19006. public torrent before it is regenerated.
  19007. Defaults to @samp{6}.
  19008. @end deftypevr
  19009. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean blocklist-enabled?
  19010. When @code{#t}, the daemon will ignore peers mentioned in the blocklist
  19011. it has most recently downloaded from @code{blocklist-url}.
  19012. Defaults to @samp{#f}.
  19013. @end deftypevr
  19014. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string blocklist-url
  19015. The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
  19016. @file{.dat} format) to be periodically downloaded and applied when
  19017. @code{blocklist-enabled?} is @code{#t}.
  19018. Defaults to @samp{disabled}.
  19019. @end deftypevr
  19020. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean download-queue-enabled?
  19021. If @code{#t}, the daemon will be limited to downloading at most
  19022. @code{download-queue-size} non-stalled torrents simultaneously.
  19023. Defaults to @samp{#t}.
  19024. @end deftypevr
  19025. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer download-queue-size
  19026. The size of the daemon's download queue, which limits the number of
  19027. non-stalled torrents it will download at any one time when
  19028. @code{download-queue-enabled?} is @code{#t}.
  19029. Defaults to @samp{5}.
  19030. @end deftypevr
  19031. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean seed-queue-enabled?
  19032. If @code{#t}, the daemon will be limited to seeding at most
  19033. @code{seed-queue-size} non-stalled torrents simultaneously.
  19034. Defaults to @samp{#f}.
  19035. @end deftypevr
  19036. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer seed-queue-size
  19037. The size of the daemon's seed queue, which limits the number of
  19038. non-stalled torrents it will seed at any one time when
  19039. @code{seed-queue-enabled?} is @code{#t}.
  19040. Defaults to @samp{10}.
  19041. @end deftypevr
  19042. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean queue-stalled-enabled?
  19043. When @code{#t}, the daemon will consider torrents for which it has not
  19044. shared data in the past @code{queue-stalled-minutes} minutes to be
  19045. stalled and not count them against its @code{download-queue-size} and
  19046. @code{seed-queue-size} limits.
  19047. Defaults to @samp{#t}.
  19048. @end deftypevr
  19049. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer queue-stalled-minutes
  19050. The maximum period, in minutes, a torrent may be idle before it is
  19051. considered to be stalled, when @code{queue-stalled-enabled?} is
  19052. @code{#t}.
  19053. Defaults to @samp{30}.
  19054. @end deftypevr
  19055. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean ratio-limit-enabled?
  19056. When @code{#t}, a torrent being seeded will automatically be paused once
  19057. it reaches the ratio specified by @code{ratio-limit}.
  19058. Defaults to @samp{#f}.
  19059. @end deftypevr
  19060. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-rational ratio-limit
  19061. The ratio at which a torrent being seeded will be paused, when
  19062. @code{ratio-limit-enabled?} is @code{#t}.
  19063. Defaults to @samp{2.0}.
  19064. @end deftypevr
  19065. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean idle-seeding-limit-enabled?
  19066. When @code{#t}, a torrent being seeded will automatically be paused once
  19067. it has been idle for @code{idle-seeding-limit} minutes.
  19068. Defaults to @samp{#f}.
  19069. @end deftypevr
  19070. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer idle-seeding-limit
  19071. The maximum period, in minutes, a torrent being seeded may be idle
  19072. before it is paused, when @code{idle-seeding-limit-enabled?} is
  19073. @code{#t}.
  19074. Defaults to @samp{30}.
  19075. @end deftypevr
  19076. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean dht-enabled?
  19077. Enable @uref{http://bittorrent.org/beps/bep_0005.html,the distributed
  19078. hash table (@acronym{DHT}) protocol}, which supports the use of
  19079. trackerless torrents.
  19080. Defaults to @samp{#t}.
  19081. @end deftypevr
  19082. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean lpd-enabled?
  19083. Enable @uref{https://en.wikipedia.org/wiki/Local_Peer_Discovery,local
  19084. peer discovery} (@acronym{LPD}), which allows the discovery of peers on
  19085. the local network and may reduce the amount of data sent over the public
  19086. Internet.
  19087. Defaults to @samp{#f}.
  19088. @end deftypevr
  19089. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean pex-enabled?
  19090. Enable @uref{https://en.wikipedia.org/wiki/Peer_exchange,peer exchange}
  19091. (@acronym{PEX}), which reduces the daemon's reliance on external
  19092. trackers and may improve its performance.
  19093. Defaults to @samp{#t}.
  19094. @end deftypevr
  19095. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean utp-enabled?
  19096. Enable @uref{http://bittorrent.org/beps/bep_0029.html,the micro
  19097. transport protocol} (@acronym{uTP}), which aims to reduce the impact of
  19098. BitTorrent traffic on other users of the local network while maintaining
  19099. full utilization of the available bandwidth.
  19100. Defaults to @samp{#t}.
  19101. @end deftypevr
  19102. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-enabled?
  19103. If @code{#t}, enable the remote procedure call (@acronym{RPC})
  19104. interface, which allows remote control of the daemon via its Web
  19105. interface, the @command{transmission-remote} command-line client, and
  19106. similar tools.
  19107. Defaults to @samp{#t}.
  19108. @end deftypevr
  19109. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-bind-address
  19110. The IP address at which to listen for @acronym{RPC} connections, or
  19111. ``0.0.0.0'' to listen at all available IP addresses.
  19112. Defaults to @samp{"0.0.0.0"}.
  19113. @end deftypevr
  19114. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number rpc-port
  19115. The port on which to listen for @acronym{RPC} connections.
  19116. Defaults to @samp{9091}.
  19117. @end deftypevr
  19118. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-url
  19119. The path prefix to use in the @acronym{RPC}-endpoint @acronym{URL}.
  19120. Defaults to @samp{"/transmission/"}.
  19121. @end deftypevr
  19122. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-authentication-required?
  19123. When @code{#t}, clients must authenticate (see @code{rpc-username} and
  19124. @code{rpc-password}) when using the @acronym{RPC} interface. Note this
  19125. has the side effect of disabling host-name whitelisting (see
  19126. @code{rpc-host-whitelist-enabled?}.
  19127. Defaults to @samp{#f}.
  19128. @end deftypevr
  19129. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string rpc-username
  19130. The username required by clients to access the @acronym{RPC} interface
  19131. when @code{rpc-authentication-required?} is @code{#t}.
  19132. Defaults to @samp{disabled}.
  19133. @end deftypevr
  19134. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-transmission-password-hash rpc-password
  19135. The password required by clients to access the @acronym{RPC} interface
  19136. when @code{rpc-authentication-required?} is @code{#t}. This must be
  19137. specified using a password hash in the format recognized by Transmission
  19138. clients, either copied from an existing @file{settings.json} file or
  19139. generated using the @code{transmission-password-hash} procedure.
  19140. Defaults to @samp{disabled}.
  19141. @end deftypevr
  19142. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-whitelist-enabled?
  19143. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  19144. originate from an address specified in @code{rpc-whitelist}.
  19145. Defaults to @samp{#t}.
  19146. @end deftypevr
  19147. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-whitelist
  19148. The list of IP and IPv6 addresses from which @acronym{RPC} requests will
  19149. be accepted when @code{rpc-whitelist-enabled?} is @code{#t}. Wildcards
  19150. may be specified using @samp{*}.
  19151. Defaults to @samp{("127.0.0.1" "::1")}.
  19152. @end deftypevr
  19153. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-host-whitelist-enabled?
  19154. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  19155. are addressed to a host named in @code{rpc-host-whitelist}. Note that
  19156. requests to ``localhost'' or ``localhost.'', or to a numeric address,
  19157. are always accepted regardless of these settings.
  19158. Note also this functionality is disabled when
  19159. @code{rpc-authentication-required?} is @code{#t}.
  19160. Defaults to @samp{#t}.
  19161. @end deftypevr
  19162. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-host-whitelist
  19163. The list of host names recognized by the @acronym{RPC} server when
  19164. @code{rpc-host-whitelist-enabled?} is @code{#t}.
  19165. Defaults to @samp{()}.
  19166. @end deftypevr
  19167. @deftypevr {@code{transmission-daemon-configuration} parameter} message-level message-level
  19168. The minimum severity level of messages to be logged (to
  19169. @file{/var/log/transmission.log}) by the daemon, one of @code{none} (no
  19170. logging), @code{error}, @code{info} and @code{debug}.
  19171. Defaults to @samp{info}.
  19172. @end deftypevr
  19173. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean start-added-torrents?
  19174. When @code{#t}, torrents are started as soon as they are added;
  19175. otherwise, they are added in ``paused'' state.
  19176. Defaults to @samp{#t}.
  19177. @end deftypevr
  19178. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean script-torrent-done-enabled?
  19179. When @code{#t}, the script specified by
  19180. @code{script-torrent-done-filename} will be invoked each time a torrent
  19181. completes.
  19182. Defaults to @samp{#f}.
  19183. @end deftypevr
  19184. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-file-object script-torrent-done-filename
  19185. A file name or file-like object specifying a script to run each time a
  19186. torrent completes, when @code{script-torrent-done-enabled?} is
  19187. @code{#t}.
  19188. Defaults to @samp{disabled}.
  19189. @end deftypevr
  19190. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean scrape-paused-torrents-enabled?
  19191. When @code{#t}, the daemon will scrape trackers for a torrent even when
  19192. the torrent is paused.
  19193. Defaults to @samp{#t}.
  19194. @end deftypevr
  19195. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer cache-size-mb
  19196. The amount of memory, in megabytes, to allocate for the daemon's
  19197. in-memory cache. A larger value may increase performance by reducing
  19198. the frequency of disk I/O.
  19199. Defaults to @samp{4}.
  19200. @end deftypevr
  19201. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean prefetch-enabled?
  19202. When @code{#t}, the daemon will try to improve I/O performance by
  19203. hinting to the operating system which data is likely to be read next
  19204. from disk to satisfy requests from peers.
  19205. Defaults to @samp{#t}.
  19206. @end deftypevr
  19207. @c %end of fragment
  19208. @node Monitoring Services
  19209. @subsection Monitoring Services
  19210. @subsubheading Tailon Service
  19211. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  19212. viewing and searching log files.
  19213. The following example will configure the service with default values.
  19214. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  19215. @lisp
  19216. (service tailon-service-type)
  19217. @end lisp
  19218. The following example customises more of the Tailon configuration,
  19219. adding @command{sed} to the list of allowed commands.
  19220. @lisp
  19221. (service tailon-service-type
  19222. (tailon-configuration
  19223. (config-file
  19224. (tailon-configuration-file
  19225. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  19226. @end lisp
  19227. @deftp {Data Type} tailon-configuration
  19228. Data type representing the configuration of Tailon.
  19229. This type has the following parameters:
  19230. @table @asis
  19231. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  19232. The configuration file to use for Tailon. This can be set to a
  19233. @dfn{tailon-configuration-file} record value, or any gexp
  19234. (@pxref{G-Expressions}).
  19235. For example, to instead use a local file, the @code{local-file} function
  19236. can be used:
  19237. @lisp
  19238. (service tailon-service-type
  19239. (tailon-configuration
  19240. (config-file (local-file "./my-tailon.conf"))))
  19241. @end lisp
  19242. @item @code{package} (default: @code{tailon})
  19243. The tailon package to use.
  19244. @end table
  19245. @end deftp
  19246. @deftp {Data Type} tailon-configuration-file
  19247. Data type representing the configuration options for Tailon.
  19248. This type has the following parameters:
  19249. @table @asis
  19250. @item @code{files} (default: @code{(list "/var/log")})
  19251. List of files to display. The list can include strings for a single file
  19252. or directory, or a list, where the first item is the name of a
  19253. subsection, and the remaining items are the files or directories in that
  19254. subsection.
  19255. @item @code{bind} (default: @code{"localhost:8080"})
  19256. Address and port to which Tailon should bind on.
  19257. @item @code{relative-root} (default: @code{#f})
  19258. URL path to use for Tailon, set to @code{#f} to not use a path.
  19259. @item @code{allow-transfers?} (default: @code{#t})
  19260. Allow downloading the log files in the web interface.
  19261. @item @code{follow-names?} (default: @code{#t})
  19262. Allow tailing of not-yet existent files.
  19263. @item @code{tail-lines} (default: @code{200})
  19264. Number of lines to read initially from each file.
  19265. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  19266. Commands to allow running. By default, @code{sed} is disabled.
  19267. @item @code{debug?} (default: @code{#f})
  19268. Set @code{debug?} to @code{#t} to show debug messages.
  19269. @item @code{wrap-lines} (default: @code{#t})
  19270. Initial line wrapping state in the web interface. Set to @code{#t} to
  19271. initially wrap lines (the default), or to @code{#f} to initially not
  19272. wrap lines.
  19273. @item @code{http-auth} (default: @code{#f})
  19274. HTTP authentication type to use. Set to @code{#f} to disable
  19275. authentication (the default). Supported values are @code{"digest"} or
  19276. @code{"basic"}.
  19277. @item @code{users} (default: @code{#f})
  19278. If HTTP authentication is enabled (see @code{http-auth}), access will be
  19279. restricted to the credentials provided here. To configure users, use a
  19280. list of pairs, where the first element of the pair is the username, and
  19281. the 2nd element of the pair is the password.
  19282. @lisp
  19283. (tailon-configuration-file
  19284. (http-auth "basic")
  19285. (users '(("user1" . "password1")
  19286. ("user2" . "password2"))))
  19287. @end lisp
  19288. @end table
  19289. @end deftp
  19290. @subsubheading Darkstat Service
  19291. @cindex darkstat
  19292. Darkstat is a packet sniffer that captures network traffic, calculates
  19293. statistics about usage, and serves reports over HTTP.
  19294. @defvar {Scheme Variable} darkstat-service-type
  19295. This is the service type for the
  19296. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  19297. service, its value must be a @code{darkstat-configuration} record as in
  19298. this example:
  19299. @lisp
  19300. (service darkstat-service-type
  19301. (darkstat-configuration
  19302. (interface "eno1")))
  19303. @end lisp
  19304. @end defvar
  19305. @deftp {Data Type} darkstat-configuration
  19306. Data type representing the configuration of @command{darkstat}.
  19307. @table @asis
  19308. @item @code{package} (default: @code{darkstat})
  19309. The darkstat package to use.
  19310. @item @code{interface}
  19311. Capture traffic on the specified network interface.
  19312. @item @code{port} (default: @code{"667"})
  19313. Bind the web interface to the specified port.
  19314. @item @code{bind-address} (default: @code{"127.0.0.1"})
  19315. Bind the web interface to the specified address.
  19316. @item @code{base} (default: @code{"/"})
  19317. Specify the path of the base URL@. This can be useful if
  19318. @command{darkstat} is accessed via a reverse proxy.
  19319. @end table
  19320. @end deftp
  19321. @subsubheading Prometheus Node Exporter Service
  19322. @cindex prometheus-node-exporter
  19323. The Prometheus ``node exporter'' makes hardware and operating system statistics
  19324. provided by the Linux kernel available for the Prometheus monitoring system.
  19325. This service should be deployed on all physical nodes and virtual machines,
  19326. where monitoring these statistics is desirable.
  19327. @defvar {Scheme variable} prometheus-node-exporter-service-type
  19328. This is the service type for the
  19329. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  19330. service, its value must be a @code{prometheus-node-exporter-configuration}.
  19331. @lisp
  19332. (service prometheus-node-exporter-service-type)
  19333. @end lisp
  19334. @end defvar
  19335. @deftp {Data Type} prometheus-node-exporter-configuration
  19336. Data type representing the configuration of @command{node_exporter}.
  19337. @table @asis
  19338. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  19339. The prometheus-node-exporter package to use.
  19340. @item @code{web-listen-address} (default: @code{":9100"})
  19341. Bind the web interface to the specified address.
  19342. @item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"})
  19343. This directory can be used to export metrics specific to this machine.
  19344. Files containing metrics in the text format, with the filename ending in
  19345. @code{.prom} should be placed in this directory.
  19346. @item @code{extra-options} (default: @code{'()})
  19347. Extra options to pass to the Prometheus node exporter.
  19348. @end table
  19349. @end deftp
  19350. @subsubheading Zabbix server
  19351. @cindex zabbix zabbix-server
  19352. Zabbix provides monitoring metrics, among others network utilization, CPU load
  19353. and disk space consumption:
  19354. @itemize
  19355. @item High performance, high capacity (able to monitor hundreds of thousands of devices).
  19356. @item Auto-discovery of servers and network devices and interfaces.
  19357. @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
  19358. @item Distributed monitoring with centralized web administration.
  19359. @item Native high performance agents.
  19360. @item SLA, and ITIL KPI metrics on reporting.
  19361. @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
  19362. @item Remote command execution through Zabbix proxies.
  19363. @end itemize
  19364. @c %start of fragment
  19365. Available @code{zabbix-server-configuration} fields are:
  19366. @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
  19367. The zabbix-server package.
  19368. @end deftypevr
  19369. @deftypevr {@code{zabbix-server-configuration} parameter} string user
  19370. User who will run the Zabbix server.
  19371. Defaults to @samp{"zabbix"}.
  19372. @end deftypevr
  19373. @deftypevr {@code{zabbix-server-configuration} parameter} group group
  19374. Group who will run the Zabbix server.
  19375. Defaults to @samp{"zabbix"}.
  19376. @end deftypevr
  19377. @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
  19378. Database host name.
  19379. Defaults to @samp{"127.0.0.1"}.
  19380. @end deftypevr
  19381. @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
  19382. Database name.
  19383. Defaults to @samp{"zabbix"}.
  19384. @end deftypevr
  19385. @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
  19386. Database user.
  19387. Defaults to @samp{"zabbix"}.
  19388. @end deftypevr
  19389. @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
  19390. Database password. Please, use @code{include-files} with
  19391. @code{DBPassword=SECRET} inside a specified file instead.
  19392. Defaults to @samp{""}.
  19393. @end deftypevr
  19394. @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
  19395. Database port.
  19396. Defaults to @samp{5432}.
  19397. @end deftypevr
  19398. @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
  19399. Specifies where log messages are written to:
  19400. @itemize @bullet
  19401. @item
  19402. @code{system} - syslog.
  19403. @item
  19404. @code{file} - file specified with @code{log-file} parameter.
  19405. @item
  19406. @code{console} - standard output.
  19407. @end itemize
  19408. Defaults to @samp{""}.
  19409. @end deftypevr
  19410. @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
  19411. Log file name for @code{log-type} @code{file} parameter.
  19412. Defaults to @samp{"/var/log/zabbix/server.log"}.
  19413. @end deftypevr
  19414. @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
  19415. Name of PID file.
  19416. Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
  19417. @end deftypevr
  19418. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
  19419. The location of certificate authority (CA) files for SSL server
  19420. certificate verification.
  19421. Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
  19422. @end deftypevr
  19423. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
  19424. Location of SSL client certificates.
  19425. Defaults to @samp{"/etc/ssl/certs"}.
  19426. @end deftypevr
  19427. @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
  19428. Extra options will be appended to Zabbix server configuration file.
  19429. Defaults to @samp{""}.
  19430. @end deftypevr
  19431. @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
  19432. You may include individual files or all files in a directory in the
  19433. configuration file.
  19434. Defaults to @samp{()}.
  19435. @end deftypevr
  19436. @c %end of fragment
  19437. @subsubheading Zabbix agent
  19438. @cindex zabbix zabbix-agent
  19439. Zabbix agent gathers information for Zabbix server.
  19440. @c %start of fragment
  19441. Available @code{zabbix-agent-configuration} fields are:
  19442. @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
  19443. The zabbix-agent package.
  19444. @end deftypevr
  19445. @deftypevr {@code{zabbix-agent-configuration} parameter} string user
  19446. User who will run the Zabbix agent.
  19447. Defaults to @samp{"zabbix"}.
  19448. @end deftypevr
  19449. @deftypevr {@code{zabbix-agent-configuration} parameter} group group
  19450. Group who will run the Zabbix agent.
  19451. Defaults to @samp{"zabbix"}.
  19452. @end deftypevr
  19453. @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
  19454. Unique, case sensitive hostname which is required for active checks and
  19455. must match hostname as configured on the server.
  19456. Defaults to @samp{""}.
  19457. @end deftypevr
  19458. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
  19459. Specifies where log messages are written to:
  19460. @itemize @bullet
  19461. @item
  19462. @code{system} - syslog.
  19463. @item
  19464. @code{file} - file specified with @code{log-file} parameter.
  19465. @item
  19466. @code{console} - standard output.
  19467. @end itemize
  19468. Defaults to @samp{""}.
  19469. @end deftypevr
  19470. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
  19471. Log file name for @code{log-type} @code{file} parameter.
  19472. Defaults to @samp{"/var/log/zabbix/agent.log"}.
  19473. @end deftypevr
  19474. @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
  19475. Name of PID file.
  19476. Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
  19477. @end deftypevr
  19478. @deftypevr {@code{zabbix-agent-configuration} parameter} list server
  19479. List of IP addresses, optionally in CIDR notation, or hostnames of
  19480. Zabbix servers and Zabbix proxies. Incoming connections will be
  19481. accepted only from the hosts listed here.
  19482. Defaults to @samp{("127.0.0.1")}.
  19483. @end deftypevr
  19484. @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
  19485. List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
  19486. proxies for active checks. If port is not specified, default port is
  19487. used. If this parameter is not specified, active checks are disabled.
  19488. Defaults to @samp{("127.0.0.1")}.
  19489. @end deftypevr
  19490. @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
  19491. Extra options will be appended to Zabbix server configuration file.
  19492. Defaults to @samp{""}.
  19493. @end deftypevr
  19494. @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
  19495. You may include individual files or all files in a directory in the
  19496. configuration file.
  19497. Defaults to @samp{()}.
  19498. @end deftypevr
  19499. @c %end of fragment
  19500. @subsubheading Zabbix front-end
  19501. @cindex zabbix zabbix-front-end
  19502. This service provides a WEB interface to Zabbix server.
  19503. @c %start of fragment
  19504. Available @code{zabbix-front-end-configuration} fields are:
  19505. @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
  19506. NGINX configuration.
  19507. @end deftypevr
  19508. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
  19509. Database host name.
  19510. Defaults to @samp{"localhost"}.
  19511. @end deftypevr
  19512. @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
  19513. Database port.
  19514. Defaults to @samp{5432}.
  19515. @end deftypevr
  19516. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
  19517. Database name.
  19518. Defaults to @samp{"zabbix"}.
  19519. @end deftypevr
  19520. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
  19521. Database user.
  19522. Defaults to @samp{"zabbix"}.
  19523. @end deftypevr
  19524. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
  19525. Database password. Please, use @code{db-secret-file} instead.
  19526. Defaults to @samp{""}.
  19527. @end deftypevr
  19528. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
  19529. Secret file containing the credentials for the Zabbix front-end. The value
  19530. must be a local file name, not a G-expression. You are expected to create
  19531. this file manually. Its contents will be copied into @file{zabbix.conf.php}
  19532. as the value of @code{$DB['PASSWORD']}.
  19533. Defaults to @samp{""}.
  19534. @end deftypevr
  19535. @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
  19536. Zabbix server hostname.
  19537. Defaults to @samp{"localhost"}.
  19538. @end deftypevr
  19539. @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
  19540. Zabbix server port.
  19541. Defaults to @samp{10051}.
  19542. @end deftypevr
  19543. @c %end of fragment
  19544. @node Kerberos Services
  19545. @subsection Kerberos Services
  19546. @cindex Kerberos
  19547. The @code{(gnu services kerberos)} module provides services relating to
  19548. the authentication protocol @dfn{Kerberos}.
  19549. @subsubheading Krb5 Service
  19550. Programs using a Kerberos client library normally
  19551. expect a configuration file in @file{/etc/krb5.conf}.
  19552. This service generates such a file from a definition provided in the
  19553. operating system declaration.
  19554. It does not cause any daemon to be started.
  19555. No ``keytab'' files are provided by this service---you must explicitly create them.
  19556. This service is known to work with the MIT client library, @code{mit-krb5}.
  19557. Other implementations have not been tested.
  19558. @defvr {Scheme Variable} krb5-service-type
  19559. A service type for Kerberos 5 clients.
  19560. @end defvr
  19561. @noindent
  19562. Here is an example of its use:
  19563. @lisp
  19564. (service krb5-service-type
  19565. (krb5-configuration
  19566. (default-realm "EXAMPLE.COM")
  19567. (allow-weak-crypto? #t)
  19568. (realms (list
  19569. (krb5-realm
  19570. (name "EXAMPLE.COM")
  19571. (admin-server "groucho.example.com")
  19572. (kdc "karl.example.com"))
  19573. (krb5-realm
  19574. (name "ARGRX.EDU")
  19575. (admin-server "kerb-admin.argrx.edu")
  19576. (kdc "keys.argrx.edu"))))))
  19577. @end lisp
  19578. @noindent
  19579. This example provides a Kerberos@tie{}5 client configuration which:
  19580. @itemize
  19581. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  19582. of which have distinct administration servers and key distribution centers;
  19583. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  19584. specified by clients;
  19585. @item Accepts services which only support encryption types known to be weak.
  19586. @end itemize
  19587. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  19588. Only the most commonly used ones are described here.
  19589. For a full list, and more detailed explanation of each, see the MIT
  19590. @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  19591. documentation.
  19592. @deftp {Data Type} krb5-realm
  19593. @cindex realm, kerberos
  19594. @table @asis
  19595. @item @code{name}
  19596. This field is a string identifying the name of the realm.
  19597. A common convention is to use the fully qualified DNS name of your organization,
  19598. converted to upper case.
  19599. @item @code{admin-server}
  19600. This field is a string identifying the host where the administration server is
  19601. running.
  19602. @item @code{kdc}
  19603. This field is a string identifying the key distribution center
  19604. for the realm.
  19605. @end table
  19606. @end deftp
  19607. @deftp {Data Type} krb5-configuration
  19608. @table @asis
  19609. @item @code{allow-weak-crypto?} (default: @code{#f})
  19610. If this flag is @code{#t} then services which only offer encryption algorithms
  19611. known to be weak will be accepted.
  19612. @item @code{default-realm} (default: @code{#f})
  19613. This field should be a string identifying the default Kerberos
  19614. realm for the client.
  19615. You should set this field to the name of your Kerberos realm.
  19616. If this value is @code{#f}
  19617. then a realm must be specified with every Kerberos principal when invoking programs
  19618. such as @command{kinit}.
  19619. @item @code{realms}
  19620. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  19621. access.
  19622. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  19623. field.
  19624. @end table
  19625. @end deftp
  19626. @subsubheading PAM krb5 Service
  19627. @cindex pam-krb5
  19628. The @code{pam-krb5} service allows for login authentication and password
  19629. management via Kerberos.
  19630. You will need this service if you want PAM enabled applications to authenticate
  19631. users using Kerberos.
  19632. @defvr {Scheme Variable} pam-krb5-service-type
  19633. A service type for the Kerberos 5 PAM module.
  19634. @end defvr
  19635. @deftp {Data Type} pam-krb5-configuration
  19636. Data type representing the configuration of the Kerberos 5 PAM module.
  19637. This type has the following parameters:
  19638. @table @asis
  19639. @item @code{pam-krb5} (default: @code{pam-krb5})
  19640. The pam-krb5 package to use.
  19641. @item @code{minimum-uid} (default: @code{1000})
  19642. The smallest user ID for which Kerberos authentications should be attempted.
  19643. Local accounts with lower values will silently fail to authenticate.
  19644. @end table
  19645. @end deftp
  19646. @node LDAP Services
  19647. @subsection LDAP Services
  19648. @cindex LDAP
  19649. @cindex nslcd, LDAP service
  19650. The @code{(gnu services authentication)} module provides the
  19651. @code{nslcd-service-type}, which can be used to authenticate against an LDAP
  19652. server. In addition to configuring the service itself, you may want to add
  19653. @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
  19654. Switch} for detailed information.
  19655. Here is a simple operating system declaration with a default configuration of
  19656. the @code{nslcd-service-type} and a Name Service Switch configuration that
  19657. consults the @code{ldap} name service last:
  19658. @lisp
  19659. (use-service-modules authentication)
  19660. (use-modules (gnu system nss))
  19661. ...
  19662. (operating-system
  19663. ...
  19664. (services
  19665. (cons*
  19666. (service nslcd-service-type)
  19667. (service dhcp-client-service-type)
  19668. %base-services))
  19669. (name-service-switch
  19670. (let ((services (list (name-service (name "db"))
  19671. (name-service (name "files"))
  19672. (name-service (name "ldap")))))
  19673. (name-service-switch
  19674. (inherit %mdns-host-lookup-nss)
  19675. (password services)
  19676. (shadow services)
  19677. (group services)
  19678. (netgroup services)
  19679. (gshadow services)))))
  19680. @end lisp
  19681. @c %start of generated documentation for nslcd-configuration
  19682. Available @code{nslcd-configuration} fields are:
  19683. @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
  19684. The @code{nss-pam-ldapd} package to use.
  19685. @end deftypevr
  19686. @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
  19687. The number of threads to start that can handle requests and perform LDAP
  19688. queries. Each thread opens a separate connection to the LDAP server.
  19689. The default is to start 5 threads.
  19690. Defaults to @samp{disabled}.
  19691. @end deftypevr
  19692. @deftypevr {@code{nslcd-configuration} parameter} string uid
  19693. This specifies the user id with which the daemon should be run.
  19694. Defaults to @samp{"nslcd"}.
  19695. @end deftypevr
  19696. @deftypevr {@code{nslcd-configuration} parameter} string gid
  19697. This specifies the group id with which the daemon should be run.
  19698. Defaults to @samp{"nslcd"}.
  19699. @end deftypevr
  19700. @deftypevr {@code{nslcd-configuration} parameter} log-option log
  19701. This option controls the way logging is done via a list containing
  19702. SCHEME and LEVEL@. The SCHEME argument may either be the symbols
  19703. @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
  19704. argument is optional and specifies the log level. The log level may be
  19705. one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
  19706. @samp{notice}, @samp{info} or @samp{debug}. All messages with the
  19707. specified log level or higher are logged.
  19708. Defaults to @samp{("/var/log/nslcd" info)}.
  19709. @end deftypevr
  19710. @deftypevr {@code{nslcd-configuration} parameter} list uri
  19711. The list of LDAP server URIs. Normally, only the first server will be
  19712. used with the following servers as fall-back.
  19713. Defaults to @samp{("ldap://localhost:389/")}.
  19714. @end deftypevr
  19715. @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
  19716. The version of the LDAP protocol to use. The default is to use the
  19717. maximum version supported by the LDAP library.
  19718. Defaults to @samp{disabled}.
  19719. @end deftypevr
  19720. @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
  19721. Specifies the distinguished name with which to bind to the directory
  19722. server for lookups. The default is to bind anonymously.
  19723. Defaults to @samp{disabled}.
  19724. @end deftypevr
  19725. @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
  19726. Specifies the credentials with which to bind. This option is only
  19727. applicable when used with binddn.
  19728. Defaults to @samp{disabled}.
  19729. @end deftypevr
  19730. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
  19731. Specifies the distinguished name to use when the root user tries to
  19732. modify a user's password using the PAM module.
  19733. Defaults to @samp{disabled}.
  19734. @end deftypevr
  19735. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
  19736. Specifies the credentials with which to bind if the root user tries to
  19737. change a user's password. This option is only applicable when used with
  19738. rootpwmoddn
  19739. Defaults to @samp{disabled}.
  19740. @end deftypevr
  19741. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
  19742. Specifies the SASL mechanism to be used when performing SASL
  19743. authentication.
  19744. Defaults to @samp{disabled}.
  19745. @end deftypevr
  19746. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
  19747. Specifies the SASL realm to be used when performing SASL authentication.
  19748. Defaults to @samp{disabled}.
  19749. @end deftypevr
  19750. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
  19751. Specifies the authentication identity to be used when performing SASL
  19752. authentication.
  19753. Defaults to @samp{disabled}.
  19754. @end deftypevr
  19755. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
  19756. Specifies the authorization identity to be used when performing SASL
  19757. authentication.
  19758. Defaults to @samp{disabled}.
  19759. @end deftypevr
  19760. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
  19761. Determines whether the LDAP server host name should be canonicalised. If
  19762. this is enabled the LDAP library will do a reverse host name lookup. By
  19763. default, it is left up to the LDAP library whether this check is
  19764. performed or not.
  19765. Defaults to @samp{disabled}.
  19766. @end deftypevr
  19767. @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
  19768. Set the name for the GSS-API Kerberos credentials cache.
  19769. Defaults to @samp{disabled}.
  19770. @end deftypevr
  19771. @deftypevr {@code{nslcd-configuration} parameter} string base
  19772. The directory search base.
  19773. Defaults to @samp{"dc=example,dc=com"}.
  19774. @end deftypevr
  19775. @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
  19776. Specifies the search scope (subtree, onelevel, base or children). The
  19777. default scope is subtree; base scope is almost never useful for name
  19778. service lookups; children scope is not supported on all servers.
  19779. Defaults to @samp{(subtree)}.
  19780. @end deftypevr
  19781. @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
  19782. Specifies the policy for dereferencing aliases. The default policy is
  19783. to never dereference aliases.
  19784. Defaults to @samp{disabled}.
  19785. @end deftypevr
  19786. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
  19787. Specifies whether automatic referral chasing should be enabled. The
  19788. default behaviour is to chase referrals.
  19789. Defaults to @samp{disabled}.
  19790. @end deftypevr
  19791. @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
  19792. This option allows for custom attributes to be looked up instead of the
  19793. default RFC 2307 attributes. It is a list of maps, each consisting of
  19794. the name of a map, the RFC 2307 attribute to match and the query
  19795. expression for the attribute as it is available in the directory.
  19796. Defaults to @samp{()}.
  19797. @end deftypevr
  19798. @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
  19799. A list of filters consisting of the name of a map to which the filter
  19800. applies and an LDAP search filter expression.
  19801. Defaults to @samp{()}.
  19802. @end deftypevr
  19803. @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
  19804. Specifies the time limit in seconds to use when connecting to the
  19805. directory server. The default value is 10 seconds.
  19806. Defaults to @samp{disabled}.
  19807. @end deftypevr
  19808. @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
  19809. Specifies the time limit (in seconds) to wait for a response from the
  19810. LDAP server. A value of zero, which is the default, is to wait
  19811. indefinitely for searches to be completed.
  19812. Defaults to @samp{disabled}.
  19813. @end deftypevr
  19814. @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
  19815. Specifies the period if inactivity (in seconds) after which the con‐
  19816. nection to the LDAP server will be closed. The default is not to time
  19817. out connections.
  19818. Defaults to @samp{disabled}.
  19819. @end deftypevr
  19820. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
  19821. Specifies the number of seconds to sleep when connecting to all LDAP
  19822. servers fails. By default one second is waited between the first
  19823. failure and the first retry.
  19824. Defaults to @samp{disabled}.
  19825. @end deftypevr
  19826. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
  19827. Specifies the time after which the LDAP server is considered to be
  19828. permanently unavailable. Once this time is reached retries will be done
  19829. only once per this time period. The default value is 10 seconds.
  19830. Defaults to @samp{disabled}.
  19831. @end deftypevr
  19832. @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
  19833. Specifies whether to use SSL/TLS or not (the default is not to). If
  19834. 'start-tls is specified then StartTLS is used rather than raw LDAP over
  19835. SSL.
  19836. Defaults to @samp{disabled}.
  19837. @end deftypevr
  19838. @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
  19839. Specifies what checks to perform on a server-supplied certificate. The
  19840. meaning of the values is described in the ldap.conf(5) manual page.
  19841. Defaults to @samp{disabled}.
  19842. @end deftypevr
  19843. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
  19844. Specifies the directory containing X.509 certificates for peer authen‐
  19845. tication. This parameter is ignored when using GnuTLS.
  19846. Defaults to @samp{disabled}.
  19847. @end deftypevr
  19848. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
  19849. Specifies the path to the X.509 certificate for peer authentication.
  19850. Defaults to @samp{disabled}.
  19851. @end deftypevr
  19852. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
  19853. Specifies the path to an entropy source. This parameter is ignored when
  19854. using GnuTLS.
  19855. Defaults to @samp{disabled}.
  19856. @end deftypevr
  19857. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
  19858. Specifies the ciphers to use for TLS as a string.
  19859. Defaults to @samp{disabled}.
  19860. @end deftypevr
  19861. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
  19862. Specifies the path to the file containing the local certificate for
  19863. client TLS authentication.
  19864. Defaults to @samp{disabled}.
  19865. @end deftypevr
  19866. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
  19867. Specifies the path to the file containing the private key for client TLS
  19868. authentication.
  19869. Defaults to @samp{disabled}.
  19870. @end deftypevr
  19871. @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
  19872. Set this to a number greater than 0 to request paged results from the
  19873. LDAP server in accordance with RFC2696. The default (0) is to not
  19874. request paged results.
  19875. Defaults to @samp{disabled}.
  19876. @end deftypevr
  19877. @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
  19878. This option prevents group membership lookups through LDAP for the
  19879. specified users. Alternatively, the value 'all-local may be used. With
  19880. that value nslcd builds a full list of non-LDAP users on startup.
  19881. Defaults to @samp{disabled}.
  19882. @end deftypevr
  19883. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
  19884. This option ensures that LDAP users with a numeric user id lower than
  19885. the specified value are ignored.
  19886. Defaults to @samp{disabled}.
  19887. @end deftypevr
  19888. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
  19889. This option specifies an offset that is added to all LDAP numeric user
  19890. ids. This can be used to avoid user id collisions with local users.
  19891. Defaults to @samp{disabled}.
  19892. @end deftypevr
  19893. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
  19894. This option specifies an offset that is added to all LDAP numeric group
  19895. ids. This can be used to avoid user id collisions with local groups.
  19896. Defaults to @samp{disabled}.
  19897. @end deftypevr
  19898. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
  19899. If this option is set, the member attribute of a group may point to
  19900. another group. Members of nested groups are also returned in the higher
  19901. level group and parent groups are returned when finding groups for a
  19902. specific user. The default is not to perform extra searches for nested
  19903. groups.
  19904. Defaults to @samp{disabled}.
  19905. @end deftypevr
  19906. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
  19907. If this option is set, the group member list is not retrieved when
  19908. looking up groups. Lookups for finding which groups a user belongs to
  19909. will remain functional so the user will likely still get the correct
  19910. groups assigned on login.
  19911. Defaults to @samp{disabled}.
  19912. @end deftypevr
  19913. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
  19914. If this option is set, functions which cause all user/group entries to
  19915. be loaded from the directory will not succeed in doing so. This can
  19916. dramatically reduce LDAP server load in situations where there are a
  19917. great number of users and/or groups. This option is not recommended for
  19918. most configurations.
  19919. Defaults to @samp{disabled}.
  19920. @end deftypevr
  19921. @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
  19922. This option can be used to specify how user and group names are verified
  19923. within the system. This pattern is used to check all user and group
  19924. names that are requested and returned from LDAP.
  19925. Defaults to @samp{disabled}.
  19926. @end deftypevr
  19927. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
  19928. This specifies whether or not to perform searches using case-insensitive
  19929. matching. Enabling this could open up the system to authorization
  19930. bypass vulnerabilities and introduce nscd cache poisoning
  19931. vulnerabilities which allow denial of service.
  19932. Defaults to @samp{disabled}.
  19933. @end deftypevr
  19934. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
  19935. This option specifies whether password policy controls are requested and
  19936. handled from the LDAP server when performing user authentication.
  19937. Defaults to @samp{disabled}.
  19938. @end deftypevr
  19939. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
  19940. By default nslcd performs an LDAP search with the user's credentials
  19941. after BIND (authentication) to ensure that the BIND operation was
  19942. successful. The default search is a simple check to see if the user's
  19943. DN exists. A search filter can be specified that will be used instead.
  19944. It should return at least one entry.
  19945. Defaults to @samp{disabled}.
  19946. @end deftypevr
  19947. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
  19948. This option allows flexible fine tuning of the authorisation check that
  19949. should be performed. The search filter specified is executed and if any
  19950. entries match, access is granted, otherwise access is denied.
  19951. Defaults to @samp{disabled}.
  19952. @end deftypevr
  19953. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
  19954. If this option is set password modification using pam_ldap will be
  19955. denied and the specified message will be presented to the user instead.
  19956. The message can be used to direct the user to an alternative means of
  19957. changing their password.
  19958. Defaults to @samp{disabled}.
  19959. @end deftypevr
  19960. @deftypevr {@code{nslcd-configuration} parameter} list pam-services
  19961. List of pam service names for which LDAP authentication should suffice.
  19962. Defaults to @samp{()}.
  19963. @end deftypevr
  19964. @c %end of generated documentation for nslcd-configuration
  19965. @node Web Services
  19966. @subsection Web Services
  19967. @cindex web
  19968. @cindex www
  19969. @cindex HTTP
  19970. The @code{(gnu services web)} module provides the Apache HTTP Server,
  19971. the nginx web server, and also a fastcgi wrapper daemon.
  19972. @subsubheading Apache HTTP Server
  19973. @deffn {Scheme Variable} httpd-service-type
  19974. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  19975. (@dfn{httpd}). The value for this service type is a
  19976. @code{httpd-configuration} record.
  19977. A simple example configuration is given below.
  19978. @lisp
  19979. (service httpd-service-type
  19980. (httpd-configuration
  19981. (config
  19982. (httpd-config-file
  19983. (server-name "www.example.com")
  19984. (document-root "/srv/http/www.example.com")))))
  19985. @end lisp
  19986. Other services can also extend the @code{httpd-service-type} to add to
  19987. the configuration.
  19988. @lisp
  19989. (simple-service 'www.example.com-server httpd-service-type
  19990. (list
  19991. (httpd-virtualhost
  19992. "*:80"
  19993. (list (string-join '("ServerName www.example.com"
  19994. "DocumentRoot /srv/http/www.example.com")
  19995. "\n")))))
  19996. @end lisp
  19997. @end deffn
  19998. The details for the @code{httpd-configuration}, @code{httpd-module},
  19999. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  20000. given below.
  20001. @deffn {Data Type} httpd-configuration
  20002. This data type represents the configuration for the httpd service.
  20003. @table @asis
  20004. @item @code{package} (default: @code{httpd})
  20005. The httpd package to use.
  20006. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  20007. The pid file used by the shepherd-service.
  20008. @item @code{config} (default: @code{(httpd-config-file)})
  20009. The configuration file to use with the httpd service. The default value
  20010. is a @code{httpd-config-file} record, but this can also be a different
  20011. G-expression that generates a file, for example a @code{plain-file}. A
  20012. file outside of the store can also be specified through a string.
  20013. @end table
  20014. @end deffn
  20015. @deffn {Data Type} httpd-module
  20016. This data type represents a module for the httpd service.
  20017. @table @asis
  20018. @item @code{name}
  20019. The name of the module.
  20020. @item @code{file}
  20021. The file for the module. This can be relative to the httpd package being
  20022. used, the absolute location of a file, or a G-expression for a file
  20023. within the store, for example @code{(file-append mod-wsgi
  20024. "/modules/mod_wsgi.so")}.
  20025. @end table
  20026. @end deffn
  20027. @defvr {Scheme Variable} %default-httpd-modules
  20028. A default list of @code{httpd-module} objects.
  20029. @end defvr
  20030. @deffn {Data Type} httpd-config-file
  20031. This data type represents a configuration file for the httpd service.
  20032. @table @asis
  20033. @item @code{modules} (default: @code{%default-httpd-modules})
  20034. The modules to load. Additional modules can be added here, or loaded by
  20035. additional configuration.
  20036. For example, in order to handle requests for PHP files, you can use Apache’s
  20037. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  20038. @lisp
  20039. (service httpd-service-type
  20040. (httpd-configuration
  20041. (config
  20042. (httpd-config-file
  20043. (modules (cons*
  20044. (httpd-module
  20045. (name "proxy_module")
  20046. (file "modules/mod_proxy.so"))
  20047. (httpd-module
  20048. (name "proxy_fcgi_module")
  20049. (file "modules/mod_proxy_fcgi.so"))
  20050. %default-httpd-modules))
  20051. (extra-config (list "\
  20052. <FilesMatch \\.php$>
  20053. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  20054. </FilesMatch>"))))))
  20055. (service php-fpm-service-type
  20056. (php-fpm-configuration
  20057. (socket "/var/run/php-fpm.sock")
  20058. (socket-group "httpd")))
  20059. @end lisp
  20060. @item @code{server-root} (default: @code{httpd})
  20061. The @code{ServerRoot} in the configuration file, defaults to the httpd
  20062. package. Directives including @code{Include} and @code{LoadModule} are
  20063. taken as relative to the server root.
  20064. @item @code{server-name} (default: @code{#f})
  20065. The @code{ServerName} in the configuration file, used to specify the
  20066. request scheme, hostname and port that the server uses to identify
  20067. itself.
  20068. This doesn't need to be set in the server config, and can be specified
  20069. in virtual hosts. The default is @code{#f} to not specify a
  20070. @code{ServerName}.
  20071. @item @code{document-root} (default: @code{"/srv/http"})
  20072. The @code{DocumentRoot} from which files will be served.
  20073. @item @code{listen} (default: @code{'("80")})
  20074. The list of values for the @code{Listen} directives in the config
  20075. file. The value should be a list of strings, when each string can
  20076. specify the port number to listen on, and optionally the IP address and
  20077. protocol to use.
  20078. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  20079. The @code{PidFile} to use. This should match the @code{pid-file} set in
  20080. the @code{httpd-configuration} so that the Shepherd service is
  20081. configured correctly.
  20082. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  20083. The @code{ErrorLog} to which the server will log errors.
  20084. @item @code{user} (default: @code{"httpd"})
  20085. The @code{User} which the server will answer requests as.
  20086. @item @code{group} (default: @code{"httpd"})
  20087. The @code{Group} which the server will answer requests as.
  20088. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  20089. A flat list of strings and G-expressions which will be added to the end
  20090. of the configuration file.
  20091. Any values which the service is extended with will be appended to this
  20092. list.
  20093. @end table
  20094. @end deffn
  20095. @deffn {Data Type} httpd-virtualhost
  20096. This data type represents a virtualhost configuration block for the httpd service.
  20097. These should be added to the extra-config for the httpd-service.
  20098. @lisp
  20099. (simple-service 'www.example.com-server httpd-service-type
  20100. (list
  20101. (httpd-virtualhost
  20102. "*:80"
  20103. (list (string-join '("ServerName www.example.com"
  20104. "DocumentRoot /srv/http/www.example.com")
  20105. "\n")))))
  20106. @end lisp
  20107. @table @asis
  20108. @item @code{addresses-and-ports}
  20109. The addresses and ports for the @code{VirtualHost} directive.
  20110. @item @code{contents}
  20111. The contents of the @code{VirtualHost} directive, this should be a list
  20112. of strings and G-expressions.
  20113. @end table
  20114. @end deffn
  20115. @anchor{NGINX}
  20116. @subsubheading NGINX
  20117. @deffn {Scheme Variable} nginx-service-type
  20118. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  20119. value for this service type is a @code{<nginx-configuration>} record.
  20120. A simple example configuration is given below.
  20121. @lisp
  20122. (service nginx-service-type
  20123. (nginx-configuration
  20124. (server-blocks
  20125. (list (nginx-server-configuration
  20126. (server-name '("www.example.com"))
  20127. (root "/srv/http/www.example.com"))))))
  20128. @end lisp
  20129. In addition to adding server blocks to the service configuration
  20130. directly, this service can be extended by other services to add server
  20131. blocks, as in this example:
  20132. @lisp
  20133. (simple-service 'my-extra-server nginx-service-type
  20134. (list (nginx-server-configuration
  20135. (root "/srv/http/extra-website")
  20136. (try-files (list "$uri" "$uri/index.html")))))
  20137. @end lisp
  20138. @end deffn
  20139. At startup, @command{nginx} has not yet read its configuration file, so
  20140. it uses a default file to log error messages. If it fails to load its
  20141. configuration file, that is where error messages are logged. After the
  20142. configuration file is loaded, the default error log file changes as per
  20143. configuration. In our case, startup error messages can be found in
  20144. @file{/var/run/nginx/logs/error.log}, and after configuration in
  20145. @file{/var/log/nginx/error.log}. The second location can be changed
  20146. with the @var{log-directory} configuration option.
  20147. @deffn {Data Type} nginx-configuration
  20148. This data type represents the configuration for NGinx. Some
  20149. configuration can be done through this and the other provided record
  20150. types, or alternatively, a config file can be provided.
  20151. @table @asis
  20152. @item @code{nginx} (default: @code{nginx})
  20153. The nginx package to use.
  20154. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  20155. The directory to which NGinx will write log files.
  20156. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  20157. The directory in which NGinx will create a pid file, and write temporary
  20158. files.
  20159. @item @code{server-blocks} (default: @code{'()})
  20160. A list of @dfn{server blocks} to create in the generated configuration
  20161. file, the elements should be of type
  20162. @code{<nginx-server-configuration>}.
  20163. The following example would setup NGinx to serve @code{www.example.com}
  20164. from the @code{/srv/http/www.example.com} directory, without using
  20165. HTTPS.
  20166. @lisp
  20167. (service nginx-service-type
  20168. (nginx-configuration
  20169. (server-blocks
  20170. (list (nginx-server-configuration
  20171. (server-name '("www.example.com"))
  20172. (root "/srv/http/www.example.com"))))))
  20173. @end lisp
  20174. @item @code{upstream-blocks} (default: @code{'()})
  20175. A list of @dfn{upstream blocks} to create in the generated configuration
  20176. file, the elements should be of type
  20177. @code{<nginx-upstream-configuration>}.
  20178. Configuring upstreams through the @code{upstream-blocks} can be useful
  20179. when combined with @code{locations} in the
  20180. @code{<nginx-server-configuration>} records. The following example
  20181. creates a server configuration with one location configuration, that
  20182. will proxy requests to a upstream configuration, which will handle
  20183. requests with two servers.
  20184. @lisp
  20185. (service
  20186. nginx-service-type
  20187. (nginx-configuration
  20188. (server-blocks
  20189. (list (nginx-server-configuration
  20190. (server-name '("www.example.com"))
  20191. (root "/srv/http/www.example.com")
  20192. (locations
  20193. (list
  20194. (nginx-location-configuration
  20195. (uri "/path1")
  20196. (body '("proxy_pass http://server-proxy;"))))))))
  20197. (upstream-blocks
  20198. (list (nginx-upstream-configuration
  20199. (name "server-proxy")
  20200. (servers (list "server1.example.com"
  20201. "server2.example.com")))))))
  20202. @end lisp
  20203. @item @code{file} (default: @code{#f})
  20204. If a configuration @var{file} is provided, this will be used, rather than
  20205. generating a configuration file from the provided @code{log-directory},
  20206. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  20207. proper operation, these arguments should match what is in @var{file} to ensure
  20208. that the directories are created when the service is activated.
  20209. This can be useful if you have an existing configuration file, or it's
  20210. not possible to do what is required through the other parts of the
  20211. nginx-configuration record.
  20212. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  20213. Bucket size for the server names hash tables, defaults to @code{#f} to
  20214. use the size of the processors cache line.
  20215. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  20216. Maximum bucket size for the server names hash tables.
  20217. @item @code{modules} (default: @code{'()})
  20218. List of nginx dynamic modules to load. This should be a list of file
  20219. names of loadable modules, as in this example:
  20220. @lisp
  20221. (modules
  20222. (list
  20223. (file-append nginx-accept-language-module "\
  20224. /etc/nginx/modules/ngx_http_accept_language_module.so")
  20225. (file-append nginx-lua-module "\
  20226. /etc/nginx/modules/ngx_http_lua_module.so")))
  20227. @end lisp
  20228. @item @code{lua-package-path} (default: @code{'()})
  20229. List of nginx lua packages to load. This should be a list of package
  20230. names of loadable lua modules, as in this example:
  20231. @lisp
  20232. (lua-package-path (list lua-resty-core
  20233. lua-resty-lrucache
  20234. lua-resty-signal
  20235. lua-tablepool
  20236. lua-resty-shell))
  20237. @end lisp
  20238. @item @code{lua-package-cpath} (default: @code{'()})
  20239. List of nginx lua C packages to load. This should be a list of package
  20240. names of loadable lua C modules, as in this example:
  20241. @lisp
  20242. (lua-package-cpath (list lua-resty-signal))
  20243. @end lisp
  20244. @item @code{global-directives} (default: @code{'((events . ()))})
  20245. Association list of global directives for the top level of the nginx
  20246. configuration. Values may themselves be association lists.
  20247. @lisp
  20248. (global-directives
  20249. `((worker_processes . 16)
  20250. (pcre_jit . on)
  20251. (events . ((worker_connections . 1024)))))
  20252. @end lisp
  20253. @item @code{extra-content} (default: @code{""})
  20254. Extra content for the @code{http} block. Should be string or a string
  20255. valued G-expression.
  20256. @end table
  20257. @end deffn
  20258. @deftp {Data Type} nginx-server-configuration
  20259. Data type representing the configuration of an nginx server block.
  20260. This type has the following parameters:
  20261. @table @asis
  20262. @item @code{listen} (default: @code{'("80" "443 ssl")})
  20263. Each @code{listen} directive sets the address and port for IP, or the
  20264. path for a UNIX-domain socket on which the server will accept requests.
  20265. Both address and port, or only address or only port can be specified.
  20266. An address may also be a hostname, for example:
  20267. @lisp
  20268. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  20269. @end lisp
  20270. @item @code{server-name} (default: @code{(list 'default)})
  20271. A list of server names this server represents. @code{'default} represents the
  20272. default server for connections matching no other server.
  20273. @item @code{root} (default: @code{"/srv/http"})
  20274. Root of the website nginx will serve.
  20275. @item @code{locations} (default: @code{'()})
  20276. A list of @dfn{nginx-location-configuration} or
  20277. @dfn{nginx-named-location-configuration} records to use within this
  20278. server block.
  20279. @item @code{index} (default: @code{(list "index.html")})
  20280. Index files to look for when clients ask for a directory. If it cannot be found,
  20281. Nginx will send the list of files in the directory.
  20282. @item @code{try-files} (default: @code{'()})
  20283. A list of files whose existence is checked in the specified order.
  20284. @code{nginx} will use the first file it finds to process the request.
  20285. @item @code{ssl-certificate} (default: @code{#f})
  20286. Where to find the certificate for secure connections. Set it to @code{#f} if
  20287. you don't have a certificate or you don't want to use HTTPS.
  20288. @item @code{ssl-certificate-key} (default: @code{#f})
  20289. Where to find the private key for secure connections. Set it to @code{#f} if
  20290. you don't have a key or you don't want to use HTTPS.
  20291. @item @code{server-tokens?} (default: @code{#f})
  20292. Whether the server should add its configuration to response.
  20293. @item @code{raw-content} (default: @code{'()})
  20294. A list of raw lines added to the server block.
  20295. @end table
  20296. @end deftp
  20297. @deftp {Data Type} nginx-upstream-configuration
  20298. Data type representing the configuration of an nginx @code{upstream}
  20299. block. This type has the following parameters:
  20300. @table @asis
  20301. @item @code{name}
  20302. Name for this group of servers.
  20303. @item @code{servers}
  20304. Specify the addresses of the servers in the group. The address can be
  20305. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  20306. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  20307. prefix @samp{unix:}. For addresses using an IP address or domain name,
  20308. the default port is 80, and a different port can be specified
  20309. explicitly.
  20310. @end table
  20311. @end deftp
  20312. @deftp {Data Type} nginx-location-configuration
  20313. Data type representing the configuration of an nginx @code{location}
  20314. block. This type has the following parameters:
  20315. @table @asis
  20316. @item @code{uri}
  20317. URI which this location block matches.
  20318. @anchor{nginx-location-configuration body}
  20319. @item @code{body}
  20320. Body of the location block, specified as a list of strings. This can contain
  20321. many
  20322. configuration directives. For example, to pass requests to a upstream
  20323. server group defined using an @code{nginx-upstream-configuration} block,
  20324. the following directive would be specified in the body @samp{(list "proxy_pass
  20325. http://upstream-name;")}.
  20326. @end table
  20327. @end deftp
  20328. @deftp {Data Type} nginx-named-location-configuration
  20329. Data type representing the configuration of an nginx named location
  20330. block. Named location blocks are used for request redirection, and not
  20331. used for regular request processing. This type has the following
  20332. parameters:
  20333. @table @asis
  20334. @item @code{name}
  20335. Name to identify this location block.
  20336. @item @code{body}
  20337. @xref{nginx-location-configuration body}, as the body for named location
  20338. blocks can be used in a similar way to the
  20339. @code{nginx-location-configuration body}. One restriction is that the
  20340. body of a named location block cannot contain location blocks.
  20341. @end table
  20342. @end deftp
  20343. @subsubheading Varnish Cache
  20344. @cindex Varnish
  20345. Varnish is a fast cache server that sits in between web applications
  20346. and end users. It proxies requests from clients and caches the
  20347. accessed URLs such that multiple requests for the same resource only
  20348. creates one request to the back-end.
  20349. @defvr {Scheme Variable} varnish-service-type
  20350. Service type for the Varnish daemon.
  20351. @end defvr
  20352. @deftp {Data Type} varnish-configuration
  20353. Data type representing the @code{varnish} service configuration.
  20354. This type has the following parameters:
  20355. @table @asis
  20356. @item @code{package} (default: @code{varnish})
  20357. The Varnish package to use.
  20358. @item @code{name} (default: @code{"default"})
  20359. A name for this Varnish instance. Varnish will create a directory in
  20360. @file{/var/varnish/} with this name and keep temporary files there. If
  20361. the name starts with a forward slash, it is interpreted as an absolute
  20362. directory name.
  20363. Pass the @code{-n} argument to other Varnish programs to connect to the
  20364. named instance, e.g.@: @command{varnishncsa -n default}.
  20365. @item @code{backend} (default: @code{"localhost:8080"})
  20366. The backend to use. This option has no effect if @code{vcl} is set.
  20367. @item @code{vcl} (default: #f)
  20368. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  20369. is @code{#f}, Varnish will proxy @code{backend} using the default
  20370. configuration. Otherwise this must be a file-like object with valid
  20371. VCL syntax.
  20372. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  20373. For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
  20374. can do something along these lines:
  20375. @lisp
  20376. (define %gnu-mirror
  20377. (plain-file "gnu.vcl"
  20378. "vcl 4.1;
  20379. backend gnu @{ .host = \"www.gnu.org\"; @}"))
  20380. (operating-system
  20381. ;; @dots{}
  20382. (services (cons (service varnish-service-type
  20383. (varnish-configuration
  20384. (listen '(":80"))
  20385. (vcl %gnu-mirror)))
  20386. %base-services)))
  20387. @end lisp
  20388. The configuration of an already running Varnish instance can be inspected
  20389. and changed using the @command{varnishadm} program.
  20390. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  20391. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  20392. comprehensive documentation on Varnish and its configuration language.
  20393. @item @code{listen} (default: @code{'("localhost:80")})
  20394. List of addresses Varnish will listen on.
  20395. @item @code{storage} (default: @code{'("malloc,128m")})
  20396. List of storage backends that will be available in VCL.
  20397. @item @code{parameters} (default: @code{'()})
  20398. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  20399. @item @code{extra-options} (default: @code{'()})
  20400. Additional arguments to pass to the @command{varnishd} process.
  20401. @end table
  20402. @end deftp
  20403. @subsubheading Patchwork
  20404. @cindex Patchwork
  20405. Patchwork is a patch tracking system. It can collect patches sent to a
  20406. mailing list, and display them in a web interface.
  20407. @defvr {Scheme Variable} patchwork-service-type
  20408. Service type for Patchwork.
  20409. @end defvr
  20410. The following example is an example of a minimal service for Patchwork, for
  20411. the @code{patchwork.example.com} domain.
  20412. @lisp
  20413. (service patchwork-service-type
  20414. (patchwork-configuration
  20415. (domain "patchwork.example.com")
  20416. (settings-module
  20417. (patchwork-settings-module
  20418. (allowed-hosts (list domain))
  20419. (default-from-email "patchwork@@patchwork.example.com")))
  20420. (getmail-retriever-config
  20421. (getmail-retriever-configuration
  20422. (type "SimpleIMAPSSLRetriever")
  20423. (server "imap.example.com")
  20424. (port 993)
  20425. (username "patchwork")
  20426. (password-command
  20427. (list (file-append coreutils "/bin/cat")
  20428. "/etc/getmail-patchwork-imap-password"))
  20429. (extra-parameters
  20430. '((mailboxes . ("Patches"))))))))
  20431. @end lisp
  20432. There are three records for configuring the Patchwork service. The
  20433. @code{<patchwork-configuration>} relates to the configuration for Patchwork
  20434. within the HTTPD service.
  20435. The @code{settings-module} field within the @code{<patchwork-configuration>}
  20436. record can be populated with the @code{<patchwork-settings-module>} record,
  20437. which describes a settings module that is generated within the Guix store.
  20438. For the @code{database-configuration} field within the
  20439. @code{<patchwork-settings-module>}, the
  20440. @code{<patchwork-database-configuration>} must be used.
  20441. @deftp {Data Type} patchwork-configuration
  20442. Data type representing the Patchwork service configuration. This type has the
  20443. following parameters:
  20444. @table @asis
  20445. @item @code{patchwork} (default: @code{patchwork})
  20446. The Patchwork package to use.
  20447. @item @code{domain}
  20448. The domain to use for Patchwork, this is used in the HTTPD service virtual
  20449. host.
  20450. @item @code{settings-module}
  20451. The settings module to use for Patchwork. As a Django application, Patchwork
  20452. is configured with a Python module containing the settings. This can either be
  20453. an instance of the @code{<patchwork-settings-module>} record, any other record
  20454. that represents the settings in the store, or a directory outside of the
  20455. store.
  20456. @item @code{static-path} (default: @code{"/static/"})
  20457. The path under which the HTTPD service should serve the static files.
  20458. @item @code{getmail-retriever-config}
  20459. The getmail-retriever-configuration record value to use with
  20460. Patchwork. Getmail will be configured with this value, the messages will be
  20461. delivered to Patchwork.
  20462. @end table
  20463. @end deftp
  20464. @deftp {Data Type} patchwork-settings-module
  20465. Data type representing a settings module for Patchwork. Some of these
  20466. settings relate directly to Patchwork, but others relate to Django, the web
  20467. framework used by Patchwork, or the Django Rest Framework library. This type
  20468. has the following parameters:
  20469. @table @asis
  20470. @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
  20471. The database connection settings used for Patchwork. See the
  20472. @code{<patchwork-database-configuration>} record type for more information.
  20473. @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
  20474. Patchwork, as a Django web application uses a secret key for cryptographically
  20475. signing values. This file should contain a unique unpredictable value.
  20476. If this file does not exist, it will be created and populated with a random
  20477. value by the patchwork-setup shepherd service.
  20478. This setting relates to Django.
  20479. @item @code{allowed-hosts}
  20480. A list of valid hosts for this Patchwork service. This should at least include
  20481. the domain specified in the @code{<patchwork-configuration>} record.
  20482. This is a Django setting.
  20483. @item @code{default-from-email}
  20484. The email address from which Patchwork should send email by default.
  20485. This is a Patchwork setting.
  20486. @item @code{static-url} (default: @code{#f})
  20487. The URL to use when serving static assets. It can be part of a URL, or a full
  20488. URL, but must end in a @code{/}.
  20489. If the default value is used, the @code{static-path} value from the
  20490. @code{<patchwork-configuration>} record will be used.
  20491. This is a Django setting.
  20492. @item @code{admins} (default: @code{'()})
  20493. Email addresses to send the details of errors that occur. Each value should
  20494. be a list containing two elements, the name and then the email address.
  20495. This is a Django setting.
  20496. @item @code{debug?} (default: @code{#f})
  20497. Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
  20498. messages will be shown.
  20499. This is a Django setting.
  20500. @item @code{enable-rest-api?} (default: @code{#t})
  20501. Whether to enable the Patchwork REST API.
  20502. This is a Patchwork setting.
  20503. @item @code{enable-xmlrpc?} (default: @code{#t})
  20504. Whether to enable the XML RPC API.
  20505. This is a Patchwork setting.
  20506. @item @code{force-https-links?} (default: @code{#t})
  20507. Whether to use HTTPS links on Patchwork pages.
  20508. This is a Patchwork setting.
  20509. @item @code{extra-settings} (default: @code{""})
  20510. Extra code to place at the end of the Patchwork settings module.
  20511. @end table
  20512. @end deftp
  20513. @deftp {Data Type} patchwork-database-configuration
  20514. Data type representing the database configuration for Patchwork.
  20515. @table @asis
  20516. @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
  20517. The database engine to use.
  20518. @item @code{name} (default: @code{"patchwork"})
  20519. The name of the database to use.
  20520. @item @code{user} (default: @code{"httpd"})
  20521. The user to connect to the database as.
  20522. @item @code{password} (default: @code{""})
  20523. The password to use when connecting to the database.
  20524. @item @code{host} (default: @code{""})
  20525. The host to make the database connection to.
  20526. @item @code{port} (default: @code{""})
  20527. The port on which to connect to the database.
  20528. @end table
  20529. @end deftp
  20530. @subsubheading Mumi
  20531. @cindex Mumi, Debbugs Web interface
  20532. @cindex Debbugs, Mumi Web interface
  20533. @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
  20534. Web interface to the Debbugs bug tracker, by default for
  20535. @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
  20536. but it also fetches and indexes mail retrieved from Debbugs.
  20537. @defvr {Scheme Variable} mumi-service-type
  20538. This is the service type for Mumi.
  20539. @end defvr
  20540. @deftp {Data Type} mumi-configuration
  20541. Data type representing the Mumi service configuration. This type has the
  20542. following fields:
  20543. @table @asis
  20544. @item @code{mumi} (default: @code{mumi})
  20545. The Mumi package to use.
  20546. @item @code{mailer?} (default: @code{#true})
  20547. Whether to enable or disable the mailer component.
  20548. @item @code{mumi-configuration-sender}
  20549. The email address used as the sender for comments.
  20550. @item @code{mumi-configuration-smtp}
  20551. A URI to configure the SMTP settings for Mailutils. This could be
  20552. something like @code{sendmail:///path/to/bin/msmtp} or any other URI
  20553. supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
  20554. mailutils, GNU@tie{}Mailutils}.
  20555. @end table
  20556. @end deftp
  20557. @subsubheading FastCGI
  20558. @cindex fastcgi
  20559. @cindex fcgiwrap
  20560. FastCGI is an interface between the front-end and the back-end of a web
  20561. service. It is a somewhat legacy facility; new web services should
  20562. generally just talk HTTP between the front-end and the back-end.
  20563. However there are a number of back-end services such as PHP or the
  20564. optimized HTTP Git repository access that use FastCGI, so we have
  20565. support for it in Guix.
  20566. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  20567. dispatch some subset of its requests to the fastcgi backend, which
  20568. listens on a local TCP or UNIX socket. There is an intermediary
  20569. @code{fcgiwrap} program that sits between the actual backend process and
  20570. the web server. The front-end indicates which backend program to run,
  20571. passing that information to the @code{fcgiwrap} process.
  20572. @defvr {Scheme Variable} fcgiwrap-service-type
  20573. A service type for the @code{fcgiwrap} FastCGI proxy.
  20574. @end defvr
  20575. @deftp {Data Type} fcgiwrap-configuration
  20576. Data type representing the configuration of the @code{fcgiwrap} service.
  20577. This type has the following parameters:
  20578. @table @asis
  20579. @item @code{package} (default: @code{fcgiwrap})
  20580. The fcgiwrap package to use.
  20581. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  20582. The socket on which the @code{fcgiwrap} process should listen, as a
  20583. string. Valid @var{socket} values include
  20584. @code{unix:@var{/path/to/unix/socket}},
  20585. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  20586. @code{tcp6:[@var{ipv6_addr}]:port}.
  20587. @item @code{user} (default: @code{fcgiwrap})
  20588. @itemx @code{group} (default: @code{fcgiwrap})
  20589. The user and group names, as strings, under which to run the
  20590. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  20591. the user asks for the specific user or group names @code{fcgiwrap} that
  20592. the corresponding user and/or group is present on the system.
  20593. It is possible to configure a FastCGI-backed web service to pass HTTP
  20594. authentication information from the front-end to the back-end, and to
  20595. allow @code{fcgiwrap} to run the back-end process as a corresponding
  20596. local user. To enable this capability on the back-end, run
  20597. @code{fcgiwrap} as the @code{root} user and group. Note that this
  20598. capability also has to be configured on the front-end as well.
  20599. @end table
  20600. @end deftp
  20601. @cindex php-fpm
  20602. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  20603. with some additional features useful for sites of any size.
  20604. These features include:
  20605. @itemize @bullet
  20606. @item Adaptive process spawning
  20607. @item Basic statistics (similar to Apache's mod_status)
  20608. @item Advanced process management with graceful stop/start
  20609. @item Ability to start workers with different uid/gid/chroot/environment
  20610. and different php.ini (replaces safe_mode)
  20611. @item Stdout & stderr logging
  20612. @item Emergency restart in case of accidental opcode cache destruction
  20613. @item Accelerated upload support
  20614. @item Support for a "slowlog"
  20615. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  20616. a special function to finish request & flush all data while continuing to do
  20617. something time-consuming (video converting, stats processing, etc.)
  20618. @end itemize
  20619. ...@: and much more.
  20620. @defvr {Scheme Variable} php-fpm-service-type
  20621. A Service type for @code{php-fpm}.
  20622. @end defvr
  20623. @deftp {Data Type} php-fpm-configuration
  20624. Data Type for php-fpm service configuration.
  20625. @table @asis
  20626. @item @code{php} (default: @code{php})
  20627. The php package to use.
  20628. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  20629. The address on which to accept FastCGI requests. Valid syntaxes are:
  20630. @table @asis
  20631. @item @code{"ip.add.re.ss:port"}
  20632. Listen on a TCP socket to a specific address on a specific port.
  20633. @item @code{"port"}
  20634. Listen on a TCP socket to all addresses on a specific port.
  20635. @item @code{"/path/to/unix/socket"}
  20636. Listen on a unix socket.
  20637. @end table
  20638. @item @code{user} (default: @code{php-fpm})
  20639. User who will own the php worker processes.
  20640. @item @code{group} (default: @code{php-fpm})
  20641. Group of the worker processes.
  20642. @item @code{socket-user} (default: @code{php-fpm})
  20643. User who can speak to the php-fpm socket.
  20644. @item @code{socket-group} (default: @code{nginx})
  20645. Group that can speak to the php-fpm socket.
  20646. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  20647. The process id of the php-fpm process is written to this file
  20648. once the service has started.
  20649. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  20650. Log for the php-fpm master process.
  20651. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  20652. Detailed settings for the php-fpm process manager.
  20653. Must be one of:
  20654. @table @asis
  20655. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  20656. @item @code{<php-fpm-static-process-manager-configuration>}
  20657. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  20658. @end table
  20659. @item @code{display-errors} (default @code{#f})
  20660. Determines whether php errors and warning should be sent to clients
  20661. and displayed in their browsers.
  20662. This is useful for local php development, but a security risk for public sites,
  20663. as error messages can reveal passwords and personal data.
  20664. @item @code{timezone} (default @code{#f})
  20665. Specifies @code{php_admin_value[date.timezone]} parameter.
  20666. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  20667. This file will log the @code{stderr} outputs of php worker processes.
  20668. Can be set to @code{#f} to disable logging.
  20669. @item @code{file} (default @code{#f})
  20670. An optional override of the whole configuration.
  20671. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  20672. @item @code{php-ini-file} (default @code{#f})
  20673. An optional override of the default php settings.
  20674. It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
  20675. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  20676. For local development it is useful to set a higher timeout and memory
  20677. limit for spawned php processes. This be accomplished with the
  20678. following operating system configuration snippet:
  20679. @lisp
  20680. (define %local-php-ini
  20681. (plain-file "php.ini"
  20682. "memory_limit = 2G
  20683. max_execution_time = 1800"))
  20684. (operating-system
  20685. ;; @dots{}
  20686. (services (cons (service php-fpm-service-type
  20687. (php-fpm-configuration
  20688. (php-ini-file %local-php-ini)))
  20689. %base-services)))
  20690. @end lisp
  20691. Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
  20692. directives} for comprehensive documentation on the acceptable
  20693. @file{php.ini} directives.
  20694. @end table
  20695. @end deftp
  20696. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  20697. Data Type for the @code{dynamic} php-fpm process manager. With the
  20698. @code{dynamic} process manager, spare worker processes are kept around
  20699. based on its configured limits.
  20700. @table @asis
  20701. @item @code{max-children} (default: @code{5})
  20702. Maximum of worker processes.
  20703. @item @code{start-servers} (default: @code{2})
  20704. How many worker processes should be started on start-up.
  20705. @item @code{min-spare-servers} (default: @code{1})
  20706. How many spare worker processes should be kept around at minimum.
  20707. @item @code{max-spare-servers} (default: @code{3})
  20708. How many spare worker processes should be kept around at maximum.
  20709. @end table
  20710. @end deftp
  20711. @deftp {Data type} php-fpm-static-process-manager-configuration
  20712. Data Type for the @code{static} php-fpm process manager. With the
  20713. @code{static} process manager, an unchanging number of worker processes
  20714. are created.
  20715. @table @asis
  20716. @item @code{max-children} (default: @code{5})
  20717. Maximum of worker processes.
  20718. @end table
  20719. @end deftp
  20720. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  20721. Data Type for the @code{on-demand} php-fpm process manager. With the
  20722. @code{on-demand} process manager, worker processes are only created as
  20723. requests arrive.
  20724. @table @asis
  20725. @item @code{max-children} (default: @code{5})
  20726. Maximum of worker processes.
  20727. @item @code{process-idle-timeout} (default: @code{10})
  20728. The time in seconds after which a process with no requests is killed.
  20729. @end table
  20730. @end deftp
  20731. @deffn {Scheme Procedure} nginx-php-location @
  20732. [#:nginx-package nginx] @
  20733. [socket (string-append "/var/run/php" @
  20734. (version-major (package-version php)) @
  20735. "-fpm.sock")]
  20736. A helper function to quickly add php to an @code{nginx-server-configuration}.
  20737. @end deffn
  20738. A simple services setup for nginx with php can look like this:
  20739. @lisp
  20740. (services (cons* (service dhcp-client-service-type)
  20741. (service php-fpm-service-type)
  20742. (service nginx-service-type
  20743. (nginx-server-configuration
  20744. (server-name '("example.com"))
  20745. (root "/srv/http/")
  20746. (locations
  20747. (list (nginx-php-location)))
  20748. (listen '("80"))
  20749. (ssl-certificate #f)
  20750. (ssl-certificate-key #f)))
  20751. %base-services))
  20752. @end lisp
  20753. @cindex cat-avatar-generator
  20754. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  20755. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  20756. the hash of a user's email address.
  20757. @deffn {Scheme Procedure} cat-avatar-generator-service @
  20758. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  20759. [#:package cat-avatar-generator] @
  20760. [#:configuration (nginx-server-configuration)]
  20761. Returns an nginx-server-configuration that inherits @code{configuration}. It
  20762. extends the nginx configuration to add a server block that serves @code{package},
  20763. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  20764. be able to use @code{cache-dir} as its cache directory.
  20765. @end deffn
  20766. A simple setup for cat-avatar-generator can look like this:
  20767. @lisp
  20768. (services (cons* (cat-avatar-generator-service
  20769. #:configuration
  20770. (nginx-server-configuration
  20771. (server-name '("example.com"))))
  20772. ...
  20773. %base-services))
  20774. @end lisp
  20775. @subsubheading Hpcguix-web
  20776. @cindex hpcguix-web
  20777. The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
  20778. program is a customizable web interface to browse Guix packages,
  20779. initially designed for users of high-performance computing (HPC)
  20780. clusters.
  20781. @defvr {Scheme Variable} hpcguix-web-service-type
  20782. The service type for @code{hpcguix-web}.
  20783. @end defvr
  20784. @deftp {Data Type} hpcguix-web-configuration
  20785. Data type for the hpcguix-web service configuration.
  20786. @table @asis
  20787. @item @code{specs}
  20788. A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
  20789. configuration. The main items available in this spec are:
  20790. @table @asis
  20791. @item @code{title-prefix} (default: @code{"hpcguix | "})
  20792. The page title prefix.
  20793. @item @code{guix-command} (default: @code{"guix"})
  20794. The @command{guix} command.
  20795. @item @code{package-filter-proc} (default: @code{(const #t)})
  20796. A procedure specifying how to filter packages that are displayed.
  20797. @item @code{package-page-extension-proc} (default: @code{(const '())})
  20798. Extension package for @code{hpcguix-web}.
  20799. @item @code{menu} (default: @code{'()})
  20800. Additional entry in page @code{menu}.
  20801. @item @code{channels} (default: @code{%default-channels})
  20802. List of channels from which the package list is built (@pxref{Channels}).
  20803. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  20804. The expiration time, in seconds, after which the package list is rebuilt from
  20805. the latest instances of the given channels.
  20806. @end table
  20807. See the hpcguix-web repository for a
  20808. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  20809. complete example}.
  20810. @item @code{package} (default: @code{hpcguix-web})
  20811. The hpcguix-web package to use.
  20812. @end table
  20813. @end deftp
  20814. A typical hpcguix-web service declaration looks like this:
  20815. @lisp
  20816. (service hpcguix-web-service-type
  20817. (hpcguix-web-configuration
  20818. (specs
  20819. #~(define site-config
  20820. (hpcweb-configuration
  20821. (title-prefix "Guix-HPC - ")
  20822. (menu '(("/about" "ABOUT"))))))))
  20823. @end lisp
  20824. @quotation Note
  20825. The hpcguix-web service periodically updates the package list it publishes by
  20826. pulling channels from Git. To that end, it needs to access X.509 certificates
  20827. so that it can authenticate Git servers when communicating over HTTPS, and it
  20828. assumes that @file{/etc/ssl/certs} contains those certificates.
  20829. Thus, make sure to add @code{nss-certs} or another certificate package to the
  20830. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  20831. more information on X.509 certificates.
  20832. @end quotation
  20833. @subsubheading gmnisrv
  20834. @cindex gmnisrv
  20835. The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
  20836. simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
  20837. @deffn {Scheme Variable} gmnisrv-service-type
  20838. This is the type of the gmnisrv service, whose value should be a
  20839. @code{gmnisrv-configuration} object, as in this example:
  20840. @lisp
  20841. (service gmnisrv-service-type
  20842. (gmnisrv-configuration
  20843. (config-file (local-file "./my-gmnisrv.ini"))))
  20844. @end lisp
  20845. @end deffn
  20846. @deftp {Data Type} gmnisrv-configuration
  20847. Data type representing the configuration of gmnisrv.
  20848. @table @asis
  20849. @item @code{package} (default: @var{gmnisrv})
  20850. Package object of the gmnisrv server.
  20851. @item @code{config-file} (default: @code{%default-gmnisrv-config-file})
  20852. File-like object of the gmnisrv configuration file to use. The default
  20853. configuration listens on port 1965 and serves files from
  20854. @file{/srv/gemini}. Certificates are stored in
  20855. @file{/var/lib/gemini/certs}. For more information, run @command{man
  20856. gmnisrv} and @command{man gmnisrv.ini}.
  20857. @end table
  20858. @end deftp
  20859. @subsubheading Agate
  20860. @cindex agate
  20861. The @uref{gemini://qwertqwefsday.eu/agate.gmi, Agate}
  20862. (@uref{https://github.com/mbrubeck/agate, GitHub page over HTTPS})
  20863. program is a simple @uref{https://gemini.circumlunar.space/, Gemini}
  20864. protocol server written in Rust.
  20865. @deffn {Scheme Variable} agate-service-type
  20866. This is the type of the agate service, whose value should be an
  20867. @code{agate-service-type} object, as in this example:
  20868. @lisp
  20869. (service agate-service-type
  20870. (agate-configuration
  20871. (content "/srv/gemini")
  20872. (cert "/srv/cert.pem")
  20873. (key "/srv/key.rsa")))
  20874. @end lisp
  20875. The example above represents the minimal tweaking necessary to get Agate
  20876. up and running. Specifying the path to the certificate and key is
  20877. always necessary, as the Gemini protocol requires TLS by default.
  20878. To obtain a certificate and a key, you could, for example, use OpenSSL,
  20879. running a command similar to the following example:
  20880. @example
  20881. openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
  20882. -days 3650 -nodes -subj "/CN=example.com"
  20883. @end example
  20884. Of course, you'll have to replace @i{example.com} with your own domain
  20885. name, and then point the Agate configuration towards the path of the
  20886. generated key and certificate.
  20887. @end deffn
  20888. @deftp {Data Type} agate-configuration
  20889. Data type representing the configuration of Agate.
  20890. @table @asis
  20891. @item @code{package} (default: @code{agate})
  20892. The package object of the Agate server.
  20893. @item @code{content} (default: @file{"/srv/gemini"})
  20894. The directory from which Agate will serve files.
  20895. @item @code{cert} (default: @code{#f})
  20896. The path to the TLS certificate PEM file to be used for encrypted
  20897. connections. Must be filled in with a value from the user.
  20898. @item @code{key} (default: @code{#f})
  20899. The path to the PKCS8 private key file to be used for encrypted
  20900. connections. Must be filled in with a value from the user.
  20901. @item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
  20902. A list of the addresses to listen on.
  20903. @item @code{hostname} (default: @code{#f})
  20904. The domain name of this Gemini server. Optional.
  20905. @item @code{lang} (default: @code{#f})
  20906. RFC 4646 language code(s) for text/gemini documents. Optional.
  20907. @item @code{silent?} (default: @code{#f})
  20908. Set to @code{#t} to disable logging output.
  20909. @item @code{serve-secret?} (default: @code{#f})
  20910. Set to @code{#t} to serve secret files (files/directories starting with
  20911. a dot).
  20912. @item @code{log-ip?} (default: @code{#t})
  20913. Whether or not to output IP addresses when logging.
  20914. @item @code{user} (default: @code{"agate"})
  20915. Owner of the @code{agate} process.
  20916. @item @code{group} (default: @code{"agate"})
  20917. Owner's group of the @code{agate} process.
  20918. @item @code{log-file} (default: @file{"/var/log/agate.log"})
  20919. The file which should store the logging output of Agate.
  20920. @end table
  20921. @end deftp
  20922. @node Certificate Services
  20923. @subsection Certificate Services
  20924. @cindex Web
  20925. @cindex HTTP, HTTPS
  20926. @cindex Let's Encrypt
  20927. @cindex TLS certificates
  20928. The @code{(gnu services certbot)} module provides a service to
  20929. automatically obtain a valid TLS certificate from the Let's Encrypt
  20930. certificate authority. These certificates can then be used to serve
  20931. content securely over HTTPS or other TLS-based protocols, with the
  20932. knowledge that the client will be able to verify the server's
  20933. authenticity.
  20934. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  20935. @code{certbot} tool to automate the certification process. This tool
  20936. first securely generates a key on the server. It then makes a request
  20937. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  20938. checks that the request originates from the host in question by using a
  20939. challenge-response protocol, requiring the server to provide its
  20940. response over HTTP@. If that protocol completes successfully, the CA
  20941. signs the key, resulting in a certificate. That certificate is valid
  20942. for a limited period of time, and therefore to continue to provide TLS
  20943. services, the server needs to periodically ask the CA to renew its
  20944. signature.
  20945. The certbot service automates this process: the initial key
  20946. generation, the initial certification request to the Let's Encrypt
  20947. service, the web server challenge/response integration, writing the
  20948. certificate to disk, the automated periodic renewals, and the deployment
  20949. tasks associated with the renewal (e.g.@: reloading services, copying keys
  20950. with different permissions).
  20951. Certbot is run twice a day, at a random minute within the hour. It
  20952. won't do anything until your certificates are due for renewal or
  20953. revoked, but running it regularly would give your service a chance of
  20954. staying online in case a Let's Encrypt-initiated revocation happened for
  20955. some reason.
  20956. By using this service, you agree to the ACME Subscriber Agreement, which
  20957. can be found there:
  20958. @url{https://acme-v01.api.letsencrypt.org/directory}.
  20959. @defvr {Scheme Variable} certbot-service-type
  20960. A service type for the @code{certbot} Let's Encrypt client. Its value
  20961. must be a @code{certbot-configuration} record as in this example:
  20962. @lisp
  20963. (define %nginx-deploy-hook
  20964. (program-file
  20965. "nginx-deploy-hook"
  20966. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  20967. (kill pid SIGHUP))))
  20968. (service certbot-service-type
  20969. (certbot-configuration
  20970. (email "foo@@example.net")
  20971. (certificates
  20972. (list
  20973. (certificate-configuration
  20974. (domains '("example.net" "www.example.net"))
  20975. (deploy-hook %nginx-deploy-hook))
  20976. (certificate-configuration
  20977. (domains '("bar.example.net")))))))
  20978. @end lisp
  20979. See below for details about @code{certbot-configuration}.
  20980. @end defvr
  20981. @deftp {Data Type} certbot-configuration
  20982. Data type representing the configuration of the @code{certbot} service.
  20983. This type has the following parameters:
  20984. @table @asis
  20985. @item @code{package} (default: @code{certbot})
  20986. The certbot package to use.
  20987. @item @code{webroot} (default: @code{/var/www})
  20988. The directory from which to serve the Let's Encrypt challenge/response
  20989. files.
  20990. @item @code{certificates} (default: @code{()})
  20991. A list of @code{certificates-configuration}s for which to generate
  20992. certificates and request signatures. Each certificate has a @code{name}
  20993. and several @code{domains}.
  20994. @item @code{email} (default: @code{#f})
  20995. Optional email address used for registration and recovery contact.
  20996. Setting this is encouraged as it allows you to receive important
  20997. notifications about the account and issued certificates.
  20998. @item @code{server} (default: @code{#f})
  20999. Optional URL of ACME server. Setting this overrides certbot's default,
  21000. which is the Let's Encrypt server.
  21001. @item @code{rsa-key-size} (default: @code{2048})
  21002. Size of the RSA key.
  21003. @item @code{default-location} (default: @i{see below})
  21004. The default @code{nginx-location-configuration}. Because @code{certbot}
  21005. needs to be able to serve challenges and responses, it needs to be able
  21006. to run a web server. It does so by extending the @code{nginx} web
  21007. service with an @code{nginx-server-configuration} listening on the
  21008. @var{domains} on port 80, and which has a
  21009. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  21010. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  21011. these nginx configuration data types.
  21012. Requests to other URL paths will be matched by the
  21013. @code{default-location}, which if present is added to all
  21014. @code{nginx-server-configuration}s.
  21015. By default, the @code{default-location} will issue a redirect from
  21016. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  21017. you to define what to serve on your site via @code{https}.
  21018. Pass @code{#f} to not issue a default location.
  21019. @end table
  21020. @end deftp
  21021. @deftp {Data Type} certificate-configuration
  21022. Data type representing the configuration of a certificate.
  21023. This type has the following parameters:
  21024. @table @asis
  21025. @item @code{name} (default: @i{see below})
  21026. This name is used by Certbot for housekeeping and in file paths; it
  21027. doesn't affect the content of the certificate itself. To see
  21028. certificate names, run @code{certbot certificates}.
  21029. Its default is the first provided domain.
  21030. @item @code{domains} (default: @code{()})
  21031. The first domain provided will be the subject CN of the certificate, and
  21032. all domains will be Subject Alternative Names on the certificate.
  21033. @item @code{challenge} (default: @code{#f})
  21034. The challenge type that has to be run by certbot. If @code{#f} is specified,
  21035. default to the HTTP challenge. If a value is specified, defaults to the
  21036. manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
  21037. the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
  21038. and gives Let's Encrypt permission to log the public IP address of the
  21039. requesting machine.
  21040. @item @code{csr} (default: @code{#f})
  21041. File name of Certificate Signing Request (CSR) in DER or PEM format.
  21042. If @code{#f} is specified, this argument will not be passed to certbot.
  21043. If a value is specified, certbot will use it to obtain a certificate, instead of
  21044. using a self-generated CSR.
  21045. The domain-name(s) mentioned in @code{domains}, must be consistent with the
  21046. domain-name(s) mentioned in CSR file.
  21047. @item @code{authentication-hook} (default: @code{#f})
  21048. Command to be run in a shell once for each certificate challenge to be
  21049. answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
  21050. will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
  21051. contains the validation string and @code{$CERTBOT_TOKEN} contains the
  21052. file name of the resource requested when performing an HTTP-01 challenge.
  21053. @item @code{cleanup-hook} (default: @code{#f})
  21054. Command to be run in a shell once for each certificate challenge that
  21055. have been answered by the @code{auth-hook}. For this command, the shell
  21056. variables available in the @code{auth-hook} script are still available, and
  21057. additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
  21058. of the @code{auth-hook} script.
  21059. @item @code{deploy-hook} (default: @code{#f})
  21060. Command to be run in a shell once for each successfully issued
  21061. certificate. For this command, the shell variable
  21062. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  21063. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  21064. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  21065. contain a space-delimited list of renewed certificate domains (for
  21066. example, @samp{"example.com www.example.com"}.
  21067. @end table
  21068. @end deftp
  21069. For each @code{certificate-configuration}, the certificate is saved to
  21070. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  21071. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  21072. @node DNS Services
  21073. @subsection DNS Services
  21074. @cindex DNS (domain name system)
  21075. @cindex domain name system (DNS)
  21076. The @code{(gnu services dns)} module provides services related to the
  21077. @dfn{domain name system} (DNS). It provides a server service for hosting
  21078. an @emph{authoritative} DNS server for multiple zones, slave or master.
  21079. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  21080. caching and forwarding DNS server for the LAN, which uses
  21081. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  21082. @subsubheading Knot Service
  21083. An example configuration of an authoritative server for two zones, one master
  21084. and one slave, is:
  21085. @lisp
  21086. (define-zone-entries example.org.zone
  21087. ;; Name TTL Class Type Data
  21088. ("@@" "" "IN" "A" "127.0.0.1")
  21089. ("@@" "" "IN" "NS" "ns")
  21090. ("ns" "" "IN" "A" "127.0.0.1"))
  21091. (define master-zone
  21092. (knot-zone-configuration
  21093. (domain "example.org")
  21094. (zone (zone-file
  21095. (origin "example.org")
  21096. (entries example.org.zone)))))
  21097. (define slave-zone
  21098. (knot-zone-configuration
  21099. (domain "plop.org")
  21100. (dnssec-policy "default")
  21101. (master (list "plop-master"))))
  21102. (define plop-master
  21103. (knot-remote-configuration
  21104. (id "plop-master")
  21105. (address (list "208.76.58.171"))))
  21106. (operating-system
  21107. ;; ...
  21108. (services (cons* (service knot-service-type
  21109. (knot-configuration
  21110. (remotes (list plop-master))
  21111. (zones (list master-zone slave-zone))))
  21112. ;; ...
  21113. %base-services)))
  21114. @end lisp
  21115. @deffn {Scheme Variable} knot-service-type
  21116. This is the type for the Knot DNS server.
  21117. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  21118. zones, that is to say domain names you would buy from a registrar. This server
  21119. is not a resolver, meaning that it can only resolve names for which it is
  21120. authoritative. This server can be configured to serve zones as a master server
  21121. or a slave server as a per-zone basis. Slave zones will get their data from
  21122. masters, and will serve it as an authoritative server. From the point of view
  21123. of a resolver, there is no difference between master and slave.
  21124. The following data types are used to configure the Knot DNS server:
  21125. @end deffn
  21126. @deftp {Data Type} knot-key-configuration
  21127. Data type representing a key.
  21128. This type has the following parameters:
  21129. @table @asis
  21130. @item @code{id} (default: @code{""})
  21131. An identifier for other configuration fields to refer to this key. IDs must
  21132. be unique and must not be empty.
  21133. @item @code{algorithm} (default: @code{#f})
  21134. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  21135. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  21136. and @code{'hmac-sha512}.
  21137. @item @code{secret} (default: @code{""})
  21138. The secret key itself.
  21139. @end table
  21140. @end deftp
  21141. @deftp {Data Type} knot-acl-configuration
  21142. Data type representing an Access Control List (ACL) configuration.
  21143. This type has the following parameters:
  21144. @table @asis
  21145. @item @code{id} (default: @code{""})
  21146. An identifier for other configuration fields to refer to this key. IDs must be
  21147. unique and must not be empty.
  21148. @item @code{address} (default: @code{'()})
  21149. An ordered list of IP addresses, network subnets, or network ranges represented
  21150. with strings. The query must match one of them. Empty value means that
  21151. address match is not required.
  21152. @item @code{key} (default: @code{'()})
  21153. An ordered list of references to keys represented with strings. The string
  21154. must match a key ID defined in a @code{knot-key-configuration}. No key means
  21155. that a key is not require to match that ACL.
  21156. @item @code{action} (default: @code{'()})
  21157. An ordered list of actions that are permitted or forbidden by this ACL@. Possible
  21158. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  21159. and @code{'update}.
  21160. @item @code{deny?} (default: @code{#f})
  21161. When true, the ACL defines restrictions. Listed actions are forbidden. When
  21162. false, listed actions are allowed.
  21163. @end table
  21164. @end deftp
  21165. @deftp {Data Type} zone-entry
  21166. Data type representing a record entry in a zone file.
  21167. This type has the following parameters:
  21168. @table @asis
  21169. @item @code{name} (default: @code{"@@"})
  21170. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  21171. are relative to the origin of the zone. For example, in the @code{example.org}
  21172. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  21173. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  21174. refers to @code{ns.example.org}.
  21175. @item @code{ttl} (default: @code{""})
  21176. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  21177. @item @code{class} (default: @code{"IN"})
  21178. The class of the record. Knot currently supports only @code{"IN"} and
  21179. partially @code{"CH"}.
  21180. @item @code{type} (default: @code{"A"})
  21181. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  21182. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  21183. defined.
  21184. @item @code{data} (default: @code{""})
  21185. The data contained in the record. For instance an IP address associated with
  21186. an A record, or a domain name associated with an NS record. Remember that
  21187. domain names are relative to the origin unless they end with a dot.
  21188. @end table
  21189. @end deftp
  21190. @deftp {Data Type} zone-file
  21191. Data type representing the content of a zone file.
  21192. This type has the following parameters:
  21193. @table @asis
  21194. @item @code{entries} (default: @code{'()})
  21195. The list of entries. The SOA record is taken care of, so you don't need to
  21196. put it in the list of entries. This list should probably contain an entry
  21197. for your primary authoritative DNS server. Other than using a list of entries
  21198. directly, you can use @code{define-zone-entries} to define a object containing
  21199. the list of entries more easily, that you can later pass to the @code{entries}
  21200. field of the @code{zone-file}.
  21201. @item @code{origin} (default: @code{""})
  21202. The name of your zone. This parameter cannot be empty.
  21203. @item @code{ns} (default: @code{"ns"})
  21204. The domain of your primary authoritative DNS server. The name is relative to
  21205. the origin, unless it ends with a dot. It is mandatory that this primary
  21206. DNS server corresponds to an NS record in the zone and that it is associated
  21207. to an IP address in the list of entries.
  21208. @item @code{mail} (default: @code{"hostmaster"})
  21209. An email address people can contact you at, as the owner of the zone. This
  21210. is translated as @code{<mail>@@<origin>}.
  21211. @item @code{serial} (default: @code{1})
  21212. The serial number of the zone. As this is used to keep track of changes by
  21213. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  21214. Always increment it when you make a change in your zone.
  21215. @item @code{refresh} (default: @code{(* 2 24 3600)})
  21216. The frequency at which slaves will do a zone transfer. This value is a number
  21217. of seconds. It can be computed by multiplications or with
  21218. @code{(string->duration)}.
  21219. @item @code{retry} (default: @code{(* 15 60)})
  21220. The period after which a slave will retry to contact its master when it fails
  21221. to do so a first time.
  21222. @item @code{expiry} (default: @code{(* 14 24 3600)})
  21223. Default TTL of records. Existing records are considered correct for at most
  21224. this amount of time. After this period, resolvers will invalidate their cache
  21225. and check again that it still exists.
  21226. @item @code{nx} (default: @code{3600})
  21227. Default TTL of inexistent records. This delay is usually short because you want
  21228. your new domains to reach everyone quickly.
  21229. @end table
  21230. @end deftp
  21231. @deftp {Data Type} knot-remote-configuration
  21232. Data type representing a remote configuration.
  21233. This type has the following parameters:
  21234. @table @asis
  21235. @item @code{id} (default: @code{""})
  21236. An identifier for other configuration fields to refer to this remote. IDs must
  21237. be unique and must not be empty.
  21238. @item @code{address} (default: @code{'()})
  21239. An ordered list of destination IP addresses. Addresses are tried in sequence.
  21240. An optional port can be given with the @@ separator. For instance:
  21241. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  21242. @item @code{via} (default: @code{'()})
  21243. An ordered list of source IP addresses. An empty list will have Knot choose
  21244. an appropriate source IP@. An optional port can be given with the @@ separator.
  21245. The default is to choose at random.
  21246. @item @code{key} (default: @code{#f})
  21247. A reference to a key, that is a string containing the identifier of a key
  21248. defined in a @code{knot-key-configuration} field.
  21249. @end table
  21250. @end deftp
  21251. @deftp {Data Type} knot-keystore-configuration
  21252. Data type representing a keystore to hold dnssec keys.
  21253. This type has the following parameters:
  21254. @table @asis
  21255. @item @code{id} (default: @code{""})
  21256. The id of the keystore. It must not be empty.
  21257. @item @code{backend} (default: @code{'pem})
  21258. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  21259. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  21260. The configuration string of the backend. An example for the PKCS#11 is:
  21261. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  21262. For the pem backend, the string represents a path in the file system.
  21263. @end table
  21264. @end deftp
  21265. @deftp {Data Type} knot-policy-configuration
  21266. Data type representing a dnssec policy. Knot DNS is able to automatically
  21267. sign your zones. It can either generate and manage your keys automatically or
  21268. use keys that you generate.
  21269. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  21270. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  21271. zone. In order to be trusted, the KSK needs to be present in the parent zone
  21272. (usually a top-level domain). If your registrar supports dnssec, you will
  21273. have to send them your KSK's hash so they can add a DS record in their zone.
  21274. This is not automated and need to be done each time you change your KSK.
  21275. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  21276. easily and use weaker cryptographic functions (they use lower parameters) in
  21277. order to sign records quickly, so they are changed often. The KSK however
  21278. requires manual interaction with the registrar, so they are changed less often
  21279. and use stronger parameters because they sign only one record.
  21280. This type has the following parameters:
  21281. @table @asis
  21282. @item @code{id} (default: @code{""})
  21283. The id of the policy. It must not be empty.
  21284. @item @code{keystore} (default: @code{"default"})
  21285. A reference to a keystore, that is a string containing the identifier of a
  21286. keystore defined in a @code{knot-keystore-configuration} field. The
  21287. @code{"default"} identifier means the default keystore (a kasp database that
  21288. was setup by this service).
  21289. @item @code{manual?} (default: @code{#f})
  21290. Whether the key management is manual or automatic.
  21291. @item @code{single-type-signing?} (default: @code{#f})
  21292. When @code{#t}, use the Single-Type Signing Scheme.
  21293. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  21294. An algorithm of signing keys and issued signatures.
  21295. @item @code{ksk-size} (default: @code{256})
  21296. The length of the KSK@. Note that this value is correct for the default
  21297. algorithm, but would be unsecure for other algorithms.
  21298. @item @code{zsk-size} (default: @code{256})
  21299. The length of the ZSK@. Note that this value is correct for the default
  21300. algorithm, but would be unsecure for other algorithms.
  21301. @item @code{dnskey-ttl} (default: @code{'default})
  21302. The TTL value for DNSKEY records added into zone apex. The special
  21303. @code{'default} value means same as the zone SOA TTL.
  21304. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  21305. The period between ZSK publication and the next rollover initiation.
  21306. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  21307. An extra delay added for each key rollover step. This value should be high
  21308. enough to cover propagation of data from the master server to all slaves.
  21309. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  21310. A validity period of newly issued signatures.
  21311. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  21312. A period how long before a signature expiration the signature will be refreshed.
  21313. @item @code{nsec3?} (default: @code{#f})
  21314. When @code{#t}, NSEC3 will be used instead of NSEC.
  21315. @item @code{nsec3-iterations} (default: @code{5})
  21316. The number of additional times the hashing is performed.
  21317. @item @code{nsec3-salt-length} (default: @code{8})
  21318. The length of a salt field in octets, which is appended to the original owner
  21319. name before hashing.
  21320. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  21321. The validity period of newly issued salt field.
  21322. @end table
  21323. @end deftp
  21324. @deftp {Data Type} knot-zone-configuration
  21325. Data type representing a zone served by Knot.
  21326. This type has the following parameters:
  21327. @table @asis
  21328. @item @code{domain} (default: @code{""})
  21329. The domain served by this configuration. It must not be empty.
  21330. @item @code{file} (default: @code{""})
  21331. The file where this zone is saved. This parameter is ignored by master zones.
  21332. Empty means default location that depends on the domain name.
  21333. @item @code{zone} (default: @code{(zone-file)})
  21334. The content of the zone file. This parameter is ignored by slave zones. It
  21335. must contain a zone-file record.
  21336. @item @code{master} (default: @code{'()})
  21337. A list of master remotes. When empty, this zone is a master. When set, this
  21338. zone is a slave. This is a list of remotes identifiers.
  21339. @item @code{ddns-master} (default: @code{#f})
  21340. The main master. When empty, it defaults to the first master in the list of
  21341. masters.
  21342. @item @code{notify} (default: @code{'()})
  21343. A list of slave remote identifiers.
  21344. @item @code{acl} (default: @code{'()})
  21345. A list of acl identifiers.
  21346. @item @code{semantic-checks?} (default: @code{#f})
  21347. When set, this adds more semantic checks to the zone.
  21348. @item @code{disable-any?} (default: @code{#f})
  21349. When set, this forbids queries of the ANY type.
  21350. @item @code{zonefile-sync} (default: @code{0})
  21351. The delay between a modification in memory and on disk. 0 means immediate
  21352. synchronization.
  21353. @item @code{zonefile-load} (default: @code{#f})
  21354. The way the zone file contents are applied during zone load. Possible values
  21355. are:
  21356. @itemize
  21357. @item @code{#f} for using the default value from Knot,
  21358. @item @code{'none} for not using the zone file at all,
  21359. @item @code{'difference} for computing the difference between already available
  21360. contents and zone contents and applying it to the current zone contents,
  21361. @item @code{'difference-no-serial} for the same as @code{'difference}, but
  21362. ignoring the SOA serial in the zone file, while the server takes care of it
  21363. automatically.
  21364. @item @code{'whole} for loading zone contents from the zone file.
  21365. @end itemize
  21366. @item @code{journal-content} (default: @code{#f})
  21367. The way the journal is used to store zone and its changes. Possible values
  21368. are @code{'none} to not use it at all, @code{'changes} to store changes and
  21369. @code{'all} to store contents. @code{#f} does not set this option, so the
  21370. default value from Knot is used.
  21371. @item @code{max-journal-usage} (default: @code{#f})
  21372. The maximum size for the journal on disk. @code{#f} does not set this option,
  21373. so the default value from Knot is used.
  21374. @item @code{max-journal-depth} (default: @code{#f})
  21375. The maximum size of the history. @code{#f} does not set this option, so the
  21376. default value from Knot is used.
  21377. @item @code{max-zone-size} (default: @code{#f})
  21378. The maximum size of the zone file. This limit is enforced for incoming
  21379. transfer and updates. @code{#f} does not set this option, so the default
  21380. value from Knot is used.
  21381. @item @code{dnssec-policy} (default: @code{#f})
  21382. A reference to a @code{knot-policy-configuration} record, or the special
  21383. name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
  21384. on this zone.
  21385. @item @code{serial-policy} (default: @code{'increment})
  21386. A policy between @code{'increment} and @code{'unixtime}.
  21387. @end table
  21388. @end deftp
  21389. @deftp {Data Type} knot-configuration
  21390. Data type representing the Knot configuration.
  21391. This type has the following parameters:
  21392. @table @asis
  21393. @item @code{knot} (default: @code{knot})
  21394. The Knot package.
  21395. @item @code{run-directory} (default: @code{"/var/run/knot"})
  21396. The run directory. This directory will be used for pid file and sockets.
  21397. @item @code{includes} (default: @code{'()})
  21398. A list of strings or file-like objects denoting other files that must be
  21399. included at the top of the configuration file.
  21400. @cindex secrets, Knot service
  21401. This can be used to manage secrets out-of-band. For example, secret
  21402. keys may be stored in an out-of-band file not managed by Guix, and
  21403. thus not visible in @file{/gnu/store}---e.g., you could store secret
  21404. key configuration in @file{/etc/knot/secrets.conf} and add this file
  21405. to the @code{includes} list.
  21406. One can generate a secret tsig key (for nsupdate and zone transfers with the
  21407. keymgr command from the knot package. Note that the package is not automatically
  21408. installed by the service. The following example shows how to generate a new
  21409. tsig key:
  21410. @example
  21411. keymgr -t mysecret > /etc/knot/secrets.conf
  21412. chmod 600 /etc/knot/secrets.conf
  21413. @end example
  21414. Also note that the generated key will be named @var{mysecret}, so it is the
  21415. name that needs to be used in the @var{key} field of the
  21416. @code{knot-acl-configuration} record and in other places that need to refer
  21417. to that key.
  21418. It can also be used to add configuration not supported by this interface.
  21419. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  21420. An ip address on which to listen.
  21421. @item @code{listen-v6} (default: @code{"::"})
  21422. An ip address on which to listen.
  21423. @item @code{listen-port} (default: @code{53})
  21424. A port on which to listen.
  21425. @item @code{keys} (default: @code{'()})
  21426. The list of knot-key-configuration used by this configuration.
  21427. @item @code{acls} (default: @code{'()})
  21428. The list of knot-acl-configuration used by this configuration.
  21429. @item @code{remotes} (default: @code{'()})
  21430. The list of knot-remote-configuration used by this configuration.
  21431. @item @code{zones} (default: @code{'()})
  21432. The list of knot-zone-configuration used by this configuration.
  21433. @end table
  21434. @end deftp
  21435. @subsubheading Knot Resolver Service
  21436. @deffn {Scheme Variable} knot-resolver-service-type
  21437. This is the type of the knot resolver service, whose value should be
  21438. an @code{knot-resolver-configuration} object as in this example:
  21439. @lisp
  21440. (service knot-resolver-service-type
  21441. (knot-resolver-configuration
  21442. (kresd-config-file (plain-file "kresd.conf" "
  21443. net.listen('192.168.0.1', 5353)
  21444. user('knot-resolver', 'knot-resolver')
  21445. modules = @{ 'hints > iterate', 'stats', 'predict' @}
  21446. cache.size = 100 * MB
  21447. "))))
  21448. @end lisp
  21449. For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
  21450. @end deffn
  21451. @deftp {Data Type} knot-resolver-configuration
  21452. Data type representing the configuration of knot-resolver.
  21453. @table @asis
  21454. @item @code{package} (default: @var{knot-resolver})
  21455. Package object of the knot DNS resolver.
  21456. @item @code{kresd-config-file} (default: %kresd.conf)
  21457. File-like object of the kresd configuration file to use, by default it
  21458. will listen on @code{127.0.0.1} and @code{::1}.
  21459. @item @code{garbage-collection-interval} (default: 1000)
  21460. Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
  21461. @end table
  21462. @end deftp
  21463. @subsubheading Dnsmasq Service
  21464. @deffn {Scheme Variable} dnsmasq-service-type
  21465. This is the type of the dnsmasq service, whose value should be an
  21466. @code{dnsmasq-configuration} object as in this example:
  21467. @lisp
  21468. (service dnsmasq-service-type
  21469. (dnsmasq-configuration
  21470. (no-resolv? #t)
  21471. (servers '("192.168.1.1"))))
  21472. @end lisp
  21473. @end deffn
  21474. @deftp {Data Type} dnsmasq-configuration
  21475. Data type representing the configuration of dnsmasq.
  21476. @table @asis
  21477. @item @code{package} (default: @var{dnsmasq})
  21478. Package object of the dnsmasq server.
  21479. @item @code{no-hosts?} (default: @code{#f})
  21480. When true, don't read the hostnames in /etc/hosts.
  21481. @item @code{port} (default: @code{53})
  21482. The port to listen on. Setting this to zero completely disables DNS
  21483. responses, leaving only DHCP and/or TFTP functions.
  21484. @item @code{local-service?} (default: @code{#t})
  21485. Accept DNS queries only from hosts whose address is on a local subnet,
  21486. ie a subnet for which an interface exists on the server.
  21487. @item @code{listen-addresses} (default: @code{'()})
  21488. Listen on the given IP addresses.
  21489. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  21490. The file to read the IP address of the upstream nameservers from.
  21491. @item @code{no-resolv?} (default: @code{#f})
  21492. When true, don't read @var{resolv-file}.
  21493. @item @code{servers} (default: @code{'()})
  21494. Specify IP address of upstream servers directly.
  21495. @item @code{addresses} (default: @code{'()})
  21496. For each entry, specify an IP address to return for any host in the
  21497. given domains. Queries in the domains are never forwarded and always
  21498. replied to with the specified IP address.
  21499. This is useful for redirecting hosts locally, for example:
  21500. @lisp
  21501. (service dnsmasq-service-type
  21502. (dnsmasq-configuration
  21503. (addresses
  21504. '(; Redirect to a local web-server.
  21505. "/example.org/127.0.0.1"
  21506. ; Redirect subdomain to a specific IP.
  21507. "/subdomain.example.org/192.168.1.42"))))
  21508. @end lisp
  21509. Note that rules in @file{/etc/hosts} take precedence over this.
  21510. @item @code{cache-size} (default: @code{150})
  21511. Set the size of dnsmasq's cache. Setting the cache size to zero
  21512. disables caching.
  21513. @item @code{negative-cache?} (default: @code{#t})
  21514. When false, disable negative caching.
  21515. @item @code{tftp-enable?} (default: @code{#f})
  21516. Whether to enable the built-in TFTP server.
  21517. @item @code{tftp-no-fail?} (default: @code{#f})
  21518. If true, does not fail dnsmasq if the TFTP server could not start up.
  21519. @item @code{tftp-single-port?} (default: @code{#f})
  21520. Whether to use only one single port for TFTP.
  21521. @item @code{tftp-secure?} (default: @code{#f})
  21522. If true, only files owned by the user running the dnsmasq process are accessible.
  21523. If dnsmasq is being run as root, different rules apply:
  21524. @code{tftp-secure?} has no effect, but only files which have the
  21525. world-readable bit set are accessible.
  21526. @item @code{tftp-max} (default: @code{#f})
  21527. If set, sets the maximal number of concurrent connections allowed.
  21528. @item @code{tftp-mtu} (default: @code{#f})
  21529. If set, sets the MTU for TFTP packets to that value.
  21530. @item @code{tftp-no-blocksize?} (default: @code{#f})
  21531. If true, stops the TFTP server from negotiating the blocksize with a client.
  21532. @item @code{tftp-lowercase?} (default: @code{#f})
  21533. Whether to convert all filenames in TFTP requests to lowercase.
  21534. @item @code{tftp-port-range} (default: @code{#f})
  21535. If set, fixes the dynamical ports (one per client) to the given range
  21536. (@code{"<start>,<end>"}).
  21537. @item @code{tftp-root} (default: @code{/var/empty,lo})
  21538. Look for files to transfer using TFTP relative to the given directory.
  21539. When this is set, TFTP paths which include @samp{..} are rejected, to stop clients
  21540. getting outside the specified root. Absolute paths (starting with @samp{/}) are
  21541. allowed, but they must be within the TFTP-root. If the optional interface
  21542. argument is given, the directory is only used for TFTP requests via that
  21543. interface.
  21544. @item @code{tftp-unique-root} (default: @code{#f})
  21545. If set, add the IP or hardware address of the TFTP client as a path component
  21546. on the end of the TFTP-root. Only valid if a TFTP root is set and the
  21547. directory exists. Defaults to adding IP address (in standard dotted-quad
  21548. format).
  21549. For instance, if @option{--tftp-root} is @samp{/tftp} and client
  21550. @samp{1.2.3.4} requests file @file{myfile} then the effective path will
  21551. be @file{/tftp/1.2.3.4/myfile} if @file{/tftp/1.2.3.4} exists or
  21552. @file{/tftp/myfile} otherwise. When @samp{=mac} is specified it will
  21553. append the MAC address instead, using lowercase zero padded digits
  21554. separated by dashes, e.g.: @samp{01-02-03-04-aa-bb}. Note that
  21555. resolving MAC addresses is only possible if the client is in the local
  21556. network or obtained a DHCP lease from dnsmasq.
  21557. @end table
  21558. @end deftp
  21559. @subsubheading ddclient Service
  21560. @cindex ddclient
  21561. The ddclient service described below runs the ddclient daemon, which takes
  21562. care of automatically updating DNS entries for service providers such as
  21563. @uref{https://dyn.com/dns/, Dyn}.
  21564. The following example show instantiates the service with its default
  21565. configuration:
  21566. @lisp
  21567. (service ddclient-service-type)
  21568. @end lisp
  21569. Note that ddclient needs to access credentials that are stored in a
  21570. @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
  21571. @code{secret-file} below). You are expected to create this file manually, in
  21572. an ``out-of-band'' fashion (you @emph{could} make this file part of the
  21573. service configuration, for instance by using @code{plain-file}, but it will be
  21574. world-readable @i{via} @file{/gnu/store}). See the examples in the
  21575. @file{share/ddclient} directory of the @code{ddclient} package.
  21576. @c %start of fragment
  21577. Available @code{ddclient-configuration} fields are:
  21578. @deftypevr {@code{ddclient-configuration} parameter} package ddclient
  21579. The ddclient package.
  21580. @end deftypevr
  21581. @deftypevr {@code{ddclient-configuration} parameter} integer daemon
  21582. The period after which ddclient will retry to check IP and domain name.
  21583. Defaults to @samp{300}.
  21584. @end deftypevr
  21585. @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
  21586. Use syslog for the output.
  21587. Defaults to @samp{#t}.
  21588. @end deftypevr
  21589. @deftypevr {@code{ddclient-configuration} parameter} string mail
  21590. Mail to user.
  21591. Defaults to @samp{"root"}.
  21592. @end deftypevr
  21593. @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
  21594. Mail failed update to user.
  21595. Defaults to @samp{"root"}.
  21596. @end deftypevr
  21597. @deftypevr {@code{ddclient-configuration} parameter} string pid
  21598. The ddclient PID file.
  21599. Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
  21600. @end deftypevr
  21601. @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
  21602. Enable SSL support.
  21603. Defaults to @samp{#t}.
  21604. @end deftypevr
  21605. @deftypevr {@code{ddclient-configuration} parameter} string user
  21606. Specifies the user name or ID that is used when running ddclient
  21607. program.
  21608. Defaults to @samp{"ddclient"}.
  21609. @end deftypevr
  21610. @deftypevr {@code{ddclient-configuration} parameter} string group
  21611. Group of the user who will run the ddclient program.
  21612. Defaults to @samp{"ddclient"}.
  21613. @end deftypevr
  21614. @deftypevr {@code{ddclient-configuration} parameter} string secret-file
  21615. Secret file which will be appended to @file{ddclient.conf} file. This
  21616. file contains credentials for use by ddclient. You are expected to
  21617. create it manually.
  21618. Defaults to @samp{"/etc/ddclient/secrets.conf"}.
  21619. @end deftypevr
  21620. @deftypevr {@code{ddclient-configuration} parameter} list extra-options
  21621. Extra options will be appended to @file{ddclient.conf} file.
  21622. Defaults to @samp{()}.
  21623. @end deftypevr
  21624. @c %end of fragment
  21625. @node VPN Services
  21626. @subsection VPN Services
  21627. @cindex VPN (virtual private network)
  21628. @cindex virtual private network (VPN)
  21629. The @code{(gnu services vpn)} module provides services related to
  21630. @dfn{virtual private networks} (VPNs).
  21631. @subsubheading Bitmask
  21632. @defvr {Scheme Variable} bitmask-service-type
  21633. A service type for the @uref{https://bitmask.net, Bitmask} VPN client. It makes
  21634. the client available in the system and loads its polkit policy. Please note that
  21635. the client expects an active polkit-agent, which is either run by your
  21636. desktop-environment or should be run manually.
  21637. @end defvr
  21638. @subsubheading OpenVPN
  21639. It provides a @emph{client} service for your machine to connect to a
  21640. VPN, and a @emph{server} service for your machine to host a VPN@.
  21641. @deffn {Scheme Procedure} openvpn-client-service @
  21642. [#:config (openvpn-client-configuration)]
  21643. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  21644. @end deffn
  21645. @deffn {Scheme Procedure} openvpn-server-service @
  21646. [#:config (openvpn-server-configuration)]
  21647. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  21648. Both can be run simultaneously.
  21649. @end deffn
  21650. @c %automatically generated documentation
  21651. Available @code{openvpn-client-configuration} fields are:
  21652. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  21653. The OpenVPN package.
  21654. @end deftypevr
  21655. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  21656. The OpenVPN pid file.
  21657. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  21658. @end deftypevr
  21659. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  21660. The protocol (UDP or TCP) used to open a channel between clients and
  21661. servers.
  21662. Defaults to @samp{udp}.
  21663. @end deftypevr
  21664. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  21665. The device type used to represent the VPN connection.
  21666. Defaults to @samp{tun}.
  21667. @end deftypevr
  21668. If you do not have some of these files (eg.@: you use a username and
  21669. password), you can disable any of the following three fields by setting
  21670. it to @code{'disabled}.
  21671. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
  21672. The certificate authority to check connections against.
  21673. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  21674. @end deftypevr
  21675. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string cert
  21676. The certificate of the machine the daemon is running on. It should be
  21677. signed by the authority given in @code{ca}.
  21678. Defaults to @samp{"/etc/openvpn/client.crt"}.
  21679. @end deftypevr
  21680. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string key
  21681. The key of the machine the daemon is running on. It must be the key whose
  21682. certificate is @code{cert}.
  21683. Defaults to @samp{"/etc/openvpn/client.key"}.
  21684. @end deftypevr
  21685. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  21686. Whether to use the lzo compression algorithm.
  21687. Defaults to @samp{#t}.
  21688. @end deftypevr
  21689. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  21690. Don't re-read key files across SIGUSR1 or --ping-restart.
  21691. Defaults to @samp{#t}.
  21692. @end deftypevr
  21693. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  21694. Don't close and reopen TUN/TAP device or run up/down scripts across
  21695. SIGUSR1 or --ping-restart restarts.
  21696. Defaults to @samp{#t}.
  21697. @end deftypevr
  21698. @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
  21699. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  21700. poll/epoll/select prior to the write operation.
  21701. Defaults to @samp{#f}.
  21702. @end deftypevr
  21703. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  21704. Verbosity level.
  21705. Defaults to @samp{3}.
  21706. @end deftypevr
  21707. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  21708. Add an additional layer of HMAC authentication on top of the TLS control
  21709. channel to protect against DoS attacks.
  21710. Defaults to @samp{#f}.
  21711. @end deftypevr
  21712. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
  21713. Authenticate with server using username/password. The option is a file
  21714. containing username/password on 2 lines. Do not use a file-like object as it
  21715. would be added to the store and readable by any user.
  21716. Defaults to @samp{'disabled}.
  21717. @end deftypevr
  21718. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  21719. Whether to check the server certificate has server usage extension.
  21720. Defaults to @samp{#t}.
  21721. @end deftypevr
  21722. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  21723. Bind to a specific local port number.
  21724. Defaults to @samp{#f}.
  21725. @end deftypevr
  21726. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  21727. Retry resolving server address.
  21728. Defaults to @samp{#t}.
  21729. @end deftypevr
  21730. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  21731. A list of remote servers to connect to.
  21732. Defaults to @samp{()}.
  21733. Available @code{openvpn-remote-configuration} fields are:
  21734. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  21735. Server name.
  21736. Defaults to @samp{"my-server"}.
  21737. @end deftypevr
  21738. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  21739. Port number the server listens to.
  21740. Defaults to @samp{1194}.
  21741. @end deftypevr
  21742. @end deftypevr
  21743. @c %end of automatic openvpn-client documentation
  21744. @c %automatically generated documentation
  21745. Available @code{openvpn-server-configuration} fields are:
  21746. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  21747. The OpenVPN package.
  21748. @end deftypevr
  21749. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  21750. The OpenVPN pid file.
  21751. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  21752. @end deftypevr
  21753. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  21754. The protocol (UDP or TCP) used to open a channel between clients and
  21755. servers.
  21756. Defaults to @samp{udp}.
  21757. @end deftypevr
  21758. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  21759. The device type used to represent the VPN connection.
  21760. Defaults to @samp{tun}.
  21761. @end deftypevr
  21762. If you do not have some of these files (eg.@: you use a username and
  21763. password), you can disable any of the following three fields by setting
  21764. it to @code{'disabled}.
  21765. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
  21766. The certificate authority to check connections against.
  21767. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  21768. @end deftypevr
  21769. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string cert
  21770. The certificate of the machine the daemon is running on. It should be
  21771. signed by the authority given in @code{ca}.
  21772. Defaults to @samp{"/etc/openvpn/client.crt"}.
  21773. @end deftypevr
  21774. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string key
  21775. The key of the machine the daemon is running on. It must be the key whose
  21776. certificate is @code{cert}.
  21777. Defaults to @samp{"/etc/openvpn/client.key"}.
  21778. @end deftypevr
  21779. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  21780. Whether to use the lzo compression algorithm.
  21781. Defaults to @samp{#t}.
  21782. @end deftypevr
  21783. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  21784. Don't re-read key files across SIGUSR1 or --ping-restart.
  21785. Defaults to @samp{#t}.
  21786. @end deftypevr
  21787. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  21788. Don't close and reopen TUN/TAP device or run up/down scripts across
  21789. SIGUSR1 or --ping-restart restarts.
  21790. Defaults to @samp{#t}.
  21791. @end deftypevr
  21792. @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
  21793. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  21794. poll/epoll/select prior to the write operation.
  21795. Defaults to @samp{#f}.
  21796. @end deftypevr
  21797. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  21798. Verbosity level.
  21799. Defaults to @samp{3}.
  21800. @end deftypevr
  21801. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  21802. Add an additional layer of HMAC authentication on top of the TLS control
  21803. channel to protect against DoS attacks.
  21804. Defaults to @samp{#f}.
  21805. @end deftypevr
  21806. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  21807. Specifies the port number on which the server listens.
  21808. Defaults to @samp{1194}.
  21809. @end deftypevr
  21810. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  21811. An ip and mask specifying the subnet inside the virtual network.
  21812. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  21813. @end deftypevr
  21814. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  21815. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  21816. Defaults to @samp{#f}.
  21817. @end deftypevr
  21818. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  21819. The Diffie-Hellman parameters file.
  21820. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  21821. @end deftypevr
  21822. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  21823. The file that records client IPs.
  21824. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  21825. @end deftypevr
  21826. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  21827. When true, the server will act as a gateway for its clients.
  21828. Defaults to @samp{#f}.
  21829. @end deftypevr
  21830. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  21831. When true, clients are allowed to talk to each other inside the VPN.
  21832. Defaults to @samp{#f}.
  21833. @end deftypevr
  21834. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  21835. Causes ping-like messages to be sent back and forth over the link so
  21836. that each side knows when the other side has gone down. @code{keepalive}
  21837. requires a pair. The first element is the period of the ping sending,
  21838. and the second element is the timeout before considering the other side
  21839. down.
  21840. @end deftypevr
  21841. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  21842. The maximum number of clients.
  21843. Defaults to @samp{100}.
  21844. @end deftypevr
  21845. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  21846. The status file. This file shows a small report on current connection.
  21847. It is truncated and rewritten every minute.
  21848. Defaults to @samp{"/var/run/openvpn/status"}.
  21849. @end deftypevr
  21850. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  21851. The list of configuration for some clients.
  21852. Defaults to @samp{()}.
  21853. Available @code{openvpn-ccd-configuration} fields are:
  21854. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  21855. Client name.
  21856. Defaults to @samp{"client"}.
  21857. @end deftypevr
  21858. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  21859. Client own network
  21860. Defaults to @samp{#f}.
  21861. @end deftypevr
  21862. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  21863. Client VPN IP.
  21864. Defaults to @samp{#f}.
  21865. @end deftypevr
  21866. @end deftypevr
  21867. @c %end of automatic openvpn-server documentation
  21868. @subheading strongSwan
  21869. Currently, the strongSwan service only provides legacy-style configuration with
  21870. @file{ipsec.conf} and @file{ipsec.secrets} files.
  21871. @defvr {Scheme Variable} strongswan-service-type
  21872. A service type for configuring strongSwan for IPsec @acronym{VPN,
  21873. Virtual Private Networking}. Its value must be a
  21874. @code{strongswan-configuration} record as in this example:
  21875. @lisp
  21876. (service strongswan-service-type
  21877. (strongswan-configuration
  21878. (ipsec-conf "/etc/ipsec.conf")
  21879. (ipsec-secrets "/etc/ipsec.secrets")))
  21880. @end lisp
  21881. @end defvr
  21882. @deftp {Data Type} strongswan-configuration
  21883. Data type representing the configuration of the StrongSwan service.
  21884. @table @asis
  21885. @item @code{strongswan}
  21886. The strongSwan package to use for this service.
  21887. @item @code{ipsec-conf} (default: @code{#f})
  21888. The file name of your @file{ipsec.conf}. If not @code{#f}, then this and
  21889. @code{ipsec-secrets} must both be strings.
  21890. @item @code{ipsec-secrets} (default @code{#f})
  21891. The file name of your @file{ipsec.secrets}. If not @code{#f}, then this and
  21892. @code{ipsec-conf} must both be strings.
  21893. @end table
  21894. @end deftp
  21895. @subsubheading Wireguard
  21896. @defvr {Scheme Variable} wireguard-service-type
  21897. A service type for a Wireguard tunnel interface. Its value must be a
  21898. @code{wireguard-configuration} record as in this example:
  21899. @lisp
  21900. (service wireguard-service-type
  21901. (wireguard-configuration
  21902. (peers
  21903. (list
  21904. (wireguard-peer
  21905. (name "my-peer")
  21906. (endpoint "my.wireguard.com:51820")
  21907. (public-key "hzpKg9X1yqu1axN6iJp0mWf6BZGo8m1wteKwtTmDGF4=")
  21908. (allowed-ips '("10.0.0.2/32")))))))
  21909. @end lisp
  21910. @end defvr
  21911. @deftp {Data Type} wireguard-configuration
  21912. Data type representing the configuration of the Wireguard service.
  21913. @table @asis
  21914. @item @code{wireguard}
  21915. The wireguard package to use for this service.
  21916. @item @code{interface} (default: @code{"wg0"})
  21917. The interface name for the VPN.
  21918. @item @code{addresses} (default: @code{'("10.0.0.1/32")})
  21919. The IP addresses to be assigned to the above interface.
  21920. @item @code{private-key} (default: @code{"/etc/wireguard/private.key"})
  21921. The private key file for the interface. It is automatically generated if
  21922. the file does not exist.
  21923. @item @code{peers} (default: @code{'()})
  21924. The authorized peers on this interface. This is a list of
  21925. @var{wireguard-peer} records.
  21926. @end table
  21927. @end deftp
  21928. @deftp {Data Type} wireguard-peer
  21929. Data type representing a Wireguard peer attached to a given interface.
  21930. @table @asis
  21931. @item @code{name}
  21932. The peer name.
  21933. @item @code{endpoint} (default: @code{#f})
  21934. The optional endpoint for the peer, such as
  21935. @code{"demo.wireguard.com:51820"}.
  21936. @item @code{public-key}
  21937. The peer public-key represented as a base64 string.
  21938. @item @code{allowed-ips}
  21939. A list of IP addresses from which incoming traffic for this peer is
  21940. allowed and to which incoming traffic for this peer is directed.
  21941. @item @code{keep-alive} (default: @code{#f})
  21942. An optional time interval in seconds. A packet will be sent to the
  21943. server endpoint once per time interval. This helps receiving
  21944. incoming connections from this peer when you are behind a NAT or
  21945. a firewall.
  21946. @end table
  21947. @end deftp
  21948. @node Network File System
  21949. @subsection Network File System
  21950. @cindex NFS
  21951. The @code{(gnu services nfs)} module provides the following services,
  21952. which are most commonly used in relation to mounting or exporting
  21953. directory trees as @dfn{network file systems} (NFS).
  21954. While it is possible to use the individual components that together make
  21955. up a Network File System service, we recommended to configure an NFS
  21956. server with the @code{nfs-service-type}.
  21957. @subsubheading NFS Service
  21958. @cindex NFS, server
  21959. The NFS service takes care of setting up all NFS component services,
  21960. kernel configuration file systems, and installs configuration files in
  21961. the locations that NFS expects.
  21962. @defvr {Scheme Variable} nfs-service-type
  21963. A service type for a complete NFS server.
  21964. @end defvr
  21965. @deftp {Data Type} nfs-configuration
  21966. This data type represents the configuration of the NFS service and all
  21967. of its subsystems.
  21968. It has the following parameters:
  21969. @table @asis
  21970. @item @code{nfs-utils} (default: @code{nfs-utils})
  21971. The nfs-utils package to use.
  21972. @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
  21973. If a list of string values is provided, the @command{rpc.nfsd} daemon
  21974. will be limited to supporting the given versions of the NFS protocol.
  21975. @item @code{exports} (default: @code{'()})
  21976. This is a list of directories the NFS server should export. Each entry
  21977. is a list consisting of two elements: a directory name and a string
  21978. containing all options. This is an example in which the directory
  21979. @file{/export} is served to all NFS clients as a read-only share:
  21980. @lisp
  21981. (nfs-configuration
  21982. (exports
  21983. '(("/export"
  21984. "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
  21985. @end lisp
  21986. @item @code{rpcmountd-port} (default: @code{#f})
  21987. The network port that the @command{rpc.mountd} daemon should use.
  21988. @item @code{rpcstatd-port} (default: @code{#f})
  21989. The network port that the @command{rpc.statd} daemon should use.
  21990. @item @code{rpcbind} (default: @code{rpcbind})
  21991. The rpcbind package to use.
  21992. @item @code{idmap-domain} (default: @code{"localdomain"})
  21993. The local NFSv4 domain name.
  21994. @item @code{nfsd-port} (default: @code{2049})
  21995. The network port that the @command{nfsd} daemon should use.
  21996. @item @code{nfsd-threads} (default: @code{8})
  21997. The number of threads used by the @command{nfsd} daemon.
  21998. @item @code{nfsd-tcp?} (default: @code{#t})
  21999. Whether the @command{nfsd} daemon should listen on a TCP socket.
  22000. @item @code{nfsd-udp?} (default: @code{#f})
  22001. Whether the @command{nfsd} daemon should listen on a UDP socket.
  22002. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  22003. The directory where the pipefs file system is mounted.
  22004. @item @code{debug} (default: @code{'()"})
  22005. A list of subsystems for which debugging output should be enabled. This
  22006. is a list of symbols. Any of these symbols are valid: @code{nfsd},
  22007. @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
  22008. @end table
  22009. @end deftp
  22010. If you don't need a complete NFS service or prefer to build it yourself
  22011. you can use the individual component services that are documented below.
  22012. @subsubheading RPC Bind Service
  22013. @cindex rpcbind
  22014. The RPC Bind service provides a facility to map program numbers into
  22015. universal addresses.
  22016. Many NFS related services use this facility. Hence it is automatically
  22017. started when a dependent service starts.
  22018. @defvr {Scheme Variable} rpcbind-service-type
  22019. A service type for the RPC portmapper daemon.
  22020. @end defvr
  22021. @deftp {Data Type} rpcbind-configuration
  22022. Data type representing the configuration of the RPC Bind Service.
  22023. This type has the following parameters:
  22024. @table @asis
  22025. @item @code{rpcbind} (default: @code{rpcbind})
  22026. The rpcbind package to use.
  22027. @item @code{warm-start?} (default: @code{#t})
  22028. If this parameter is @code{#t}, then the daemon will read a
  22029. state file on startup thus reloading state information saved by a previous
  22030. instance.
  22031. @end table
  22032. @end deftp
  22033. @subsubheading Pipefs Pseudo File System
  22034. @cindex pipefs
  22035. @cindex rpc_pipefs
  22036. The pipefs file system is used to transfer NFS related data
  22037. between the kernel and user space programs.
  22038. @defvr {Scheme Variable} pipefs-service-type
  22039. A service type for the pipefs pseudo file system.
  22040. @end defvr
  22041. @deftp {Data Type} pipefs-configuration
  22042. Data type representing the configuration of the pipefs pseudo file system service.
  22043. This type has the following parameters:
  22044. @table @asis
  22045. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  22046. The directory to which the file system is to be attached.
  22047. @end table
  22048. @end deftp
  22049. @subsubheading GSS Daemon Service
  22050. @cindex GSSD
  22051. @cindex GSS
  22052. @cindex global security system
  22053. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  22054. based protocols.
  22055. Before exchanging RPC requests an RPC client must establish a security
  22056. context. Typically this is done using the Kerberos command @command{kinit}
  22057. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  22058. @defvr {Scheme Variable} gss-service-type
  22059. A service type for the Global Security System (GSS) daemon.
  22060. @end defvr
  22061. @deftp {Data Type} gss-configuration
  22062. Data type representing the configuration of the GSS daemon service.
  22063. This type has the following parameters:
  22064. @table @asis
  22065. @item @code{nfs-utils} (default: @code{nfs-utils})
  22066. The package in which the @command{rpc.gssd} command is to be found.
  22067. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  22068. The directory where the pipefs file system is mounted.
  22069. @end table
  22070. @end deftp
  22071. @subsubheading IDMAP Daemon Service
  22072. @cindex idmapd
  22073. @cindex name mapper
  22074. The idmap daemon service provides mapping between user IDs and user names.
  22075. Typically it is required in order to access file systems mounted via NFSv4.
  22076. @defvr {Scheme Variable} idmap-service-type
  22077. A service type for the Identity Mapper (IDMAP) daemon.
  22078. @end defvr
  22079. @deftp {Data Type} idmap-configuration
  22080. Data type representing the configuration of the IDMAP daemon service.
  22081. This type has the following parameters:
  22082. @table @asis
  22083. @item @code{nfs-utils} (default: @code{nfs-utils})
  22084. The package in which the @command{rpc.idmapd} command is to be found.
  22085. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  22086. The directory where the pipefs file system is mounted.
  22087. @item @code{domain} (default: @code{#f})
  22088. The local NFSv4 domain name.
  22089. This must be a string or @code{#f}.
  22090. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  22091. @item @code{verbosity} (default: @code{0})
  22092. The verbosity level of the daemon.
  22093. @end table
  22094. @end deftp
  22095. @node Continuous Integration
  22096. @subsection Continuous Integration
  22097. @cindex continuous integration
  22098. @uref{https://guix.gnu.org/cuirass/, Cuirass} is a continuous
  22099. integration tool for Guix. It can be used both for development and for
  22100. providing substitutes to others (@pxref{Substitutes}).
  22101. The @code{(gnu services cuirass)} module provides the following service.
  22102. @defvr {Scheme Procedure} cuirass-service-type
  22103. The type of the Cuirass service. Its value must be a
  22104. @code{cuirass-configuration} object, as described below.
  22105. @end defvr
  22106. To add build jobs, you have to set the @code{specifications} field of
  22107. the configuration. For instance, the following example will build all
  22108. the packages provided by the @code{my-channel} channel.
  22109. @lisp
  22110. (define %cuirass-specs
  22111. #~(list (specification
  22112. (name "my-channel")
  22113. (build '(channels my-channel))
  22114. (channels
  22115. (cons (channel
  22116. (name 'my-channel)
  22117. (url "https://my-channel.git"))
  22118. %default-channels)))))
  22119. (service cuirass-service-type
  22120. (cuirass-configuration
  22121. (specifications %cuirass-specs)))
  22122. @end lisp
  22123. To build the @code{linux-libre} package defined by the default Guix
  22124. channel, one can use the following configuration.
  22125. @lisp
  22126. (define %cuirass-specs
  22127. #~(list (specification
  22128. (name "my-linux")
  22129. (build '(packages "linux-libre")))))
  22130. (service cuirass-service-type
  22131. (cuirass-configuration
  22132. (specifications %cuirass-specs)))
  22133. @end lisp
  22134. The other configuration possibilities, as well as the specification
  22135. record itself are described in the Cuirass manual
  22136. (@pxref{Specifications,,, cuirass, Cuirass}).
  22137. While information related to build jobs is located directly in the
  22138. specifications, global settings for the @command{cuirass} process are
  22139. accessible in other @code{cuirass-configuration} fields.
  22140. @deftp {Data Type} cuirass-configuration
  22141. Data type representing the configuration of Cuirass.
  22142. @table @asis
  22143. @item @code{cuirass} (default: @code{cuirass})
  22144. The Cuirass package to use.
  22145. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  22146. Location of the log file.
  22147. @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
  22148. Location of the log file used by the web interface.
  22149. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  22150. Location of the repository cache.
  22151. @item @code{user} (default: @code{"cuirass"})
  22152. Owner of the @code{cuirass} process.
  22153. @item @code{group} (default: @code{"cuirass"})
  22154. Owner's group of the @code{cuirass} process.
  22155. @item @code{interval} (default: @code{60})
  22156. Number of seconds between the poll of the repositories followed by the
  22157. Cuirass jobs.
  22158. @item @code{parameters} (default: @code{#f})
  22159. Read parameters from the given @var{parameters} file. The supported
  22160. parameters are described here (@pxref{Parameters,,, cuirass, Cuirass}).
  22161. @item @code{remote-server} (default: @code{#f})
  22162. A @code{cuirass-remote-server-configuration} record to use the build
  22163. remote mechanism or @code{#f} to use the default build mechanism.
  22164. @item @code{database} (default: @code{"dbname=cuirass host=/var/run/postgresql"})
  22165. Use @var{database} as the database containing the jobs and the past
  22166. build results. Since Cuirass uses PostgreSQL as a database engine,
  22167. @var{database} must be a string such as @code{"dbname=cuirass
  22168. host=localhost"}.
  22169. @item @code{port} (default: @code{8081})
  22170. Port number used by the HTTP server.
  22171. @item @code{host} (default: @code{"localhost"})
  22172. Listen on the network interface for @var{host}. The default is to
  22173. accept connections from localhost.
  22174. @item @code{specifications} (default: @code{#~'()})
  22175. A gexp (@pxref{G-Expressions}) that evaluates to a list of
  22176. specifications records. The specification record is described in the
  22177. Cuirass manual (@pxref{Specifications,,, cuirass, Cuirass}).
  22178. @item @code{use-substitutes?} (default: @code{#f})
  22179. This allows using substitutes to avoid building every dependencies of a job
  22180. from source.
  22181. @item @code{one-shot?} (default: @code{#f})
  22182. Only evaluate specifications and build derivations once.
  22183. @item @code{fallback?} (default: @code{#f})
  22184. When substituting a pre-built binary fails, fall back to building
  22185. packages locally.
  22186. @item @code{extra-options} (default: @code{'()})
  22187. Extra options to pass when running the Cuirass processes.
  22188. @end table
  22189. @end deftp
  22190. @cindex remote build
  22191. @subsubheading Cuirass remote building
  22192. Cuirass supports two mechanisms to build derivations.
  22193. @itemize
  22194. @item Using the local Guix daemon.
  22195. This is the default build mechanism. Once the build jobs are
  22196. evaluated, they are sent to the local Guix daemon. Cuirass then
  22197. listens to the Guix daemon output to detect the various build events.
  22198. @item Using the remote build mechanism.
  22199. The build jobs are not submitted to the local Guix daemon. Instead, a
  22200. remote server dispatches build requests to the connect remote workers,
  22201. according to the build priorities.
  22202. @end itemize
  22203. To enable this build mode a @code{cuirass-remote-server-configuration}
  22204. record must be passed as @code{remote-server} argument of the
  22205. @code{cuirass-configuration} record. The
  22206. @code{cuirass-remote-server-configuration} record is described below.
  22207. This build mode scales way better than the default build mode. This is
  22208. the build mode that is used on the GNU Guix build farm at
  22209. @url{https://ci.guix.gnu.org}. It should be preferred when using
  22210. Cuirass to build large amount of packages.
  22211. @deftp {Data Type} cuirass-remote-server-configuration
  22212. Data type representing the configuration of the Cuirass remote-server.
  22213. @table @asis
  22214. @item @code{backend-port} (default: @code{5555})
  22215. The TCP port for communicating with @code{remote-worker} processes
  22216. using ZMQ. It defaults to @code{5555}.
  22217. @item @code{log-port} (default: @code{5556})
  22218. The TCP port of the log server. It defaults to @code{5556}.
  22219. @item @code{publish-port} (default: @code{5557})
  22220. The TCP port of the publish server. It defaults to @code{5557}.
  22221. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-server.log"})
  22222. Location of the log file.
  22223. @item @code{cache} (default: @code{"/var/cache/cuirass/remote"})
  22224. Use @var{cache} directory to cache build log files.
  22225. @item @code{trigger-url} (default: @code{#f})
  22226. Once a substitute is successfully fetched, trigger substitute baking at
  22227. @var{trigger-url}.
  22228. @item @code{publish?} (default: @code{#t})
  22229. If set to false, do not start a publish server and ignore the
  22230. @code{publish-port} argument. This can be useful if there is already a
  22231. standalone publish server standing next to the remote server.
  22232. @item @code{public-key}
  22233. @item @code{private-key}
  22234. Use the specific @var{file}s as the public/private key pair used to sign
  22235. the store items being published.
  22236. @end table
  22237. @end deftp
  22238. At least one remote worker must also be started on any machine of the
  22239. local network to actually perform the builds and report their status.
  22240. @deftp {Data Type} cuirass-remote-worker-configuration
  22241. Data type representing the configuration of the Cuirass remote-worker.
  22242. @table @asis
  22243. @item @code{cuirass} (default: @code{cuirass})
  22244. The Cuirass package to use.
  22245. @item @code{workers} (default: @code{1})
  22246. Start @var{workers} parallel workers.
  22247. @item @code{server} (default: @code{#f})
  22248. Do not use Avahi discovery and connect to the given @code{server} IP
  22249. address instead.
  22250. @item @code{systems} (default: @code{(list (%current-system))})
  22251. Only request builds for the given @var{systems}.
  22252. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-worker.log"})
  22253. Location of the log file.
  22254. @item @code{publish-port} (default: @code{5558})
  22255. The TCP port of the publish server. It defaults to @code{5558}.
  22256. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  22257. The list of URLs where to look for substitutes by default.
  22258. @item @code{public-key}
  22259. @item @code{private-key}
  22260. Use the specific @var{file}s as the public/private key pair used to sign
  22261. the store items being published.
  22262. @end table
  22263. @end deftp
  22264. @subsubheading Laminar
  22265. @uref{https://laminar.ohwg.net/, Laminar} is a lightweight and modular
  22266. Continuous Integration service. It doesn't have a configuration web UI
  22267. instead uses version-controllable configuration files and scripts.
  22268. Laminar encourages the use of existing tools such as bash and cron
  22269. instead of reinventing them.
  22270. @defvr {Scheme Procedure} laminar-service-type
  22271. The type of the Laminar service. Its value must be a
  22272. @code{laminar-configuration} object, as described below.
  22273. All configuration values have defaults, a minimal configuration to get
  22274. Laminar running is shown below. By default, the web interface is
  22275. available on port 8080.
  22276. @lisp
  22277. (service laminar-service-type)
  22278. @end lisp
  22279. @end defvr
  22280. @deftp {Data Type} laminar-configuration
  22281. Data type representing the configuration of Laminar.
  22282. @table @asis
  22283. @item @code{laminar} (default: @code{laminar})
  22284. The Laminar package to use.
  22285. @item @code{home-directory} (default: @code{"/var/lib/laminar"})
  22286. The directory for job configurations and run directories.
  22287. @item @code{bind-http} (default: @code{"*:8080"})
  22288. The interface/port or unix socket on which laminard should listen for
  22289. incoming connections to the web frontend.
  22290. @item @code{bind-rpc} (default: @code{"unix-abstract:laminar"})
  22291. The interface/port or unix socket on which laminard should listen for
  22292. incoming commands such as build triggers.
  22293. @item @code{title} (default: @code{"Laminar"})
  22294. The page title to show in the web frontend.
  22295. @item @code{keep-rundirs} (default: @code{0})
  22296. Set to an integer defining how many rundirs to keep per job. The
  22297. lowest-numbered ones will be deleted. The default is 0, meaning all run
  22298. dirs will be immediately deleted.
  22299. @item @code{archive-url} (default: @code{#f})
  22300. The web frontend served by laminard will use this URL to form links to
  22301. artefacts archived jobs.
  22302. @item @code{base-url} (default: @code{#f})
  22303. Base URL to use for links to laminar itself.
  22304. @end table
  22305. @end deftp
  22306. @node Power Management Services
  22307. @subsection Power Management Services
  22308. @cindex tlp
  22309. @cindex power management with TLP
  22310. @subsubheading TLP daemon
  22311. The @code{(gnu services pm)} module provides a Guix service definition
  22312. for the Linux power management tool TLP.
  22313. TLP enables various powersaving modes in userspace and kernel.
  22314. Contrary to @code{upower-service}, it is not a passive,
  22315. monitoring tool, as it will apply custom settings each time a new power
  22316. source is detected. More information can be found at
  22317. @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
  22318. @deffn {Scheme Variable} tlp-service-type
  22319. The service type for the TLP tool. The default settings are optimised
  22320. for battery life on most systems, but you can tweak them to your heart's
  22321. content by adding a valid @code{tlp-configuration}:
  22322. @lisp
  22323. (service tlp-service-type
  22324. (tlp-configuration
  22325. (cpu-scaling-governor-on-ac (list "performance"))
  22326. (sched-powersave-on-bat? #t)))
  22327. @end lisp
  22328. @end deffn
  22329. Each parameter definition is preceded by its type; for example,
  22330. @samp{boolean foo} indicates that the @code{foo} parameter
  22331. should be specified as a boolean. Types starting with
  22332. @code{maybe-} denote parameters that won't show up in TLP config file
  22333. when their value is @code{'disabled}.
  22334. @c The following documentation was initially generated by
  22335. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  22336. @c documentation is better, so we shouldn't hesitate to edit below as
  22337. @c needed. However if the change you want to make to this documentation
  22338. @c can be done in an automated way, it's probably easier to change
  22339. @c (generate-documentation) than to make it below and have to deal with
  22340. @c the churn as TLP updates.
  22341. Available @code{tlp-configuration} fields are:
  22342. @deftypevr {@code{tlp-configuration} parameter} package tlp
  22343. The TLP package.
  22344. @end deftypevr
  22345. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  22346. Set to true if you wish to enable TLP.
  22347. Defaults to @samp{#t}.
  22348. @end deftypevr
  22349. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  22350. Default mode when no power supply can be detected. Alternatives are AC
  22351. and BAT.
  22352. Defaults to @samp{"AC"}.
  22353. @end deftypevr
  22354. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  22355. Number of seconds Linux kernel has to wait after the disk goes idle,
  22356. before syncing on AC.
  22357. Defaults to @samp{0}.
  22358. @end deftypevr
  22359. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  22360. Same as @code{disk-idle-ac} but on BAT mode.
  22361. Defaults to @samp{2}.
  22362. @end deftypevr
  22363. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  22364. Dirty pages flushing periodicity, expressed in seconds.
  22365. Defaults to @samp{15}.
  22366. @end deftypevr
  22367. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  22368. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  22369. Defaults to @samp{60}.
  22370. @end deftypevr
  22371. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  22372. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  22373. alternatives are powersave and performance. With acpi-cpufreq driver,
  22374. alternatives are ondemand, powersave, performance and conservative.
  22375. Defaults to @samp{disabled}.
  22376. @end deftypevr
  22377. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  22378. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  22379. Defaults to @samp{disabled}.
  22380. @end deftypevr
  22381. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  22382. Set the min available frequency for the scaling governor on AC.
  22383. Defaults to @samp{disabled}.
  22384. @end deftypevr
  22385. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  22386. Set the max available frequency for the scaling governor on AC.
  22387. Defaults to @samp{disabled}.
  22388. @end deftypevr
  22389. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  22390. Set the min available frequency for the scaling governor on BAT.
  22391. Defaults to @samp{disabled}.
  22392. @end deftypevr
  22393. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  22394. Set the max available frequency for the scaling governor on BAT.
  22395. Defaults to @samp{disabled}.
  22396. @end deftypevr
  22397. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  22398. Limit the min P-state to control the power dissipation of the CPU, in AC
  22399. mode. Values are stated as a percentage of the available performance.
  22400. Defaults to @samp{disabled}.
  22401. @end deftypevr
  22402. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  22403. Limit the max P-state to control the power dissipation of the CPU, in AC
  22404. mode. Values are stated as a percentage of the available performance.
  22405. Defaults to @samp{disabled}.
  22406. @end deftypevr
  22407. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  22408. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  22409. Defaults to @samp{disabled}.
  22410. @end deftypevr
  22411. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  22412. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  22413. Defaults to @samp{disabled}.
  22414. @end deftypevr
  22415. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  22416. Enable CPU turbo boost feature on AC mode.
  22417. Defaults to @samp{disabled}.
  22418. @end deftypevr
  22419. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  22420. Same as @code{cpu-boost-on-ac?} on BAT mode.
  22421. Defaults to @samp{disabled}.
  22422. @end deftypevr
  22423. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  22424. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  22425. used under light load conditions.
  22426. Defaults to @samp{#f}.
  22427. @end deftypevr
  22428. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  22429. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  22430. Defaults to @samp{#t}.
  22431. @end deftypevr
  22432. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  22433. Enable Linux kernel NMI watchdog.
  22434. Defaults to @samp{#f}.
  22435. @end deftypevr
  22436. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  22437. For Linux kernels with PHC patch applied, change CPU voltages. An
  22438. example value would be @samp{"F:V F:V F:V F:V"}.
  22439. Defaults to @samp{disabled}.
  22440. @end deftypevr
  22441. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  22442. Set CPU performance versus energy saving policy on AC@. Alternatives are
  22443. performance, normal, powersave.
  22444. Defaults to @samp{"performance"}.
  22445. @end deftypevr
  22446. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  22447. Same as @code{energy-perf-policy-ac} but on BAT mode.
  22448. Defaults to @samp{"powersave"}.
  22449. @end deftypevr
  22450. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  22451. Hard disk devices.
  22452. @end deftypevr
  22453. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  22454. Hard disk advanced power management level.
  22455. @end deftypevr
  22456. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  22457. Same as @code{disk-apm-bat} but on BAT mode.
  22458. @end deftypevr
  22459. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  22460. Hard disk spin down timeout. One value has to be specified for each
  22461. declared hard disk.
  22462. Defaults to @samp{disabled}.
  22463. @end deftypevr
  22464. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  22465. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  22466. Defaults to @samp{disabled}.
  22467. @end deftypevr
  22468. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  22469. Select IO scheduler for disk devices. One value has to be specified for
  22470. each declared hard disk. Example alternatives are cfq, deadline and
  22471. noop.
  22472. Defaults to @samp{disabled}.
  22473. @end deftypevr
  22474. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  22475. SATA aggressive link power management (ALPM) level. Alternatives are
  22476. min_power, medium_power, max_performance.
  22477. Defaults to @samp{"max_performance"}.
  22478. @end deftypevr
  22479. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  22480. Same as @code{sata-linkpwr-ac} but on BAT mode.
  22481. Defaults to @samp{"min_power"}.
  22482. @end deftypevr
  22483. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  22484. Exclude specified SATA host devices for link power management.
  22485. Defaults to @samp{disabled}.
  22486. @end deftypevr
  22487. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  22488. Enable Runtime Power Management for AHCI controller and disks on AC
  22489. mode.
  22490. Defaults to @samp{disabled}.
  22491. @end deftypevr
  22492. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  22493. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  22494. Defaults to @samp{disabled}.
  22495. @end deftypevr
  22496. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  22497. Seconds of inactivity before disk is suspended.
  22498. Defaults to @samp{15}.
  22499. @end deftypevr
  22500. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  22501. PCI Express Active State Power Management level. Alternatives are
  22502. default, performance, powersave.
  22503. Defaults to @samp{"performance"}.
  22504. @end deftypevr
  22505. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  22506. Same as @code{pcie-aspm-ac} but on BAT mode.
  22507. Defaults to @samp{"powersave"}.
  22508. @end deftypevr
  22509. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  22510. Radeon graphics clock speed level. Alternatives are low, mid, high,
  22511. auto, default.
  22512. Defaults to @samp{"high"}.
  22513. @end deftypevr
  22514. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  22515. Same as @code{radeon-power-ac} but on BAT mode.
  22516. Defaults to @samp{"low"}.
  22517. @end deftypevr
  22518. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  22519. Radeon dynamic power management method (DPM). Alternatives are battery,
  22520. performance.
  22521. Defaults to @samp{"performance"}.
  22522. @end deftypevr
  22523. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  22524. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  22525. Defaults to @samp{"battery"}.
  22526. @end deftypevr
  22527. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  22528. Radeon DPM performance level. Alternatives are auto, low, high.
  22529. Defaults to @samp{"auto"}.
  22530. @end deftypevr
  22531. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  22532. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  22533. Defaults to @samp{"auto"}.
  22534. @end deftypevr
  22535. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  22536. Wifi power saving mode.
  22537. Defaults to @samp{#f}.
  22538. @end deftypevr
  22539. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  22540. Same as @code{wifi-power-ac?} but on BAT mode.
  22541. Defaults to @samp{#t}.
  22542. @end deftypevr
  22543. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  22544. Disable wake on LAN.
  22545. Defaults to @samp{#t}.
  22546. @end deftypevr
  22547. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  22548. Timeout duration in seconds before activating audio power saving on
  22549. Intel HDA and AC97 devices. A value of 0 disables power saving.
  22550. Defaults to @samp{0}.
  22551. @end deftypevr
  22552. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  22553. Same as @code{sound-powersave-ac} but on BAT mode.
  22554. Defaults to @samp{1}.
  22555. @end deftypevr
  22556. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  22557. Disable controller in powersaving mode on Intel HDA devices.
  22558. Defaults to @samp{#t}.
  22559. @end deftypevr
  22560. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  22561. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  22562. powered on again by releasing (and reinserting) the eject lever or by
  22563. pressing the disc eject button on newer models.
  22564. Defaults to @samp{#f}.
  22565. @end deftypevr
  22566. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  22567. Name of the optical drive device to power off.
  22568. Defaults to @samp{"sr0"}.
  22569. @end deftypevr
  22570. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  22571. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  22572. and auto.
  22573. Defaults to @samp{"on"}.
  22574. @end deftypevr
  22575. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  22576. Same as @code{runtime-pm-ac} but on BAT mode.
  22577. Defaults to @samp{"auto"}.
  22578. @end deftypevr
  22579. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  22580. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  22581. ones.
  22582. Defaults to @samp{#t}.
  22583. @end deftypevr
  22584. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  22585. Exclude specified PCI(e) device addresses from Runtime Power Management.
  22586. Defaults to @samp{disabled}.
  22587. @end deftypevr
  22588. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  22589. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  22590. Power Management.
  22591. @end deftypevr
  22592. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  22593. Enable USB autosuspend feature.
  22594. Defaults to @samp{#t}.
  22595. @end deftypevr
  22596. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  22597. Exclude specified devices from USB autosuspend.
  22598. Defaults to @samp{disabled}.
  22599. @end deftypevr
  22600. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  22601. Exclude WWAN devices from USB autosuspend.
  22602. Defaults to @samp{#t}.
  22603. @end deftypevr
  22604. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  22605. Include specified devices into USB autosuspend, even if they are already
  22606. excluded by the driver or via @code{usb-blacklist-wwan?}.
  22607. Defaults to @samp{disabled}.
  22608. @end deftypevr
  22609. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  22610. Enable USB autosuspend before shutdown.
  22611. Defaults to @samp{disabled}.
  22612. @end deftypevr
  22613. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  22614. Restore radio device state (bluetooth, wifi, wwan) from previous
  22615. shutdown on system startup.
  22616. Defaults to @samp{#f}.
  22617. @end deftypevr
  22618. @cindex thermald
  22619. @cindex CPU frequency scaling with thermald
  22620. @subsubheading Thermald daemon
  22621. The @code{(gnu services pm)} module provides an interface to
  22622. thermald, a CPU frequency scaling service which helps prevent overheating.
  22623. @defvr {Scheme Variable} thermald-service-type
  22624. This is the service type for
  22625. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  22626. Thermal Daemon, which is responsible for controlling the thermal state
  22627. of processors and preventing overheating.
  22628. @end defvr
  22629. @deftp {Data Type} thermald-configuration
  22630. Data type representing the configuration of @code{thermald-service-type}.
  22631. @table @asis
  22632. @item @code{ignore-cpuid-check?} (default: @code{#f})
  22633. Ignore cpuid check for supported CPU models.
  22634. @item @code{thermald} (default: @var{thermald})
  22635. Package object of thermald.
  22636. @end table
  22637. @end deftp
  22638. @node Audio Services
  22639. @subsection Audio Services
  22640. The @code{(gnu services audio)} module provides a service to start MPD
  22641. (the Music Player Daemon).
  22642. @cindex mpd
  22643. @subsubheading Music Player Daemon
  22644. The Music Player Daemon (MPD) is a service that can play music while
  22645. being controlled from the local machine or over the network by a variety
  22646. of clients.
  22647. The following example shows how one might run @code{mpd} as user
  22648. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  22649. @lisp
  22650. (service mpd-service-type
  22651. (mpd-configuration
  22652. (user "bob")
  22653. (port "6666")))
  22654. @end lisp
  22655. @defvr {Scheme Variable} mpd-service-type
  22656. The service type for @command{mpd}
  22657. @end defvr
  22658. @deftp {Data Type} mpd-configuration
  22659. Data type representing the configuration of @command{mpd}.
  22660. @table @asis
  22661. @item @code{user} (default: @code{"mpd"})
  22662. The user to run mpd as.
  22663. @item @code{music-dir} (default: @code{"~/Music"})
  22664. The directory to scan for music files.
  22665. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  22666. The directory to store playlists.
  22667. @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
  22668. The location of the music database.
  22669. @item @code{state-file} (default: @code{"~/.mpd/state"})
  22670. The location of the file that stores current MPD's state.
  22671. @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
  22672. The location of the sticker database.
  22673. @item @code{port} (default: @code{"6600"})
  22674. The port to run mpd on.
  22675. @item @code{address} (default: @code{"any"})
  22676. The address that mpd will bind to. To use a Unix domain socket,
  22677. an absolute path can be specified here.
  22678. @item @code{outputs} (default: @code{"(list (mpd-output))"})
  22679. The audio outputs that MPD can use. By default this is a single output using pulseaudio.
  22680. @end table
  22681. @end deftp
  22682. @deftp {Data Type} mpd-output
  22683. Data type representing an @command{mpd} audio output.
  22684. @table @asis
  22685. @item @code{name} (default: @code{"MPD"})
  22686. The name of the audio output.
  22687. @item @code{type} (default: @code{"pulse"})
  22688. The type of audio output.
  22689. @item @code{enabled?} (default: @code{#t})
  22690. Specifies whether this audio output is enabled when MPD is started. By
  22691. default, all audio outputs are enabled. This is just the default
  22692. setting when there is no state file; with a state file, the previous
  22693. state is restored.
  22694. @item @code{tags?} (default: @code{#t})
  22695. If set to @code{#f}, then MPD will not send tags to this output. This
  22696. is only useful for output plugins that can receive tags, for example the
  22697. @code{httpd} output plugin.
  22698. @item @code{always-on?} (default: @code{#f})
  22699. If set to @code{#t}, then MPD attempts to keep this audio output always
  22700. open. This may be useful for streaming servers, when you don’t want to
  22701. disconnect all listeners even when playback is accidentally stopped.
  22702. @item @code{mixer-type}
  22703. This field accepts a symbol that specifies which mixer should be used
  22704. for this audio output: the @code{hardware} mixer, the @code{software}
  22705. mixer, the @code{null} mixer (allows setting the volume, but with no
  22706. effect; this can be used as a trick to implement an external mixer
  22707. External Mixer) or no mixer (@code{none}).
  22708. @item @code{extra-options} (default: @code{'()})
  22709. An association list of option symbols to string values to be appended to
  22710. the audio output configuration.
  22711. @end table
  22712. @end deftp
  22713. The following example shows a configuration of @code{mpd} that provides
  22714. an HTTP audio streaming output.
  22715. @lisp
  22716. (service mpd-service-type
  22717. (mpd-configuration
  22718. (outputs
  22719. (list (mpd-output
  22720. (name "streaming")
  22721. (type "httpd")
  22722. (mixer-type 'null)
  22723. (extra-options
  22724. `((encoder . "vorbis")
  22725. (port . "8080"))))))))
  22726. @end lisp
  22727. @node Virtualization Services
  22728. @subsection Virtualization Services
  22729. The @code{(gnu services virtualization)} module provides services for
  22730. the libvirt and virtlog daemons, as well as other virtualization-related
  22731. services.
  22732. @subsubheading Libvirt daemon
  22733. @code{libvirtd} is the server side daemon component of the libvirt
  22734. virtualization management system. This daemon runs on host servers
  22735. and performs required management tasks for virtualized guests.
  22736. @deffn {Scheme Variable} libvirt-service-type
  22737. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  22738. Its value must be a @code{libvirt-configuration}.
  22739. @lisp
  22740. (service libvirt-service-type
  22741. (libvirt-configuration
  22742. (unix-sock-group "libvirt")
  22743. (tls-port "16555")))
  22744. @end lisp
  22745. @end deffn
  22746. @c Auto-generated with (generate-libvirt-documentation)
  22747. Available @code{libvirt-configuration} fields are:
  22748. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  22749. Libvirt package.
  22750. @end deftypevr
  22751. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  22752. Flag listening for secure TLS connections on the public TCP/IP port.
  22753. You must set @code{listen} for this to have any effect.
  22754. It is necessary to setup a CA and issue server certificates before using
  22755. this capability.
  22756. Defaults to @samp{#t}.
  22757. @end deftypevr
  22758. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  22759. Listen for unencrypted TCP connections on the public TCP/IP port. You must
  22760. set @code{listen} for this to have any effect.
  22761. Using the TCP socket requires SASL authentication by default. Only SASL
  22762. mechanisms which support data encryption are allowed. This is
  22763. DIGEST_MD5 and GSSAPI (Kerberos5).
  22764. Defaults to @samp{#f}.
  22765. @end deftypevr
  22766. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  22767. Port for accepting secure TLS connections. This can be a port number,
  22768. or service name.
  22769. Defaults to @samp{"16514"}.
  22770. @end deftypevr
  22771. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  22772. Port for accepting insecure TCP connections. This can be a port number,
  22773. or service name.
  22774. Defaults to @samp{"16509"}.
  22775. @end deftypevr
  22776. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  22777. IP address or hostname used for client connections.
  22778. Defaults to @samp{"0.0.0.0"}.
  22779. @end deftypevr
  22780. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  22781. Flag toggling mDNS advertisement of the libvirt service.
  22782. Alternatively can disable for all services on a host by stopping the
  22783. Avahi daemon.
  22784. Defaults to @samp{#f}.
  22785. @end deftypevr
  22786. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  22787. Default mDNS advertisement name. This must be unique on the immediate
  22788. broadcast network.
  22789. Defaults to @samp{"Virtualization Host <hostname>"}.
  22790. @end deftypevr
  22791. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  22792. UNIX domain socket group ownership. This can be used to allow a
  22793. 'trusted' set of users access to management capabilities without
  22794. becoming root.
  22795. Defaults to @samp{"root"}.
  22796. @end deftypevr
  22797. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  22798. UNIX socket permissions for the R/O socket. This is used for monitoring
  22799. VM status only.
  22800. Defaults to @samp{"0777"}.
  22801. @end deftypevr
  22802. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  22803. UNIX socket permissions for the R/W socket. Default allows only root.
  22804. If PolicyKit is enabled on the socket, the default will change to allow
  22805. everyone (eg, 0777)
  22806. Defaults to @samp{"0770"}.
  22807. @end deftypevr
  22808. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  22809. UNIX socket permissions for the admin socket. Default allows only owner
  22810. (root), do not change it unless you are sure to whom you are exposing
  22811. the access to.
  22812. Defaults to @samp{"0777"}.
  22813. @end deftypevr
  22814. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  22815. The directory in which sockets will be found/created.
  22816. Defaults to @samp{"/var/run/libvirt"}.
  22817. @end deftypevr
  22818. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  22819. Authentication scheme for UNIX read-only sockets. By default socket
  22820. permissions allow anyone to connect
  22821. Defaults to @samp{"polkit"}.
  22822. @end deftypevr
  22823. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  22824. Authentication scheme for UNIX read-write sockets. By default socket
  22825. permissions only allow root. If PolicyKit support was compiled into
  22826. libvirt, the default will be to use 'polkit' auth.
  22827. Defaults to @samp{"polkit"}.
  22828. @end deftypevr
  22829. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  22830. Authentication scheme for TCP sockets. If you don't enable SASL, then
  22831. all TCP traffic is cleartext. Don't do this outside of a dev/test
  22832. scenario.
  22833. Defaults to @samp{"sasl"}.
  22834. @end deftypevr
  22835. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  22836. Authentication scheme for TLS sockets. TLS sockets already have
  22837. encryption provided by the TLS layer, and limited authentication is done
  22838. by certificates.
  22839. It is possible to make use of any SASL authentication mechanism as well,
  22840. by using 'sasl' for this option
  22841. Defaults to @samp{"none"}.
  22842. @end deftypevr
  22843. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  22844. API access control scheme.
  22845. By default an authenticated user is allowed access to all APIs. Access
  22846. drivers can place restrictions on this.
  22847. Defaults to @samp{()}.
  22848. @end deftypevr
  22849. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  22850. Server key file path. If set to an empty string, then no private key is
  22851. loaded.
  22852. Defaults to @samp{""}.
  22853. @end deftypevr
  22854. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  22855. Server key file path. If set to an empty string, then no certificate is
  22856. loaded.
  22857. Defaults to @samp{""}.
  22858. @end deftypevr
  22859. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  22860. Server key file path. If set to an empty string, then no CA certificate
  22861. is loaded.
  22862. Defaults to @samp{""}.
  22863. @end deftypevr
  22864. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  22865. Certificate revocation list path. If set to an empty string, then no
  22866. CRL is loaded.
  22867. Defaults to @samp{""}.
  22868. @end deftypevr
  22869. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  22870. Disable verification of our own server certificates.
  22871. When libvirtd starts it performs some sanity checks against its own
  22872. certificates.
  22873. Defaults to @samp{#f}.
  22874. @end deftypevr
  22875. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  22876. Disable verification of client certificates.
  22877. Client certificate verification is the primary authentication mechanism.
  22878. Any client which does not present a certificate signed by the CA will be
  22879. rejected.
  22880. Defaults to @samp{#f}.
  22881. @end deftypevr
  22882. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  22883. Whitelist of allowed x509 Distinguished Name.
  22884. Defaults to @samp{()}.
  22885. @end deftypevr
  22886. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  22887. Whitelist of allowed SASL usernames. The format for username depends on
  22888. the SASL authentication mechanism.
  22889. Defaults to @samp{()}.
  22890. @end deftypevr
  22891. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  22892. Override the compile time default TLS priority string. The default is
  22893. usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
  22894. is desired for libvirt to deviate from the global default settings.
  22895. Defaults to @samp{"NORMAL"}.
  22896. @end deftypevr
  22897. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  22898. Maximum number of concurrent client connections to allow over all
  22899. sockets combined.
  22900. Defaults to @samp{5000}.
  22901. @end deftypevr
  22902. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  22903. Maximum length of queue of connections waiting to be accepted by the
  22904. daemon. Note, that some protocols supporting retransmission may obey
  22905. this so that a later reattempt at connection succeeds.
  22906. Defaults to @samp{1000}.
  22907. @end deftypevr
  22908. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  22909. Maximum length of queue of accepted but not yet authenticated clients.
  22910. Set this to zero to turn this feature off
  22911. Defaults to @samp{20}.
  22912. @end deftypevr
  22913. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  22914. Number of workers to start up initially.
  22915. Defaults to @samp{5}.
  22916. @end deftypevr
  22917. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  22918. Maximum number of worker threads.
  22919. If the number of active clients exceeds @code{min-workers}, then more
  22920. threads are spawned, up to max_workers limit. Typically you'd want
  22921. max_workers to equal maximum number of clients allowed.
  22922. Defaults to @samp{20}.
  22923. @end deftypevr
  22924. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  22925. Number of priority workers. If all workers from above pool are stuck,
  22926. some calls marked as high priority (notably domainDestroy) can be
  22927. executed in this pool.
  22928. Defaults to @samp{5}.
  22929. @end deftypevr
  22930. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  22931. Total global limit on concurrent RPC calls.
  22932. Defaults to @samp{20}.
  22933. @end deftypevr
  22934. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  22935. Limit on concurrent requests from a single client connection. To avoid
  22936. one client monopolizing the server this should be a small fraction of
  22937. the global max_requests and max_workers parameter.
  22938. Defaults to @samp{5}.
  22939. @end deftypevr
  22940. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  22941. Same as @code{min-workers} but for the admin interface.
  22942. Defaults to @samp{1}.
  22943. @end deftypevr
  22944. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  22945. Same as @code{max-workers} but for the admin interface.
  22946. Defaults to @samp{5}.
  22947. @end deftypevr
  22948. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  22949. Same as @code{max-clients} but for the admin interface.
  22950. Defaults to @samp{5}.
  22951. @end deftypevr
  22952. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  22953. Same as @code{max-queued-clients} but for the admin interface.
  22954. Defaults to @samp{5}.
  22955. @end deftypevr
  22956. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  22957. Same as @code{max-client-requests} but for the admin interface.
  22958. Defaults to @samp{5}.
  22959. @end deftypevr
  22960. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  22961. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  22962. Defaults to @samp{3}.
  22963. @end deftypevr
  22964. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  22965. Logging filters.
  22966. A filter allows to select a different logging level for a given category
  22967. of logs. The format for a filter is one of:
  22968. @itemize @bullet
  22969. @item
  22970. x:name
  22971. @item
  22972. x:+name
  22973. @end itemize
  22974. where @code{name} is a string which is matched against the category
  22975. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  22976. file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
  22977. name in the filter can be a substring of the full category name, in
  22978. order to match multiple similar categories), the optional @samp{"+"}
  22979. prefix tells libvirt to log stack trace for each message matching name,
  22980. and @code{x} is the minimal level where matching messages should be
  22981. logged:
  22982. @itemize @bullet
  22983. @item
  22984. 1: DEBUG
  22985. @item
  22986. 2: INFO
  22987. @item
  22988. 3: WARNING
  22989. @item
  22990. 4: ERROR
  22991. @end itemize
  22992. Multiple filters can be defined in a single filters statement, they just
  22993. need to be separated by spaces.
  22994. Defaults to @samp{"3:remote 4:event"}.
  22995. @end deftypevr
  22996. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  22997. Logging outputs.
  22998. An output is one of the places to save logging information. The format
  22999. for an output can be:
  23000. @table @code
  23001. @item x:stderr
  23002. output goes to stderr
  23003. @item x:syslog:name
  23004. use syslog for the output and use the given name as the ident
  23005. @item x:file:file_path
  23006. output to a file, with the given filepath
  23007. @item x:journald
  23008. output to journald logging system
  23009. @end table
  23010. In all case the x prefix is the minimal level, acting as a filter
  23011. @itemize @bullet
  23012. @item
  23013. 1: DEBUG
  23014. @item
  23015. 2: INFO
  23016. @item
  23017. 3: WARNING
  23018. @item
  23019. 4: ERROR
  23020. @end itemize
  23021. Multiple outputs can be defined, they just need to be separated by
  23022. spaces.
  23023. Defaults to @samp{"3:stderr"}.
  23024. @end deftypevr
  23025. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  23026. Allows usage of the auditing subsystem to be altered
  23027. @itemize @bullet
  23028. @item
  23029. 0: disable all auditing
  23030. @item
  23031. 1: enable auditing, only if enabled on host
  23032. @item
  23033. 2: enable auditing, and exit if disabled on host.
  23034. @end itemize
  23035. Defaults to @samp{1}.
  23036. @end deftypevr
  23037. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  23038. Send audit messages via libvirt logging infrastructure.
  23039. Defaults to @samp{#f}.
  23040. @end deftypevr
  23041. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  23042. Host UUID@. UUID must not have all digits be the same.
  23043. Defaults to @samp{""}.
  23044. @end deftypevr
  23045. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  23046. Source to read host UUID.
  23047. @itemize @bullet
  23048. @item
  23049. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  23050. @item
  23051. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  23052. @end itemize
  23053. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  23054. be generated.
  23055. Defaults to @samp{"smbios"}.
  23056. @end deftypevr
  23057. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  23058. A keepalive message is sent to a client after @code{keepalive_interval}
  23059. seconds of inactivity to check if the client is still responding. If
  23060. set to -1, libvirtd will never send keepalive requests; however clients
  23061. can still send them and the daemon will send responses.
  23062. Defaults to @samp{5}.
  23063. @end deftypevr
  23064. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  23065. Maximum number of keepalive messages that are allowed to be sent to the
  23066. client without getting any response before the connection is considered
  23067. broken.
  23068. In other words, the connection is automatically closed approximately
  23069. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  23070. the last message received from the client. When @code{keepalive-count}
  23071. is set to 0, connections will be automatically closed after
  23072. @code{keepalive-interval} seconds of inactivity without sending any
  23073. keepalive messages.
  23074. Defaults to @samp{5}.
  23075. @end deftypevr
  23076. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  23077. Same as above but for admin interface.
  23078. Defaults to @samp{5}.
  23079. @end deftypevr
  23080. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  23081. Same as above but for admin interface.
  23082. Defaults to @samp{5}.
  23083. @end deftypevr
  23084. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  23085. Timeout for Open vSwitch calls.
  23086. The @code{ovs-vsctl} utility is used for the configuration and its
  23087. timeout option is set by default to 5 seconds to avoid potential
  23088. infinite waits blocking libvirt.
  23089. Defaults to @samp{5}.
  23090. @end deftypevr
  23091. @c %end of autogenerated docs
  23092. @subsubheading Virtlog daemon
  23093. The virtlogd service is a server side daemon component of libvirt that is
  23094. used to manage logs from virtual machine consoles.
  23095. This daemon is not used directly by libvirt client applications, rather it
  23096. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  23097. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  23098. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  23099. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  23100. @deffn {Scheme Variable} virtlog-service-type
  23101. This is the type of the virtlog daemon.
  23102. Its value must be a @code{virtlog-configuration}.
  23103. @lisp
  23104. (service virtlog-service-type
  23105. (virtlog-configuration
  23106. (max-clients 1000)))
  23107. @end lisp
  23108. @end deffn
  23109. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  23110. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  23111. Defaults to @samp{3}.
  23112. @end deftypevr
  23113. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  23114. Logging filters.
  23115. A filter allows to select a different logging level for a given category
  23116. of logs The format for a filter is one of:
  23117. @itemize @bullet
  23118. @item
  23119. x:name
  23120. @item
  23121. x:+name
  23122. @end itemize
  23123. where @code{name} is a string which is matched against the category
  23124. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  23125. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  23126. be a substring of the full category name, in order to match multiple
  23127. similar categories), the optional "+" prefix tells libvirt to log stack
  23128. trace for each message matching name, and @code{x} is the minimal level
  23129. where matching messages should be logged:
  23130. @itemize @bullet
  23131. @item
  23132. 1: DEBUG
  23133. @item
  23134. 2: INFO
  23135. @item
  23136. 3: WARNING
  23137. @item
  23138. 4: ERROR
  23139. @end itemize
  23140. Multiple filters can be defined in a single filters statement, they just
  23141. need to be separated by spaces.
  23142. Defaults to @samp{"3:remote 4:event"}.
  23143. @end deftypevr
  23144. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  23145. Logging outputs.
  23146. An output is one of the places to save logging information The format
  23147. for an output can be:
  23148. @table @code
  23149. @item x:stderr
  23150. output goes to stderr
  23151. @item x:syslog:name
  23152. use syslog for the output and use the given name as the ident
  23153. @item x:file:file_path
  23154. output to a file, with the given filepath
  23155. @item x:journald
  23156. output to journald logging system
  23157. @end table
  23158. In all case the x prefix is the minimal level, acting as a filter
  23159. @itemize @bullet
  23160. @item
  23161. 1: DEBUG
  23162. @item
  23163. 2: INFO
  23164. @item
  23165. 3: WARNING
  23166. @item
  23167. 4: ERROR
  23168. @end itemize
  23169. Multiple outputs can be defined, they just need to be separated by
  23170. spaces.
  23171. Defaults to @samp{"3:stderr"}.
  23172. @end deftypevr
  23173. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  23174. Maximum number of concurrent client connections to allow over all
  23175. sockets combined.
  23176. Defaults to @samp{1024}.
  23177. @end deftypevr
  23178. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  23179. Maximum file size before rolling over.
  23180. Defaults to @samp{2MB}
  23181. @end deftypevr
  23182. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  23183. Maximum number of backup files to keep.
  23184. Defaults to @samp{3}
  23185. @end deftypevr
  23186. @anchor{transparent-emulation-qemu}
  23187. @subsubheading Transparent Emulation with QEMU
  23188. @cindex emulation
  23189. @cindex @code{binfmt_misc}
  23190. @code{qemu-binfmt-service-type} provides support for transparent
  23191. emulation of program binaries built for different architectures---e.g.,
  23192. it allows you to transparently execute an ARMv7 program on an x86_64
  23193. machine. It achieves this by combining the @uref{https://www.qemu.org,
  23194. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  23195. This feature only allows you to emulate GNU/Linux on a different
  23196. architecture, but see below for GNU/Hurd support.
  23197. @defvr {Scheme Variable} qemu-binfmt-service-type
  23198. This is the type of the QEMU/binfmt service for transparent emulation.
  23199. Its value must be a @code{qemu-binfmt-configuration} object, which
  23200. specifies the QEMU package to use as well as the architecture we want to
  23201. emulated:
  23202. @lisp
  23203. (service qemu-binfmt-service-type
  23204. (qemu-binfmt-configuration
  23205. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  23206. @end lisp
  23207. In this example, we enable transparent emulation for the ARM and aarch64
  23208. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  23209. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  23210. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  23211. @end defvr
  23212. @deftp {Data Type} qemu-binfmt-configuration
  23213. This is the configuration for the @code{qemu-binfmt} service.
  23214. @table @asis
  23215. @item @code{platforms} (default: @code{'()})
  23216. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  23217. object} as returned by @code{lookup-qemu-platforms} (see below).
  23218. For example, let's suppose you're on an x86_64 machine and you have this
  23219. service:
  23220. @lisp
  23221. (service qemu-binfmt-service-type
  23222. (qemu-binfmt-configuration
  23223. (platforms (lookup-qemu-platforms "arm"))))
  23224. @end lisp
  23225. You can run:
  23226. @example
  23227. guix build -s armhf-linux inkscape
  23228. @end example
  23229. @noindent
  23230. and it will build Inkscape for ARMv7 @emph{as if it were a native
  23231. build}, transparently using QEMU to emulate the ARMv7 CPU@. Pretty handy
  23232. if you'd like to test a package build for an architecture you don't have
  23233. access to!
  23234. @item @code{qemu} (default: @code{qemu})
  23235. The QEMU package to use.
  23236. @end table
  23237. @end deftp
  23238. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  23239. Return the list of QEMU platform objects corresponding to
  23240. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  23241. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  23242. @code{"mips64el"}, and so on.
  23243. @end deffn
  23244. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  23245. Return true if @var{obj} is a platform object.
  23246. @end deffn
  23247. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  23248. Return the name of @var{platform}---a string such as @code{"arm"}.
  23249. @end deffn
  23250. @subsubheading The Hurd in a Virtual Machine
  23251. @cindex @code{hurd}
  23252. @cindex the Hurd
  23253. @cindex childhurd
  23254. Service @code{hurd-vm} provides support for running GNU/Hurd in a
  23255. virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
  23256. to be used on GNU/Linux and the given GNU/Hurd operating system
  23257. configuration is cross-compiled. The virtual machine is a Shepherd
  23258. service that can be referred to by the names @code{hurd-vm} and
  23259. @code{childhurd} and be controlled with commands such as:
  23260. @example
  23261. herd start hurd-vm
  23262. herd stop childhurd
  23263. @end example
  23264. When the service is running, you can view its console by connecting to
  23265. it with a VNC client, for example with:
  23266. @example
  23267. guix environment --ad-hoc tigervnc-client -- \
  23268. vncviewer localhost:5900
  23269. @end example
  23270. The default configuration (see @code{hurd-vm-configuration} below)
  23271. spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
  23272. (the virtual machine emulator) redirects to port 10222 on the host.
  23273. Thus, you can connect over SSH to the childhurd with:
  23274. @example
  23275. ssh root@@localhost -p 10022
  23276. @end example
  23277. The childhurd is volatile and stateless: it starts with a fresh root
  23278. file system every time you restart it. By default though, all the files
  23279. under @file{/etc/childhurd} on the host are copied as is to the root
  23280. file system of the childhurd when it boots. This allows you to
  23281. initialize ``secrets'' inside the VM: SSH host keys, authorized
  23282. substitute keys, and so on---see the explanation of @code{secret-root}
  23283. below.
  23284. @defvr {Scheme Variable} hurd-vm-service-type
  23285. This is the type of the Hurd in a Virtual Machine service. Its value
  23286. must be a @code{hurd-vm-configuration} object, which specifies the
  23287. operating system (@pxref{operating-system Reference}) and the disk size
  23288. for the Hurd Virtual Machine, the QEMU package to use as well as the
  23289. options for running it.
  23290. For example:
  23291. @lisp
  23292. (service hurd-vm-service-type
  23293. (hurd-vm-configuration
  23294. (disk-size (* 5000 (expt 2 20))) ;5G
  23295. (memory-size 1024))) ;1024MiB
  23296. @end lisp
  23297. would create a disk image big enough to build GNU@tie{}Hello, with some
  23298. extra memory.
  23299. @end defvr
  23300. @deftp {Data Type} hurd-vm-configuration
  23301. The data type representing the configuration for
  23302. @code{hurd-vm-service-type}.
  23303. @table @asis
  23304. @item @code{os} (default: @var{%hurd-vm-operating-system})
  23305. The operating system to instantiate. This default is bare-bones with a
  23306. permissive OpenSSH secure shell daemon listening on port 2222
  23307. (@pxref{Networking Services, @code{openssh-service-type}}).
  23308. @item @code{qemu} (default: @code{qemu-minimal})
  23309. The QEMU package to use.
  23310. @item @code{image} (default: @var{hurd-vm-disk-image})
  23311. The procedure used to build the disk-image built from this
  23312. configuration.
  23313. @item @code{disk-size} (default: @code{'guess})
  23314. The size of the disk image.
  23315. @item @code{memory-size} (default: @code{512})
  23316. The memory size of the Virtual Machine in mebibytes.
  23317. @item @code{options} (default: @code{'("--snapshot")})
  23318. The extra options for running QEMU.
  23319. @item @code{id} (default: @code{#f})
  23320. If set, a non-zero positive integer used to parameterize Childhurd
  23321. instances. It is appended to the service's name,
  23322. e.g. @code{childhurd1}.
  23323. @item @code{net-options} (default: @var{hurd-vm-net-options})
  23324. The procedure used to produce the list of QEMU networking options.
  23325. By default, it produces
  23326. @lisp
  23327. '("--device" "rtl8139,netdev=net0"
  23328. "--netdev" (string-append
  23329. "user,id=net0,"
  23330. "hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004,"
  23331. "hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222,"
  23332. "hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900"))
  23333. @end lisp
  23334. with forwarded ports:
  23335. @example
  23336. @var{secrets-port}: @code{(+ 11004 (* 1000 @var{ID}))}
  23337. @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
  23338. @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
  23339. @end example
  23340. @item @code{secret-root} (default: @file{/etc/childhurd})
  23341. The root directory with out-of-band secrets to be installed into the
  23342. childhurd once it runs. Childhurds are volatile which means that on
  23343. every startup, secrets such as the SSH host keys and Guix signing key
  23344. are recreated.
  23345. If the @file{/etc/childhurd} directory does not exist, the
  23346. @code{secret-service} running in the Childhurd will be sent an empty
  23347. list of secrets.
  23348. By default, the service automatically populates @file{/etc/childhurd}
  23349. with the following non-volatile secrets, unless they already exist:
  23350. @example
  23351. /etc/childhurd/etc/guix/acl
  23352. /etc/childhurd/etc/guix/signing-key.pub
  23353. /etc/childhurd/etc/guix/signing-key.sec
  23354. /etc/childhurd/etc/ssh/ssh_host_ed25519_key
  23355. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
  23356. /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
  23357. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
  23358. @end example
  23359. These files are automatically sent to the guest Hurd VM when it boots,
  23360. including permissions.
  23361. @cindex childhurd, offloading
  23362. @cindex Hurd, offloading
  23363. Having these files in place means that only a couple of things are
  23364. missing to allow the host to offload @code{i586-gnu} builds to the
  23365. childhurd:
  23366. @enumerate
  23367. @item
  23368. Authorizing the childhurd's key on the host so that the host accepts
  23369. build results coming from the childhurd, which can be done like so:
  23370. @example
  23371. guix archive --authorize < \
  23372. /etc/childhurd/etc/guix/signing-key.pub
  23373. @end example
  23374. @item
  23375. Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
  23376. Offload Setup}).
  23377. @end enumerate
  23378. We're working towards making that happen automatically---get in touch
  23379. with us at @email{guix-devel@@gnu.org} to discuss it!
  23380. @end table
  23381. @end deftp
  23382. Note that by default the VM image is volatile, i.e., once stopped the
  23383. contents are lost. If you want a stateful image instead, override the
  23384. configuration's @code{image} and @code{options} without
  23385. the @code{--snapshot} flag using something along these lines:
  23386. @lisp
  23387. (service hurd-vm-service-type
  23388. (hurd-vm-configuration
  23389. (image (const "/out/of/store/writable/hurd.img"))
  23390. (options '())))
  23391. @end lisp
  23392. @subsubheading Ganeti
  23393. @cindex ganeti
  23394. @quotation Note
  23395. This service is considered experimental. Configuration options may be changed
  23396. in a backwards-incompatible manner, and not all features have been thorougly
  23397. tested. Users of this service are encouraged to share their experience at
  23398. @email{guix-devel@@gnu.org}.
  23399. @end quotation
  23400. Ganeti is a virtual machine management system. It is designed to keep virtual
  23401. machines running on a cluster of servers even in the event of hardware failures,
  23402. and to make maintenance and recovery tasks easy. It consists of multiple
  23403. services which are described later in this section. In addition to the Ganeti
  23404. service, you will need the OpenSSH service (@pxref{Networking Services,
  23405. @code{openssh-service-type}}), and update the @file{/etc/hosts} file
  23406. (@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
  23407. and address (or use a DNS server).
  23408. All nodes participating in a Ganeti cluster should have the same Ganeti and
  23409. @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
  23410. cluster node that supports multiple storage backends, and installs the
  23411. @code{debootstrap} and @code{guix} @dfn{OS providers}:
  23412. @lisp
  23413. (use-package-modules virtualization)
  23414. (use-service-modules base ganeti networking ssh)
  23415. (operating-system
  23416. ;; @dots{}
  23417. (host-name "node1")
  23418. (hosts-file (plain-file "hosts" (format #f "
  23419. 127.0.0.1 localhost
  23420. ::1 localhost
  23421. 192.168.1.200 ganeti.example.com
  23422. 192.168.1.201 node1.example.com node1
  23423. 192.168.1.202 node2.example.com node2
  23424. ")))
  23425. ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
  23426. ;; in order to use the "plain", "drbd" and "rbd" storage backends.
  23427. (packages (append (map specification->package
  23428. '("qemu" "lvm2" "drbd-utils" "ceph"
  23429. ;; Add the debootstrap and guix OS providers.
  23430. "ganeti-instance-guix" "ganeti-instance-debootstrap"))
  23431. %base-packages))
  23432. (services
  23433. (append (list (static-networking-service "eth0" "192.168.1.201"
  23434. #:netmask "255.255.255.0"
  23435. #:gateway "192.168.1.254"
  23436. #:name-servers '("192.168.1.252"
  23437. "192.168.1.253"))
  23438. ;; Ganeti uses SSH to communicate between nodes.
  23439. (service openssh-service-type
  23440. (openssh-configuration
  23441. (permit-root-login 'prohibit-password)))
  23442. (service ganeti-service-type
  23443. (ganeti-configuration
  23444. ;; This list specifies allowed file system paths
  23445. ;; for storing virtual machine images.
  23446. (file-storage-paths '("/srv/ganeti/file-storage"))
  23447. ;; This variable configures a single "variant" for
  23448. ;; both Debootstrap and Guix that works with KVM.
  23449. (os %default-ganeti-os))))
  23450. %base-services)))
  23451. @end lisp
  23452. Users are advised to read the
  23453. @url{http://docs.ganeti.org/ganeti/master/html/admin.html,Ganeti
  23454. administrators guide} to learn about the various cluster options and
  23455. day-to-day operations. There is also a
  23456. @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
  23457. describing how to configure and initialize a small cluster.
  23458. @defvr {Scheme Variable} ganeti-service-type
  23459. This is a service type that includes all the various services that Ganeti
  23460. nodes should run.
  23461. Its value is a @code{ganeti-configuration} object that defines the package
  23462. to use for CLI operations, as well as configuration for the various daemons.
  23463. Allowed file storage paths and available guest operating systems are also
  23464. configured through this data type.
  23465. @end defvr
  23466. @deftp {Data Type} ganeti-configuration
  23467. The @code{ganeti} service takes the following configuration options:
  23468. @table @asis
  23469. @item @code{ganeti} (default: @code{ganeti})
  23470. The @code{ganeti} package to use. It will be installed to the system profile
  23471. and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
  23472. that the value specified here does not affect the other services as each refer
  23473. to a specific @code{ganeti} package (see below).
  23474. @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
  23475. @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
  23476. @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
  23477. @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
  23478. @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
  23479. @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
  23480. @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
  23481. @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
  23482. @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
  23483. @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
  23484. These options control the various daemons and cron jobs that are distributed
  23485. with Ganeti. The possible values for these are described in detail below.
  23486. To override a setting, you must use the configuration type for that service:
  23487. @lisp
  23488. (service ganeti-service-type
  23489. (ganeti-configuration
  23490. (rapi-configuration
  23491. (ganeti-rapi-configuration
  23492. (interface "eth1"))))
  23493. (watcher-configuration
  23494. (ganeti-watcher-configuration
  23495. (rapi-ip "10.0.0.1"))))
  23496. @end lisp
  23497. @item @code{file-storage-paths} (default: @code{'()})
  23498. List of allowed directories for file storage backend.
  23499. @item @code{os} (default: @code{%default-ganeti-os})
  23500. List of @code{<ganeti-os>} records.
  23501. @end table
  23502. In essence @code{ganeti-service-type} is shorthand for declaring each service
  23503. individually:
  23504. @lisp
  23505. (service ganeti-noded-service-type)
  23506. (service ganeti-confd-service-type)
  23507. (service ganeti-wconfd-service-type)
  23508. (service ganeti-luxid-service-type)
  23509. (service ganeti-kvmd-service-type)
  23510. (service ganeti-mond-service-type)
  23511. (service ganeti-metad-service-type)
  23512. (service ganeti-watcher-service-type)
  23513. (service ganeti-cleaner-service-type)
  23514. @end lisp
  23515. Plus a service extension for @code{etc-service-type} that configures the file
  23516. storage backend and OS variants.
  23517. @end deftp
  23518. @deftp {Data Type} ganeti-os
  23519. This data type is suitable for passing to the @code{os} parameter of
  23520. @code{ganeti-configuration}. It takes the following parameters:
  23521. @table @asis
  23522. @item @code{name}
  23523. The name for this OS provider. It is only used to specify where the
  23524. configuration ends up. Setting it to ``debootstrap'' will create
  23525. @file{/etc/ganeti/instance-debootstrap}.
  23526. @item @code{extension}
  23527. The file extension for variants of this OS type. For example
  23528. @file{.conf} or @file{.scm}.
  23529. @item @code{variants} (default: @code{'()})
  23530. List of @code{ganeti-os-variant} objects for this OS.
  23531. @end table
  23532. @end deftp
  23533. @deftp {Data Type} ganeti-os-variant
  23534. This is the data type for a Ganeti OS variant. It takes the following
  23535. parameters:
  23536. @table @asis
  23537. @item @code{name}
  23538. The name of this variant.
  23539. @item @code{configuration}
  23540. A configuration file for this variant.
  23541. @end table
  23542. @end deftp
  23543. @defvr {Scheme Variable} %default-debootstrap-hooks
  23544. This variable contains hooks to configure networking and the GRUB bootloader.
  23545. @end defvr
  23546. @defvr {Scheme Variable} %default-debootstrap-extra-pkgs
  23547. This variable contains a list of packages suitable for a fully-virtualized guest.
  23548. @end defvr
  23549. @deftp {Data Type} debootstrap-configuration
  23550. This data type creates configuration files suitable for the debootstrap OS provider.
  23551. @table @asis
  23552. @item @code{hooks} (default: @code{%default-debootstrap-hooks})
  23553. When not @code{#f}, this must be a G-expression that specifies a directory with
  23554. scripts that will run when the OS is installed. It can also be a list of
  23555. @code{(name . file-like)} pairs. For example:
  23556. @lisp
  23557. `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
  23558. @end lisp
  23559. That will create a directory with one executable named @code{99-hello-world}
  23560. and run it every time this variant is installed. If set to @code{#f}, hooks
  23561. in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
  23562. @item @code{proxy} (default: @code{#f})
  23563. Optional HTTP proxy to use.
  23564. @item @code{mirror} (default: @code{#f})
  23565. The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
  23566. The default varies depending on the distribution.
  23567. @item @code{arch} (default: @code{#f})
  23568. The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
  23569. on an AArch64 host. Default is to use the current system architecture.
  23570. @item @code{suite} (default: @code{"stable"})
  23571. When set, this must be a Debian distribution ``suite'' such as @code{buster}
  23572. or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
  23573. @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
  23574. List of extra packages that will get installed by dpkg in addition
  23575. to the minimal system.
  23576. @item @code{components} (default: @code{#f})
  23577. When set, must be a list of Debian repository ``components''. For example
  23578. @code{'("main" "contrib")}.
  23579. @item @code{generate-cache?} (default: @code{#t})
  23580. Whether to automatically cache the generated debootstrap archive.
  23581. @item @code{clean-cache} (default: @code{14})
  23582. Discard the cache after this amount of days. Use @code{#f} to never
  23583. clear the cache.
  23584. @item @code{partition-style} (default: @code{'msdos})
  23585. The type of partition to create. When set, it must be one of
  23586. @code{'msdos}, @code{'none} or a string.
  23587. @item @code{partition-alignment} (default: @code{2048})
  23588. Alignment of the partition in sectors.
  23589. @end table
  23590. @end deftp
  23591. @deffn {Scheme Procedure} debootstrap-variant @var{name} @var{configuration}
  23592. This is a helper procedure that creates a @code{ganeti-os-variant} record. It
  23593. takes two parameters: a name and a @code{debootstrap-configuration} object.
  23594. @end deffn
  23595. @deffn {Scheme Procedure} debootstrap-os @var{variants}@dots{}
  23596. This is a helper procedure that creates a @code{ganeti-os} record. It takes
  23597. a list of variants created with @code{debootstrap-variant}.
  23598. @end deffn
  23599. @deffn {Scheme Procedure} guix-variant @var{name} @var{configuration}
  23600. This is a helper procedure that creates a @code{ganeti-os-variant} record for
  23601. use with the Guix OS provider. It takes a name and a G-expression that returns
  23602. a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
  23603. Guix System configuration.
  23604. @end deffn
  23605. @deffn {Scheme Procedure} guix-os @var{variants}@dots{}
  23606. This is a helper procedure that creates a @code{ganeti-os} record. It
  23607. takes a list of variants produced by @code{guix-variant}.
  23608. @end deffn
  23609. @defvr {Scheme Variable} %default-debootstrap-variants
  23610. This is a convenience variable to make the debootstrap provider work
  23611. ``out of the box'' without users having to declare variants manually. It
  23612. contains a single debootstrap variant with the default configuration:
  23613. @lisp
  23614. (list (debootstrap-variant
  23615. "default"
  23616. (debootstrap-configuration)))
  23617. @end lisp
  23618. @end defvr
  23619. @defvr {Scheme Variable} %default-guix-variants
  23620. This is a convenience variable to make the Guix OS provider work without
  23621. additional configuration. It creates a virtual machine that has an SSH
  23622. server, a serial console, and authorizes the Ganeti hosts SSH keys.
  23623. @lisp
  23624. (list (guix-variant
  23625. "default"
  23626. (file-append ganeti-instance-guix
  23627. "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
  23628. @end lisp
  23629. @end defvr
  23630. Users can implement support for OS providers unbeknownst to Guix by extending
  23631. the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
  23632. For example:
  23633. @lisp
  23634. (ganeti-os
  23635. (name "custom")
  23636. (extension ".conf")
  23637. (variants
  23638. (list (ganeti-os-variant
  23639. (name "foo")
  23640. (configuration (plain-file "bar" "this is fine"))))))
  23641. @end lisp
  23642. That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
  23643. to a file in the store with contents @code{this is fine}. It also creates
  23644. @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
  23645. Obviously this may not work for all OS providers out there. If you find the
  23646. interface limiting, please reach out to @email{guix-devel@@gnu.org}.
  23647. The rest of this section documents the various services that are included by
  23648. @code{ganeti-service-type}.
  23649. @defvr {Scheme Variable} ganeti-noded-service-type
  23650. @command{ganeti-noded} is the daemon responsible for node-specific functions
  23651. within the Ganeti system. The value of this service must be a
  23652. @code{ganeti-noded-configuration} object.
  23653. @end defvr
  23654. @deftp {Data Type} ganeti-noded-configuration
  23655. This is the configuration for the @code{ganeti-noded} service.
  23656. @table @asis
  23657. @item @code{ganeti} (default: @code{ganeti})
  23658. The @code{ganeti} package to use for this service.
  23659. @item @code{port} (default: @code{1811})
  23660. The TCP port on which the node daemon listens for network requests.
  23661. @item @code{address} (default: @code{"0.0.0.0"})
  23662. The network address that the daemon will bind to. The default address means
  23663. bind to all available addresses.
  23664. @item @code{interface} (default: @code{#f})
  23665. When this is set, it must be a specific network interface (e.g.@: @code{eth0})
  23666. that the daemon will bind to.
  23667. @item @code{max-clients} (default: @code{20})
  23668. This sets a limit on the maximum number of simultaneous client connections
  23669. that the daemon will handle. Connections above this count are accepted, but
  23670. no responses will be sent until enough connections have closed.
  23671. @item @code{ssl?} (default: @code{#t})
  23672. Whether to use SSL/TLS to encrypt network communications. The certificate
  23673. is automatically provisioned by the cluster and can be rotated with
  23674. @command{gnt-cluster renew-crypto}.
  23675. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  23676. This can be used to provide a specific encryption key for TLS communications.
  23677. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  23678. This can be used to provide a specific certificate for TLS communications.
  23679. @item @code{debug?} (default: @code{#f})
  23680. When true, the daemon performs additional logging for debugging purposes.
  23681. Note that this will leak encryption details to the log files, use with caution.
  23682. @end table
  23683. @end deftp
  23684. @defvr {Scheme Variable} ganeti-confd-service-type
  23685. @command{ganeti-confd} answers queries related to the configuration of a
  23686. Ganeti cluster. The purpose of this daemon is to have a highly available
  23687. and fast way to query cluster configuration values. It is automatically
  23688. active on all @dfn{master candidates}. The value of this service must be a
  23689. @code{ganeti-confd-configuration} object.
  23690. @end defvr
  23691. @deftp {Data Type} ganeti-confd-configuration
  23692. This is the configuration for the @code{ganeti-confd} service.
  23693. @table @asis
  23694. @item @code{ganeti} (default: @code{ganeti})
  23695. The @code{ganeti} package to use for this service.
  23696. @item @code{port} (default: @code{1814})
  23697. The UDP port on which to listen for network requests.
  23698. @item @code{address} (default: @code{"0.0.0.0"})
  23699. Network address that the daemon will bind to.
  23700. @item @code{debug?} (default: @code{#f})
  23701. When true, the daemon performs additional logging for debugging purposes.
  23702. @end table
  23703. @end deftp
  23704. @defvr {Scheme Variable} ganeti-wconfd-service-type
  23705. @command{ganeti-wconfd} is the daemon that has authoritative knowledge
  23706. about the cluster configuration and is the only entity that can accept
  23707. changes to it. All jobs that need to modify the configuration will do so
  23708. by sending appropriate requests to this daemon. It only runs on the
  23709. @dfn{master node} and will automatically disable itself on other nodes.
  23710. The value of this service must be a
  23711. @code{ganeti-wconfd-configuration} object.
  23712. @end defvr
  23713. @deftp {Data Type} ganeti-wconfd-configuration
  23714. This is the configuration for the @code{ganeti-wconfd} service.
  23715. @table @asis
  23716. @item @code{ganeti} (default: @code{ganeti})
  23717. The @code{ganeti} package to use for this service.
  23718. @item @code{no-voting?} (default: @code{#f})
  23719. The daemon will refuse to start if the majority of cluster nodes does not
  23720. agree that it is running on the master node. Set to @code{#t} to start
  23721. even if a quorum can not be reached (dangerous, use with caution).
  23722. @item @code{debug?} (default: @code{#f})
  23723. When true, the daemon performs additional logging for debugging purposes.
  23724. @end table
  23725. @end deftp
  23726. @defvr {Scheme Variable} ganeti-luxid-service-type
  23727. @command{ganeti-luxid} is a daemon used to answer queries related to the
  23728. configuration and the current live state of a Ganeti cluster. Additionally,
  23729. it is the authoritative daemon for the Ganeti job queue. Jobs can be
  23730. submitted via this daemon and it schedules and starts them.
  23731. It takes a @code{ganeti-luxid-configuration} object.
  23732. @end defvr
  23733. @deftp {Data Type} ganeti-luxid-configuration
  23734. This is the configuration for the @code{ganeti-wconfd} service.
  23735. @table @asis
  23736. @item @code{ganeti} (default: @code{ganeti})
  23737. The @code{ganeti} package to use for this service.
  23738. @item @code{no-voting?} (default: @code{#f})
  23739. The daemon will refuse to start if it cannot verify that the majority of
  23740. cluster nodes believes that it is running on the master node. Set to
  23741. @code{#t} to ignore such checks and start anyway (this can be dangerous).
  23742. @item @code{debug?} (default: @code{#f})
  23743. When true, the daemon performs additional logging for debugging purposes.
  23744. @end table
  23745. @end deftp
  23746. @defvr {Scheme Variable} ganeti-rapi-service-type
  23747. @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
  23748. the master node and can be used to perform cluster actions programmatically
  23749. via a JSON-based RPC protocol.
  23750. Most query operations are allowed without authentication (unless
  23751. @var{require-authentication?} is set), whereas write operations require
  23752. explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
  23753. the @url{http://docs.ganeti.org/ganeti/master/html/rapi.html, Ganeti Remote
  23754. API documentation} for more information.
  23755. The value of this service must be a @code{ganeti-rapi-configuration} object.
  23756. @end defvr
  23757. @deftp {Data Type} ganeti-rapi-configuration
  23758. This is the configuration for the @code{ganeti-rapi} service.
  23759. @table @asis
  23760. @item @code{ganeti} (default: @code{ganeti})
  23761. The @code{ganeti} package to use for this service.
  23762. @item @code{require-authentication?} (default: @code{#f})
  23763. Whether to require authentication even for read-only operations.
  23764. @item @code{port} (default: @code{5080})
  23765. The TCP port on which to listen to API requests.
  23766. @item @code{address} (default: @code{"0.0.0.0"})
  23767. The network address that the service will bind to. By default it listens
  23768. on all configured addresses.
  23769. @item @code{interface} (default: @code{#f})
  23770. When set, it must specify a specific network interface such as @code{eth0}
  23771. that the daemon will bind to.
  23772. @item @code{max-clients} (default: @code{20})
  23773. The maximum number of simultaneous client requests to handle. Further
  23774. connections are allowed, but no responses are sent until enough connections
  23775. have closed.
  23776. @item @code{ssl?} (default: @code{#t})
  23777. Whether to use SSL/TLS encryption on the RAPI port.
  23778. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  23779. This can be used to provide a specific encryption key for TLS communications.
  23780. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  23781. This can be used to provide a specific certificate for TLS communications.
  23782. @item @code{debug?} (default: @code{#f})
  23783. When true, the daemon performs additional logging for debugging purposes.
  23784. Note that this will leak encryption details to the log files, use with caution.
  23785. @end table
  23786. @end deftp
  23787. @defvr {Scheme Variable} ganeti-kvmd-service-type
  23788. @command{ganeti-kvmd} is responsible for determining whether a given KVM
  23789. instance was shut down by an administrator or a user. Normally Ganeti will
  23790. restart an instance that was not stopped through Ganeti itself. If the
  23791. cluster option @code{user_shutdown} is true, this daemon monitors the
  23792. @code{QMP} socket provided by QEMU and listens for shutdown events, and
  23793. marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
  23794. it shuts down gracefully by itself.
  23795. It takes a @code{ganeti-kvmd-configuration} object.
  23796. @end defvr
  23797. @deftp {Data Type} ganeti-kvmd-configuration
  23798. @table @asis
  23799. @item @code{ganeti} (default: @code{ganeti})
  23800. The @code{ganeti} package to use for this service.
  23801. @item @code{debug?} (default: @code{#f})
  23802. When true, the daemon performs additional logging for debugging purposes.
  23803. @end table
  23804. @end deftp
  23805. @defvr {Scheme Variable} ganeti-mond-service-type
  23806. @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
  23807. functionality. It is responsible for running data collectors and publish the
  23808. collected information through a HTTP interface.
  23809. It takes a @code{ganeti-mond-configuration} object.
  23810. @end defvr
  23811. @deftp {Data Type} ganeti-mond-configuration
  23812. @table @asis
  23813. @item @code{ganeti} (default: @code{ganeti})
  23814. The @code{ganeti} package to use for this service.
  23815. @item @code{port} (default: @code{1815})
  23816. The port on which the daemon will listen.
  23817. @item @code{address} (default: @code{"0.0.0.0"})
  23818. The network address that the daemon will bind to. By default it binds to all
  23819. available interfaces.
  23820. @item @code{debug?} (default: @code{#f})
  23821. When true, the daemon performs additional logging for debugging purposes.
  23822. @end table
  23823. @end deftp
  23824. @defvr {Scheme Variable} ganeti-metad-service-type
  23825. @command{ganeti-metad} is an optional daemon that can be used to provide
  23826. information about the cluster to instances or OS install scripts.
  23827. It takes a @code{ganeti-metad-configuration} object.
  23828. @end defvr
  23829. @deftp {Data Type} ganeti-metad-configuration
  23830. @table @asis
  23831. @item @code{ganeti} (default: @code{ganeti})
  23832. The @code{ganeti} package to use for this service.
  23833. @item @code{port} (default: @code{80})
  23834. The port on which the daemon will listen.
  23835. @item @code{address} (default: @code{#f})
  23836. If set, the daemon will bind to this address only. If left unset, the behavior
  23837. depends on the cluster configuration.
  23838. @item @code{debug?} (default: @code{#f})
  23839. When true, the daemon performs additional logging for debugging purposes.
  23840. @end table
  23841. @end deftp
  23842. @defvr {Scheme Variable} ganeti-watcher-service-type
  23843. @command{ganeti-watcher} is a script designed to run periodically and ensure
  23844. the health of a cluster. It will automatically restart instances that have
  23845. stopped without Ganeti's consent, and repairs DRBD links in case a node has
  23846. rebooted. It also archives old cluster jobs and restarts Ganeti daemons
  23847. that are not running. If the cluster parameter @code{ensure_node_health}
  23848. is set, the watcher will also shutdown instances and DRBD devices if the
  23849. node it is running on is declared offline by known master candidates.
  23850. It can be paused on all nodes with @command{gnt-cluster watcher pause}.
  23851. The service takes a @code{ganeti-watcher-configuration} object.
  23852. @end defvr
  23853. @deftp {Data Type} ganeti-watcher-configuration
  23854. @table @asis
  23855. @item @code{ganeti} (default: @code{ganeti})
  23856. The @code{ganeti} package to use for this service.
  23857. @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
  23858. How often to run the script. The default is every five minutes.
  23859. @item @code{rapi-ip} (default: @code{#f})
  23860. This option needs to be specified only if the RAPI daemon is configured to use
  23861. a particular interface or address. By default the cluster address is used.
  23862. @item @code{job-age} (default: @code{(* 6 3600)})
  23863. Archive cluster jobs older than this age, specified in seconds. The default
  23864. is 6 hours. This keeps @command{gnt-job list} manageable.
  23865. @item @code{verify-disks?} (default: @code{#t})
  23866. If this is @code{#f}, the watcher will not try to repair broken DRBD links
  23867. automatically. Administrators will need to use @command{gnt-cluster verify-disks}
  23868. manually instead.
  23869. @item @code{debug?} (default: @code{#f})
  23870. When @code{#t}, the script performs additional logging for debugging purposes.
  23871. @end table
  23872. @end deftp
  23873. @defvr {Scheme Variable} ganeti-cleaner-service-type
  23874. @command{ganeti-cleaner} is a script designed to run periodically and remove
  23875. old files from the cluster. This service type controls two @dfn{cron jobs}:
  23876. one intended for the master node that permanently purges old cluster jobs,
  23877. and one intended for every node that removes expired X509 certificates, keys,
  23878. and outdated @command{ganeti-watcher} information. Like all Ganeti services,
  23879. it is safe to include even on non-master nodes as it will disable itself as
  23880. necessary.
  23881. It takes a @code{ganeti-cleaner-configuration} object.
  23882. @end defvr
  23883. @deftp {Data Type} ganeti-cleaner-configuration
  23884. @table @asis
  23885. @item @code{ganeti} (default: @code{ganeti})
  23886. The @code{ganeti} package to use for the @command{gnt-cleaner} command.
  23887. @item @code{master-schedule} (default: @code{"45 1 * * *"})
  23888. How often to run the master cleaning job. The default is once per day, at
  23889. 01:45:00.
  23890. @item @code{node-schedule} (default: @code{"45 2 * * *"})
  23891. How often to run the node cleaning job. The default is once per day, at
  23892. 02:45:00.
  23893. @end table
  23894. @end deftp
  23895. @node Version Control Services
  23896. @subsection Version Control Services
  23897. The @code{(gnu services version-control)} module provides a service to
  23898. allow remote access to local Git repositories. There are three options:
  23899. the @code{git-daemon-service}, which provides access to repositories via
  23900. the @code{git://} unsecured TCP-based protocol, extending the
  23901. @code{nginx} web server to proxy some requests to
  23902. @code{git-http-backend}, or providing a web interface with
  23903. @code{cgit-service-type}.
  23904. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  23905. Return a service that runs @command{git daemon}, a simple TCP server to
  23906. expose repositories over the Git protocol for anonymous access.
  23907. The optional @var{config} argument should be a
  23908. @code{<git-daemon-configuration>} object, by default it allows read-only
  23909. access to exported@footnote{By creating the magic file
  23910. @file{git-daemon-export-ok} in the repository directory.} repositories under
  23911. @file{/srv/git}.
  23912. @end deffn
  23913. @deftp {Data Type} git-daemon-configuration
  23914. Data type representing the configuration for @code{git-daemon-service}.
  23915. @table @asis
  23916. @item @code{package} (default: @code{git})
  23917. Package object of the Git distributed version control system.
  23918. @item @code{export-all?} (default: @code{#f})
  23919. Whether to allow access for all Git repositories, even if they do not
  23920. have the @file{git-daemon-export-ok} file.
  23921. @item @code{base-path} (default: @file{/srv/git})
  23922. Whether to remap all the path requests as relative to the given path.
  23923. If you run @command{git daemon} with @code{(base-path "/srv/git")} on
  23924. @samp{example.com}, then if you later try to pull
  23925. @indicateurl{git://example.com/hello.git}, git daemon will interpret the
  23926. path as @file{/srv/git/hello.git}.
  23927. @item @code{user-path} (default: @code{#f})
  23928. Whether to allow @code{~user} notation to be used in requests. When
  23929. specified with empty string, requests to
  23930. @indicateurl{git://host/~alice/foo} is taken as a request to access
  23931. @code{foo} repository in the home directory of user @code{alice}. If
  23932. @code{(user-path "@var{path}")} is specified, the same request is taken
  23933. as a request to access @file{@var{path}/foo} repository in the home
  23934. directory of user @code{alice}.
  23935. @item @code{listen} (default: @code{'()})
  23936. Whether to listen on specific IP addresses or hostnames, defaults to
  23937. all.
  23938. @item @code{port} (default: @code{#f})
  23939. Whether to listen on an alternative port, which defaults to 9418.
  23940. @item @code{whitelist} (default: @code{'()})
  23941. If not empty, only allow access to this list of directories.
  23942. @item @code{extra-options} (default: @code{'()})
  23943. Extra options will be passed to @command{git daemon}, please run
  23944. @command{man git-daemon} for more information.
  23945. @end table
  23946. @end deftp
  23947. The @code{git://} protocol lacks authentication. When you pull from a
  23948. repository fetched via @code{git://}, you don't know whether the data you
  23949. receive was modified or is even coming from the specified host, and your
  23950. connection is subject to eavesdropping. It's better to use an authenticated
  23951. and encrypted transport, such as @code{https}. Although Git allows you
  23952. to serve repositories using unsophisticated file-based web servers,
  23953. there is a faster protocol implemented by the @code{git-http-backend}
  23954. program. This program is the back-end of a proper Git web service. It
  23955. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  23956. on running the necessary @code{fcgiwrap} daemon.
  23957. Guix has a separate configuration data type for serving Git repositories
  23958. over HTTP.
  23959. @deftp {Data Type} git-http-configuration
  23960. Data type representing the configuration for a future
  23961. @code{git-http-service-type}; can currently be used to configure Nginx
  23962. through @code{git-http-nginx-location-configuration}.
  23963. @table @asis
  23964. @item @code{package} (default: @var{git})
  23965. Package object of the Git distributed version control system.
  23966. @item @code{git-root} (default: @file{/srv/git})
  23967. Directory containing the Git repositories to expose to the world.
  23968. @item @code{export-all?} (default: @code{#f})
  23969. Whether to expose access for all Git repositories in @var{git-root},
  23970. even if they do not have the @file{git-daemon-export-ok} file.
  23971. @item @code{uri-path} (default: @samp{/git/})
  23972. Path prefix for Git access. With the default @samp{/git/} prefix, this
  23973. will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
  23974. @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  23975. with this prefix are not passed on to this Git instance.
  23976. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  23977. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  23978. Services}.
  23979. @end table
  23980. @end deftp
  23981. There is no @code{git-http-service-type}, currently; instead you can
  23982. create an @code{nginx-location-configuration} from a
  23983. @code{git-http-configuration} and then add that location to a web
  23984. server.
  23985. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  23986. [config=(git-http-configuration)]
  23987. Compute an @code{nginx-location-configuration} that corresponds to the
  23988. given Git http configuration. An example nginx service definition to
  23989. serve the default @file{/srv/git} over HTTPS might be:
  23990. @lisp
  23991. (service nginx-service-type
  23992. (nginx-configuration
  23993. (server-blocks
  23994. (list
  23995. (nginx-server-configuration
  23996. (listen '("443 ssl"))
  23997. (server-name "git.my-host.org")
  23998. (ssl-certificate
  23999. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  24000. (ssl-certificate-key
  24001. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  24002. (locations
  24003. (list
  24004. (git-http-nginx-location-configuration
  24005. (git-http-configuration (uri-path "/"))))))))))
  24006. @end lisp
  24007. This example assumes that you are using Let's Encrypt to get your TLS
  24008. certificate. @xref{Certificate Services}. The default @code{certbot}
  24009. service will redirect all HTTP traffic on @code{git.my-host.org} to
  24010. HTTPS@. You will also need to add an @code{fcgiwrap} proxy to your
  24011. system services. @xref{Web Services}.
  24012. @end deffn
  24013. @subsubheading Cgit Service
  24014. @cindex Cgit service
  24015. @cindex Git, web interface
  24016. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  24017. repositories written in C.
  24018. The following example will configure the service with default values.
  24019. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  24020. @lisp
  24021. (service cgit-service-type)
  24022. @end lisp
  24023. The @code{file-object} type designates either a file-like object
  24024. (@pxref{G-Expressions, file-like objects}) or a string.
  24025. @c %start of fragment
  24026. Available @code{cgit-configuration} fields are:
  24027. @deftypevr {@code{cgit-configuration} parameter} package package
  24028. The CGIT package.
  24029. @end deftypevr
  24030. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  24031. NGINX configuration.
  24032. @end deftypevr
  24033. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  24034. Specifies a command which will be invoked to format the content of about
  24035. pages (both top-level and for each repository).
  24036. Defaults to @samp{""}.
  24037. @end deftypevr
  24038. @deftypevr {@code{cgit-configuration} parameter} string agefile
  24039. Specifies a path, relative to each repository path, which can be used to
  24040. specify the date and time of the youngest commit in the repository.
  24041. Defaults to @samp{""}.
  24042. @end deftypevr
  24043. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  24044. Specifies a command that will be invoked for authenticating repository
  24045. access.
  24046. Defaults to @samp{""}.
  24047. @end deftypevr
  24048. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  24049. Flag which, when set to @samp{age}, enables date ordering in the branch
  24050. ref list, and when set @samp{name} enables ordering by branch name.
  24051. Defaults to @samp{"name"}.
  24052. @end deftypevr
  24053. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  24054. Path used to store the cgit cache entries.
  24055. Defaults to @samp{"/var/cache/cgit"}.
  24056. @end deftypevr
  24057. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  24058. Number which specifies the time-to-live, in minutes, for the cached
  24059. version of repository pages accessed with a fixed SHA1.
  24060. Defaults to @samp{-1}.
  24061. @end deftypevr
  24062. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  24063. Number which specifies the time-to-live, in minutes, for the cached
  24064. version of repository pages accessed without a fixed SHA1.
  24065. Defaults to @samp{5}.
  24066. @end deftypevr
  24067. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  24068. Number which specifies the time-to-live, in minutes, for the cached
  24069. version of the repository summary page.
  24070. Defaults to @samp{5}.
  24071. @end deftypevr
  24072. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  24073. Number which specifies the time-to-live, in minutes, for the cached
  24074. version of the repository index page.
  24075. Defaults to @samp{5}.
  24076. @end deftypevr
  24077. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  24078. Number which specifies the time-to-live, in minutes, for the result of
  24079. scanning a path for Git repositories.
  24080. Defaults to @samp{15}.
  24081. @end deftypevr
  24082. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  24083. Number which specifies the time-to-live, in minutes, for the cached
  24084. version of the repository about page.
  24085. Defaults to @samp{15}.
  24086. @end deftypevr
  24087. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  24088. Number which specifies the time-to-live, in minutes, for the cached
  24089. version of snapshots.
  24090. Defaults to @samp{5}.
  24091. @end deftypevr
  24092. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  24093. The maximum number of entries in the cgit cache. When set to @samp{0},
  24094. caching is disabled.
  24095. Defaults to @samp{0}.
  24096. @end deftypevr
  24097. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  24098. Sort items in the repo list case sensitively.
  24099. Defaults to @samp{#t}.
  24100. @end deftypevr
  24101. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  24102. List of common prefixes which, when combined with a repository URL,
  24103. generates valid clone URLs for the repository.
  24104. Defaults to @samp{()}.
  24105. @end deftypevr
  24106. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  24107. List of @code{clone-url} templates.
  24108. Defaults to @samp{()}.
  24109. @end deftypevr
  24110. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  24111. Command which will be invoked to format commit messages.
  24112. Defaults to @samp{""}.
  24113. @end deftypevr
  24114. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  24115. Flag which, when set to @samp{date}, enables strict date ordering in the
  24116. commit log, and when set to @samp{topo} enables strict topological
  24117. ordering.
  24118. Defaults to @samp{"git log"}.
  24119. @end deftypevr
  24120. @deftypevr {@code{cgit-configuration} parameter} file-object css
  24121. URL which specifies the css document to include in all cgit pages.
  24122. Defaults to @samp{"/share/cgit/cgit.css"}.
  24123. @end deftypevr
  24124. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  24125. Specifies a command which will be invoked to format names and email
  24126. address of committers, authors, and taggers, as represented in various
  24127. places throughout the cgit interface.
  24128. Defaults to @samp{""}.
  24129. @end deftypevr
  24130. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  24131. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  24132. fragment suitable for embedding in other HTML pages.
  24133. Defaults to @samp{#f}.
  24134. @end deftypevr
  24135. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  24136. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  24137. commit history graph to the left of the commit messages in the
  24138. repository log page.
  24139. Defaults to @samp{#f}.
  24140. @end deftypevr
  24141. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  24142. Flag which, when set to @samp{#t}, allows all filter settings to be
  24143. overridden in repository-specific cgitrc files.
  24144. Defaults to @samp{#f}.
  24145. @end deftypevr
  24146. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  24147. Flag which, when set to @samp{#t}, allows users to follow a file in the
  24148. log view.
  24149. Defaults to @samp{#f}.
  24150. @end deftypevr
  24151. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  24152. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  24153. clones.
  24154. Defaults to @samp{#t}.
  24155. @end deftypevr
  24156. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  24157. Flag which, when set to @samp{#t}, will make cgit generate extra links
  24158. "summary", "commit", "tree" for each repo in the repository index.
  24159. Defaults to @samp{#f}.
  24160. @end deftypevr
  24161. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  24162. Flag which, when set to @samp{#t}, will make cgit display the owner of
  24163. each repo in the repository index.
  24164. Defaults to @samp{#t}.
  24165. @end deftypevr
  24166. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  24167. Flag which, when set to @samp{#t}, will make cgit print the number of
  24168. modified files for each commit on the repository log page.
  24169. Defaults to @samp{#f}.
  24170. @end deftypevr
  24171. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  24172. Flag which, when set to @samp{#t}, will make cgit print the number of
  24173. added and removed lines for each commit on the repository log page.
  24174. Defaults to @samp{#f}.
  24175. @end deftypevr
  24176. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  24177. Flag which, when set to @code{#t}, will make cgit display remote
  24178. branches in the summary and refs views.
  24179. Defaults to @samp{#f}.
  24180. @end deftypevr
  24181. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  24182. Flag which, when set to @code{1}, will make cgit use the subject of the
  24183. parent commit as link text when generating links to parent commits in
  24184. commit view.
  24185. Defaults to @samp{#f}.
  24186. @end deftypevr
  24187. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  24188. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  24189. parent commit as link text when generating links to parent commits in
  24190. commit view.
  24191. Defaults to @samp{#f}.
  24192. @end deftypevr
  24193. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  24194. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  24195. links for plaintext blobs printed in the tree view.
  24196. Defaults to @samp{#t}.
  24197. @end deftypevr
  24198. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  24199. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  24200. set any repo specific settings.
  24201. Defaults to @samp{#f}.
  24202. @end deftypevr
  24203. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  24204. URL used as link to a shortcut icon for cgit.
  24205. Defaults to @samp{"/favicon.ico"}.
  24206. @end deftypevr
  24207. @deftypevr {@code{cgit-configuration} parameter} string footer
  24208. The content of the file specified with this option will be included
  24209. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  24210. "generated by..."@: message).
  24211. Defaults to @samp{""}.
  24212. @end deftypevr
  24213. @deftypevr {@code{cgit-configuration} parameter} string head-include
  24214. The content of the file specified with this option will be included
  24215. verbatim in the HTML HEAD section on all pages.
  24216. Defaults to @samp{""}.
  24217. @end deftypevr
  24218. @deftypevr {@code{cgit-configuration} parameter} string header
  24219. The content of the file specified with this option will be included
  24220. verbatim at the top of all pages.
  24221. Defaults to @samp{""}.
  24222. @end deftypevr
  24223. @deftypevr {@code{cgit-configuration} parameter} file-object include
  24224. Name of a configfile to include before the rest of the current config-
  24225. file is parsed.
  24226. Defaults to @samp{""}.
  24227. @end deftypevr
  24228. @deftypevr {@code{cgit-configuration} parameter} string index-header
  24229. The content of the file specified with this option will be included
  24230. verbatim above the repository index.
  24231. Defaults to @samp{""}.
  24232. @end deftypevr
  24233. @deftypevr {@code{cgit-configuration} parameter} string index-info
  24234. The content of the file specified with this option will be included
  24235. verbatim below the heading on the repository index page.
  24236. Defaults to @samp{""}.
  24237. @end deftypevr
  24238. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  24239. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  24240. in the servers timezone.
  24241. Defaults to @samp{#f}.
  24242. @end deftypevr
  24243. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  24244. URL which specifies the source of an image which will be used as a logo
  24245. on all cgit pages.
  24246. Defaults to @samp{"/share/cgit/cgit.png"}.
  24247. @end deftypevr
  24248. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  24249. URL loaded when clicking on the cgit logo image.
  24250. Defaults to @samp{""}.
  24251. @end deftypevr
  24252. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  24253. Command which will be invoked to format the Owner column of the main
  24254. page.
  24255. Defaults to @samp{""}.
  24256. @end deftypevr
  24257. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  24258. Number of items to display in atom feeds view.
  24259. Defaults to @samp{10}.
  24260. @end deftypevr
  24261. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  24262. Number of entries to list per page in "log" view.
  24263. Defaults to @samp{50}.
  24264. @end deftypevr
  24265. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  24266. Number of commit message characters to display in "log" view.
  24267. Defaults to @samp{80}.
  24268. @end deftypevr
  24269. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  24270. Specifies the number of entries to list per page on the repository index
  24271. page.
  24272. Defaults to @samp{50}.
  24273. @end deftypevr
  24274. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  24275. Specifies the maximum number of repo description characters to display
  24276. on the repository index page.
  24277. Defaults to @samp{80}.
  24278. @end deftypevr
  24279. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  24280. Specifies the maximum size of a blob to display HTML for in KBytes.
  24281. Defaults to @samp{0}.
  24282. @end deftypevr
  24283. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  24284. Maximum statistics period. Valid values are @samp{week},@samp{month},
  24285. @samp{quarter} and @samp{year}.
  24286. Defaults to @samp{""}.
  24287. @end deftypevr
  24288. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  24289. Mimetype for the specified filename extension.
  24290. Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
  24291. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  24292. "image/png") (svg "image/svg+xml"))}.
  24293. @end deftypevr
  24294. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  24295. Specifies the file to use for automatic mimetype lookup.
  24296. Defaults to @samp{""}.
  24297. @end deftypevr
  24298. @deftypevr {@code{cgit-configuration} parameter} string module-link
  24299. Text which will be used as the formatstring for a hyperlink when a
  24300. submodule is printed in a directory listing.
  24301. Defaults to @samp{""}.
  24302. @end deftypevr
  24303. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  24304. If set to the value @samp{#t} caching will be disabled.
  24305. Defaults to @samp{#f}.
  24306. @end deftypevr
  24307. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  24308. If set to @samp{#t} showing full author email addresses will be
  24309. disabled.
  24310. Defaults to @samp{#f}.
  24311. @end deftypevr
  24312. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  24313. Flag which, when set to @samp{#t}, will make cgit omit the standard
  24314. header on all pages.
  24315. Defaults to @samp{#f}.
  24316. @end deftypevr
  24317. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  24318. A list of subdirectories inside of @code{repository-directory}, relative
  24319. to it, that should loaded as Git repositories. An empty list means that
  24320. all subdirectories will be loaded.
  24321. Defaults to @samp{()}.
  24322. @end deftypevr
  24323. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  24324. Text which will be used as default value for @code{cgit-repo-readme}.
  24325. Defaults to @samp{""}.
  24326. @end deftypevr
  24327. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  24328. If set to @code{#t} and @code{repository-directory} is enabled, if any
  24329. repositories are found with a suffix of @code{.git}, this suffix will be
  24330. removed for the URL and name.
  24331. Defaults to @samp{#f}.
  24332. @end deftypevr
  24333. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  24334. Maximum number of files to consider when detecting renames.
  24335. Defaults to @samp{-1}.
  24336. @end deftypevr
  24337. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  24338. The way in which repositories in each section are sorted.
  24339. Defaults to @samp{""}.
  24340. @end deftypevr
  24341. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  24342. Text used as content for the @code{robots} meta-tag.
  24343. Defaults to @samp{("noindex" "nofollow")}.
  24344. @end deftypevr
  24345. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  24346. Text printed below the heading on the repository index page.
  24347. Defaults to @samp{"a fast webinterface for the git dscm"}.
  24348. @end deftypevr
  24349. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  24350. The content of the file specified with this option will be included
  24351. verbatim below the ``about'' link on the repository index page.
  24352. Defaults to @samp{""}.
  24353. @end deftypevr
  24354. @deftypevr {@code{cgit-configuration} parameter} string root-title
  24355. Text printed as heading on the repository index page.
  24356. Defaults to @samp{""}.
  24357. @end deftypevr
  24358. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  24359. If set to @samp{#t} and repository-directory is enabled,
  24360. repository-directory will recurse into directories whose name starts
  24361. with a period. Otherwise, repository-directory will stay away from such
  24362. directories, considered as ``hidden''. Note that this does not apply to
  24363. the @file{.git} directory in non-bare repos.
  24364. Defaults to @samp{#f}.
  24365. @end deftypevr
  24366. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  24367. Text which specifies the default set of snapshot formats that cgit
  24368. generates links for.
  24369. Defaults to @samp{()}.
  24370. @end deftypevr
  24371. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  24372. Name of the directory to scan for repositories (represents
  24373. @code{scan-path}).
  24374. Defaults to @samp{"/srv/git"}.
  24375. @end deftypevr
  24376. @deftypevr {@code{cgit-configuration} parameter} string section
  24377. The name of the current repository section - all repositories defined
  24378. after this option will inherit the current section name.
  24379. Defaults to @samp{""}.
  24380. @end deftypevr
  24381. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  24382. Flag which, when set to @samp{1}, will sort the sections on the
  24383. repository listing by name.
  24384. Defaults to @samp{""}.
  24385. @end deftypevr
  24386. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  24387. A number which, if defined prior to repository-directory, specifies how
  24388. many path elements from each repo path to use as a default section name.
  24389. Defaults to @samp{0}.
  24390. @end deftypevr
  24391. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  24392. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  24393. default.
  24394. Defaults to @samp{#f}.
  24395. @end deftypevr
  24396. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  24397. Specifies a command which will be invoked to format plaintext blobs in
  24398. the tree view.
  24399. Defaults to @samp{""}.
  24400. @end deftypevr
  24401. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  24402. Specifies the number of branches to display in the repository ``summary''
  24403. view.
  24404. Defaults to @samp{10}.
  24405. @end deftypevr
  24406. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  24407. Specifies the number of log entries to display in the repository
  24408. ``summary'' view.
  24409. Defaults to @samp{10}.
  24410. @end deftypevr
  24411. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  24412. Specifies the number of tags to display in the repository ``summary''
  24413. view.
  24414. Defaults to @samp{10}.
  24415. @end deftypevr
  24416. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  24417. Filename which, if specified, needs to be present within the repository
  24418. for cgit to allow access to that repository.
  24419. Defaults to @samp{""}.
  24420. @end deftypevr
  24421. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  24422. URL which, if specified, will be used as root for all cgit links.
  24423. Defaults to @samp{"/"}.
  24424. @end deftypevr
  24425. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  24426. A list of @dfn{cgit-repo} records to use with config.
  24427. Defaults to @samp{()}.
  24428. Available @code{repository-cgit-configuration} fields are:
  24429. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  24430. A mask of snapshot formats for this repo that cgit generates links for,
  24431. restricted by the global @code{snapshots} setting.
  24432. Defaults to @samp{()}.
  24433. @end deftypevr
  24434. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  24435. Override the default @code{source-filter}.
  24436. Defaults to @samp{""}.
  24437. @end deftypevr
  24438. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  24439. The relative URL used to access the repository.
  24440. Defaults to @samp{""}.
  24441. @end deftypevr
  24442. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  24443. Override the default @code{about-filter}.
  24444. Defaults to @samp{""}.
  24445. @end deftypevr
  24446. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  24447. Flag which, when set to @samp{age}, enables date ordering in the branch
  24448. ref list, and when set to @samp{name} enables ordering by branch name.
  24449. Defaults to @samp{""}.
  24450. @end deftypevr
  24451. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  24452. A list of URLs which can be used to clone repo.
  24453. Defaults to @samp{()}.
  24454. @end deftypevr
  24455. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  24456. Override the default @code{commit-filter}.
  24457. Defaults to @samp{""}.
  24458. @end deftypevr
  24459. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  24460. Flag which, when set to @samp{date}, enables strict date ordering in the
  24461. commit log, and when set to @samp{topo} enables strict topological
  24462. ordering.
  24463. Defaults to @samp{""}.
  24464. @end deftypevr
  24465. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  24466. The name of the default branch for this repository. If no such branch
  24467. exists in the repository, the first branch name (when sorted) is used as
  24468. default instead. By default branch pointed to by HEAD, or ``master'' if
  24469. there is no suitable HEAD.
  24470. Defaults to @samp{""}.
  24471. @end deftypevr
  24472. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  24473. The value to show as repository description.
  24474. Defaults to @samp{""}.
  24475. @end deftypevr
  24476. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  24477. The value to show as repository homepage.
  24478. Defaults to @samp{""}.
  24479. @end deftypevr
  24480. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  24481. Override the default @code{email-filter}.
  24482. Defaults to @samp{""}.
  24483. @end deftypevr
  24484. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  24485. A flag which can be used to disable the global setting
  24486. @code{enable-commit-graph?}.
  24487. Defaults to @samp{disabled}.
  24488. @end deftypevr
  24489. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  24490. A flag which can be used to disable the global setting
  24491. @code{enable-log-filecount?}.
  24492. Defaults to @samp{disabled}.
  24493. @end deftypevr
  24494. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  24495. A flag which can be used to disable the global setting
  24496. @code{enable-log-linecount?}.
  24497. Defaults to @samp{disabled}.
  24498. @end deftypevr
  24499. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  24500. Flag which, when set to @code{#t}, will make cgit display remote
  24501. branches in the summary and refs views.
  24502. Defaults to @samp{disabled}.
  24503. @end deftypevr
  24504. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  24505. A flag which can be used to override the global setting
  24506. @code{enable-subject-links?}.
  24507. Defaults to @samp{disabled}.
  24508. @end deftypevr
  24509. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  24510. A flag which can be used to override the global setting
  24511. @code{enable-html-serving?}.
  24512. Defaults to @samp{disabled}.
  24513. @end deftypevr
  24514. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  24515. Flag which, when set to @code{#t}, hides the repository from the
  24516. repository index.
  24517. Defaults to @samp{#f}.
  24518. @end deftypevr
  24519. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  24520. Flag which, when set to @samp{#t}, ignores the repository.
  24521. Defaults to @samp{#f}.
  24522. @end deftypevr
  24523. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  24524. URL which specifies the source of an image which will be used as a logo
  24525. on this repo’s pages.
  24526. Defaults to @samp{""}.
  24527. @end deftypevr
  24528. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  24529. URL loaded when clicking on the cgit logo image.
  24530. Defaults to @samp{""}.
  24531. @end deftypevr
  24532. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  24533. Override the default @code{owner-filter}.
  24534. Defaults to @samp{""}.
  24535. @end deftypevr
  24536. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  24537. Text which will be used as the formatstring for a hyperlink when a
  24538. submodule is printed in a directory listing. The arguments for the
  24539. formatstring are the path and SHA1 of the submodule commit.
  24540. Defaults to @samp{""}.
  24541. @end deftypevr
  24542. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  24543. Text which will be used as the formatstring for a hyperlink when a
  24544. submodule with the specified subdirectory path is printed in a directory
  24545. listing.
  24546. Defaults to @samp{()}.
  24547. @end deftypevr
  24548. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  24549. Override the default maximum statistics period.
  24550. Defaults to @samp{""}.
  24551. @end deftypevr
  24552. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  24553. The value to show as repository name.
  24554. Defaults to @samp{""}.
  24555. @end deftypevr
  24556. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  24557. A value used to identify the owner of the repository.
  24558. Defaults to @samp{""}.
  24559. @end deftypevr
  24560. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  24561. An absolute path to the repository directory.
  24562. Defaults to @samp{""}.
  24563. @end deftypevr
  24564. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  24565. A path (relative to repo) which specifies a file to include verbatim as
  24566. the ``About'' page for this repo.
  24567. Defaults to @samp{""}.
  24568. @end deftypevr
  24569. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  24570. The name of the current repository section - all repositories defined
  24571. after this option will inherit the current section name.
  24572. Defaults to @samp{""}.
  24573. @end deftypevr
  24574. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  24575. Extra options will be appended to cgitrc file.
  24576. Defaults to @samp{()}.
  24577. @end deftypevr
  24578. @end deftypevr
  24579. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  24580. Extra options will be appended to cgitrc file.
  24581. Defaults to @samp{()}.
  24582. @end deftypevr
  24583. @c %end of fragment
  24584. However, it could be that you just want to get a @code{cgitrc} up and
  24585. running. In that case, you can pass an @code{opaque-cgit-configuration}
  24586. as a record to @code{cgit-service-type}. As its name indicates, an
  24587. opaque configuration does not have easy reflective capabilities.
  24588. Available @code{opaque-cgit-configuration} fields are:
  24589. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  24590. The cgit package.
  24591. @end deftypevr
  24592. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  24593. The contents of the @code{cgitrc}, as a string.
  24594. @end deftypevr
  24595. For example, if your @code{cgitrc} is just the empty string, you
  24596. could instantiate a cgit service like this:
  24597. @lisp
  24598. (service cgit-service-type
  24599. (opaque-cgit-configuration
  24600. (cgitrc "")))
  24601. @end lisp
  24602. @subsubheading Gitolite Service
  24603. @cindex Gitolite service
  24604. @cindex Git, hosting
  24605. @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  24606. repositories on a central server.
  24607. Gitolite can handle multiple repositories and users, and supports flexible
  24608. configuration of the permissions for the users on the repositories.
  24609. The following example will configure Gitolite using the default @code{git}
  24610. user, and the provided SSH public key.
  24611. @lisp
  24612. (service gitolite-service-type
  24613. (gitolite-configuration
  24614. (admin-pubkey (plain-file
  24615. "yourname.pub"
  24616. "ssh-rsa AAAA... guix@@example.com"))))
  24617. @end lisp
  24618. Gitolite is configured through a special admin repository which you can clone,
  24619. for example, if you setup Gitolite on @code{example.com}, you would run the
  24620. following command to clone the admin repository.
  24621. @example
  24622. git clone git@@example.com:gitolite-admin
  24623. @end example
  24624. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  24625. be inserted in to the @file{keydir} directory in the gitolite-admin
  24626. repository. If this results in a change in the repository, it will be
  24627. committed using the message ``gitolite setup by GNU Guix''.
  24628. @deftp {Data Type} gitolite-configuration
  24629. Data type representing the configuration for @code{gitolite-service-type}.
  24630. @table @asis
  24631. @item @code{package} (default: @var{gitolite})
  24632. Gitolite package to use.
  24633. @item @code{user} (default: @var{git})
  24634. User to use for Gitolite. This will be user that you use when accessing
  24635. Gitolite over SSH.
  24636. @item @code{group} (default: @var{git})
  24637. Group to use for Gitolite.
  24638. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  24639. Directory in which to store the Gitolite configuration and repositories.
  24640. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  24641. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  24642. representing the configuration for Gitolite.
  24643. @item @code{admin-pubkey} (default: @var{#f})
  24644. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  24645. setup Gitolite. This will be inserted in to the @file{keydir} directory
  24646. within the gitolite-admin repository.
  24647. To specify the SSH key as a string, use the @code{plain-file} function.
  24648. @lisp
  24649. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  24650. @end lisp
  24651. @end table
  24652. @end deftp
  24653. @deftp {Data Type} gitolite-rc-file
  24654. Data type representing the Gitolite RC file.
  24655. @table @asis
  24656. @item @code{umask} (default: @code{#o0077})
  24657. This controls the permissions Gitolite sets on the repositories and their
  24658. contents.
  24659. A value like @code{#o0027} will give read access to the group used by Gitolite
  24660. (by default: @code{git}). This is necessary when using Gitolite with software
  24661. like cgit or gitweb.
  24662. @item @code{unsafe-pattern} (default: @code{#f})
  24663. An optional Perl regular expression for catching unsafe configurations in
  24664. the configuration file. See
  24665. @uref{https://gitolite.com/gitolite/git-config.html#compensating-for-unsafe_patt,
  24666. Gitolite's documentation} for more information.
  24667. When the value is not @code{#f}, it should be a string containing a Perl
  24668. regular expression, such as @samp{"[`~#\$\&()|;<>]"}, which is the default
  24669. value used by gitolite. It rejects any special character in configuration
  24670. that might be interpreted by a shell, which is useful when sharing the
  24671. administration burden with other people that do not otherwise have shell
  24672. access on the server.
  24673. @item @code{git-config-keys} (default: @code{""})
  24674. Gitolite allows you to set git config values using the @samp{config}
  24675. keyword. This setting allows control over the config keys to accept.
  24676. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  24677. Set the role names allowed to be used by users running the perms command.
  24678. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  24679. This setting controls the commands and features to enable within Gitolite.
  24680. @end table
  24681. @end deftp
  24682. @subsubheading Gitile Service
  24683. @cindex Gitile service
  24684. @cindex Git, forge
  24685. @uref{https://git.lepiller.eu/gitile, Gitile} is a Git forge for viewing
  24686. public git repository contents from a web browser.
  24687. Gitile works best in collaboration with Gitolite, and will serve the public
  24688. repositories from Gitolite by default. The service should listen only on
  24689. a local port, and a webserver should be configured to serve static resources.
  24690. The gitile service provides an easy way to extend the Nginx service for
  24691. that purpose (@pxref{NGINX}).
  24692. The following example will configure Gitile to serve repositories from a
  24693. custom location, with some default messages for the home page and the
  24694. footers.
  24695. @lisp
  24696. (service gitile-service-type
  24697. (gitile-configuration
  24698. (repositories "/srv/git")
  24699. (base-git-url "https://myweb.site/git")
  24700. (index-title "My git repositories")
  24701. (intro '((p "This is all my public work!")))
  24702. (footer '((p "This is the end")))
  24703. (nginx-server-block
  24704. (nginx-server-configuration
  24705. (ssl-certificate
  24706. "/etc/letsencrypt/live/myweb.site/fullchain.pem")
  24707. (ssl-certificate-key
  24708. "/etc/letsencrypt/live/myweb.site/privkey.pem")
  24709. (listen '("443 ssl http2" "[::]:443 ssl http2"))
  24710. (locations
  24711. (list
  24712. ;; Allow for https anonymous fetch on /git/ urls.
  24713. (git-http-nginx-location-configuration
  24714. (git-http-configuration
  24715. (uri-path "/git/")
  24716. (git-root "/var/lib/gitolite/repositories")))))))))
  24717. @end lisp
  24718. In addition to the configuration record, you should configure your git
  24719. repositories to contain some optional information. First, your public
  24720. repositories need to contain the @file{git-daemon-export-ok} magic file
  24721. that allows Git to export the repository. Gitile uses the presence of this
  24722. file to detect public repositories it should make accessible. To do so with
  24723. Gitolite for instance, modify your @file{conf/gitolite.conf} to include
  24724. this in the repositories you want to make public:
  24725. @example
  24726. repo foo
  24727. R = daemon
  24728. @end example
  24729. In addition, Gitile can read the repository configuration to display more
  24730. infomation on the repository. Gitile uses the gitweb namespace for its
  24731. configuration. As an example, you can use the following in your
  24732. @file{conf/gitolite.conf}:
  24733. @example
  24734. repo foo
  24735. R = daemon
  24736. desc = A long description, optionally with <i>HTML</i>, shown on the index page
  24737. config gitweb.name = The Foo Project
  24738. config gitweb.synopsis = A short description, shown on the main page of the project
  24739. @end example
  24740. Do not forget to commit and push these changes once you are satisfied. You
  24741. may need to change your gitolite configuration to allow the previous
  24742. configuration options to be set. One way to do that is to add the
  24743. following service definition:
  24744. @lisp
  24745. (service gitolite-service-type
  24746. (gitolite-configuration
  24747. (admin-pubkey (local-file "key.pub"))
  24748. (rc-file
  24749. (gitolite-rc-file
  24750. (umask #o0027)
  24751. ;; Allow to set any configuration key
  24752. (git-config-keys ".*")
  24753. ;; Allow any text as a valid configuration value
  24754. (unsafe-patt "^$")))))
  24755. @end lisp
  24756. @deftp {Data Type} gitile-configuration
  24757. Data type representing the configuration for @code{gitile-service-type}.
  24758. @table @asis
  24759. @item @code{package} (default: @var{gitile})
  24760. Gitile package to use.
  24761. @item @code{host} (default: @code{"localhost"})
  24762. The host on which gitile is listening.
  24763. @item @code{port} (default: @code{8080})
  24764. The port on which gitile is listening.
  24765. @item @code{database} (default: @code{"/var/lib/gitile/gitile-db.sql"})
  24766. The location of the database.
  24767. @item @code{repositories} (default: @code{"/var/lib/gitolite/repositories"})
  24768. The location of the repositories. Note that only public repositories will
  24769. be shown by Gitile. To make a repository public, add an empty
  24770. @file{git-daemon-export-ok} file at the root of that repository.
  24771. @item @code{base-git-url}
  24772. The base git url that will be used to show clone commands.
  24773. @item @code{index-title} (default: @code{"Index"})
  24774. The page title for the index page that lists all the available repositories.
  24775. @item @code{intro} (default: @code{'()})
  24776. The intro content, as a list of sxml expressions. This is shown above the list
  24777. of repositories, on the index page.
  24778. @item @code{footer} (default: @code{'()})
  24779. The footer content, as a list of sxml expressions. This is shown on every
  24780. page served by Gitile.
  24781. @item @code{nginx-server-block}
  24782. An nginx server block that will be extended and used as a reverse proxy by
  24783. Gitile to serve its pages, and as a normal web server to serve its assets.
  24784. You can use this block to add more custom URLs to your domain, such as a
  24785. @code{/git/} URL for anonymous clones, or serving any other files you would
  24786. like to serve.
  24787. @end table
  24788. @end deftp
  24789. @node Game Services
  24790. @subsection Game Services
  24791. @subsubheading The Battle for Wesnoth Service
  24792. @cindex wesnothd
  24793. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  24794. based tactical strategy game, with several single player campaigns, and
  24795. multiplayer games (both networked and local).
  24796. @defvar {Scheme Variable} wesnothd-service-type
  24797. Service type for the wesnothd service. Its value must be a
  24798. @code{wesnothd-configuration} object. To run wesnothd in the default
  24799. configuration, instantiate it as:
  24800. @lisp
  24801. (service wesnothd-service-type)
  24802. @end lisp
  24803. @end defvar
  24804. @deftp {Data Type} wesnothd-configuration
  24805. Data type representing the configuration of @command{wesnothd}.
  24806. @table @asis
  24807. @item @code{package} (default: @code{wesnoth-server})
  24808. The wesnoth server package to use.
  24809. @item @code{port} (default: @code{15000})
  24810. The port to bind the server to.
  24811. @end table
  24812. @end deftp
  24813. @node PAM Mount Service
  24814. @subsection PAM Mount Service
  24815. @cindex pam-mount
  24816. The @code{(gnu services pam-mount)} module provides a service allowing
  24817. users to mount volumes when they log in. It should be able to mount any
  24818. volume format supported by the system.
  24819. @defvar {Scheme Variable} pam-mount-service-type
  24820. Service type for PAM Mount support.
  24821. @end defvar
  24822. @deftp {Data Type} pam-mount-configuration
  24823. Data type representing the configuration of PAM Mount.
  24824. It takes the following parameters:
  24825. @table @asis
  24826. @item @code{rules}
  24827. The configuration rules that will be used to generate
  24828. @file{/etc/security/pam_mount.conf.xml}.
  24829. The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
  24830. Guile Reference Manual}), and the default ones don't mount anything for
  24831. anyone at login:
  24832. @lisp
  24833. `((debug (@@ (enable "0")))
  24834. (mntoptions (@@ (allow ,(string-join
  24835. '("nosuid" "nodev" "loop"
  24836. "encryption" "fsck" "nonempty"
  24837. "allow_root" "allow_other")
  24838. ","))))
  24839. (mntoptions (@@ (require "nosuid,nodev")))
  24840. (logout (@@ (wait "0")
  24841. (hup "0")
  24842. (term "no")
  24843. (kill "no")))
  24844. (mkmountpoint (@@ (enable "1")
  24845. (remove "true"))))
  24846. @end lisp
  24847. Some @code{volume} elements must be added to automatically mount volumes
  24848. at login. Here's an example allowing the user @code{alice} to mount her
  24849. encrypted @env{HOME} directory and allowing the user @code{bob} to mount
  24850. the partition where he stores his data:
  24851. @lisp
  24852. (define pam-mount-rules
  24853. `((debug (@@ (enable "0")))
  24854. (volume (@@ (user "alice")
  24855. (fstype "crypt")
  24856. (path "/dev/sda2")
  24857. (mountpoint "/home/alice")))
  24858. (volume (@@ (user "bob")
  24859. (fstype "auto")
  24860. (path "/dev/sdb3")
  24861. (mountpoint "/home/bob/data")
  24862. (options "defaults,autodefrag,compress")))
  24863. (mntoptions (@@ (allow ,(string-join
  24864. '("nosuid" "nodev" "loop"
  24865. "encryption" "fsck" "nonempty"
  24866. "allow_root" "allow_other")
  24867. ","))))
  24868. (mntoptions (@@ (require "nosuid,nodev")))
  24869. (logout (@@ (wait "0")
  24870. (hup "0")
  24871. (term "no")
  24872. (kill "no")))
  24873. (mkmountpoint (@@ (enable "1")
  24874. (remove "true")))))
  24875. (service pam-mount-service-type
  24876. (pam-mount-configuration
  24877. (rules pam-mount-rules)))
  24878. @end lisp
  24879. The complete list of possible options can be found in the man page for
  24880. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
  24881. @end table
  24882. @end deftp
  24883. @node Guix Services
  24884. @subsection Guix Services
  24885. @subsubheading Guix Build Coordinator
  24886. The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
  24887. Coordinator} aids in distributing derivation builds among machines
  24888. running an @dfn{agent}. The build daemon is still used to build the
  24889. derivations, but the Guix Build Coordinator manages allocating builds
  24890. and working with the results.
  24891. @quotation Note
  24892. This service is considered experimental. Configuration options may be
  24893. changed in a backwards-incompatible manner, and not all features have
  24894. been thorougly tested.
  24895. @end quotation
  24896. The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
  24897. more connected @dfn{agent} processes. The coordinator process handles
  24898. clients submitting builds, and allocating builds to agents. The agent
  24899. processes talk to a build daemon to actually perform the builds, then
  24900. send the results back to the coordinator.
  24901. There is a script to run the coordinator component of the Guix Build
  24902. Coordinator, but the Guix service uses a custom Guile script instead, to
  24903. provide better integration with G-expressions used in the configuration.
  24904. @defvar {Scheme Variable} guix-build-coordinator-service-type
  24905. Service type for the Guix Build Coordinator. Its value must be a
  24906. @code{guix-build-coordinator-configuration} object.
  24907. @end defvar
  24908. @deftp {Data Type} guix-build-coordinator-configuration
  24909. Data type representing the configuration of the Guix Build Coordinator.
  24910. @table @asis
  24911. @item @code{package} (default: @code{guix-build-coordinator})
  24912. The Guix Build Coordinator package to use.
  24913. @item @code{user} (default: @code{"guix-build-coordinator"})
  24914. The system user to run the service as.
  24915. @item @code{group} (default: @code{"guix-build-coordinator"})
  24916. The system group to run the service as.
  24917. @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
  24918. The URI to use for the database.
  24919. @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
  24920. The URI describing how to listen to requests from agent processes.
  24921. @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
  24922. The URI describing how to listen to requests from clients. The client
  24923. API allows submitting builds and currently isn't authenticated, so take
  24924. care when configuring this value.
  24925. @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
  24926. A G-expression for the allocation strategy to be used. This is a
  24927. procedure that takes the datastore as an argument and populates the
  24928. allocation plan in the database.
  24929. @item @code{hooks} (default: @var{'()})
  24930. An association list of hooks. These provide a way to execute arbitrary
  24931. code upon certain events, like a build result being processed.
  24932. @item @code{guile} (default: @code{guile-3.0-latest})
  24933. The Guile package with which to run the Guix Build Coordinator.
  24934. @end table
  24935. @end deftp
  24936. @defvar {Scheme Variable} guix-build-coordinator-agent-service-type
  24937. Service type for a Guix Build Coordinator agent. Its value must be a
  24938. @code{guix-build-coordinator-agent-configuration} object.
  24939. @end defvar
  24940. @deftp {Data Type} guix-build-coordinator-agent-configuration
  24941. Data type representing the configuration a Guix Build Coordinator agent.
  24942. @table @asis
  24943. @item @code{package} (default: @code{guix-build-coordinator})
  24944. The Guix Build Coordinator package to use.
  24945. @item @code{user} (default: @code{"guix-build-coordinator-agent"})
  24946. The system user to run the service as.
  24947. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  24948. The URI to use when connecting to the coordinator.
  24949. @item @code{authentication}
  24950. Record describing how this agent should authenticate with the
  24951. coordinator. Possible record types are described below.
  24952. @item @code{systems} (default: @code{#f})
  24953. The systems for which this agent should fetch builds. The agent process
  24954. will use the current system it's running on as the default.
  24955. @item @code{max-parallel-builds} (default: @code{1})
  24956. The number of builds to perform in parallel.
  24957. @item @code{max-1min-load-average} (default: @code{#f})
  24958. Load average value to look at when considering starting new builds, if
  24959. the 1 minute load average exceeds this value, the agent will wait before
  24960. starting new builds.
  24961. This will be unspecified if the value is @code{#f}, and the agent will
  24962. use the number of cores reported by the system as the max 1 minute load
  24963. average.
  24964. @item @code{derivation-substitute-urls} (default: @code{#f})
  24965. URLs from which to attempt to fetch substitutes for derivations, if the
  24966. derivations aren't already available.
  24967. @item @code{non-derivation-substitute-urls} (default: @code{#f})
  24968. URLs from which to attempt to fetch substitutes for build inputs, if the
  24969. input store items aren't already available.
  24970. @end table
  24971. @end deftp
  24972. @deftp {Data Type} guix-build-coordinator-agent-password-auth
  24973. Data type representing an agent authenticating with a coordinator via a
  24974. UUID and password.
  24975. @table @asis
  24976. @item @code{uuid}
  24977. The UUID of the agent. This should be generated by the coordinator
  24978. process, stored in the coordinator database, and used by the intended
  24979. agent.
  24980. @item @code{password}
  24981. The password to use when connecting to the coordinator.
  24982. @end table
  24983. @end deftp
  24984. @deftp {Data Type} guix-build-coordinator-agent-password-file-auth
  24985. Data type representing an agent authenticating with a coordinator via a
  24986. UUID and password read from a file.
  24987. @table @asis
  24988. @item @code{uuid}
  24989. The UUID of the agent. This should be generated by the coordinator
  24990. process, stored in the coordinator database, and used by the intended
  24991. agent.
  24992. @item @code{password-file}
  24993. A file containing the password to use when connecting to the
  24994. coordinator.
  24995. @end table
  24996. @end deftp
  24997. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth
  24998. Data type representing an agent authenticating with a coordinator via a
  24999. dynamic auth token and agent name.
  25000. @table @asis
  25001. @item @code{agent-name}
  25002. Name of an agent, this is used to match up to an existing entry in the
  25003. database if there is one. When no existing entry is found, a new entry
  25004. is automatically added.
  25005. @item @code{token}
  25006. Dynamic auth token, this is created and stored in the coordinator
  25007. database, and is used by the agent to authenticate.
  25008. @end table
  25009. @end deftp
  25010. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth-with-file
  25011. Data type representing an agent authenticating with a coordinator via a
  25012. dynamic auth token read from a file and agent name.
  25013. @table @asis
  25014. @item @code{agent-name}
  25015. Name of an agent, this is used to match up to an existing entry in the
  25016. database if there is one. When no existing entry is found, a new entry
  25017. is automatically added.
  25018. @item @code{token-file}
  25019. File containing the dynamic auth token, this is created and stored in
  25020. the coordinator database, and is used by the agent to authenticate.
  25021. @end table
  25022. @end deftp
  25023. The Guix Build Coordinator package contains a script to query an
  25024. instance of the Guix Data Service for derivations to build, and then
  25025. submit builds for those derivations to the coordinator. The service
  25026. type below assists in running this script. This is an additional tool
  25027. that may be useful when building derivations contained within an
  25028. instance of the Guix Data Service.
  25029. @defvar {Scheme Variable} guix-build-coordinator-queue-builds-service-type
  25030. Service type for the
  25031. guix-build-coordinator-queue-builds-from-guix-data-service script. Its
  25032. value must be a @code{guix-build-coordinator-queue-builds-configuration}
  25033. object.
  25034. @end defvar
  25035. @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
  25036. Data type representing the options to the queue builds from guix data
  25037. service script.
  25038. @table @asis
  25039. @item @code{package} (default: @code{guix-build-coordinator})
  25040. The Guix Build Coordinator package to use.
  25041. @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
  25042. The system user to run the service as.
  25043. @item @code{coordinator} (default: @code{"http://localhost:8746"})
  25044. The URI to use when connecting to the coordinator.
  25045. @item @code{systems} (default: @code{#f})
  25046. The systems for which to fetch derivations to build.
  25047. @item @code{systems-and-targets} (default: @code{#f})
  25048. An association list of system and target pairs for which to fetch
  25049. derivations to build.
  25050. @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
  25051. The Guix Data Service instance from which to query to find out about
  25052. derivations to build.
  25053. @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
  25054. A file to record which commits have been processed, to avoid needlessly
  25055. processing them again if the service is restarted.
  25056. @end table
  25057. @end deftp
  25058. @subsubheading Guix Data Service
  25059. The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
  25060. and provides data about GNU Guix. This includes information about
  25061. packages, derivations and lint warnings.
  25062. The data is stored in a PostgreSQL database, and available through a web
  25063. interface.
  25064. @defvar {Scheme Variable} guix-data-service-type
  25065. Service type for the Guix Data Service. Its value must be a
  25066. @code{guix-data-service-configuration} object. The service optionally
  25067. extends the getmail service, as the guix-commits mailing list is used to
  25068. find out about changes in the Guix git repository.
  25069. @end defvar
  25070. @deftp {Data Type} guix-data-service-configuration
  25071. Data type representing the configuration of the Guix Data Service.
  25072. @table @asis
  25073. @item @code{package} (default: @code{guix-data-service})
  25074. The Guix Data Service package to use.
  25075. @item @code{user} (default: @code{"guix-data-service"})
  25076. The system user to run the service as.
  25077. @item @code{group} (default: @code{"guix-data-service"})
  25078. The system group to run the service as.
  25079. @item @code{port} (default: @code{8765})
  25080. The port to bind the web service to.
  25081. @item @code{host} (default: @code{"127.0.0.1"})
  25082. The host to bind the web service to.
  25083. @item @code{getmail-idle-mailboxes} (default: @code{#f})
  25084. If set, this is the list of mailboxes that the getmail service will be
  25085. configured to listen to.
  25086. @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
  25087. If set, this is the @code{getmail-retriever-configuration} object with
  25088. which to configure getmail to fetch mail from the guix-commits mailing
  25089. list.
  25090. @item @code{extra-options} (default: @var{'()})
  25091. Extra command line options for @code{guix-data-service}.
  25092. @item @code{extra-process-jobs-options} (default: @var{'()})
  25093. Extra command line options for @code{guix-data-service-process-jobs}.
  25094. @end table
  25095. @end deftp
  25096. @node Linux Services
  25097. @subsection Linux Services
  25098. @cindex oom
  25099. @cindex out of memory killer
  25100. @cindex earlyoom
  25101. @cindex early out of memory daemon
  25102. @subsubheading Early OOM Service
  25103. @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
  25104. Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
  25105. space and provides a more responsive and configurable alternative to the
  25106. in-kernel OOM killer. It is useful to prevent the system from becoming
  25107. unresponsive when it runs out of memory.
  25108. @deffn {Scheme Variable} earlyoom-service-type
  25109. The service type for running @command{earlyoom}, the Early OOM daemon.
  25110. Its value must be a @code{earlyoom-configuration} object, described
  25111. below. The service can be instantiated in its default configuration
  25112. with:
  25113. @lisp
  25114. (service earlyoom-service-type)
  25115. @end lisp
  25116. @end deffn
  25117. @deftp {Data Type} earlyoom-configuration
  25118. This is the configuration record for the @code{earlyoom-service-type}.
  25119. @table @asis
  25120. @item @code{earlyoom} (default: @var{earlyoom})
  25121. The Earlyoom package to use.
  25122. @item @code{minimum-available-memory} (default: @code{10})
  25123. The threshold for the minimum @emph{available} memory, in percentages.
  25124. @item @code{minimum-free-swap} (default: @code{10})
  25125. The threshold for the minimum free swap memory, in percentages.
  25126. @item @code{prefer-regexp} (default: @code{#f})
  25127. A regular expression (as a string) to match the names of the processes
  25128. that should be preferably killed.
  25129. @item @code{avoid-regexp} (default: @code{#f})
  25130. A regular expression (as a string) to match the names of the processes
  25131. that should @emph{not} be killed.
  25132. @item @code{memory-report-interval} (default: @code{0})
  25133. The interval in seconds at which a memory report is printed. It is
  25134. disabled by default.
  25135. @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
  25136. A boolean indicating whether the positive adjustments set in
  25137. @file{/proc/*/oom_score_adj} should be ignored.
  25138. @item @code{show-debug-messages?} (default: @code{#f})
  25139. A boolean indicating whether debug messages should be printed. The logs
  25140. are saved at @file{/var/log/earlyoom.log}.
  25141. @item @code{send-notification-command} (default: @code{#f})
  25142. This can be used to provide a custom command used for sending
  25143. notifications.
  25144. @end table
  25145. @end deftp
  25146. @cindex modprobe
  25147. @cindex kernel module loader
  25148. @subsubheading Kernel Module Loader Service
  25149. The kernel module loader service allows one to load loadable kernel
  25150. modules at boot. This is especially useful for modules that don't
  25151. autoload and need to be manually loaded, as is the case with
  25152. @code{ddcci}.
  25153. @deffn {Scheme Variable} kernel-module-loader-service-type
  25154. The service type for loading loadable kernel modules at boot with
  25155. @command{modprobe}. Its value must be a list of strings representing
  25156. module names. For example loading the drivers provided by
  25157. @code{ddcci-driver-linux}, in debugging mode by passing some module
  25158. parameters, can be done as follow:
  25159. @lisp
  25160. (use-modules (gnu) (gnu services))
  25161. (use-package-modules linux)
  25162. (use-service-modules linux)
  25163. (define ddcci-config
  25164. (plain-file "ddcci.conf"
  25165. "options ddcci dyndbg delay=120"))
  25166. (operating-system
  25167. ...
  25168. (services (cons* (service kernel-module-loader-service-type
  25169. '("ddcci" "ddcci_backlight"))
  25170. (simple-service 'ddcci-config etc-service-type
  25171. (list `("modprobe.d/ddcci.conf"
  25172. ,ddcci-config)))
  25173. %base-services))
  25174. (kernel-loadable-modules (list ddcci-driver-linux)))
  25175. @end lisp
  25176. @end deffn
  25177. @cindex rasdaemon
  25178. @cindex Platform Reliability, Availability and Serviceability daemon
  25179. @subsubheading Rasdaemon Service
  25180. The Rasdaemon service provides a daemon which monitors platform
  25181. @acronym{RAS, Reliability@comma{} Availability@comma{} and Serviceability} reports from
  25182. Linux kernel trace events, logging them to syslogd.
  25183. Reliability, Availability and Serviceability is a concept used on servers meant
  25184. to measure their robustness.
  25185. @strong{Relability} is the probability that a system will produce correct
  25186. outputs:
  25187. @itemize @bullet
  25188. @item Generally measured as Mean Time Between Failures (MTBF), and
  25189. @item Enhanced by features that help to avoid, detect and repair hardware
  25190. faults
  25191. @end itemize
  25192. @strong{Availability} is the probability that a system is operational at a
  25193. given time:
  25194. @itemize @bullet
  25195. @item Generally measured as a percentage of downtime per a period of time, and
  25196. @item Often uses mechanisms to detect and correct hardware faults in runtime.
  25197. @end itemize
  25198. @strong{Serviceability} is the simplicity and speed with which a system can be
  25199. repaired or maintained:
  25200. @itemize @bullet
  25201. @item Generally measured on Mean Time Between Repair (MTBR).
  25202. @end itemize
  25203. Among the monitoring measures, the most usual ones include:
  25204. @itemize @bullet
  25205. @item CPU – detect errors at instruction execution and at L1/L2/L3 caches;
  25206. @item Memory – add error correction logic (ECC) to detect and correct errors;
  25207. @item I/O – add CRC checksums for transferred data;
  25208. @item Storage – RAID, journal file systems, checksums, Self-Monitoring,
  25209. Analysis and Reporting Technology (SMART).
  25210. @end itemize
  25211. By monitoring the number of occurrences of error detections, it is possible to
  25212. identify if the probability of hardware errors is increasing, and, on such
  25213. case, do a preventive maintenance to replace a degraded component while those
  25214. errors are correctable.
  25215. For detailed information about the types of error events gathered and how to
  25216. make sense of them, see the kernel administrator's guide at
  25217. @url{https://www.kernel.org/doc/html/latest/admin-guide/ras.html}.
  25218. @defvr {Scheme Variable} rasdaemon-service-type
  25219. Service type for the @command{rasdaemon} service. It accepts a
  25220. @code{rasdaemon-configuration} object. Instantiating like
  25221. @lisp
  25222. (service rasdaemon-service-type)
  25223. @end lisp
  25224. will load with a default configuration, which monitors all events and logs to
  25225. syslogd.
  25226. @end defvr
  25227. @deftp {Data Type} rasdaemon-configuration
  25228. The data type representing the configuration of @command{rasdaemon}.
  25229. @table @asis
  25230. @item @code{record?} (default: @code{#f})
  25231. A boolean indicating whether to record the events in an SQLite database. This
  25232. provides a more structured access to the information contained in the log file.
  25233. The database location is hard-coded to @file{/var/lib/rasdaemon/ras-mc_event.db}.
  25234. @end table
  25235. @end deftp
  25236. @cindex zram
  25237. @cindex compressed swap
  25238. @cindex Compressed RAM-based block devices
  25239. @subsubheading Zram Device Service
  25240. The Zram device service provides a compressed swap device in system
  25241. memory. The Linux Kernel documentation has more information about
  25242. @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
  25243. devices.
  25244. @deffn {Scheme Variable} zram-device-service-type
  25245. This service creates the zram block device, formats it as swap and
  25246. enables it as a swap device. The service's value is a
  25247. @code{zram-device-configuration} record.
  25248. @deftp {Data Type} zram-device-configuration
  25249. This is the data type representing the configuration for the zram-device
  25250. service.
  25251. @table @asis
  25252. @item @code{size} (default @code{"1G"})
  25253. This is the amount of space you wish to provide for the zram device. It
  25254. accepts a string and can be a number of bytes or use a suffix, eg.:
  25255. @code{"512M"} or @code{1024000}.
  25256. @item @code{compression-algorithm} (default @code{'lzo})
  25257. This is the compression algorithm you wish to use. It is difficult to
  25258. list all the possible compression options, but common ones supported by
  25259. Guix's Linux Libre Kernel include @code{'lzo}, @code{'lz4} and @code{'zstd}.
  25260. @item @code{memory-limit} (default @code{0})
  25261. This is the maximum amount of memory which the zram device can use.
  25262. Setting it to '0' disables the limit. While it is generally expected
  25263. that compression will be 2:1, it is possible that uncompressable data
  25264. can be written to swap and this is a method to limit how much memory can
  25265. be used. It accepts a string and can be a number of bytes or use a
  25266. suffix, eg.: @code{"2G"}.
  25267. @item @code{priority} (default @code{-1})
  25268. This is the priority of the swap device created from the zram device.
  25269. @code{swapon} accepts values between -1 and 32767, with higher values
  25270. indicating higher priority. Higher priority swap will generally be used
  25271. first.
  25272. @end table
  25273. @end deftp
  25274. @end deffn
  25275. @node Hurd Services
  25276. @subsection Hurd Services
  25277. @defvr {Scheme Variable} hurd-console-service-type
  25278. This service starts the fancy @code{VGA} console client on the Hurd.
  25279. The service's value is a @code{hurd-console-configuration} record.
  25280. @end defvr
  25281. @deftp {Data Type} hurd-console-configuration
  25282. This is the data type representing the configuration for the
  25283. hurd-console-service.
  25284. @table @asis
  25285. @item @code{hurd} (default: @var{hurd})
  25286. The Hurd package to use.
  25287. @end table
  25288. @end deftp
  25289. @defvr {Scheme Variable} hurd-getty-service-type
  25290. This service starts a tty using the Hurd @code{getty} program.
  25291. The service's value is a @code{hurd-getty-configuration} record.
  25292. @end defvr
  25293. @deftp {Data Type} hurd-getty-configuration
  25294. This is the data type representing the configuration for the
  25295. hurd-getty-service.
  25296. @table @asis
  25297. @item @code{hurd} (default: @var{hurd})
  25298. The Hurd package to use.
  25299. @item @code{tty}
  25300. The name of the console this Getty runs on---e.g., @code{"tty1"}.
  25301. @item @code{baud-rate} (default: @code{38400})
  25302. An integer specifying the baud rate of the tty.
  25303. @end table
  25304. @end deftp
  25305. @node Miscellaneous Services
  25306. @subsection Miscellaneous Services
  25307. @cindex fingerprint
  25308. @subsubheading Fingerprint Service
  25309. The @code{(gnu services authentication)} module provides a DBus service to
  25310. read and identify fingerprints via a fingerprint sensor.
  25311. @defvr {Scheme Variable} fprintd-service-type
  25312. The service type for @command{fprintd}, which provides the fingerprint
  25313. reading capability.
  25314. @lisp
  25315. (service fprintd-service-type)
  25316. @end lisp
  25317. @end defvr
  25318. @cindex sysctl
  25319. @subsubheading System Control Service
  25320. The @code{(gnu services sysctl)} provides a service to configure kernel
  25321. parameters at boot.
  25322. @defvr {Scheme Variable} sysctl-service-type
  25323. The service type for @command{sysctl}, which modifies kernel parameters
  25324. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  25325. instantiated as:
  25326. @lisp
  25327. (service sysctl-service-type
  25328. (sysctl-configuration
  25329. (settings '(("net.ipv4.ip_forward" . "1")))))
  25330. @end lisp
  25331. Since @code{sysctl-service-type} is used in the default lists of
  25332. services, @code{%base-services} and @code{%desktop-services}, you can
  25333. use @code{modify-services} to change its configuration and add the
  25334. kernel parameters that you want (@pxref{Service Reference,
  25335. @code{modify-services}}).
  25336. @lisp
  25337. (modify-services %base-services
  25338. (sysctl-service-type config =>
  25339. (sysctl-configuration
  25340. (settings (append '(("net.ipv4.ip_forward" . "1"))
  25341. %default-sysctl-settings)))))
  25342. @end lisp
  25343. @end defvr
  25344. @deftp {Data Type} sysctl-configuration
  25345. The data type representing the configuration of @command{sysctl}.
  25346. @table @asis
  25347. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  25348. The @command{sysctl} executable to use.
  25349. @item @code{settings} (default: @code{%default-sysctl-settings})
  25350. An association list specifies kernel parameters and their values.
  25351. @end table
  25352. @end deftp
  25353. @defvr {Scheme Variable} %default-sysctl-settings
  25354. An association list specifying the default @command{sysctl} parameters
  25355. on Guix System.
  25356. @end defvr
  25357. @cindex pcscd
  25358. @subsubheading PC/SC Smart Card Daemon Service
  25359. The @code{(gnu services security-token)} module provides the following service
  25360. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  25361. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  25362. manager that coordinates communications with smart card readers, smart cards
  25363. and cryptographic tokens that are connected to the system.
  25364. @defvr {Scheme Variable} pcscd-service-type
  25365. Service type for the @command{pcscd} service. Its value must be a
  25366. @code{pcscd-configuration} object. To run pcscd in the default
  25367. configuration, instantiate it as:
  25368. @lisp
  25369. (service pcscd-service-type)
  25370. @end lisp
  25371. @end defvr
  25372. @deftp {Data Type} pcscd-configuration
  25373. The data type representing the configuration of @command{pcscd}.
  25374. @table @asis
  25375. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  25376. The pcsc-lite package that provides pcscd.
  25377. @item @code{usb-drivers} (default: @code{(list ccid)})
  25378. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  25379. under @file{pcsc/drivers} in the store directory of the package.
  25380. @end table
  25381. @end deftp
  25382. @cindex lirc
  25383. @subsubheading Lirc Service
  25384. The @code{(gnu services lirc)} module provides the following service.
  25385. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  25386. [#:device #f] [#:driver #f] [#:config-file #f] @
  25387. [#:extra-options '()]
  25388. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  25389. decodes infrared signals from remote controls.
  25390. Optionally, @var{device}, @var{driver} and @var{config-file}
  25391. (configuration file name) may be specified. See @command{lircd} manual
  25392. for details.
  25393. Finally, @var{extra-options} is a list of additional command-line options
  25394. passed to @command{lircd}.
  25395. @end deffn
  25396. @cindex spice
  25397. @subsubheading Spice Service
  25398. The @code{(gnu services spice)} module provides the following service.
  25399. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  25400. Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
  25401. that enables sharing the clipboard with a vm and setting the guest display
  25402. resolution when the graphical console window resizes.
  25403. @end deffn
  25404. @cindex inputattach
  25405. @subsubheading inputattach Service
  25406. @cindex tablet input, for Xorg
  25407. @cindex touchscreen input, for Xorg
  25408. The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
  25409. use input devices such as Wacom tablets, touchscreens, or joysticks with the
  25410. Xorg display server.
  25411. @deffn {Scheme Variable} inputattach-service-type
  25412. Type of a service that runs @command{inputattach} on a device and
  25413. dispatches events from it.
  25414. @end deffn
  25415. @deftp {Data Type} inputattach-configuration
  25416. @table @asis
  25417. @item @code{device-type} (default: @code{"wacom"})
  25418. The type of device to connect to. Run @command{inputattach --help}, from the
  25419. @code{inputattach} package, to see the list of supported device types.
  25420. @item @code{device} (default: @code{"/dev/ttyS0"})
  25421. The device file to connect to the device.
  25422. @item @code{baud-rate} (default: @code{#f})
  25423. Baud rate to use for the serial connection.
  25424. Should be a number or @code{#f}.
  25425. @item @code{log-file} (default: @code{#f})
  25426. If true, this must be the name of a file to log messages to.
  25427. @end table
  25428. @end deftp
  25429. @subsubheading Dictionary Service
  25430. @cindex dictionary
  25431. The @code{(gnu services dict)} module provides the following service:
  25432. @defvr {Scheme Variable} dicod-service-type
  25433. This is the type of the service that runs the @command{dicod} daemon, an
  25434. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  25435. @end defvr
  25436. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  25437. Return a service that runs the @command{dicod} daemon, an implementation
  25438. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  25439. The optional @var{config} argument specifies the configuration for
  25440. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  25441. default it serves the GNU Collaborative International Dictionary of English.
  25442. You can add @command{open localhost} to your @file{~/.dico} file to make
  25443. @code{localhost} the default server for @command{dico} client
  25444. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  25445. @end deffn
  25446. @deftp {Data Type} dicod-configuration
  25447. Data type representing the configuration of dicod.
  25448. @table @asis
  25449. @item @code{dico} (default: @var{dico})
  25450. Package object of the GNU Dico dictionary server.
  25451. @item @code{interfaces} (default: @var{'("localhost")})
  25452. This is the list of IP addresses and ports and possibly socket file
  25453. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  25454. dico, GNU Dico Manual}).
  25455. @item @code{handlers} (default: @var{'()})
  25456. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  25457. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  25458. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  25459. @end table
  25460. @end deftp
  25461. @deftp {Data Type} dicod-handler
  25462. Data type representing a dictionary handler (module instance).
  25463. @table @asis
  25464. @item @code{name}
  25465. Name of the handler (module instance).
  25466. @item @code{module} (default: @var{#f})
  25467. Name of the dicod module of the handler (instance). If it is @code{#f},
  25468. the module has the same name as the handler.
  25469. (@pxref{Modules,,, dico, GNU Dico Manual}).
  25470. @item @code{options}
  25471. List of strings or gexps representing the arguments for the module handler
  25472. @end table
  25473. @end deftp
  25474. @deftp {Data Type} dicod-database
  25475. Data type representing a dictionary database.
  25476. @table @asis
  25477. @item @code{name}
  25478. Name of the database, will be used in DICT commands.
  25479. @item @code{handler}
  25480. Name of the dicod handler (module instance) used by this database
  25481. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  25482. @item @code{complex?} (default: @var{#f})
  25483. Whether the database configuration complex. The complex configuration
  25484. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  25485. @item @code{options}
  25486. List of strings or gexps representing the arguments for the database
  25487. (@pxref{Databases,,, dico, GNU Dico Manual}).
  25488. @end table
  25489. @end deftp
  25490. @defvr {Scheme Variable} %dicod-database:gcide
  25491. A @code{<dicod-database>} object serving the GNU Collaborative International
  25492. Dictionary of English using the @code{gcide} package.
  25493. @end defvr
  25494. The following is an example @code{dicod-service} configuration.
  25495. @lisp
  25496. (dicod-service #:config
  25497. (dicod-configuration
  25498. (handlers (list (dicod-handler
  25499. (name "wordnet")
  25500. (module "dictorg")
  25501. (options
  25502. (list #~(string-append "dbdir=" #$wordnet))))))
  25503. (databases (list (dicod-database
  25504. (name "wordnet")
  25505. (complex? #t)
  25506. (handler "wordnet")
  25507. (options '("database=wn")))
  25508. %dicod-database:gcide))))
  25509. @end lisp
  25510. @cindex Docker
  25511. @subsubheading Docker Service
  25512. The @code{(gnu services docker)} module provides the following services.
  25513. @defvr {Scheme Variable} docker-service-type
  25514. This is the type of the service that runs @url{https://www.docker.com,Docker},
  25515. a daemon that can execute application bundles (sometimes referred to as
  25516. ``containers'') in isolated environments.
  25517. @end defvr
  25518. @deftp {Data Type} docker-configuration
  25519. This is the data type representing the configuration of Docker and Containerd.
  25520. @table @asis
  25521. @item @code{docker} (default: @code{docker})
  25522. The Docker daemon package to use.
  25523. @item @code{docker-cli} (default: @code{docker-cli})
  25524. The Docker client package to use.
  25525. @item @code{containerd} (default: @var{containerd})
  25526. The Containerd package to use.
  25527. @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
  25528. The Docker user-land networking proxy package to use.
  25529. @item @code{enable-proxy?} (default @code{#t})
  25530. Enable or disable the use of the Docker user-land networking proxy.
  25531. @item @code{debug?} (default @code{#f})
  25532. Enable or disable debug output.
  25533. @item @code{enable-iptables?} (default @code{#t})
  25534. Enable or disable the addition of iptables rules.
  25535. @end table
  25536. @end deftp
  25537. @cindex Singularity, container service
  25538. @defvr {Scheme Variable} singularity-service-type
  25539. This is the type of the service that allows you to run
  25540. @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
  25541. create and run application bundles (aka. ``containers''). The value for this
  25542. service is the Singularity package to use.
  25543. The service does not install a daemon; instead, it installs helper programs as
  25544. setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
  25545. @command{singularity run} and similar commands.
  25546. @end defvr
  25547. @cindex Audit
  25548. @subsubheading Auditd Service
  25549. The @code{(gnu services auditd)} module provides the following service.
  25550. @defvr {Scheme Variable} auditd-service-type
  25551. This is the type of the service that runs
  25552. @url{https://people.redhat.com/sgrubb/audit/,auditd},
  25553. a daemon that tracks security-relevant information on your system.
  25554. Examples of things that can be tracked:
  25555. @enumerate
  25556. @item
  25557. File accesses
  25558. @item
  25559. System calls
  25560. @item
  25561. Invoked commands
  25562. @item
  25563. Failed login attempts
  25564. @item
  25565. Firewall filtering
  25566. @item
  25567. Network access
  25568. @end enumerate
  25569. @command{auditctl} from the @code{audit} package can be used in order
  25570. to add or remove events to be tracked (until the next reboot).
  25571. In order to permanently track events, put the command line arguments
  25572. of auditctl into a file called @code{audit.rules} in the configuration
  25573. directory (see below).
  25574. @command{aureport} from the @code{audit} package can be used in order
  25575. to view a report of all recorded events.
  25576. The audit daemon by default logs into the file
  25577. @file{/var/log/audit.log}.
  25578. @end defvr
  25579. @deftp {Data Type} auditd-configuration
  25580. This is the data type representing the configuration of auditd.
  25581. @table @asis
  25582. @item @code{audit} (default: @code{audit})
  25583. The audit package to use.
  25584. @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
  25585. The directory containing the configuration file for the audit package, which
  25586. must be named @code{auditd.conf}, and optionally some audit rules to
  25587. instantiate on startup.
  25588. @end table
  25589. @end deftp
  25590. @cindex rshiny
  25591. @subsubheading R-Shiny service
  25592. The @code{(gnu services science)} module provides the following service.
  25593. @defvr {Scheme Variable} rshiny-service-type
  25594. This is a type of service which is used to run a webapp created with
  25595. @code{r-shiny}. This service sets the @env{R_LIBS_USER} environment
  25596. variable and runs the provided script to call @code{runApp}.
  25597. @deftp {Data Type} rshiny-configuration
  25598. This is the data type representing the configuration of rshiny.
  25599. @table @asis
  25600. @item @code{package} (default: @code{r-shiny})
  25601. The package to use.
  25602. @item @code{binary} (defaunlt @code{"rshiny"})
  25603. The name of the binary or shell script located at @code{package/bin/} to
  25604. run when the service is run.
  25605. The common way to create this file is as follows:
  25606. @lisp
  25607. @dots{}
  25608. (let* ((out (assoc-ref %outputs "out"))
  25609. (targetdir (string-append out "/share/" ,name))
  25610. (app (string-append out "/bin/" ,name))
  25611. (Rbin (string-append (assoc-ref %build-inputs "r-min")
  25612. "/bin/Rscript")))
  25613. ;; @dots{}
  25614. (mkdir-p (string-append out "/bin"))
  25615. (call-with-output-file app
  25616. (lambda (port)
  25617. (format port
  25618. "#!~a
  25619. library(shiny)
  25620. setwd(\"~a\")
  25621. runApp(launch.browser=0, port=4202)~%\n"
  25622. Rbin targetdir))))
  25623. @end lisp
  25624. @end table
  25625. @end deftp
  25626. @end defvr
  25627. @cindex Nix
  25628. @subsubheading Nix service
  25629. The @code{(gnu services nix)} module provides the following service.
  25630. @defvr {Scheme Variable} nix-service-type
  25631. This is the type of the service that runs build daemon of the
  25632. @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
  25633. how to use it:
  25634. @lisp
  25635. (use-modules (gnu))
  25636. (use-service-modules nix)
  25637. (use-package-modules package-management)
  25638. (operating-system
  25639. ;; @dots{}
  25640. (packages (append (list nix)
  25641. %base-packages))
  25642. (services (append (list (service nix-service-type))
  25643. %base-services)))
  25644. @end lisp
  25645. After @command{guix system reconfigure} configure Nix for your user:
  25646. @itemize
  25647. @item Add a Nix channel and update it. See
  25648. @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
  25649. @item Create a symlink to your profile and activate Nix profile:
  25650. @end itemize
  25651. @example
  25652. $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
  25653. $ source /run/current-system/profile/etc/profile.d/nix.sh
  25654. @end example
  25655. @end defvr
  25656. @deftp {Data Type} nix-configuration
  25657. This data type represents the configuration of the Nix daemon.
  25658. @table @asis
  25659. @item @code{nix} (default: @code{nix})
  25660. The Nix package to use.
  25661. @item @code{sandbox} (default: @code{#t})
  25662. Specifies whether builds are sandboxed by default.
  25663. @item @code{build-sandbox-items} (default: @code{'()})
  25664. This is a list of strings or objects appended to the
  25665. @code{build-sandbox-items} field of the configuration file.
  25666. @item @code{extra-config} (default: @code{'()})
  25667. This is a list of strings or objects appended to the configuration file.
  25668. It is used to pass extra text to be added verbatim to the configuration
  25669. file.
  25670. @item @code{extra-options} (default: @code{'()})
  25671. Extra command line options for @code{nix-service-type}.
  25672. @end table
  25673. @end deftp
  25674. @node Setuid Programs
  25675. @section Setuid Programs
  25676. @cindex setuid programs
  25677. Some programs need to run with ``root'' privileges, even when they are
  25678. launched by unprivileged users. A notorious example is the
  25679. @command{passwd} program, which users can run to change their
  25680. password, and which needs to access the @file{/etc/passwd} and
  25681. @file{/etc/shadow} files---something normally restricted to root, for
  25682. obvious security reasons. To address that, these executables are
  25683. @dfn{setuid-root}, meaning that they always run with root privileges
  25684. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  25685. for more info about the setuid mechanism).
  25686. The store itself @emph{cannot} contain setuid programs: that would be a
  25687. security issue since any user on the system can write derivations that
  25688. populate the store (@pxref{The Store}). Thus, a different mechanism is
  25689. used: instead of changing the setuid bit directly on files that are in
  25690. the store, we let the system administrator @emph{declare} which programs
  25691. should be setuid root.
  25692. The @code{setuid-programs} field of an @code{operating-system}
  25693. declaration contains a list of @code{<setuid-program>} denoting the
  25694. names of programs to have a setuid or setgid bit set (@pxref{Using the
  25695. Configuration System}). For instance, the @command{passwd} program,
  25696. which is part of the Shadow package, with a setuid root can be
  25697. designated like this:
  25698. @example
  25699. (setuid-program
  25700. (program (file-append #$shadow "/bin/passwd")))
  25701. @end example
  25702. @deftp {Data Type} setuid-program
  25703. This data type represents a program with a setuid or setgid bit set.
  25704. @table @asis
  25705. @item @code{program}
  25706. A file-like object having its setuid and/or setgid bit set.
  25707. @item @code{setuid?} (default: @code{#t})
  25708. Whether to set user setuid bit.
  25709. @item @code{setgid?} (default: @code{#f})
  25710. Whether to set group setgid bit.
  25711. @item @code{user} (default: @code{0})
  25712. UID (integer) or user name (string) for the user owner of the program,
  25713. defaults to root.
  25714. @item @code{group} (default: @code{0})
  25715. GID (integer) goup name (string) for the group owner of the program,
  25716. defaults to root.
  25717. @end table
  25718. @end deftp
  25719. A default set of setuid programs is defined by the
  25720. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  25721. @defvr {Scheme Variable} %setuid-programs
  25722. A list of @code{<setuid-program>} denoting common programs that are
  25723. setuid-root.
  25724. The list includes commands such as @command{passwd}, @command{ping},
  25725. @command{su}, and @command{sudo}.
  25726. @end defvr
  25727. Under the hood, the actual setuid programs are created in the
  25728. @file{/run/setuid-programs} directory at system activation time. The
  25729. files in this directory refer to the ``real'' binaries, which are in the
  25730. store.
  25731. @node X.509 Certificates
  25732. @section X.509 Certificates
  25733. @cindex HTTPS, certificates
  25734. @cindex X.509 certificates
  25735. @cindex TLS
  25736. Web servers available over HTTPS (that is, HTTP over the transport-layer
  25737. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  25738. that the client can then use to @emph{authenticate} the server. To do
  25739. that, clients verify that the server's certificate is signed by a
  25740. so-called @dfn{certificate authority} (CA). But to verify the CA's
  25741. signature, clients must have first acquired the CA's certificate.
  25742. Web browsers such as GNU@tie{}IceCat include their own set of CA
  25743. certificates, such that they are able to verify CA signatures
  25744. out-of-the-box.
  25745. However, most other programs that can talk HTTPS---@command{wget},
  25746. @command{git}, @command{w3m}, etc.---need to be told where CA
  25747. certificates can be found.
  25748. @cindex @code{nss-certs}
  25749. In Guix, this is done by adding a package that provides certificates
  25750. to the @code{packages} field of the @code{operating-system} declaration
  25751. (@pxref{operating-system Reference}). Guix includes one such package,
  25752. @code{nss-certs}, which is a set of CA certificates provided as part of
  25753. Mozilla's Network Security Services.
  25754. Note that it is @emph{not} part of @code{%base-packages}, so you need to
  25755. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  25756. most applications and libraries look for certificates by default, points
  25757. to the certificates installed globally.
  25758. Unprivileged users, including users of Guix on a foreign distro,
  25759. can also install their own certificate package in
  25760. their profile. A number of environment variables need to be defined so
  25761. that applications and libraries know where to find them. Namely, the
  25762. OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
  25763. variables. Some applications add their own environment variables; for
  25764. instance, the Git version control system honors the certificate bundle
  25765. pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
  25766. would typically run something like:
  25767. @example
  25768. guix install nss-certs
  25769. export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  25770. export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  25771. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  25772. @end example
  25773. As another example, R requires the @env{CURL_CA_BUNDLE} environment
  25774. variable to point to a certificate bundle, so you would have to run
  25775. something like this:
  25776. @example
  25777. guix install nss-certs
  25778. export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  25779. @end example
  25780. For other applications you may want to look up the required environment
  25781. variable in the relevant documentation.
  25782. @node Name Service Switch
  25783. @section Name Service Switch
  25784. @cindex name service switch
  25785. @cindex NSS
  25786. The @code{(gnu system nss)} module provides bindings to the
  25787. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  25788. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  25789. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  25790. extended with new ``name'' lookup methods for system databases, which
  25791. includes host names, service names, user accounts, and more (@pxref{Name
  25792. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  25793. C Library Reference Manual}).
  25794. The NSS configuration specifies, for each system database, which lookup
  25795. method is to be used, and how the various methods are chained
  25796. together---for instance, under which circumstances NSS should try the
  25797. next method in the list. The NSS configuration is given in the
  25798. @code{name-service-switch} field of @code{operating-system} declarations
  25799. (@pxref{operating-system Reference, @code{name-service-switch}}).
  25800. @cindex nss-mdns
  25801. @cindex .local, host name lookup
  25802. As an example, the declaration below configures the NSS to use the
  25803. @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  25804. back-end}, which supports host name lookups over multicast DNS (mDNS)
  25805. for host names ending in @code{.local}:
  25806. @lisp
  25807. (name-service-switch
  25808. (hosts (list %files ;first, check /etc/hosts
  25809. ;; If the above did not succeed, try
  25810. ;; with 'mdns_minimal'.
  25811. (name-service
  25812. (name "mdns_minimal")
  25813. ;; 'mdns_minimal' is authoritative for
  25814. ;; '.local'. When it returns "not found",
  25815. ;; no need to try the next methods.
  25816. (reaction (lookup-specification
  25817. (not-found => return))))
  25818. ;; Then fall back to DNS.
  25819. (name-service
  25820. (name "dns"))
  25821. ;; Finally, try with the "full" 'mdns'.
  25822. (name-service
  25823. (name "mdns")))))
  25824. @end lisp
  25825. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  25826. contains this configuration, so you will not have to type it if all you
  25827. want is to have @code{.local} host lookup working.
  25828. Note that, in this case, in addition to setting the
  25829. @code{name-service-switch} of the @code{operating-system} declaration,
  25830. you also need to use @code{avahi-service-type} (@pxref{Networking Services,
  25831. @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
  25832. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  25833. to the name service cache daemon (@pxref{Base Services,
  25834. @code{nscd-service}}).
  25835. For convenience, the following variables provide typical NSS
  25836. configurations.
  25837. @defvr {Scheme Variable} %default-nss
  25838. This is the default name service switch configuration, a
  25839. @code{name-service-switch} object.
  25840. @end defvr
  25841. @defvr {Scheme Variable} %mdns-host-lookup-nss
  25842. This is the name service switch configuration with support for host name
  25843. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  25844. @end defvr
  25845. The reference for name service switch configuration is given below. It
  25846. is a direct mapping of the configuration file format of the C library , so
  25847. please refer to the C library manual for more information (@pxref{NSS
  25848. Configuration File,,, libc, The GNU C Library Reference Manual}).
  25849. Compared to the configuration file format of libc NSS, it has the advantage
  25850. not only of adding this warm parenthetic feel that we like, but also
  25851. static checks: you will know about syntax errors and typos as soon as you
  25852. run @command{guix system}.
  25853. @deftp {Data Type} name-service-switch
  25854. This is the data type representation the configuration of libc's name
  25855. service switch (NSS). Each field below represents one of the supported
  25856. system databases.
  25857. @table @code
  25858. @item aliases
  25859. @itemx ethers
  25860. @itemx group
  25861. @itemx gshadow
  25862. @itemx hosts
  25863. @itemx initgroups
  25864. @itemx netgroup
  25865. @itemx networks
  25866. @itemx password
  25867. @itemx public-key
  25868. @itemx rpc
  25869. @itemx services
  25870. @itemx shadow
  25871. The system databases handled by the NSS@. Each of these fields must be a
  25872. list of @code{<name-service>} objects (see below).
  25873. @end table
  25874. @end deftp
  25875. @deftp {Data Type} name-service
  25876. This is the data type representing an actual name service and the
  25877. associated lookup action.
  25878. @table @code
  25879. @item name
  25880. A string denoting the name service (@pxref{Services in the NSS
  25881. configuration,,, libc, The GNU C Library Reference Manual}).
  25882. Note that name services listed here must be visible to nscd. This is
  25883. achieved by passing the @code{#:name-services} argument to
  25884. @code{nscd-service} the list of packages providing the needed name
  25885. services (@pxref{Base Services, @code{nscd-service}}).
  25886. @item reaction
  25887. An action specified using the @code{lookup-specification} macro
  25888. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  25889. Reference Manual}). For example:
  25890. @lisp
  25891. (lookup-specification (unavailable => continue)
  25892. (success => return))
  25893. @end lisp
  25894. @end table
  25895. @end deftp
  25896. @node Initial RAM Disk
  25897. @section Initial RAM Disk
  25898. @cindex initrd
  25899. @cindex initial RAM disk
  25900. For bootstrapping purposes, the Linux-Libre kernel is passed an
  25901. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  25902. root file system as well as an initialization script. The latter is
  25903. responsible for mounting the real root file system, and for loading any
  25904. kernel modules that may be needed to achieve that.
  25905. The @code{initrd-modules} field of an @code{operating-system}
  25906. declaration allows you to specify Linux-libre kernel modules that must
  25907. be available in the initrd. In particular, this is where you would list
  25908. modules needed to actually drive the hard disk where your root partition
  25909. is---although the default value of @code{initrd-modules} should cover
  25910. most use cases. For example, assuming you need the @code{megaraid_sas}
  25911. module in addition to the default modules to be able to access your root
  25912. file system, you would write:
  25913. @lisp
  25914. (operating-system
  25915. ;; @dots{}
  25916. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  25917. @end lisp
  25918. @defvr {Scheme Variable} %base-initrd-modules
  25919. This is the list of kernel modules included in the initrd by default.
  25920. @end defvr
  25921. Furthermore, if you need lower-level customization, the @code{initrd}
  25922. field of an @code{operating-system} declaration allows
  25923. you to specify which initrd you would like to use. The @code{(gnu
  25924. system linux-initrd)} module provides three ways to build an initrd: the
  25925. high-level @code{base-initrd} procedure and the low-level
  25926. @code{raw-initrd} and @code{expression->initrd} procedures.
  25927. The @code{base-initrd} procedure is intended to cover most common uses.
  25928. For example, if you want to add a bunch of kernel modules to be loaded
  25929. at boot time, you can define the @code{initrd} field of the operating
  25930. system declaration like this:
  25931. @lisp
  25932. (initrd (lambda (file-systems . rest)
  25933. ;; Create a standard initrd but set up networking
  25934. ;; with the parameters QEMU expects by default.
  25935. (apply base-initrd file-systems
  25936. #:qemu-networking? #t
  25937. rest)))
  25938. @end lisp
  25939. The @code{base-initrd} procedure also handles common use cases that
  25940. involves using the system as a QEMU guest, or as a ``live'' system with
  25941. volatile root file system.
  25942. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  25943. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  25944. such as trying to guess which kernel modules and packages should be included
  25945. to the initrd. An example use of @code{raw-initrd} is when a user has
  25946. a custom Linux kernel configuration and default kernel modules included by
  25947. @code{base-initrd} are not available.
  25948. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  25949. honors several options passed on the Linux kernel command line
  25950. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  25951. @code{-append} option of QEMU), notably:
  25952. @table @code
  25953. @item --load=@var{boot}
  25954. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  25955. program, once it has mounted the root file system.
  25956. Guix uses this option to yield control to a boot program that runs the
  25957. service activation programs and then spawns the GNU@tie{}Shepherd, the
  25958. initialization system.
  25959. @item --root=@var{root}
  25960. Mount @var{root} as the root file system. @var{root} can be a device
  25961. name like @code{/dev/sda1}, a file system label, or a file system UUID.
  25962. When unspecified, the device name from the root file system of the
  25963. operating system declaration is used.
  25964. @item --system=@var{system}
  25965. Have @file{/run/booted-system} and @file{/run/current-system} point to
  25966. @var{system}.
  25967. @item modprobe.blacklist=@var{modules}@dots{}
  25968. @cindex module, black-listing
  25969. @cindex black list, of kernel modules
  25970. Instruct the initial RAM disk as well as the @command{modprobe} command
  25971. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  25972. must be a comma-separated list of module names---e.g.,
  25973. @code{usbkbd,9pnet}.
  25974. @item --repl
  25975. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  25976. tries to load kernel modules and to mount the root file system. Our
  25977. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  25978. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  25979. Manual}, for more information on Guile's REPL.
  25980. @end table
  25981. Now that you know all the features that initial RAM disks produced by
  25982. @code{base-initrd} and @code{raw-initrd} provide,
  25983. here is how to use it and customize it further.
  25984. @cindex initrd
  25985. @cindex initial RAM disk
  25986. @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
  25987. [#:linux-modules '()] [#:mapped-devices '()] @
  25988. [#:keyboard-layout #f] @
  25989. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  25990. Return a derivation that builds a raw initrd. @var{file-systems} is
  25991. a list of file systems to be mounted by the initrd, possibly in addition to
  25992. the root file system specified on the kernel command line via @option{--root}.
  25993. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  25994. @var{mapped-devices} is a list of device mappings to realize before
  25995. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  25996. @var{helper-packages} is a list of packages to be copied in the initrd.
  25997. It may
  25998. include @code{e2fsck/static} or other packages needed by the initrd to check
  25999. the root file system.
  26000. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  26001. the desired console keyboard layout. This is done before @var{mapped-devices}
  26002. are set up and before @var{file-systems} are mounted such that, should the
  26003. user need to enter a passphrase or use the REPL, this happens using the
  26004. intended keyboard layout.
  26005. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  26006. parameters. When @var{virtio?} is true, load additional modules so that the
  26007. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  26008. When @var{volatile-root?} is true, the root file system is writable but any changes
  26009. to it are lost.
  26010. @end deffn
  26011. @deffn {Scheme Procedure} base-initrd @var{file-systems} @
  26012. [#:mapped-devices '()] [#:keyboard-layout #f] @
  26013. [#:qemu-networking? #f] [#:volatile-root? #f] @
  26014. [#:linux-modules '()]
  26015. Return as a file-like object a generic initrd, with kernel
  26016. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  26017. mounted by the initrd, possibly in addition to the root file system specified
  26018. on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device
  26019. mappings to realize before @var{file-systems} are mounted.
  26020. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  26021. the desired console keyboard layout. This is done before @var{mapped-devices}
  26022. are set up and before @var{file-systems} are mounted such that, should the
  26023. user need to enter a passphrase or use the REPL, this happens using the
  26024. intended keyboard layout.
  26025. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  26026. The initrd is automatically populated with all the kernel modules necessary
  26027. for @var{file-systems} and for the given options. Additional kernel
  26028. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  26029. loaded at boot time in the order in which they appear.
  26030. @end deffn
  26031. Needless to say, the initrds we produce and use embed a
  26032. statically-linked Guile, and the initialization program is a Guile
  26033. program. That gives a lot of flexibility. The
  26034. @code{expression->initrd} procedure builds such an initrd, given the
  26035. program to run in that initrd.
  26036. @deffn {Scheme Procedure} expression->initrd @var{exp} @
  26037. [#:guile %guile-static-stripped] [#:name "guile-initrd"]
  26038. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  26039. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  26040. upon booting. All the derivations referenced by @var{exp} are
  26041. automatically copied to the initrd.
  26042. @end deffn
  26043. @node Bootloader Configuration
  26044. @section Bootloader Configuration
  26045. @cindex bootloader
  26046. @cindex boot loader
  26047. The operating system supports multiple bootloaders. The bootloader is
  26048. configured using @code{bootloader-configuration} declaration. All the
  26049. fields of this structure are bootloader agnostic except for one field,
  26050. @code{bootloader} that indicates the bootloader to be configured and
  26051. installed.
  26052. Some of the bootloaders do not honor every field of
  26053. @code{bootloader-configuration}. For instance, the extlinux
  26054. bootloader does not support themes and thus ignores the @code{theme}
  26055. field.
  26056. @deftp {Data Type} bootloader-configuration
  26057. The type of a bootloader configuration declaration.
  26058. @table @asis
  26059. @item @code{bootloader}
  26060. @cindex EFI, bootloader
  26061. @cindex UEFI, bootloader
  26062. @cindex BIOS, bootloader
  26063. The bootloader to use, as a @code{bootloader} object. For now
  26064. @code{grub-bootloader}, @code{grub-efi-bootloader},
  26065. @code{grub-efi-netboot-bootloader}, @code{extlinux-bootloader} and
  26066. @code{u-boot-bootloader} are supported.
  26067. @cindex ARM, bootloaders
  26068. @cindex AArch64, bootloaders
  26069. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  26070. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  26071. of bootloaders for a wide range of ARM and AArch64 systems, using the
  26072. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  26073. @vindex grub-efi-bootloader
  26074. @code{grub-efi-bootloader} allows to boot on modern systems using the
  26075. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  26076. use if the installation image contains a @file{/sys/firmware/efi} directory
  26077. when you boot it on your system.
  26078. @vindex grub-bootloader
  26079. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  26080. in ``legacy'' BIOS mode.
  26081. @vindex grub-efi-netboot-bootloader
  26082. @code{grub-efi-netboot-bootloader} allows you to boot your system over network
  26083. through TFTP@. In combination with an NFS root file system this allows you to
  26084. build a diskless Guix system.
  26085. The installation of the @code{grub-efi-netboot-bootloader} generates the
  26086. content of the TFTP root directory at @code{targets} (@pxref{Bootloader
  26087. Configuration, @code{targets}}), to be served by a TFTP server. You may
  26088. want to mount your TFTP server directories onto the @code{targets} to
  26089. move the required files to the TFTP server automatically.
  26090. If you plan to use an NFS root file system as well (actually if you mount the
  26091. store from an NFS share), then the TFTP server needs to serve the file
  26092. @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
  26093. image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
  26094. initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
  26095. files from the store will be accessed by GRUB through TFTP with their normal
  26096. store path, for example as
  26097. @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
  26098. Two symlinks are created to make this possible. For each target in the
  26099. @code{targets} field, the first symlink is
  26100. @samp{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
  26101. @file{../../../boot/grub/grub.cfg}, where @samp{target} may be
  26102. @file{/boot}. In this case the link is not leaving the served TFTP root
  26103. directory, but otherwise it does. The second link is
  26104. @samp{target}@file{/gnu/store} and points to @file{../gnu/store}. This
  26105. link is leaving the served TFTP root directory.
  26106. The assumption behind all this is that you have an NFS server exporting
  26107. the root file system for your Guix system, and additionally a TFTP
  26108. server exporting your @code{targets} directories—usually a single
  26109. @file{/boot}—from that same root file system for your Guix system. In
  26110. this constellation the symlinks will work.
  26111. For other constellations you will have to program your own bootloader
  26112. installer, which then takes care to make necessary files from the store
  26113. accessible through TFTP, for example by copying them into the TFTP root
  26114. directory to your @code{targets}.
  26115. It is important to note that symlinks pointing outside the TFTP root directory
  26116. may need to be allowed in the configuration of your TFTP server. Further the
  26117. store link exposes the whole store through TFTP@. Both points need to be
  26118. considered carefully for security aspects.
  26119. Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
  26120. NFS servers, you also need a properly configured DHCP server to make the booting
  26121. over netboot possible. For all this we can currently only recommend you to look
  26122. for instructions about @acronym{PXE, Preboot eXecution Environment}.
  26123. @item @code{targets}
  26124. This is a list of strings denoting the targets onto which to install the
  26125. bootloader.
  26126. The interpretation of targets depends on the bootloader in question.
  26127. For @code{grub-bootloader}, for example, they should be device names
  26128. understood by the bootloader @command{installer} command, such as
  26129. @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub,
  26130. GNU GRUB Manual}). For @code{grub-efi-bootloader}, they should be mount
  26131. points of the EFI file system, usually @file{/boot/efi}. For
  26132. @code{grub-efi-netboot-bootloader}, @code{targets} should be the mount
  26133. points corresponding to TFTP root directories served by your TFTP
  26134. server.
  26135. @item @code{menu-entries} (default: @code{()})
  26136. A possibly empty list of @code{menu-entry} objects (see below), denoting
  26137. entries to appear in the bootloader menu, in addition to the current
  26138. system entry and the entry pointing to previous system generations.
  26139. @item @code{default-entry} (default: @code{0})
  26140. The index of the default boot menu entry. Index 0 is for the entry of the
  26141. current system.
  26142. @item @code{timeout} (default: @code{5})
  26143. The number of seconds to wait for keyboard input before booting. Set to
  26144. 0 to boot immediately, and to -1 to wait indefinitely.
  26145. @cindex keyboard layout, for the bootloader
  26146. @item @code{keyboard-layout} (default: @code{#f})
  26147. If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
  26148. layout, usually US@tie{}English (``qwerty'').
  26149. Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
  26150. Layout}).
  26151. @quotation Note
  26152. This option is currently ignored by bootloaders other than @code{grub} and
  26153. @code{grub-efi}.
  26154. @end quotation
  26155. @item @code{theme} (default: @var{#f})
  26156. The bootloader theme object describing the theme to use. If no theme
  26157. is provided, some bootloaders might use a default theme, that's true
  26158. for GRUB.
  26159. @item @code{terminal-outputs} (default: @code{'(gfxterm)})
  26160. The output terminals used for the bootloader boot menu, as a list of
  26161. symbols. GRUB accepts the values: @code{console}, @code{serial},
  26162. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  26163. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  26164. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  26165. configuration,,, grub,GNU GRUB manual}).
  26166. @item @code{terminal-inputs} (default: @code{'()})
  26167. The input terminals used for the bootloader boot menu, as a list of
  26168. symbols. For GRUB, the default is the native platform terminal as
  26169. determined at run-time. GRUB accepts the values: @code{console},
  26170. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  26171. @code{usb_keyboard}. This field corresponds to the GRUB variable
  26172. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  26173. manual}).
  26174. @item @code{serial-unit} (default: @code{#f})
  26175. The serial unit used by the bootloader, as an integer from 0 to 3.
  26176. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  26177. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  26178. @item @code{serial-speed} (default: @code{#f})
  26179. The speed of the serial interface, as an integer. For GRUB, the
  26180. default value is chosen at run-time; currently GRUB chooses
  26181. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  26182. @end table
  26183. @end deftp
  26184. @cindex dual boot
  26185. @cindex boot menu
  26186. Should you want to list additional boot menu entries @i{via} the
  26187. @code{menu-entries} field above, you will need to create them with the
  26188. @code{menu-entry} form. For example, imagine you want to be able to
  26189. boot another distro (hard to imagine!), you can define a menu entry
  26190. along these lines:
  26191. @lisp
  26192. (menu-entry
  26193. (label "The Other Distro")
  26194. (linux "/boot/old/vmlinux-2.6.32")
  26195. (linux-arguments '("root=/dev/sda2"))
  26196. (initrd "/boot/old/initrd"))
  26197. @end lisp
  26198. Details below.
  26199. @deftp {Data Type} menu-entry
  26200. The type of an entry in the bootloader menu.
  26201. @table @asis
  26202. @item @code{label}
  26203. The label to show in the menu---e.g., @code{"GNU"}.
  26204. @item @code{linux} (default: @code{#f})
  26205. The Linux kernel image to boot, for example:
  26206. @lisp
  26207. (file-append linux-libre "/bzImage")
  26208. @end lisp
  26209. For GRUB, it is also possible to specify a device explicitly in the
  26210. file path using GRUB's device naming convention (@pxref{Naming
  26211. convention,,, grub, GNU GRUB manual}), for example:
  26212. @example
  26213. "(hd0,msdos1)/boot/vmlinuz"
  26214. @end example
  26215. If the device is specified explicitly as above, then the @code{device}
  26216. field is ignored entirely.
  26217. @item @code{linux-arguments} (default: @code{()})
  26218. The list of extra Linux kernel command-line arguments---e.g.,
  26219. @code{("console=ttyS0")}.
  26220. @item @code{initrd} (default: @code{#f})
  26221. A G-Expression or string denoting the file name of the initial RAM disk
  26222. to use (@pxref{G-Expressions}).
  26223. @item @code{device} (default: @code{#f})
  26224. The device where the kernel and initrd are to be found---i.e., for GRUB,
  26225. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  26226. This may be a file system label (a string), a file system UUID (a
  26227. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  26228. the bootloader will search the device containing the file specified by
  26229. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  26230. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  26231. @item @code{multiboot-kernel} (default: @code{#f})
  26232. The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
  26233. manual}). When this field is set, a Multiboot menu-entry is generated.
  26234. For example:
  26235. @lisp
  26236. (file-append mach "/boot/gnumach")
  26237. @end lisp
  26238. @item @code{multiboot-arguments} (default: @code{()})
  26239. The list of extra command-line arguments for the multiboot-kernel.
  26240. @item @code{multiboot-modules} (default: @code{()})
  26241. The list of commands for loading Multiboot modules. For example:
  26242. @lisp
  26243. (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
  26244. @dots{})
  26245. (list (file-append libc "/lib/ld.so.1") "exec"
  26246. @dots{}))
  26247. @end lisp
  26248. @end table
  26249. @end deftp
  26250. @cindex HDPI
  26251. @cindex HiDPI
  26252. @cindex resolution
  26253. @c FIXME: Write documentation once it's stable.
  26254. For now only GRUB has theme support. GRUB themes are created using
  26255. the @code{grub-theme} form, which is not fully documented yet.
  26256. @deftp {Data Type} grub-theme
  26257. Data type representing the configuration of the GRUB theme.
  26258. @table @asis
  26259. @item @code{gfxmode} (default: @code{'("auto")})
  26260. The GRUB @code{gfxmode} to set (a list of screen resolution strings,
  26261. @pxref{gfxmode,,, grub, GNU GRUB manual}).
  26262. @end table
  26263. @end deftp
  26264. @deffn {Scheme Procedure} grub-theme
  26265. Return the default GRUB theme used by the operating system if no
  26266. @code{theme} field is specified in @code{bootloader-configuration}
  26267. record.
  26268. It comes with a fancy background image displaying the GNU and Guix
  26269. logos.
  26270. @end deffn
  26271. For example, to override the default resolution, you may use something
  26272. like
  26273. @lisp
  26274. (bootloader
  26275. (bootloader-configuration
  26276. ;; @dots{}
  26277. (theme (grub-theme
  26278. (inherit (grub-theme))
  26279. (gfxmode '("1024x786x32" "auto"))))))
  26280. @end lisp
  26281. @node Invoking guix system
  26282. @section Invoking @code{guix system}
  26283. Once you have written an operating system declaration as seen in the
  26284. previous section, it can be @dfn{instantiated} using the @command{guix
  26285. system} command. The synopsis is:
  26286. @example
  26287. guix system @var{options}@dots{} @var{action} @var{file}
  26288. @end example
  26289. @var{file} must be the name of a file containing an
  26290. @code{operating-system} declaration. @var{action} specifies how the
  26291. operating system is instantiated. Currently the following values are
  26292. supported:
  26293. @table @code
  26294. @item search
  26295. Display available service type definitions that match the given regular
  26296. expressions, sorted by relevance:
  26297. @cindex HDPI
  26298. @cindex HiDPI
  26299. @cindex resolution
  26300. @example
  26301. $ guix system search console
  26302. name: console-fonts
  26303. location: gnu/services/base.scm:806:2
  26304. extends: shepherd-root
  26305. description: Install the given fonts on the specified ttys (fonts are per
  26306. + virtual console on GNU/Linux). The value of this service is a list of
  26307. + tty/font pairs. The font can be the name of a font provided by the `kbd'
  26308. + package or any valid argument to `setfont', as in this example:
  26309. +
  26310. + '(("tty1" . "LatGrkCyr-8x16")
  26311. + ("tty2" . (file-append
  26312. + font-tamzen
  26313. + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  26314. + ("tty3" . (file-append
  26315. + font-terminus
  26316. + "/share/consolefonts/ter-132n"))) ; for HDPI
  26317. relevance: 9
  26318. name: mingetty
  26319. location: gnu/services/base.scm:1190:2
  26320. extends: shepherd-root
  26321. description: Provide console login using the `mingetty' program.
  26322. relevance: 2
  26323. name: login
  26324. location: gnu/services/base.scm:860:2
  26325. extends: pam
  26326. description: Provide a console log-in service as specified by its
  26327. + configuration value, a `login-configuration' object.
  26328. relevance: 2
  26329. @dots{}
  26330. @end example
  26331. As for @command{guix package --search}, the result is written in
  26332. @code{recutils} format, which makes it easy to filter the output
  26333. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  26334. @item reconfigure
  26335. Build the operating system described in @var{file}, activate it, and
  26336. switch to it@footnote{This action (and the related actions
  26337. @code{switch-generation} and @code{roll-back}) are usable only on
  26338. systems already running Guix System.}.
  26339. @quotation Note
  26340. @c The paragraph below refers to the problem discussed at
  26341. @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  26342. It is highly recommended to run @command{guix pull} once before you run
  26343. @command{guix system reconfigure} for the first time (@pxref{Invoking
  26344. guix pull}). Failing to do that you would see an older version of Guix
  26345. once @command{reconfigure} has completed.
  26346. @end quotation
  26347. This effects all the configuration specified in @var{file}: user
  26348. accounts, system services, global package list, setuid programs, etc.
  26349. The command starts system services specified in @var{file} that are not
  26350. currently running; if a service is currently running this command will
  26351. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  26352. @code{herd stop X} or @code{herd restart X}).
  26353. This command creates a new generation whose number is one greater than
  26354. the current generation (as reported by @command{guix system
  26355. list-generations}). If that generation already exists, it will be
  26356. overwritten. This behavior mirrors that of @command{guix package}
  26357. (@pxref{Invoking guix package}).
  26358. It also adds a bootloader menu entry for the new OS configuration,
  26359. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  26360. entries for older configurations to a submenu, allowing you to choose
  26361. an older system generation at boot time should you need it.
  26362. @cindex provenance tracking, of the operating system
  26363. Upon completion, the new system is deployed under
  26364. @file{/run/current-system}. This directory contains @dfn{provenance
  26365. meta-data}: the list of channels in use (@pxref{Channels}) and
  26366. @var{file} itself, when available. You can view it by running:
  26367. @example
  26368. guix system describe
  26369. @end example
  26370. This information is useful should you later want to inspect how this
  26371. particular generation was built. In fact, assuming @var{file} is
  26372. self-contained, you can later rebuild generation @var{n} of your
  26373. operating system with:
  26374. @example
  26375. guix time-machine \
  26376. -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
  26377. system reconfigure \
  26378. /var/guix/profiles/system-@var{n}-link/configuration.scm
  26379. @end example
  26380. You can think of it as some sort of built-in version control! Your
  26381. system is not just a binary artifact: @emph{it carries its own source}.
  26382. @xref{Service Reference, @code{provenance-service-type}}, for more
  26383. information on provenance tracking.
  26384. By default, @command{reconfigure} @emph{prevents you from downgrading
  26385. your system}, which could (re)introduce security vulnerabilities and
  26386. also cause problems with ``stateful'' services such as database
  26387. management systems. You can override that behavior by passing
  26388. @option{--allow-downgrades}.
  26389. @item switch-generation
  26390. @cindex generations
  26391. Switch to an existing system generation. This action atomically
  26392. switches the system profile to the specified system generation. It
  26393. also rearranges the system's existing bootloader menu entries. It
  26394. makes the menu entry for the specified system generation the default,
  26395. and it moves the entries for the other generations to a submenu, if
  26396. supported by the bootloader being used. The next time the system
  26397. boots, it will use the specified system generation.
  26398. The bootloader itself is not being reinstalled when using this
  26399. command. Thus, the installed bootloader is used with an updated
  26400. configuration file.
  26401. The target generation can be specified explicitly by its generation
  26402. number. For example, the following invocation would switch to system
  26403. generation 7:
  26404. @example
  26405. guix system switch-generation 7
  26406. @end example
  26407. The target generation can also be specified relative to the current
  26408. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  26409. ``3 generations ahead of the current generation,'' and @code{-1} means
  26410. ``1 generation prior to the current generation.'' When specifying a
  26411. negative value such as @code{-1}, you must precede it with @code{--} to
  26412. prevent it from being parsed as an option. For example:
  26413. @example
  26414. guix system switch-generation -- -1
  26415. @end example
  26416. Currently, the effect of invoking this action is @emph{only} to switch
  26417. the system profile to an existing generation and rearrange the
  26418. bootloader menu entries. To actually start using the target system
  26419. generation, you must reboot after running this action. In the future,
  26420. it will be updated to do the same things as @command{reconfigure},
  26421. like activating and deactivating services.
  26422. This action will fail if the specified generation does not exist.
  26423. @item roll-back
  26424. @cindex rolling back
  26425. Switch to the preceding system generation. The next time the system
  26426. boots, it will use the preceding system generation. This is the inverse
  26427. of @command{reconfigure}, and it is exactly the same as invoking
  26428. @command{switch-generation} with an argument of @code{-1}.
  26429. Currently, as with @command{switch-generation}, you must reboot after
  26430. running this action to actually start using the preceding system
  26431. generation.
  26432. @item delete-generations
  26433. @cindex deleting system generations
  26434. @cindex saving space
  26435. Delete system generations, making them candidates for garbage collection
  26436. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  26437. collector'').
  26438. This works in the same way as @samp{guix package --delete-generations}
  26439. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  26440. arguments, all system generations but the current one are deleted:
  26441. @example
  26442. guix system delete-generations
  26443. @end example
  26444. You can also select the generations you want to delete. The example below
  26445. deletes all the system generations that are more than two month old:
  26446. @example
  26447. guix system delete-generations 2m
  26448. @end example
  26449. Running this command automatically reinstalls the bootloader with an updated
  26450. list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
  26451. longer lists the generations that have been deleted.
  26452. @item build
  26453. Build the derivation of the operating system, which includes all the
  26454. configuration files and programs needed to boot and run the system.
  26455. This action does not actually install anything.
  26456. @item init
  26457. Populate the given directory with all the files necessary to run the
  26458. operating system specified in @var{file}. This is useful for first-time
  26459. installations of Guix System. For instance:
  26460. @example
  26461. guix system init my-os-config.scm /mnt
  26462. @end example
  26463. copies to @file{/mnt} all the store items required by the configuration
  26464. specified in @file{my-os-config.scm}. This includes configuration
  26465. files, packages, and so on. It also creates other essential files
  26466. needed for the system to operate correctly---e.g., the @file{/etc},
  26467. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  26468. This command also installs bootloader on the targets specified in
  26469. @file{my-os-config}, unless the @option{--no-bootloader} option was
  26470. passed.
  26471. @item vm
  26472. @cindex virtual machine
  26473. @cindex VM
  26474. @anchor{guix system vm}
  26475. Build a virtual machine that contains the operating system declared in
  26476. @var{file}, and return a script to run that virtual machine (VM).
  26477. @quotation Note
  26478. The @code{vm} action and others below
  26479. can use KVM support in the Linux-libre kernel. Specifically, if the
  26480. machine has hardware virtualization support, the corresponding
  26481. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  26482. must exist and be readable and writable by the user and by the
  26483. build users of the daemon (@pxref{Build Environment Setup}).
  26484. @end quotation
  26485. Arguments given to the script are passed to QEMU as in the example
  26486. below, which enables networking and requests 1@tie{}GiB of RAM for the
  26487. emulated machine:
  26488. @example
  26489. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -nic user,model=virtio-net-pci
  26490. @end example
  26491. The VM shares its store with the host system.
  26492. Additional file systems can be shared between the host and the VM using
  26493. the @option{--share} and @option{--expose} command-line options: the former
  26494. specifies a directory to be shared with write access, while the latter
  26495. provides read-only access to the shared directory.
  26496. The example below creates a VM in which the user's home directory is
  26497. accessible read-only, and where the @file{/exchange} directory is a
  26498. read-write mapping of @file{$HOME/tmp} on the host:
  26499. @example
  26500. guix system vm my-config.scm \
  26501. --expose=$HOME --share=$HOME/tmp=/exchange
  26502. @end example
  26503. On GNU/Linux, the default is to boot directly to the kernel; this has
  26504. the advantage of requiring only a very tiny root disk image since the
  26505. store of the host can then be mounted.
  26506. The @option{--full-boot} option forces a complete boot sequence, starting
  26507. with the bootloader. This requires more disk space since a root image
  26508. containing at least the kernel, initrd, and bootloader data files must
  26509. be created. The @option{--image-size} option can be used to specify the
  26510. size of the image.
  26511. @cindex System images, creation in various formats
  26512. @cindex Creating system images in various formats
  26513. @item image
  26514. @itemx docker-image
  26515. Return a virtual machine, disk image, or Docker image of the operating
  26516. system declared in @var{file} that stands alone. By default,
  26517. @command{guix system} estimates the size of the image needed to store
  26518. the system, but you can use the @option{--image-size} option to specify
  26519. a value. Docker images are built to contain exactly what they need, so
  26520. the @option{--image-size} option is ignored in the case of
  26521. @code{docker-image}.
  26522. @cindex image, creating disk images
  26523. The @code{image} command can produce various image types. The
  26524. image type can be selected using the @option{--image-type} option. It
  26525. defaults to @code{efi-raw}. When its value is @code{iso9660}, the
  26526. @option{--label} option can be used to specify a volume ID with
  26527. @code{image}. By default, the root file system of a disk image is
  26528. mounted non-volatile; the @option{--volatile} option can be provided to
  26529. make it volatile instead. When using @code{image}, the bootloader
  26530. installed on the generated image is taken from the provided
  26531. @code{operating-system} definition. The following example demonstrates
  26532. how to generate an image that uses the @code{grub-efi-bootloader}
  26533. bootloader and boot it with QEMU:
  26534. @example
  26535. image=$(guix system image --image-type=qcow2 \
  26536. gnu/system/examples/lightweight-desktop.tmpl)
  26537. cp $image /tmp/my-image.qcow2
  26538. chmod +w /tmp/my-image.qcow2
  26539. qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
  26540. -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
  26541. @end example
  26542. When using the @code{efi-raw} image type, a raw disk image is produced;
  26543. it can be copied as is to a USB stick, for instance. Assuming
  26544. @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
  26545. the image to it using the following command:
  26546. @example
  26547. # dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress
  26548. @end example
  26549. The @code{--list-image-types} command lists all the available image
  26550. types.
  26551. @cindex creating virtual machine images
  26552. When using the @code{qcow2} image type, the returned image is in qcow2
  26553. format, which the QEMU emulator can efficiently use. @xref{Running Guix
  26554. in a VM}, for more information on how to run the image in a virtual
  26555. machine. The @code{grub-bootloader} bootloader is always used
  26556. independently of what is declared in the @code{operating-system} file
  26557. passed as argument. This is to make it easier to work with QEMU, which
  26558. uses the SeaBIOS BIOS by default, expecting a bootloader to be installed
  26559. in the Master Boot Record (MBR).
  26560. @cindex docker-image, creating docker images
  26561. When using @code{docker-image}, a Docker image is produced. Guix builds
  26562. the image from scratch, not from a pre-existing Docker base image. As a
  26563. result, it contains @emph{exactly} what you define in the operating
  26564. system configuration file. You can then load the image and launch a
  26565. Docker container using commands like the following:
  26566. @example
  26567. image_id="$(docker load < guix-system-docker-image.tar.gz)"
  26568. container_id="$(docker create $image_id)"
  26569. docker start $container_id
  26570. @end example
  26571. This command starts a new Docker container from the specified image. It
  26572. will boot the Guix system in the usual manner, which means it will
  26573. start any services you have defined in the operating system
  26574. configuration. You can get an interactive shell running in the container
  26575. using @command{docker exec}:
  26576. @example
  26577. docker exec -ti $container_id /run/current-system/profile/bin/bash --login
  26578. @end example
  26579. Depending on what you run in the Docker container, it
  26580. may be necessary to give the container additional permissions. For
  26581. example, if you intend to build software using Guix inside of the Docker
  26582. container, you may need to pass the @option{--privileged} option to
  26583. @code{docker create}.
  26584. Last, the @option{--network} option applies to @command{guix system
  26585. docker-image}: it produces an image where network is supposedly shared
  26586. with the host, and thus without services like nscd or NetworkManager.
  26587. @item container
  26588. Return a script to run the operating system declared in @var{file}
  26589. within a container. Containers are a set of lightweight isolation
  26590. mechanisms provided by the kernel Linux-libre. Containers are
  26591. substantially less resource-demanding than full virtual machines since
  26592. the kernel, shared objects, and other resources can be shared with the
  26593. host system; this also means they provide thinner isolation.
  26594. Currently, the script must be run as root in order to support more than
  26595. a single user and group. The container shares its store with the host
  26596. system.
  26597. As with the @code{vm} action (@pxref{guix system vm}), additional file
  26598. systems to be shared between the host and container can be specified
  26599. using the @option{--share} and @option{--expose} options:
  26600. @example
  26601. guix system container my-config.scm \
  26602. --expose=$HOME --share=$HOME/tmp=/exchange
  26603. @end example
  26604. @quotation Note
  26605. This option requires Linux-libre 3.19 or newer.
  26606. @end quotation
  26607. @end table
  26608. @var{options} can contain any of the common build options (@pxref{Common
  26609. Build Options}). In addition, @var{options} can contain one of the
  26610. following:
  26611. @table @option
  26612. @item --expression=@var{expr}
  26613. @itemx -e @var{expr}
  26614. Consider the operating-system @var{expr} evaluates to.
  26615. This is an alternative to specifying a file which evaluates to an
  26616. operating system.
  26617. This is used to generate the Guix system installer @pxref{Building the
  26618. Installation Image}).
  26619. @item --system=@var{system}
  26620. @itemx -s @var{system}
  26621. Attempt to build for @var{system} instead of the host system type.
  26622. This works as per @command{guix build} (@pxref{Invoking guix build}).
  26623. @item --derivation
  26624. @itemx -d
  26625. Return the derivation file name of the given operating system without
  26626. building anything.
  26627. @cindex provenance tracking, of the operating system
  26628. @item --save-provenance
  26629. As discussed above, @command{guix system init} and @command{guix system
  26630. reconfigure} always save provenance information @i{via} a dedicated
  26631. service (@pxref{Service Reference, @code{provenance-service-type}}).
  26632. However, other commands don't do that by default. If you wish to, say,
  26633. create a virtual machine image that contains provenance information, you
  26634. can run:
  26635. @example
  26636. guix system image -t qcow2 --save-provenance config.scm
  26637. @end example
  26638. That way, the resulting image will effectively ``embed its own source''
  26639. in the form of meta-data in @file{/run/current-system}. With that
  26640. information, one can rebuild the image to make sure it really contains
  26641. what it pretends to contain; or they could use that to derive a variant
  26642. of the image.
  26643. @item --image-type=@var{type}
  26644. @itemx -t @var{type}
  26645. For the @code{image} action, create an image with given @var{type}.
  26646. When this option is omitted, @command{guix system} uses the
  26647. @code{efi-raw} image type.
  26648. @cindex ISO-9660 format
  26649. @cindex CD image format
  26650. @cindex DVD image format
  26651. @option{--image-type=iso9660} produces an ISO-9660 image, suitable
  26652. for burning on CDs and DVDs.
  26653. @item --image-size=@var{size}
  26654. For the @code{image} action, create an image of the given @var{size}.
  26655. @var{size} may be a number of bytes, or it may include a unit as a
  26656. suffix (@pxref{Block size, size specifications,, coreutils, GNU
  26657. Coreutils}).
  26658. When this option is omitted, @command{guix system} computes an estimate
  26659. of the image size as a function of the size of the system declared in
  26660. @var{file}.
  26661. @item --network
  26662. @itemx -N
  26663. For the @code{container} action, allow containers to access the host network,
  26664. that is, do not create a network namespace.
  26665. @item --root=@var{file}
  26666. @itemx -r @var{file}
  26667. Make @var{file} a symlink to the result, and register it as a garbage
  26668. collector root.
  26669. @item --skip-checks
  26670. Skip pre-installation safety checks.
  26671. By default, @command{guix system init} and @command{guix system
  26672. reconfigure} perform safety checks: they make sure the file systems that
  26673. appear in the @code{operating-system} declaration actually exist
  26674. (@pxref{File Systems}), and that any Linux kernel modules that may be
  26675. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  26676. RAM Disk}). Passing this option skips these tests altogether.
  26677. @item --allow-downgrades
  26678. Instruct @command{guix system reconfigure} to allow system downgrades.
  26679. By default, @command{reconfigure} prevents you from downgrading your
  26680. system. It achieves that by comparing the provenance info of your
  26681. system (shown by @command{guix system describe}) with that of your
  26682. @command{guix} command (shown by @command{guix describe}). If the
  26683. commits for @command{guix} are not descendants of those used for your
  26684. system, @command{guix system reconfigure} errors out. Passing
  26685. @option{--allow-downgrades} allows you to bypass these checks.
  26686. @quotation Note
  26687. Make sure you understand its security implications before using
  26688. @option{--allow-downgrades}.
  26689. @end quotation
  26690. @cindex on-error
  26691. @cindex on-error strategy
  26692. @cindex error strategy
  26693. @item --on-error=@var{strategy}
  26694. Apply @var{strategy} when an error occurs when reading @var{file}.
  26695. @var{strategy} may be one of the following:
  26696. @table @code
  26697. @item nothing-special
  26698. Report the error concisely and exit. This is the default strategy.
  26699. @item backtrace
  26700. Likewise, but also display a backtrace.
  26701. @item debug
  26702. Report the error and enter Guile's debugger. From there, you can run
  26703. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  26704. display local variable values, and more generally inspect the state of the
  26705. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  26706. a list of available debugging commands.
  26707. @end table
  26708. @end table
  26709. Once you have built, configured, re-configured, and re-re-configured
  26710. your Guix installation, you may find it useful to list the operating
  26711. system generations available on disk---and that you can choose from the
  26712. bootloader boot menu:
  26713. @table @code
  26714. @item describe
  26715. Describe the current system generation: its file name, the kernel and
  26716. bootloader used, etc., as well as provenance information when available.
  26717. @item list-generations
  26718. List a summary of each generation of the operating system available on
  26719. disk, in a human-readable way. This is similar to the
  26720. @option{--list-generations} option of @command{guix package}
  26721. (@pxref{Invoking guix package}).
  26722. Optionally, one can specify a pattern, with the same syntax that is used
  26723. in @command{guix package --list-generations}, to restrict the list of
  26724. generations displayed. For instance, the following command displays
  26725. generations that are up to 10 days old:
  26726. @example
  26727. $ guix system list-generations 10d
  26728. @end example
  26729. @end table
  26730. The @command{guix system} command has even more to offer! The following
  26731. sub-commands allow you to visualize how your system services relate to
  26732. each other:
  26733. @anchor{system-extension-graph}
  26734. @table @code
  26735. @item extension-graph
  26736. Emit to standard output the @dfn{service
  26737. extension graph} of the operating system defined in @var{file}
  26738. (@pxref{Service Composition}, for more information on service
  26739. extensions). By default the output is in Dot/Graphviz format, but you
  26740. can choose a different format with @option{--graph-backend}, as with
  26741. @command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}):
  26742. The command:
  26743. @example
  26744. $ guix system extension-graph @var{file} | xdot -
  26745. @end example
  26746. shows the extension relations among services.
  26747. @anchor{system-shepherd-graph}
  26748. @item shepherd-graph
  26749. Emit to standard output the @dfn{dependency
  26750. graph} of shepherd services of the operating system defined in
  26751. @var{file}. @xref{Shepherd Services}, for more information and for an
  26752. example graph.
  26753. Again, the default output format is Dot/Graphviz, but you can pass
  26754. @option{--graph-backend} to select a different one.
  26755. @end table
  26756. @node Invoking guix deploy
  26757. @section Invoking @code{guix deploy}
  26758. We've already seen @code{operating-system} declarations used to manage a
  26759. machine's configuration locally. Suppose you need to configure multiple
  26760. machines, though---perhaps you're managing a service on the web that's
  26761. comprised of several servers. @command{guix deploy} enables you to use those
  26762. same @code{operating-system} declarations to manage multiple remote hosts at
  26763. once as a logical ``deployment''.
  26764. @quotation Note
  26765. The functionality described in this section is still under development
  26766. and is subject to change. Get in touch with us on
  26767. @email{guix-devel@@gnu.org}!
  26768. @end quotation
  26769. @example
  26770. guix deploy @var{file}
  26771. @end example
  26772. Such an invocation will deploy the machines that the code within @var{file}
  26773. evaluates to. As an example, @var{file} might contain a definition like this:
  26774. @lisp
  26775. ;; This is a Guix deployment of a "bare bones" setup, with
  26776. ;; no X11 display server, to a machine with an SSH daemon
  26777. ;; listening on localhost:2222. A configuration such as this
  26778. ;; may be appropriate for virtual machine with ports
  26779. ;; forwarded to the host's loopback interface.
  26780. (use-service-modules networking ssh)
  26781. (use-package-modules bootloaders)
  26782. (define %system
  26783. (operating-system
  26784. (host-name "gnu-deployed")
  26785. (timezone "Etc/UTC")
  26786. (bootloader (bootloader-configuration
  26787. (bootloader grub-bootloader)
  26788. (targets '("/dev/vda"))
  26789. (terminal-outputs '(console))))
  26790. (file-systems (cons (file-system
  26791. (mount-point "/")
  26792. (device "/dev/vda1")
  26793. (type "ext4"))
  26794. %base-file-systems))
  26795. (services
  26796. (append (list (service dhcp-client-service-type)
  26797. (service openssh-service-type
  26798. (openssh-configuration
  26799. (permit-root-login #t)
  26800. (allow-empty-passwords? #t))))
  26801. %base-services))))
  26802. (list (machine
  26803. (operating-system %system)
  26804. (environment managed-host-environment-type)
  26805. (configuration (machine-ssh-configuration
  26806. (host-name "localhost")
  26807. (system "x86_64-linux")
  26808. (user "alice")
  26809. (identity "./id_rsa")
  26810. (port 2222)))))
  26811. @end lisp
  26812. The file should evaluate to a list of @var{machine} objects. This example,
  26813. upon being deployed, will create a new generation on the remote system
  26814. realizing the @code{operating-system} declaration @code{%system}.
  26815. @code{environment} and @code{configuration} specify how the machine should be
  26816. provisioned---that is, how the computing resources should be created and
  26817. managed. The above example does not create any resources, as a
  26818. @code{'managed-host} is a machine that is already running the Guix system and
  26819. available over the network. This is a particularly simple case; a more
  26820. complex deployment may involve, for example, starting virtual machines through
  26821. a Virtual Private Server (VPS) provider. In such a case, a different
  26822. @var{environment} type would be used.
  26823. Do note that you first need to generate a key pair on the coordinator machine
  26824. to allow the daemon to export signed archives of files from the store
  26825. (@pxref{Invoking guix archive}), though this step is automatic on Guix
  26826. System:
  26827. @example
  26828. # guix archive --generate-key
  26829. @end example
  26830. @noindent
  26831. Each target machine must authorize the key of the master machine so that it
  26832. accepts store items it receives from the coordinator:
  26833. @example
  26834. # guix archive --authorize < coordinator-public-key.txt
  26835. @end example
  26836. @code{user}, in this example, specifies the name of the user account to log in
  26837. as to perform the deployment. Its default value is @code{root}, but root
  26838. login over SSH may be forbidden in some cases. To work around this,
  26839. @command{guix deploy} can log in as an unprivileged user and employ
  26840. @code{sudo} to escalate privileges. This will only work if @code{sudo} is
  26841. currently installed on the remote and can be invoked non-interactively as
  26842. @code{user}. That is, the line in @code{sudoers} granting @code{user} the
  26843. ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
  26844. be accomplished with the following operating system configuration snippet:
  26845. @lisp
  26846. (use-modules ...
  26847. (gnu system)) ;for %sudoers-specification
  26848. (define %user "username")
  26849. (operating-system
  26850. ...
  26851. (sudoers-file
  26852. (plain-file "sudoers"
  26853. (string-append (plain-file-content %sudoers-specification)
  26854. (format #f "~a ALL = NOPASSWD: ALL~%"
  26855. %user)))))
  26856. @end lisp
  26857. For more information regarding the format of the @file{sudoers} file,
  26858. consult @command{man sudoers}.
  26859. @deftp {Data Type} machine
  26860. This is the data type representing a single machine in a heterogeneous Guix
  26861. deployment.
  26862. @table @asis
  26863. @item @code{operating-system}
  26864. The object of the operating system configuration to deploy.
  26865. @item @code{environment}
  26866. An @code{environment-type} describing how the machine should be provisioned.
  26867. @item @code{configuration} (default: @code{#f})
  26868. An object describing the configuration for the machine's @code{environment}.
  26869. If the @code{environment} has a default configuration, @code{#f} may be used.
  26870. If @code{#f} is used for an environment with no default configuration,
  26871. however, an error will be thrown.
  26872. @end table
  26873. @end deftp
  26874. @deftp {Data Type} machine-ssh-configuration
  26875. This is the data type representing the SSH client parameters for a machine
  26876. with an @code{environment} of @code{managed-host-environment-type}.
  26877. @table @asis
  26878. @item @code{host-name}
  26879. @item @code{build-locally?} (default: @code{#t})
  26880. If false, system derivations will be built on the machine being deployed to.
  26881. @item @code{system}
  26882. The system type describing the architecture of the machine being deployed
  26883. to---e.g., @code{"x86_64-linux"}.
  26884. @item @code{authorize?} (default: @code{#t})
  26885. If true, the coordinator's signing key will be added to the remote's ACL
  26886. keyring.
  26887. @item @code{port} (default: @code{22})
  26888. @item @code{user} (default: @code{"root"})
  26889. @item @code{identity} (default: @code{#f})
  26890. If specified, the path to the SSH private key to use to authenticate with the
  26891. remote host.
  26892. @item @code{host-key} (default: @code{#f})
  26893. This should be the SSH host key of the machine, which looks like this:
  26894. @example
  26895. ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
  26896. @end example
  26897. When @code{host-key} is @code{#f}, the server is authenticated against
  26898. the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
  26899. client does.
  26900. @item @code{allow-downgrades?} (default: @code{#f})
  26901. Whether to allow potential downgrades.
  26902. Like @command{guix system reconfigure}, @command{guix deploy} compares
  26903. the channel commits currently deployed on the remote host (as returned
  26904. by @command{guix system describe}) to those currently in use (as
  26905. returned by @command{guix describe}) to determine whether commits
  26906. currently in use are descendants of those deployed. When this is not
  26907. the case and @code{allow-downgrades?} is false, it raises an error.
  26908. This ensures you do not accidentally downgrade remote machines.
  26909. @end table
  26910. @end deftp
  26911. @deftp {Data Type} digital-ocean-configuration
  26912. This is the data type describing the Droplet that should be created for a
  26913. machine with an @code{environment} of @code{digital-ocean-environment-type}.
  26914. @table @asis
  26915. @item @code{ssh-key}
  26916. The path to the SSH private key to use to authenticate with the remote
  26917. host. In the future, this field may not exist.
  26918. @item @code{tags}
  26919. A list of string ``tags'' that uniquely identify the machine. Must be given
  26920. such that no two machines in the deployment have the same set of tags.
  26921. @item @code{region}
  26922. A Digital Ocean region slug, such as @code{"nyc3"}.
  26923. @item @code{size}
  26924. A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
  26925. @item @code{enable-ipv6?}
  26926. Whether or not the droplet should be created with IPv6 networking.
  26927. @end table
  26928. @end deftp
  26929. @node Running Guix in a VM
  26930. @section Running Guix in a Virtual Machine
  26931. @cindex virtual machine
  26932. To run Guix in a virtual machine (VM), one can use the pre-built Guix VM
  26933. image distributed at
  26934. @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.qcow2}.
  26935. This image is a compressed image in QCOW format. You can pass it to an
  26936. emulator such as @uref{https://qemu.org/, QEMU} (see below for details).
  26937. This image boots the Xfce graphical environment and it contains some
  26938. commonly used tools. You can install more software in the image by running
  26939. @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
  26940. also reconfigure the system based on its initial configuration file available
  26941. as @file{/run/current-system/configuration.scm} (@pxref{Using the
  26942. Configuration System}).
  26943. Instead of using this pre-built image, one can also build their own
  26944. image using @command{guix system image} (@pxref{Invoking guix system}).
  26945. @cindex QEMU
  26946. If you built your own image, you must copy it out of the store
  26947. (@pxref{The Store}) and give yourself permission to write to the copy
  26948. before you can use it. When invoking QEMU, you must choose a system
  26949. emulator that is suitable for your hardware platform. Here is a minimal
  26950. QEMU invocation that will boot the result of @command{guix system
  26951. image -t qcow2} on x86_64 hardware:
  26952. @example
  26953. $ qemu-system-x86_64 \
  26954. -nic user,model=virtio-net-pci \
  26955. -enable-kvm -m 1024 \
  26956. -device virtio-blk,drive=myhd \
  26957. -drive if=none,file=/tmp/qemu-image,id=myhd
  26958. @end example
  26959. Here is what each of these options means:
  26960. @table @code
  26961. @item qemu-system-x86_64
  26962. This specifies the hardware platform to emulate. This should match the
  26963. host.
  26964. @item -nic user,model=virtio-net-pci
  26965. Enable the unprivileged user-mode network stack. The guest OS can
  26966. access the host but not vice versa. This is the simplest way to get the
  26967. guest OS online. @code{model} specifies which network device to emulate:
  26968. @code{virtio-net-pci} is a special device made for virtualized operating
  26969. systems and recommended for most uses. Assuming your hardware platform is
  26970. x86_64, you can get a list of available NIC models by running
  26971. @command{qemu-system-x86_64 -nic model=help}.
  26972. @item -enable-kvm
  26973. If your system has hardware virtualization extensions, enabling the
  26974. virtual machine support (KVM) of the Linux kernel will make things run
  26975. faster.
  26976. @c To run Xfce + 'guix pull', we need at least 1G of RAM.
  26977. @item -m 1024
  26978. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  26979. which may be insufficient for some operations.
  26980. @item -device virtio-blk,drive=myhd
  26981. Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
  26982. ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
  26983. better performance than if it were emulating a complete disk drive. See the
  26984. QEMU and KVM documentation for more info.
  26985. @item -drive if=none,file=/tmp/qemu-image,id=myhd
  26986. Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing
  26987. store of the ``myhd'' drive.
  26988. @end table
  26989. The default @command{run-vm.sh} script that is returned by an invocation of
  26990. @command{guix system vm} does not add a @command{-nic user} flag by default.
  26991. To get network access from within the vm add the @code{(dhcp-client-service)}
  26992. to your system definition and start the VM using
  26993. @command{$(guix system vm config.scm) -nic user}. An important caveat of using
  26994. @command{-nic user} for networking is that @command{ping} will not work, because
  26995. it uses the ICMP protocol. You'll have to use a different command to check for
  26996. network connectivity, for example @command{guix download}.
  26997. @subsection Connecting Through SSH
  26998. @cindex SSH
  26999. @cindex SSH server
  27000. To enable SSH inside a VM you need to add an SSH server like
  27001. @code{openssh-service-type} to your VM (@pxref{Networking Services,
  27002. @code{openssh-service-type}}). In addition you need to forward the SSH port,
  27003. 22 by default, to the host. You can do this with
  27004. @example
  27005. $(guix system vm config.scm) -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  27006. @end example
  27007. To connect to the VM you can run
  27008. @example
  27009. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 localhost
  27010. @end example
  27011. The @command{-p} tells @command{ssh} the port you want to connect to.
  27012. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  27013. every time you modify your @command{config.scm} file and the
  27014. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  27015. connection to an unknown host every time you connect.
  27016. @quotation Note
  27017. If you find the above @samp{hostfwd} example not to be working (e.g.,
  27018. your SSH client hangs attempting to connect to the mapped port of your
  27019. VM), make sure that your Guix System VM has networking support, such as
  27020. by using the @code{dhcp-client-service-type} service type.
  27021. @end quotation
  27022. @subsection Using @command{virt-viewer} with Spice
  27023. As an alternative to the default @command{qemu} graphical client you can
  27024. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  27025. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  27026. @command{qemu}. See previous section for further information on how to do this.
  27027. Spice also allows you to do some nice stuff like share your clipboard with your
  27028. VM@. To enable that you'll also have to pass the following flags to @command{qemu}:
  27029. @example
  27030. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  27031. -chardev spicevmc,name=vdagent,id=vdagent
  27032. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
  27033. name=com.redhat.spice.0
  27034. @end example
  27035. You'll also need to add the @code{(spice-vdagent-service)} to your
  27036. system definition (@pxref{Miscellaneous Services, Spice service}).
  27037. @node Defining Services
  27038. @section Defining Services
  27039. The previous sections show the available services and how one can combine
  27040. them in an @code{operating-system} declaration. But how do we define
  27041. them in the first place? And what is a service anyway?
  27042. @menu
  27043. * Service Composition:: The model for composing services.
  27044. * Service Types and Services:: Types and services.
  27045. * Service Reference:: API reference.
  27046. * Shepherd Services:: A particular type of service.
  27047. @end menu
  27048. @node Service Composition
  27049. @subsection Service Composition
  27050. @cindex services
  27051. @cindex daemons
  27052. Here we define a @dfn{service} as, broadly, something that extends the
  27053. functionality of the operating system. Often a service is a process---a
  27054. @dfn{daemon}---started when the system boots: a secure shell server, a
  27055. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  27056. whose execution can be triggered by another daemon---e.g., an FTP server
  27057. started by @command{inetd} or a D-Bus service activated by
  27058. @command{dbus-daemon}. Occasionally, a service does not map to a
  27059. daemon. For instance, the ``account'' service collects user accounts
  27060. and makes sure they exist when the system runs; the ``udev'' service
  27061. collects device management rules and makes them available to the eudev
  27062. daemon; the @file{/etc} service populates the @file{/etc} directory
  27063. of the system.
  27064. @cindex service extensions
  27065. Guix system services are connected by @dfn{extensions}. For instance, the
  27066. secure shell service @emph{extends} the Shepherd---the
  27067. initialization system, running as PID@tie{}1---by giving it the command
  27068. lines to start and stop the secure shell daemon (@pxref{Networking
  27069. Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
  27070. service by passing it its @file{.service} specification, and extends the
  27071. udev service by passing it device management rules (@pxref{Desktop
  27072. Services, @code{upower-service}}); the Guix daemon service extends the
  27073. Shepherd by passing it the command lines to start and stop the daemon,
  27074. and extends the account service by passing it a list of required build
  27075. user accounts (@pxref{Base Services}).
  27076. All in all, services and their ``extends'' relations form a directed
  27077. acyclic graph (DAG). If we represent services as boxes and extensions
  27078. as arrows, a typical system might provide something like this:
  27079. @image{images/service-graph,,5in,Typical service extension graph.}
  27080. @cindex system service
  27081. At the bottom, we see the @dfn{system service}, which produces the
  27082. directory containing everything to run and boot the system, as returned
  27083. by the @command{guix system build} command. @xref{Service Reference},
  27084. to learn about the other service types shown here.
  27085. @xref{system-extension-graph, the @command{guix system extension-graph}
  27086. command}, for information on how to generate this representation for a
  27087. particular operating system definition.
  27088. @cindex service types
  27089. Technically, developers can define @dfn{service types} to express these
  27090. relations. There can be any number of services of a given type on the
  27091. system---for instance, a system running two instances of the GNU secure
  27092. shell server (lsh) has two instances of @code{lsh-service-type}, with
  27093. different parameters.
  27094. The following section describes the programming interface for service
  27095. types and services.
  27096. @node Service Types and Services
  27097. @subsection Service Types and Services
  27098. A @dfn{service type} is a node in the DAG described above. Let us start
  27099. with a simple example, the service type for the Guix build daemon
  27100. (@pxref{Invoking guix-daemon}):
  27101. @lisp
  27102. (define guix-service-type
  27103. (service-type
  27104. (name 'guix)
  27105. (extensions
  27106. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  27107. (service-extension account-service-type guix-accounts)
  27108. (service-extension activation-service-type guix-activation)))
  27109. (default-value (guix-configuration))))
  27110. @end lisp
  27111. @noindent
  27112. It defines three things:
  27113. @enumerate
  27114. @item
  27115. A name, whose sole purpose is to make inspection and debugging easier.
  27116. @item
  27117. A list of @dfn{service extensions}, where each extension designates the
  27118. target service type and a procedure that, given the parameters of the
  27119. service, returns a list of objects to extend the service of that type.
  27120. Every service type has at least one service extension. The only
  27121. exception is the @dfn{boot service type}, which is the ultimate service.
  27122. @item
  27123. Optionally, a default value for instances of this type.
  27124. @end enumerate
  27125. In this example, @code{guix-service-type} extends three services:
  27126. @table @code
  27127. @item shepherd-root-service-type
  27128. The @code{guix-shepherd-service} procedure defines how the Shepherd
  27129. service is extended. Namely, it returns a @code{<shepherd-service>}
  27130. object that defines how @command{guix-daemon} is started and stopped
  27131. (@pxref{Shepherd Services}).
  27132. @item account-service-type
  27133. This extension for this service is computed by @code{guix-accounts},
  27134. which returns a list of @code{user-group} and @code{user-account}
  27135. objects representing the build user accounts (@pxref{Invoking
  27136. guix-daemon}).
  27137. @item activation-service-type
  27138. Here @code{guix-activation} is a procedure that returns a gexp, which is
  27139. a code snippet to run at ``activation time''---e.g., when the service is
  27140. booted.
  27141. @end table
  27142. A service of this type is instantiated like this:
  27143. @lisp
  27144. (service guix-service-type
  27145. (guix-configuration
  27146. (build-accounts 5)
  27147. (extra-options '("--gc-keep-derivations"))))
  27148. @end lisp
  27149. The second argument to the @code{service} form is a value representing
  27150. the parameters of this specific service instance.
  27151. @xref{guix-configuration-type, @code{guix-configuration}}, for
  27152. information about the @code{guix-configuration} data type. When the
  27153. value is omitted, the default value specified by
  27154. @code{guix-service-type} is used:
  27155. @lisp
  27156. (service guix-service-type)
  27157. @end lisp
  27158. @code{guix-service-type} is quite simple because it extends other
  27159. services but is not extensible itself.
  27160. @c @subsubsubsection Extensible Service Types
  27161. The service type for an @emph{extensible} service looks like this:
  27162. @lisp
  27163. (define udev-service-type
  27164. (service-type (name 'udev)
  27165. (extensions
  27166. (list (service-extension shepherd-root-service-type
  27167. udev-shepherd-service)))
  27168. (compose concatenate) ;concatenate the list of rules
  27169. (extend (lambda (config rules)
  27170. (match config
  27171. (($ <udev-configuration> udev initial-rules)
  27172. (udev-configuration
  27173. (udev udev) ;the udev package to use
  27174. (rules (append initial-rules rules)))))))))
  27175. @end lisp
  27176. This is the service type for the
  27177. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  27178. management daemon}. Compared to the previous example, in addition to an
  27179. extension of @code{shepherd-root-service-type}, we see two new fields:
  27180. @table @code
  27181. @item compose
  27182. This is the procedure to @dfn{compose} the list of extensions to
  27183. services of this type.
  27184. Services can extend the udev service by passing it lists of rules; we
  27185. compose those extensions simply by concatenating them.
  27186. @item extend
  27187. This procedure defines how the value of the service is @dfn{extended} with
  27188. the composition of the extensions.
  27189. Udev extensions are composed into a list of rules, but the udev service
  27190. value is itself a @code{<udev-configuration>} record. So here, we
  27191. extend that record by appending the list of rules it contains to the
  27192. list of contributed rules.
  27193. @item description
  27194. This is a string giving an overview of the service type. The string can
  27195. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  27196. @command{guix system search} command searches these strings and displays
  27197. them (@pxref{Invoking guix system}).
  27198. @end table
  27199. There can be only one instance of an extensible service type such as
  27200. @code{udev-service-type}. If there were more, the
  27201. @code{service-extension} specifications would be ambiguous.
  27202. Still here? The next section provides a reference of the programming
  27203. interface for services.
  27204. @node Service Reference
  27205. @subsection Service Reference
  27206. We have seen an overview of service types (@pxref{Service Types and
  27207. Services}). This section provides a reference on how to manipulate
  27208. services and service types. This interface is provided by the
  27209. @code{(gnu services)} module.
  27210. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  27211. Return a new service of @var{type}, a @code{<service-type>} object (see
  27212. below). @var{value} can be any object; it represents the parameters of
  27213. this particular service instance.
  27214. When @var{value} is omitted, the default value specified by @var{type}
  27215. is used; if @var{type} does not specify a default value, an error is
  27216. raised.
  27217. For instance, this:
  27218. @lisp
  27219. (service openssh-service-type)
  27220. @end lisp
  27221. @noindent
  27222. is equivalent to this:
  27223. @lisp
  27224. (service openssh-service-type
  27225. (openssh-configuration))
  27226. @end lisp
  27227. In both cases the result is an instance of @code{openssh-service-type}
  27228. with the default configuration.
  27229. @end deffn
  27230. @deffn {Scheme Procedure} service? @var{obj}
  27231. Return true if @var{obj} is a service.
  27232. @end deffn
  27233. @deffn {Scheme Procedure} service-kind @var{service}
  27234. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  27235. @end deffn
  27236. @deffn {Scheme Procedure} service-value @var{service}
  27237. Return the value associated with @var{service}. It represents its
  27238. parameters.
  27239. @end deffn
  27240. Here is an example of how a service is created and manipulated:
  27241. @lisp
  27242. (define s
  27243. (service nginx-service-type
  27244. (nginx-configuration
  27245. (nginx nginx)
  27246. (log-directory log-directory)
  27247. (run-directory run-directory)
  27248. (file config-file))))
  27249. (service? s)
  27250. @result{} #t
  27251. (eq? (service-kind s) nginx-service-type)
  27252. @result{} #t
  27253. @end lisp
  27254. The @code{modify-services} form provides a handy way to change the
  27255. parameters of some of the services of a list such as
  27256. @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  27257. evaluates to a list of services. Of course, you could always use
  27258. standard list combinators such as @code{map} and @code{fold} to do that
  27259. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  27260. @code{modify-services} simply provides a more concise form for this
  27261. common pattern.
  27262. @deffn {Scheme Syntax} modify-services @var{services} @
  27263. (@var{type} @var{variable} => @var{body}) @dots{}
  27264. Modify the services listed in @var{services} according to the given
  27265. clauses. Each clause has the form:
  27266. @example
  27267. (@var{type} @var{variable} => @var{body})
  27268. @end example
  27269. where @var{type} is a service type---e.g.,
  27270. @code{guix-service-type}---and @var{variable} is an identifier that is
  27271. bound within the @var{body} to the service parameters---e.g., a
  27272. @code{guix-configuration} instance---of the original service of that
  27273. @var{type}.
  27274. The @var{body} should evaluate to the new service parameters, which will
  27275. be used to configure the new service. This new service will replace the
  27276. original in the resulting list. Because a service's service parameters
  27277. are created using @code{define-record-type*}, you can write a succinct
  27278. @var{body} that evaluates to the new service parameters by using the
  27279. @code{inherit} feature that @code{define-record-type*} provides.
  27280. @xref{Using the Configuration System}, for example usage.
  27281. @end deffn
  27282. Next comes the programming interface for service types. This is
  27283. something you want to know when writing new service definitions, but not
  27284. necessarily when simply looking for ways to customize your
  27285. @code{operating-system} declaration.
  27286. @deftp {Data Type} service-type
  27287. @cindex service type
  27288. This is the representation of a @dfn{service type} (@pxref{Service Types
  27289. and Services}).
  27290. @table @asis
  27291. @item @code{name}
  27292. This is a symbol, used only to simplify inspection and debugging.
  27293. @item @code{extensions}
  27294. A non-empty list of @code{<service-extension>} objects (see below).
  27295. @item @code{compose} (default: @code{#f})
  27296. If this is @code{#f}, then the service type denotes services that cannot
  27297. be extended---i.e., services that do not receive ``values'' from other
  27298. services.
  27299. Otherwise, it must be a one-argument procedure. The procedure is called
  27300. by @code{fold-services} and is passed a list of values collected from
  27301. extensions. It may return any single value.
  27302. @item @code{extend} (default: @code{#f})
  27303. If this is @code{#f}, services of this type cannot be extended.
  27304. Otherwise, it must be a two-argument procedure: @code{fold-services}
  27305. calls it, passing it the initial value of the service as the first
  27306. argument and the result of applying @code{compose} to the extension
  27307. values as the second argument. It must return a value that is a valid
  27308. parameter value for the service instance.
  27309. @item @code{description}
  27310. This is a string, possibly using Texinfo markup, describing in a couple
  27311. of sentences what the service is about. This string allows users to
  27312. find about the service through @command{guix system search}
  27313. (@pxref{Invoking guix system}).
  27314. @item @code{default-value} (default: @code{&no-default-value})
  27315. The default value associated for instances of this service type. This
  27316. allows users to use the @code{service} form without its second argument:
  27317. @lisp
  27318. (service @var{type})
  27319. @end lisp
  27320. The returned service in this case has the default value specified by
  27321. @var{type}.
  27322. @end table
  27323. @xref{Service Types and Services}, for examples.
  27324. @end deftp
  27325. @deffn {Scheme Procedure} service-extension @var{target-type} @
  27326. @var{compute}
  27327. Return a new extension for services of type @var{target-type}.
  27328. @var{compute} must be a one-argument procedure: @code{fold-services}
  27329. calls it, passing it the value associated with the service that provides
  27330. the extension; it must return a valid value for the target service.
  27331. @end deffn
  27332. @deffn {Scheme Procedure} service-extension? @var{obj}
  27333. Return true if @var{obj} is a service extension.
  27334. @end deffn
  27335. Occasionally, you might want to simply extend an existing service. This
  27336. involves creating a new service type and specifying the extension of
  27337. interest, which can be verbose; the @code{simple-service} procedure
  27338. provides a shorthand for this.
  27339. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  27340. Return a service that extends @var{target} with @var{value}. This works
  27341. by creating a singleton service type @var{name}, of which the returned
  27342. service is an instance.
  27343. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  27344. an additional job:
  27345. @lisp
  27346. (simple-service 'my-mcron-job mcron-service-type
  27347. #~(job '(next-hour (3)) "guix gc -F 2G"))
  27348. @end lisp
  27349. @end deffn
  27350. At the core of the service abstraction lies the @code{fold-services}
  27351. procedure, which is responsible for ``compiling'' a list of services
  27352. down to a single directory that contains everything needed to boot and
  27353. run the system---the directory shown by the @command{guix system build}
  27354. command (@pxref{Invoking guix system}). In essence, it propagates
  27355. service extensions down the service graph, updating each node parameters
  27356. on the way, until it reaches the root node.
  27357. @deffn {Scheme Procedure} fold-services @var{services} @
  27358. [#:target-type @var{system-service-type}]
  27359. Fold @var{services} by propagating their extensions down to the root of
  27360. type @var{target-type}; return the root service adjusted accordingly.
  27361. @end deffn
  27362. Lastly, the @code{(gnu services)} module also defines several essential
  27363. service types, some of which are listed below.
  27364. @defvr {Scheme Variable} system-service-type
  27365. This is the root of the service graph. It produces the system directory
  27366. as returned by the @command{guix system build} command.
  27367. @end defvr
  27368. @defvr {Scheme Variable} boot-service-type
  27369. The type of the ``boot service'', which produces the @dfn{boot script}.
  27370. The boot script is what the initial RAM disk runs when booting.
  27371. @end defvr
  27372. @defvr {Scheme Variable} etc-service-type
  27373. The type of the @file{/etc} service. This service is used to create
  27374. files under @file{/etc} and can be extended by
  27375. passing it name/file tuples such as:
  27376. @lisp
  27377. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  27378. @end lisp
  27379. In this example, the effect would be to add an @file{/etc/issue} file
  27380. pointing to the given file.
  27381. @end defvr
  27382. @defvr {Scheme Variable} setuid-program-service-type
  27383. Type for the ``setuid-program service''. This service collects lists of
  27384. executable file names, passed as gexps, and adds them to the set of
  27385. setuid-root programs on the system (@pxref{Setuid Programs}).
  27386. @end defvr
  27387. @defvr {Scheme Variable} profile-service-type
  27388. Type of the service that populates the @dfn{system profile}---i.e., the
  27389. programs under @file{/run/current-system/profile}. Other services can
  27390. extend it by passing it lists of packages to add to the system profile.
  27391. @end defvr
  27392. @cindex provenance tracking, of the operating system
  27393. @anchor{provenance-service-type}
  27394. @defvr {Scheme Variable} provenance-service-type
  27395. This is the type of the service that records @dfn{provenance meta-data}
  27396. in the system itself. It creates several files under
  27397. @file{/run/current-system}:
  27398. @table @file
  27399. @item channels.scm
  27400. This is a ``channel file'' that can be passed to @command{guix pull -C}
  27401. or @command{guix time-machine -C}, and which describes the channels used
  27402. to build the system, if that information was available
  27403. (@pxref{Channels}).
  27404. @item configuration.scm
  27405. This is the file that was passed as the value for this
  27406. @code{provenance-service-type} service. By default, @command{guix
  27407. system reconfigure} automatically passes the OS configuration file it
  27408. received on the command line.
  27409. @item provenance
  27410. This contains the same information as the two other files but in a
  27411. format that is more readily processable.
  27412. @end table
  27413. In general, these two pieces of information (channels and configuration
  27414. file) are enough to reproduce the operating system ``from source''.
  27415. @quotation Caveats
  27416. This information is necessary to rebuild your operating system, but it
  27417. is not always sufficient. In particular, @file{configuration.scm}
  27418. itself is insufficient if it is not self-contained---if it refers to
  27419. external Guile modules or to extra files. If you want
  27420. @file{configuration.scm} to be self-contained, we recommend that modules
  27421. or files it refers to be part of a channel.
  27422. Besides, provenance meta-data is ``silent'' in the sense that it does
  27423. not change the bits contained in your system, @emph{except for the
  27424. meta-data bits themselves}. Two different OS configurations or sets of
  27425. channels can lead to the same system, bit-for-bit; when
  27426. @code{provenance-service-type} is used, these two systems will have
  27427. different meta-data and thus different store file names, which makes
  27428. comparison less trivial.
  27429. @end quotation
  27430. This service is automatically added to your operating system
  27431. configuration when you use @command{guix system reconfigure},
  27432. @command{guix system init}, or @command{guix deploy}.
  27433. @end defvr
  27434. @defvr {Scheme Variable} linux-loadable-module-service-type
  27435. Type of the service that collects lists of packages containing
  27436. kernel-loadable modules, and adds them to the set of kernel-loadable
  27437. modules.
  27438. This service type is intended to be extended by other service types,
  27439. such as below:
  27440. @lisp
  27441. (simple-service 'installing-module
  27442. linux-loadable-module-service-type
  27443. (list module-to-install-1
  27444. module-to-install-2))
  27445. @end lisp
  27446. This does not actually load modules at bootup, only adds it to the
  27447. kernel profile so that it @emph{can} be loaded by other means.
  27448. @end defvr
  27449. @node Shepherd Services
  27450. @subsection Shepherd Services
  27451. @cindex shepherd services
  27452. @cindex PID 1
  27453. @cindex init system
  27454. The @code{(gnu services shepherd)} module provides a way to define
  27455. services managed by the GNU@tie{}Shepherd, which is the
  27456. initialization system---the first process that is started when the
  27457. system boots, also known as PID@tie{}1
  27458. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  27459. Services in the Shepherd can depend on each other. For instance, the
  27460. SSH daemon may need to be started after the syslog daemon has been
  27461. started, which in turn can only happen once all the file systems have
  27462. been mounted. The simple operating system defined earlier (@pxref{Using
  27463. the Configuration System}) results in a service graph like this:
  27464. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  27465. You can actually generate such a graph for any operating system
  27466. definition using the @command{guix system shepherd-graph} command
  27467. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  27468. The @code{%shepherd-root-service} is a service object representing
  27469. PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
  27470. by passing it lists of @code{<shepherd-service>} objects.
  27471. @deftp {Data Type} shepherd-service
  27472. The data type representing a service managed by the Shepherd.
  27473. @table @asis
  27474. @item @code{provision}
  27475. This is a list of symbols denoting what the service provides.
  27476. These are the names that may be passed to @command{herd start},
  27477. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  27478. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  27479. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  27480. @item @code{requirement} (default: @code{'()})
  27481. List of symbols denoting the Shepherd services this one depends on.
  27482. @cindex one-shot services, for the Shepherd
  27483. @item @code{one-shot?} (default: @code{#f})
  27484. Whether this service is @dfn{one-shot}. One-shot services stop immediately
  27485. after their @code{start} action has completed. @xref{Slots of services,,,
  27486. shepherd, The GNU Shepherd Manual}, for more info.
  27487. @item @code{respawn?} (default: @code{#t})
  27488. Whether to restart the service when it stops, for instance when the
  27489. underlying process dies.
  27490. @item @code{start}
  27491. @itemx @code{stop} (default: @code{#~(const #f)})
  27492. The @code{start} and @code{stop} fields refer to the Shepherd's
  27493. facilities to start and stop processes (@pxref{Service De- and
  27494. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  27495. G-expressions that get expanded in the Shepherd configuration file
  27496. (@pxref{G-Expressions}).
  27497. @item @code{actions} (default: @code{'()})
  27498. @cindex actions, of Shepherd services
  27499. This is a list of @code{shepherd-action} objects (see below) defining
  27500. @dfn{actions} supported by the service, in addition to the standard
  27501. @code{start} and @code{stop} actions. Actions listed here become available as
  27502. @command{herd} sub-commands:
  27503. @example
  27504. herd @var{action} @var{service} [@var{arguments}@dots{}]
  27505. @end example
  27506. @item @code{auto-start?} (default: @code{#t})
  27507. Whether this service should be started automatically by the Shepherd. If it
  27508. is @code{#f} the service has to be started manually with @code{herd start}.
  27509. @item @code{documentation}
  27510. A documentation string, as shown when running:
  27511. @example
  27512. herd doc @var{service-name}
  27513. @end example
  27514. where @var{service-name} is one of the symbols in @code{provision}
  27515. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  27516. @item @code{modules} (default: @code{%default-modules})
  27517. This is the list of modules that must be in scope when @code{start} and
  27518. @code{stop} are evaluated.
  27519. @end table
  27520. @end deftp
  27521. The example below defines a Shepherd service that spawns
  27522. @command{syslogd}, the system logger from the GNU Networking Utilities
  27523. (@pxref{syslogd invocation, @command{syslogd},, inetutils, GNU
  27524. Inetutils}):
  27525. @example
  27526. (let ((config (plain-file "syslogd.conf" "@dots{}")))
  27527. (shepherd-service
  27528. (documentation "Run the syslog daemon (syslogd).")
  27529. (provision '(syslogd))
  27530. (requirement '(user-processes))
  27531. (start #~(make-forkexec-constructor
  27532. (list #$(file-append inetutils "/libexec/syslogd")
  27533. "--rcfile" #$config)
  27534. #:pid-file "/var/run/syslog.pid"))
  27535. (stop #~(make-kill-destructor))))
  27536. @end example
  27537. Key elements in this example are the @code{start} and @code{stop}
  27538. fields: they are @dfn{staged} code snippets that use the
  27539. @code{make-forkexec-constructor} procedure provided by the Shepherd and
  27540. its dual, @code{make-kill-destructor} (@pxref{Service De- and
  27541. Constructors,,, shepherd, The GNU Shepherd Manual}). The @code{start}
  27542. field will have @command{shepherd} spawn @command{syslogd} with the
  27543. given option; note that we pass @code{config} after @option{--rcfile},
  27544. which is a configuration file declared above (contents of this file are
  27545. omitted). Likewise, the @code{stop} field tells how this service is to
  27546. be stopped; in this case, it is stopped by making the @code{kill} system
  27547. call on its PID@. Code staging is achieved using G-expressions:
  27548. @code{#~} stages code, while @code{#$} ``escapes'' back to host code
  27549. (@pxref{G-Expressions}).
  27550. @deftp {Data Type} shepherd-action
  27551. This is the data type that defines additional actions implemented by a
  27552. Shepherd service (see above).
  27553. @table @code
  27554. @item name
  27555. Symbol naming the action.
  27556. @item documentation
  27557. This is a documentation string for the action. It can be viewed by running:
  27558. @example
  27559. herd doc @var{service} action @var{action}
  27560. @end example
  27561. @item procedure
  27562. This should be a gexp that evaluates to a procedure of at least one argument,
  27563. which is the ``running value'' of the service (@pxref{Slots of services,,,
  27564. shepherd, The GNU Shepherd Manual}).
  27565. @end table
  27566. The following example defines an action called @code{say-hello} that kindly
  27567. greets the user:
  27568. @lisp
  27569. (shepherd-action
  27570. (name 'say-hello)
  27571. (documentation "Say hi!")
  27572. (procedure #~(lambda (running . args)
  27573. (format #t "Hello, friend! arguments: ~s\n"
  27574. args)
  27575. #t)))
  27576. @end lisp
  27577. Assuming this action is added to the @code{example} service, then you can do:
  27578. @example
  27579. # herd say-hello example
  27580. Hello, friend! arguments: ()
  27581. # herd say-hello example a b c
  27582. Hello, friend! arguments: ("a" "b" "c")
  27583. @end example
  27584. This, as you can see, is a fairly sophisticated way to say hello.
  27585. @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
  27586. info on actions.
  27587. @end deftp
  27588. @defvr {Scheme Variable} shepherd-root-service-type
  27589. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  27590. This is the service type that extensions target when they want to create
  27591. shepherd services (@pxref{Service Types and Services}, for an example).
  27592. Each extension must pass a list of @code{<shepherd-service>}. Its
  27593. value must be a @code{shepherd-configuration}, as described below.
  27594. @end defvr
  27595. @deftp {Data Type} shepherd-configuration
  27596. This data type represents the Shepherd's configuration.
  27597. @table @code
  27598. @item shepherd (default: @code{shepherd})
  27599. The Shepherd package to use.
  27600. @item services (default: @code{'()})
  27601. A list of @code{<shepherd-service>} to start.
  27602. You should probably use the service extension
  27603. mechanism instead (@pxref{Shepherd Services}).
  27604. @end table
  27605. @end deftp
  27606. The following example specifies the Shepherd package for the operating
  27607. system:
  27608. @lisp
  27609. (operating-system
  27610. ;; ...
  27611. (services (append (list openssh-service-type))
  27612. ;; ...
  27613. %desktop-services)
  27614. ;; ...
  27615. ;; Use own Shepherd package.
  27616. (essential-services
  27617. (modify-services (operating-system-default-essential-services
  27618. this-operating-system)
  27619. (shepherd-root-service-type config => (shepherd-configuration
  27620. (inherit config)
  27621. (shepherd my-shepherd))))))
  27622. @end lisp
  27623. @defvr {Scheme Variable} %shepherd-root-service
  27624. This service represents PID@tie{}1.
  27625. @end defvr
  27626. @node Documentation
  27627. @chapter Documentation
  27628. @cindex documentation, searching for
  27629. @cindex searching for documentation
  27630. @cindex Info, documentation format
  27631. @cindex man pages
  27632. @cindex manual pages
  27633. In most cases packages installed with Guix come with documentation.
  27634. There are two main documentation formats: ``Info'', a browsable
  27635. hypertext format used for GNU software, and ``manual pages'' (or ``man
  27636. pages''), the linear documentation format traditionally found on Unix.
  27637. Info manuals are accessed with the @command{info} command or with Emacs,
  27638. and man pages are accessed using @command{man}.
  27639. You can look for documentation of software installed on your system by
  27640. keyword. For example, the following command searches for information
  27641. about ``TLS'' in Info manuals:
  27642. @example
  27643. $ info -k TLS
  27644. "(emacs)Network Security" -- STARTTLS
  27645. "(emacs)Network Security" -- TLS
  27646. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  27647. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  27648. @dots{}
  27649. @end example
  27650. @noindent
  27651. The command below searches for the same keyword in man pages:
  27652. @example
  27653. $ man -k TLS
  27654. SSL (7) - OpenSSL SSL/TLS library
  27655. certtool (1) - GnuTLS certificate tool
  27656. @dots {}
  27657. @end example
  27658. These searches are purely local to your computer so you have the
  27659. guarantee that documentation you find corresponds to what you have
  27660. actually installed, you can access it off-line, and your privacy is
  27661. respected.
  27662. Once you have these results, you can view the relevant documentation by
  27663. running, say:
  27664. @example
  27665. $ info "(gnutls)Core TLS API"
  27666. @end example
  27667. @noindent
  27668. or:
  27669. @example
  27670. $ man certtool
  27671. @end example
  27672. Info manuals contain sections and indices as well as hyperlinks like
  27673. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  27674. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  27675. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  27676. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  27677. Introduction}, for an introduction to Info navigation.
  27678. @node Installing Debugging Files
  27679. @chapter Installing Debugging Files
  27680. @cindex debugging files
  27681. Program binaries, as produced by the GCC compilers for instance, are
  27682. typically written in the ELF format, with a section containing
  27683. @dfn{debugging information}. Debugging information is what allows the
  27684. debugger, GDB, to map binary code to source code; it is required to
  27685. debug a compiled program in good conditions.
  27686. This chapter explains how to use separate debug info when packages
  27687. provide it, and how to rebuild packages with debug info when it's
  27688. missing.
  27689. @menu
  27690. * Separate Debug Info:: Installing 'debug' outputs.
  27691. * Rebuilding Debug Info:: Building missing debug info.
  27692. @end menu
  27693. @node Separate Debug Info
  27694. @section Separate Debug Info
  27695. The problem with debugging information is that is takes up a fair amount
  27696. of disk space. For example, debugging information for the GNU C Library
  27697. weighs in at more than 60 MiB@. Thus, as a user, keeping all the
  27698. debugging info of all the installed programs is usually not an option.
  27699. Yet, space savings should not come at the cost of an impediment to
  27700. debugging---especially in the GNU system, which should make it easier
  27701. for users to exert their computing freedom (@pxref{GNU Distribution}).
  27702. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  27703. mechanism that allows users to get the best of both worlds: debugging
  27704. information can be stripped from the binaries and stored in separate
  27705. files. GDB is then able to load debugging information from those files,
  27706. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  27707. with GDB}).
  27708. The GNU distribution takes advantage of this by storing debugging
  27709. information in the @code{lib/debug} sub-directory of a separate package
  27710. output unimaginatively called @code{debug} (@pxref{Packages with
  27711. Multiple Outputs}). Users can choose to install the @code{debug} output
  27712. of a package when they need it. For instance, the following command
  27713. installs the debugging information for the GNU C Library and for GNU
  27714. Guile:
  27715. @example
  27716. guix install glibc:debug guile:debug
  27717. @end example
  27718. GDB must then be told to look for debug files in the user's profile, by
  27719. setting the @code{debug-file-directory} variable (consider setting it
  27720. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  27721. GDB}):
  27722. @example
  27723. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  27724. @end example
  27725. From there on, GDB will pick up debugging information from the
  27726. @file{.debug} files under @file{~/.guix-profile/lib/debug}.
  27727. Below is an alternative GDB script which is useful when working with
  27728. other profiles. It takes advantage of the optional Guile integration in
  27729. GDB. This snippet is included by default on Guix System in the
  27730. @file{~/.gdbinit} file.
  27731. @example
  27732. guile
  27733. (use-modules (gdb))
  27734. (execute (string-append "set debug-file-directory "
  27735. (or (getenv "GDB_DEBUG_FILE_DIRECTORY")
  27736. "~/.guix-profile/lib/debug")))
  27737. end
  27738. @end example
  27739. In addition, you will most likely want GDB to be able to show the source
  27740. code being debugged. To do that, you will have to unpack the source
  27741. code of the package of interest (obtained with @code{guix build
  27742. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  27743. directory using the @code{directory} command (@pxref{Source Path,
  27744. @code{directory},, gdb, Debugging with GDB}).
  27745. @c XXX: keep me up-to-date
  27746. The @code{debug} output mechanism in Guix is implemented by the
  27747. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  27748. opt-in---debugging information is available only for the packages with
  27749. definitions explicitly declaring a @code{debug} output. To check
  27750. whether a package has a @code{debug} output, use @command{guix package
  27751. --list-available} (@pxref{Invoking guix package}).
  27752. Read on for how to deal with packages lacking a @code{debug} output.
  27753. @node Rebuilding Debug Info
  27754. @section Rebuilding Debug Info
  27755. @cindex debugging info, rebuilding
  27756. As we saw above, some packages, but not all, provide debugging info in a
  27757. @code{debug} output. What can you do when debugging info is missing?
  27758. The @option{--with-debug-info} option provides a solution to that: it
  27759. allows you to rebuild the package(s) for which debugging info is
  27760. missing---and only those---and to graft those onto the application
  27761. you're debugging. Thus, while it's not as fast as installing a
  27762. @code{debug} output, it is relatively inexpensive.
  27763. Let's illustrate that. Suppose you're experiencing a bug in Inkscape
  27764. and would like to see what's going on in GLib, a library that's deep
  27765. down in its dependency graph. As it turns out, GLib does not have a
  27766. @code{debug} output and the backtrace GDB shows is all sadness:
  27767. @example
  27768. (gdb) bt
  27769. #0 0x00007ffff5f92190 in g_getenv ()
  27770. from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0
  27771. #1 0x00007ffff608a7d6 in gobject_init_ctor ()
  27772. from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0
  27773. #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8,
  27774. env=env@@entry=0x7fffffffcfe8) at dl-init.c:72
  27775. #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>)
  27776. at dl-init.c:118
  27777. @end example
  27778. To address that, you install Inkscape linked against a variant GLib that
  27779. contains debug info:
  27780. @example
  27781. guix install inkscape --with-debug-info=glib
  27782. @end example
  27783. This time, debugging will be a whole lot nicer:
  27784. @example
  27785. $ gdb --args sh -c 'exec inkscape'
  27786. @dots{}
  27787. (gdb) b g_getenv
  27788. Function "g_getenv" not defined.
  27789. Make breakpoint pending on future shared library load? (y or [n]) y
  27790. Breakpoint 1 (g_getenv) pending.
  27791. (gdb) r
  27792. Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape
  27793. @dots{}
  27794. (gdb) bt
  27795. #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252
  27796. #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380
  27797. #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493
  27798. #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088,
  27799. env=env@@entry=0x7fffffffd0a8) at dl-init.c:72
  27800. @dots{}
  27801. @end example
  27802. Much better!
  27803. Note that there can be packages for which @option{--with-debug-info}
  27804. will not have the desired effect. @xref{Package Transformation Options,
  27805. @option{--with-debug-info}}, for more information.
  27806. @node Security Updates
  27807. @chapter Security Updates
  27808. @cindex security updates
  27809. @cindex security vulnerabilities
  27810. Occasionally, important security vulnerabilities are discovered in software
  27811. packages and must be patched. Guix developers try hard to keep track of
  27812. known vulnerabilities and to apply fixes as soon as possible in the
  27813. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  27814. containing only security updates). The @command{guix lint} tool helps
  27815. developers find out about vulnerable versions of software packages in the
  27816. distribution:
  27817. @smallexample
  27818. $ guix lint -c cve
  27819. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  27820. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  27821. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  27822. @dots{}
  27823. @end smallexample
  27824. @xref{Invoking guix lint}, for more information.
  27825. Guix follows a functional
  27826. package management discipline (@pxref{Introduction}), which implies
  27827. that, when a package is changed, @emph{every package that depends on it}
  27828. must be rebuilt. This can significantly slow down the deployment of
  27829. fixes in core packages such as libc or Bash, since basically the whole
  27830. distribution would need to be rebuilt. Using pre-built binaries helps
  27831. (@pxref{Substitutes}), but deployment may still take more time than
  27832. desired.
  27833. @cindex grafts
  27834. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  27835. for fast deployment of critical updates without the costs associated
  27836. with a whole-distribution rebuild. The idea is to rebuild only the
  27837. package that needs to be patched, and then to ``graft'' it onto packages
  27838. explicitly installed by the user and that were previously referring to
  27839. the original package. The cost of grafting is typically very low, and
  27840. order of magnitudes lower than a full rebuild of the dependency chain.
  27841. @cindex replacements of packages, for grafts
  27842. For instance, suppose a security update needs to be applied to Bash.
  27843. Guix developers will provide a package definition for the ``fixed''
  27844. Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
  27845. Packages}). Then, the original package definition is augmented with a
  27846. @code{replacement} field pointing to the package containing the bug fix:
  27847. @lisp
  27848. (define bash
  27849. (package
  27850. (name "bash")
  27851. ;; @dots{}
  27852. (replacement bash-fixed)))
  27853. @end lisp
  27854. From there on, any package depending directly or indirectly on Bash---as
  27855. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  27856. gc})---that is installed is automatically ``rewritten'' to refer to
  27857. @code{bash-fixed} instead of @code{bash}. This grafting process takes
  27858. time proportional to the size of the package, usually less than a
  27859. minute for an ``average'' package on a recent machine. Grafting is
  27860. recursive: when an indirect dependency requires grafting, then grafting
  27861. ``propagates'' up to the package that the user is installing.
  27862. Currently, the length of the name and version of the graft and that of
  27863. the package it replaces (@code{bash-fixed} and @code{bash} in the example
  27864. above) must be equal. This restriction mostly comes from the fact that
  27865. grafting works by patching files, including binary files, directly.
  27866. Other restrictions may apply: for instance, when adding a graft to a
  27867. package providing a shared library, the original shared library and its
  27868. replacement must have the same @code{SONAME} and be binary-compatible.
  27869. The @option{--no-grafts} command-line option allows you to forcefully
  27870. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  27871. Thus, the command:
  27872. @example
  27873. guix build bash --no-grafts
  27874. @end example
  27875. @noindent
  27876. returns the store file name of the original Bash, whereas:
  27877. @example
  27878. guix build bash
  27879. @end example
  27880. @noindent
  27881. returns the store file name of the ``fixed'', replacement Bash. This
  27882. allows you to distinguish between the two variants of Bash.
  27883. To verify which Bash your whole profile refers to, you can run
  27884. (@pxref{Invoking guix gc}):
  27885. @example
  27886. guix gc -R $(readlink -f ~/.guix-profile) | grep bash
  27887. @end example
  27888. @noindent
  27889. @dots{} and compare the store file names that you get with those above.
  27890. Likewise for a complete Guix system generation:
  27891. @example
  27892. guix gc -R $(guix system build my-config.scm) | grep bash
  27893. @end example
  27894. Lastly, to check which Bash running processes are using, you can use the
  27895. @command{lsof} command:
  27896. @example
  27897. lsof | grep /gnu/store/.*bash
  27898. @end example
  27899. @node Bootstrapping
  27900. @chapter Bootstrapping
  27901. @c Adapted from the ELS 2013 paper.
  27902. @cindex bootstrapping
  27903. Bootstrapping in our context refers to how the distribution gets built
  27904. ``from nothing''. Remember that the build environment of a derivation
  27905. contains nothing but its declared inputs (@pxref{Introduction}). So
  27906. there's an obvious chicken-and-egg problem: how does the first package
  27907. get built? How does the first compiler get compiled?
  27908. It is tempting to think of this question as one that only die-hard
  27909. hackers may care about. However, while the answer to that question is
  27910. technical in nature, its implications are wide-ranging. How the
  27911. distribution is bootstrapped defines the extent to which we, as
  27912. individuals and as a collective of users and hackers, can trust the
  27913. software we run. It is a central concern from the standpoint of
  27914. @emph{security} and from a @emph{user freedom} viewpoint.
  27915. @cindex bootstrap binaries
  27916. The GNU system is primarily made of C code, with libc at its core. The
  27917. GNU build system itself assumes the availability of a Bourne shell and
  27918. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  27919. `grep'. Furthermore, build programs---programs that run
  27920. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  27921. (@pxref{Derivations}). Consequently, to be able to build anything at
  27922. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  27923. Binutils, libc, and the other packages mentioned above---the
  27924. @dfn{bootstrap binaries}.
  27925. These bootstrap binaries are ``taken for granted'', though we can also
  27926. re-create them if needed (@pxref{Preparing to Use the Bootstrap
  27927. Binaries}).
  27928. @menu
  27929. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  27930. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  27931. @end menu
  27932. @node Reduced Binary Seed Bootstrap
  27933. @section The Reduced Binary Seed Bootstrap
  27934. Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
  27935. a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
  27936. Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
  27937. GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
  27938. ``taken for granted.''
  27939. Taking the bootstrap binaries for granted means that we consider them to
  27940. be a correct and trustworthy ``seed'' for building the complete system.
  27941. Therein lies a problem: the combined size of these bootstrap binaries is
  27942. about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
  27943. or even inspecting these is next to impossible.
  27944. For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
  27945. ``Reduced Binary Seed'' bootstrap @footnote{We would like to say: ``Full
  27946. Source Bootstrap'' and while we are working towards that goal it would
  27947. be hyperbole to use that term for what we do now.}.
  27948. The Reduced Binary Seed bootstrap removes the most critical tools---from a
  27949. trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
  27950. Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
  27951. linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
  27952. written in Scheme and the Mes C Library, built for TinyCC and for GCC).
  27953. Using these new binary seeds the ``missing'' Binutils, GCC, and the GNU
  27954. C Library are built from source. From here on the more traditional
  27955. bootstrap process resumes. This approach has reduced the bootstrap
  27956. binaries in size to about 145MB in Guix v1.1.
  27957. The next step that Guix has taken is to replace the shell and all its
  27958. utilities with implementations in Guile Scheme, the @emph{Scheme-only
  27959. bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
  27960. POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
  27961. which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
  27962. Gzip, Sed, and Tar. The rest of the bootstrap binary seeds that were
  27963. removed are now built from source.
  27964. Building the GNU System from source is currently only possible by adding
  27965. some historical GNU packages as intermediate steps@footnote{Packages
  27966. such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
  27967. @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
  27968. @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
  27969. and GNU packages become more bootstrappable again (e.g., new releases of
  27970. GNU Sed will also ship as gzipped tarballs again, as alternative to the
  27971. hard to bootstrap @code{xz}-compression), this set of added packages can
  27972. hopefully be reduced again.
  27973. The graph below shows the resulting dependency graph for
  27974. @code{gcc-core-mesboot0}, the bootstrap compiler used for the
  27975. traditional bootstrap of the rest of the Guix System.
  27976. @c ./pre-inst-env guix graph -e '(@@ (gnu packages commencement) gcc-core-mesboot0)' | sed -re 's,((bootstrap-mescc-tools|bootstrap-mes|guile-bootstrap).*shape =) box,\1 ellipse,' > doc/images/gcc-core-mesboot0-graph.dot
  27977. @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
  27978. The only significant binary bootstrap seeds that remain@footnote{
  27979. Ignoring the 68KB @code{mescc-tools}; that will be removed later,
  27980. together with @code{mes}.} are a Scheme interpreter and a Scheme
  27981. compiler: GNU Mes and GNU Guile@footnote{Not shown in this graph are the
  27982. static binaries for @file{bash}, @code{tar}, and @code{xz} that are used
  27983. to get Guile running.}.
  27984. This further reduction has brought down the size of the binary seed to
  27985. about 60MB for @code{i686-linux} and @code{x86_64-linux}.
  27986. Work is ongoing to remove all binary blobs from our free software
  27987. bootstrap stack, working towards a Full Source Bootstrap. Also ongoing
  27988. is work to bring these bootstraps to the @code{arm-linux} and
  27989. @code{aarch64-linux} architectures and to the Hurd.
  27990. If you are interested, join us on @samp{#bootstrappable} on the Freenode
  27991. IRC network or discuss on @email{bug-mes@@gnu.org} or
  27992. @email{gash-devel@@nongnu.org}.
  27993. @node Preparing to Use the Bootstrap Binaries
  27994. @section Preparing to Use the Bootstrap Binaries
  27995. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  27996. @c large image, it's hard to scroll. Oh well.
  27997. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  27998. The figure above shows the very beginning of the dependency graph of the
  27999. distribution, corresponding to the package definitions of the @code{(gnu
  28000. packages bootstrap)} module. A similar figure can be generated with
  28001. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  28002. @example
  28003. guix graph -t derivation \
  28004. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  28005. | dot -Tps > gcc.ps
  28006. @end example
  28007. or, for the further Reduced Binary Seed bootstrap
  28008. @example
  28009. guix graph -t derivation \
  28010. -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
  28011. | dot -Tps > mes.ps
  28012. @end example
  28013. At this level of detail, things are
  28014. slightly complex. First, Guile itself consists of an ELF executable,
  28015. along with many source and compiled Scheme files that are dynamically
  28016. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  28017. tarball shown in this graph. This tarball is part of Guix's ``source''
  28018. distribution, and gets inserted into the store with @code{add-to-store}
  28019. (@pxref{The Store}).
  28020. But how do we write a derivation that unpacks this tarball and adds it
  28021. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  28022. derivation---the first one that gets built---uses @code{bash} as its
  28023. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  28024. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  28025. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  28026. the Guix source distribution, whose sole purpose is to allow the Guile
  28027. tarball to be unpacked.
  28028. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  28029. Guile that can be used to run subsequent build programs. Its first task
  28030. is to download tarballs containing the other pre-built binaries---this
  28031. is what the @file{.tar.xz.drv} derivations do. Guix modules such as
  28032. @code{ftp-client.scm} are used for this purpose. The
  28033. @code{module-import.drv} derivations import those modules in a directory
  28034. in the store, using the original layout. The
  28035. @code{module-import-compiled.drv} derivations compile those modules, and
  28036. write them in an output directory with the right layout. This
  28037. corresponds to the @code{#:modules} argument of
  28038. @code{build-expression->derivation} (@pxref{Derivations}).
  28039. Finally, the various tarballs are unpacked by the derivations
  28040. @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
  28041. @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
  28042. point we have a working C tool chain.
  28043. @unnumberedsec Building the Build Tools
  28044. Bootstrapping is complete when we have a full tool chain that does not
  28045. depend on the pre-built bootstrap tools discussed above. This
  28046. no-dependency requirement is verified by checking whether the files of
  28047. the final tool chain contain references to the @file{/gnu/store}
  28048. directories of the bootstrap inputs. The process that leads to this
  28049. ``final'' tool chain is described by the package definitions found in
  28050. the @code{(gnu packages commencement)} module.
  28051. The @command{guix graph} command allows us to ``zoom out'' compared to
  28052. the graph above, by looking at the level of package objects instead of
  28053. individual derivations---remember that a package may translate to
  28054. several derivations, typically one derivation to download its source,
  28055. one to build the Guile modules it needs, and one to actually build the
  28056. package from source. The command:
  28057. @example
  28058. guix graph -t bag \
  28059. -e '(@@@@ (gnu packages commencement)
  28060. glibc-final-with-bootstrap-bash)' | xdot -
  28061. @end example
  28062. @noindent
  28063. displays the dependency graph leading to the ``final'' C
  28064. library@footnote{You may notice the @code{glibc-intermediate} label,
  28065. suggesting that it is not @emph{quite} final, but as a good
  28066. approximation, we will consider it final.}, depicted below.
  28067. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  28068. @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  28069. The first tool that gets built with the bootstrap binaries is
  28070. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  28071. for all the following packages. From there Findutils and Diffutils get
  28072. built.
  28073. Then come the first-stage Binutils and GCC, built as pseudo cross
  28074. tools---i.e., with @option{--target} equal to @option{--host}. They are
  28075. used to build libc. Thanks to this cross-build trick, this libc is
  28076. guaranteed not to hold any reference to the initial tool chain.
  28077. From there the final Binutils and GCC (not shown above) are built. GCC
  28078. uses @command{ld} from the final Binutils, and links programs against
  28079. the just-built libc. This tool chain is used to build the other
  28080. packages used by Guix and by the GNU Build System: Guile, Bash,
  28081. Coreutils, etc.
  28082. And voilà! At this point we have the complete set of build tools that
  28083. the GNU Build System expects. These are in the @code{%final-inputs}
  28084. variable of the @code{(gnu packages commencement)} module, and are
  28085. implicitly used by any package that uses @code{gnu-build-system}
  28086. (@pxref{Build Systems, @code{gnu-build-system}}).
  28087. @unnumberedsec Building the Bootstrap Binaries
  28088. @cindex bootstrap binaries
  28089. Because the final tool chain does not depend on the bootstrap binaries,
  28090. those rarely need to be updated. Nevertheless, it is useful to have an
  28091. automated way to produce them, should an update occur, and this is what
  28092. the @code{(gnu packages make-bootstrap)} module provides.
  28093. The following command builds the tarballs containing the bootstrap binaries
  28094. (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
  28095. bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
  28096. and Guile, and a tarball containing a mixture of Coreutils and other basic
  28097. command-line tools):
  28098. @example
  28099. guix build bootstrap-tarballs
  28100. @end example
  28101. The generated tarballs are those that should be referred to in the
  28102. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  28103. this section.
  28104. Still here? Then perhaps by now you've started to wonder: when do we
  28105. reach a fixed point? That is an interesting question! The answer is
  28106. unknown, but if you would like to investigate further (and have
  28107. significant computational and storage resources to do so), then let us
  28108. know.
  28109. @unnumberedsec Reducing the Set of Bootstrap Binaries
  28110. Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
  28111. binary code! Why is that a problem? It's a problem because these big chunks
  28112. of binary code are practically non-auditable, which makes it hard to establish
  28113. what source code produced them. Every unauditable binary also leaves us
  28114. vulnerable to compiler backdoors as described by Ken Thompson in the 1984
  28115. paper @emph{Reflections on Trusting Trust}.
  28116. This is mitigated by the fact that our bootstrap binaries were generated
  28117. from an earlier Guix revision. Nevertheless it lacks the level of
  28118. transparency that we get in the rest of the package dependency graph,
  28119. where Guix always gives us a source-to-binary mapping. Thus, our goal
  28120. is to reduce the set of bootstrap binaries to the bare minimum.
  28121. The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
  28122. on-going projects to do that. One of these is about replacing the
  28123. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  28124. of increasing complexity, which could be built from source starting from
  28125. a simple and auditable assembler.
  28126. Our first major achievement is the replacement of of GCC, the GNU C Library
  28127. and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
  28128. (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
  28129. and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
  28130. bootstrapped yet and thus we inject them as binary seeds. We call this the
  28131. Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
  28132. binaries! Also, it has eliminated the C compiler binary; i686-linux and
  28133. x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
  28134. Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
  28135. also looking at any other bootstrap binaries. Your help is welcome!
  28136. @node Porting
  28137. @chapter Porting to a New Platform
  28138. As discussed above, the GNU distribution is self-contained, and
  28139. self-containment is achieved by relying on pre-built ``bootstrap
  28140. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  28141. operating system kernel, CPU architecture, and application binary
  28142. interface (ABI). Thus, to port the distribution to a platform that is
  28143. not yet supported, one must build those bootstrap binaries, and update
  28144. the @code{(gnu packages bootstrap)} module to use them on that platform.
  28145. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  28146. When everything goes well, and assuming the GNU tool chain supports the
  28147. target platform, this can be as simple as running a command like this
  28148. one:
  28149. @example
  28150. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  28151. @end example
  28152. For this to work, the @code{glibc-dynamic-linker} procedure in
  28153. @code{(gnu packages bootstrap)} must be augmented to return the right
  28154. file name for libc's dynamic linker on that platform; likewise,
  28155. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  28156. taught about the new platform.
  28157. Once these are built, the @code{(gnu packages bootstrap)} module needs
  28158. to be updated to refer to these binaries on the target platform. That
  28159. is, the hashes and URLs of the bootstrap tarballs for the new platform
  28160. must be added alongside those of the currently supported platforms. The
  28161. bootstrap Guile tarball is treated specially: it is expected to be
  28162. available locally, and @file{gnu/local.mk} has rules to download it for
  28163. the supported architectures; a rule for the new platform must be added
  28164. as well.
  28165. In practice, there may be some complications. First, it may be that the
  28166. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  28167. above) is not recognized by all the GNU tools. Typically, glibc
  28168. recognizes some of these, whereas GCC uses an extra @option{--with-abi}
  28169. configure flag (see @code{gcc.scm} for examples of how to handle this).
  28170. Second, some of the required packages could fail to build for that
  28171. platform. Lastly, the generated binaries could be broken for some
  28172. reason.
  28173. @c *********************************************************************
  28174. @include contributing.texi
  28175. @c *********************************************************************
  28176. @node Acknowledgments
  28177. @chapter Acknowledgments
  28178. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  28179. which was designed and
  28180. implemented by Eelco Dolstra, with contributions from other people (see
  28181. the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
  28182. management, and promoted unprecedented features, such as transactional
  28183. package upgrades and rollbacks, per-user profiles, and referentially
  28184. transparent build processes. Without this work, Guix would not exist.
  28185. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  28186. an inspiration for Guix.
  28187. GNU@tie{}Guix itself is a collective work with contributions from a
  28188. number of people. See the @file{AUTHORS} file in Guix for more
  28189. information on these fine people. The @file{THANKS} file lists people
  28190. who have helped by reporting bugs, taking care of the infrastructure,
  28191. providing artwork and themes, making suggestions, and more---thank you!
  28192. @c *********************************************************************
  28193. @node GNU Free Documentation License
  28194. @appendix GNU Free Documentation License
  28195. @cindex license, GNU Free Documentation License
  28196. @include fdl-1.3.texi
  28197. @c *********************************************************************
  28198. @node Concept Index
  28199. @unnumbered Concept Index
  28200. @printindex cp
  28201. @node Programming Index
  28202. @unnumbered Programming Index
  28203. @syncodeindex tp fn
  28204. @syncodeindex vr fn
  28205. @printindex fn
  28206. @bye
  28207. @c Local Variables:
  28208. @c ispell-local-dictionary: "american";
  28209. @c End: