guix.texi 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guix.info
  5. @documentencoding UTF-8
  6. @settitle GNU Guix Reference Manual
  7. @c %**end of header
  8. @include version.texi
  9. @c Identifier of the OpenPGP key used to sign tarballs and such.
  10. @set OPENPGP-SIGNING-KEY-ID 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
  11. @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=15145
  12. @c Base URL for downloads.
  13. @set BASE-URL https://ftp.gnu.org/gnu/guix
  14. @c The official substitute server used by default.
  15. @set SUBSTITUTE-SERVER ci.guix.gnu.org
  16. @set SUBSTITUTE-URL https://@value{SUBSTITUTE-SERVER}
  17. @copying
  18. Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès@*
  19. Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
  20. Copyright @copyright{} 2013 Nikita Karetnikov@*
  21. Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
  22. Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
  23. Copyright @copyright{} 2014 Pierre-Antoine Rault@*
  24. Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
  25. Copyright @copyright{} 2015, 2016, 2017, 2019, 2020, 2021 Leo Famulari@*
  26. Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020 Ricardo Wurmus@*
  27. Copyright @copyright{} 2016 Ben Woodcroft@*
  28. Copyright @copyright{} 2016, 2017, 2018, 2021 Chris Marusich@*
  29. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Efraim Flashner@*
  30. Copyright @copyright{} 2016 John Darrington@*
  31. Copyright @copyright{} 2016, 2017 Nikita Gillmann@*
  32. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Jan Nieuwenhuizen@*
  33. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Julien Lepiller@*
  34. Copyright @copyright{} 2016 Alex ter Weele@*
  35. Copyright @copyright{} 2016, 2017, 2018, 2019 Christopher Baines@*
  36. Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
  37. Copyright @copyright{} 2017, 2018, 2020, 2021 Mathieu Othacehe@*
  38. Copyright @copyright{} 2017 Federico Beffa@*
  39. Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
  40. Copyright @copyright{} 2017 Thomas Danckaert@*
  41. Copyright @copyright{} 2017 humanitiesNerd@*
  42. Copyright @copyright{} 2017, 2021 Christopher Lemmer Webber@*
  43. Copyright @copyright{} 2017, 2018, 2019, 2020 Marius Bakke@*
  44. Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@*
  45. Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@*
  46. Copyright @copyright{} 2017, 2018, 2019, 2020, 2021 Tobias Geerinckx-Rice@*
  47. Copyright @copyright{} 2017 George Clemmer@*
  48. Copyright @copyright{} 2017 Andy Wingo@*
  49. Copyright @copyright{} 2017, 2018, 2019, 2020 Arun Isaac@*
  50. Copyright @copyright{} 2017 nee@*
  51. Copyright @copyright{} 2018 Rutger Helling@*
  52. Copyright @copyright{} 2018, 2021 Oleg Pykhalov@*
  53. Copyright @copyright{} 2018 Mike Gerwitz@*
  54. Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
  55. Copyright @copyright{} 2018, 2019 Gábor Boskovits@*
  56. Copyright @copyright{} 2018, 2019, 2020 Florian Pelz@*
  57. Copyright @copyright{} 2018 Laura Lazzati@*
  58. Copyright @copyright{} 2018 Alex Vong@*
  59. Copyright @copyright{} 2019 Josh Holland@*
  60. Copyright @copyright{} 2019, 2020 Diego Nicola Barbato@*
  61. Copyright @copyright{} 2019 Ivan Petkov@*
  62. Copyright @copyright{} 2019 Jakob L. Kreuze@*
  63. Copyright @copyright{} 2019 Kyle Andrews@*
  64. Copyright @copyright{} 2019 Alex Griffin@*
  65. Copyright @copyright{} 2019, 2020 Guillaume Le Vaillant@*
  66. Copyright @copyright{} 2020 Leo Prikler@*
  67. Copyright @copyright{} 2019, 2020 Simon Tournier@*
  68. Copyright @copyright{} 2020 Wiktor Żelazny@*
  69. Copyright @copyright{} 2020 Damien Cassou@*
  70. Copyright @copyright{} 2020 Jakub Kądziołka@*
  71. Copyright @copyright{} 2020 Jack Hill@*
  72. Copyright @copyright{} 2020 Naga Malleswari@*
  73. Copyright @copyright{} 2020 Brice Waegeneire@*
  74. Copyright @copyright{} 2020 R Veera Kumar@*
  75. Copyright @copyright{} 2020 Pierre Langlois@*
  76. Copyright @copyright{} 2020 pinoaffe@*
  77. Copyright @copyright{} 2020 André Batista@*
  78. Copyright @copyright{} 2020, 2021 Alexandru-Sergiu Marton@*
  79. Copyright @copyright{} 2020 raingloom@*
  80. Copyright @copyright{} 2020 Daniel Brooks@*
  81. Copyright @copyright{} 2020 John Soo@*
  82. Copyright @copyright{} 2020 Jonathan Brielmaier@*
  83. Copyright @copyright{} 2020 Edgar Vincent@*
  84. Permission is granted to copy, distribute and/or modify this document
  85. under the terms of the GNU Free Documentation License, Version 1.3 or
  86. any later version published by the Free Software Foundation; with no
  87. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  88. copy of the license is included in the section entitled ``GNU Free
  89. Documentation License''.
  90. @end copying
  91. @dircategory System administration
  92. @direntry
  93. * Guix: (guix). Manage installed software and system configuration.
  94. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  95. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  96. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  97. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  98. * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
  99. @end direntry
  100. @dircategory Software development
  101. @direntry
  102. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  103. * guix build: (guix)Invoking guix build. Building packages.
  104. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  105. @end direntry
  106. @titlepage
  107. @title GNU Guix Reference Manual
  108. @subtitle Using the GNU Guix Functional Package Manager
  109. @author The GNU Guix Developers
  110. @page
  111. @vskip 0pt plus 1filll
  112. Edition @value{EDITION} @*
  113. @value{UPDATED} @*
  114. @insertcopying
  115. @end titlepage
  116. @contents
  117. @c *********************************************************************
  118. @node Top
  119. @top GNU Guix
  120. This document describes GNU Guix version @value{VERSION}, a functional
  121. package management tool written for the GNU system.
  122. @c TRANSLATORS: You can replace the following paragraph with information on
  123. @c how to join your own translation team and how to report issues with the
  124. @c translation.
  125. This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
  126. GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
  127. Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
  128. Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
  129. Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
  130. would like to translate it in your native language, consider joining
  131. @uref{https://translate.fedoraproject.org/projects/guix/documentation-manual,
  132. Weblate}.
  133. @menu
  134. * Introduction:: What is Guix about?
  135. * Installation:: Installing Guix.
  136. * System Installation:: Installing the whole operating system.
  137. * Getting Started:: Your first steps.
  138. * Package Management:: Package installation, upgrade, etc.
  139. * Channels:: Customizing the package collection.
  140. * Development:: Guix-aided software development.
  141. * Programming Interface:: Using Guix in Scheme.
  142. * Utilities:: Package management commands.
  143. * System Configuration:: Configuring the operating system.
  144. * Documentation:: Browsing software user manuals.
  145. * Installing Debugging Files:: Feeding the debugger.
  146. * Security Updates:: Deploying security fixes quickly.
  147. * Bootstrapping:: GNU/Linux built from scratch.
  148. * Porting:: Targeting another platform or kernel.
  149. * Contributing:: Your help needed!
  150. * Acknowledgments:: Thanks!
  151. * GNU Free Documentation License:: The license of this manual.
  152. * Concept Index:: Concepts.
  153. * Programming Index:: Data types, functions, and variables.
  154. @detailmenu
  155. --- The Detailed Node Listing ---
  156. Introduction
  157. * Managing Software the Guix Way:: What's special.
  158. * GNU Distribution:: The packages and tools.
  159. Installation
  160. * Binary Installation:: Getting Guix running in no time!
  161. * Requirements:: Software needed to build and run Guix.
  162. * Running the Test Suite:: Testing Guix.
  163. * Setting Up the Daemon:: Preparing the build daemon's environment.
  164. * Invoking guix-daemon:: Running the build daemon.
  165. * Application Setup:: Application-specific setup.
  166. * Upgrading Guix:: Upgrading Guix and its build daemon.
  167. Setting Up the Daemon
  168. * Build Environment Setup:: Preparing the isolated build environment.
  169. * Daemon Offload Setup:: Offloading builds to remote machines.
  170. * SELinux Support:: Using an SELinux policy for the daemon.
  171. System Installation
  172. * Limitations:: What you can expect.
  173. * Hardware Considerations:: Supported hardware.
  174. * USB Stick and DVD Installation:: Preparing the installation medium.
  175. * Preparing for Installation:: Networking, partitioning, etc.
  176. * Guided Graphical Installation:: Easy graphical installation.
  177. * Manual Installation:: Manual installation for wizards.
  178. * After System Installation:: When installation succeeded.
  179. * Installing Guix in a VM:: Guix System playground.
  180. * Building the Installation Image:: How this comes to be.
  181. Manual Installation
  182. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  183. * Proceeding with the Installation:: Installing.
  184. Package Management
  185. * Features:: How Guix will make your life brighter.
  186. * Invoking guix package:: Package installation, removal, etc.
  187. * Substitutes:: Downloading pre-built binaries.
  188. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  189. * Invoking guix gc:: Running the garbage collector.
  190. * Invoking guix pull:: Fetching the latest Guix and distribution.
  191. * Invoking guix time-machine:: Running an older revision of Guix.
  192. * Inferiors:: Interacting with another revision of Guix.
  193. * Invoking guix describe:: Display information about your Guix revision.
  194. * Invoking guix archive:: Exporting and importing store files.
  195. Substitutes
  196. * Official Substitute Server:: One particular source of substitutes.
  197. * Substitute Server Authorization:: How to enable or disable substitutes.
  198. * Getting Substitutes from Other Servers:: Substitute diversity.
  199. * Substitute Authentication:: How Guix verifies substitutes.
  200. * Proxy Settings:: How to get substitutes via proxy.
  201. * Substitution Failure:: What happens when substitution fails.
  202. * On Trusting Binaries:: How can you trust that binary blob?
  203. Channels
  204. * Specifying Additional Channels:: Extending the package collection.
  205. * Using a Custom Guix Channel:: Using a customized Guix.
  206. * Replicating Guix:: Running the @emph{exact same} Guix.
  207. * Channel Authentication:: How Guix verifies what it fetches.
  208. * Channels with Substitutes:: Using channels with available substitutes.
  209. * Creating a Channel:: How to write your custom channel.
  210. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  211. * Declaring Channel Dependencies:: How to depend on other channels.
  212. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  213. * Primary URL:: Distinguishing mirror to original.
  214. * Writing Channel News:: Communicating information to channel's users.
  215. Development
  216. * Invoking guix environment:: Setting up development environments.
  217. * Invoking guix pack:: Creating software bundles.
  218. * The GCC toolchain:: Working with languages supported by GCC.
  219. * Invoking guix git authenticate:: Authenticating Git repositories.
  220. Programming Interface
  221. * Package Modules:: Packages from the programmer's viewpoint.
  222. * Defining Packages:: Defining new packages.
  223. * Defining Package Variants:: Customizing packages.
  224. * Build Systems:: Specifying how packages are built.
  225. * Build Phases:: Phases of the build process of a package.
  226. * Build Utilities:: Helpers for your package definitions and more.
  227. * The Store:: Manipulating the package store.
  228. * Derivations:: Low-level interface to package derivations.
  229. * The Store Monad:: Purely functional interface to the store.
  230. * G-Expressions:: Manipulating build expressions.
  231. * Invoking guix repl:: Programming Guix in Guile.
  232. Defining Packages
  233. * package Reference:: The package data type.
  234. * origin Reference:: The origin data type.
  235. Utilities
  236. * Invoking guix build:: Building packages from the command line.
  237. * Invoking guix edit:: Editing package definitions.
  238. * Invoking guix download:: Downloading a file and printing its hash.
  239. * Invoking guix hash:: Computing the cryptographic hash of a file.
  240. * Invoking guix import:: Importing package definitions.
  241. * Invoking guix refresh:: Updating package definitions.
  242. * Invoking guix lint:: Finding errors in package definitions.
  243. * Invoking guix size:: Profiling disk usage.
  244. * Invoking guix graph:: Visualizing the graph of packages.
  245. * Invoking guix publish:: Sharing substitutes.
  246. * Invoking guix challenge:: Challenging substitute servers.
  247. * Invoking guix copy:: Copying to and from a remote store.
  248. * Invoking guix container:: Process isolation.
  249. * Invoking guix weather:: Assessing substitute availability.
  250. * Invoking guix processes:: Listing client processes.
  251. Invoking @command{guix build}
  252. * Common Build Options:: Build options for most commands.
  253. * Package Transformation Options:: Creating variants of packages.
  254. * Additional Build Options:: Options specific to 'guix build'.
  255. * Debugging Build Failures:: Real life packaging experience.
  256. System Configuration
  257. * Using the Configuration System:: Customizing your GNU system.
  258. * operating-system Reference:: Detail of operating-system declarations.
  259. * File Systems:: Configuring file system mounts.
  260. * Mapped Devices:: Block device extra processing.
  261. * User Accounts:: Specifying user accounts.
  262. * Keyboard Layout:: How the system interprets key strokes.
  263. * Locales:: Language and cultural convention settings.
  264. * Services:: Specifying system services.
  265. * Setuid Programs:: Programs running with root privileges.
  266. * X.509 Certificates:: Authenticating HTTPS servers.
  267. * Name Service Switch:: Configuring libc's name service switch.
  268. * Initial RAM Disk:: Linux-Libre bootstrapping.
  269. * Bootloader Configuration:: Configuring the boot loader.
  270. * Invoking guix system:: Instantiating a system configuration.
  271. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  272. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  273. * Defining Services:: Adding new service definitions.
  274. Services
  275. * Base Services:: Essential system services.
  276. * Scheduled Job Execution:: The mcron service.
  277. * Log Rotation:: The rottlog service.
  278. * Networking Services:: Network setup, SSH daemon, etc.
  279. * Unattended Upgrades:: Automated system upgrades.
  280. * X Window:: Graphical display.
  281. * Printing Services:: Local and remote printer support.
  282. * Desktop Services:: D-Bus and desktop services.
  283. * Sound Services:: ALSA and Pulseaudio services.
  284. * Database Services:: SQL databases, key-value stores, etc.
  285. * Mail Services:: IMAP, POP3, SMTP, and all that.
  286. * Messaging Services:: Messaging services.
  287. * Telephony Services:: Telephony services.
  288. * Monitoring Services:: Monitoring services.
  289. * Kerberos Services:: Kerberos services.
  290. * LDAP Services:: LDAP services.
  291. * Web Services:: Web servers.
  292. * Certificate Services:: TLS certificates via Let's Encrypt.
  293. * DNS Services:: DNS daemons.
  294. * VPN Services:: VPN daemons.
  295. * Network File System:: NFS related services.
  296. * Continuous Integration:: The Cuirass service.
  297. * Power Management Services:: Extending battery life.
  298. * Audio Services:: The MPD.
  299. * Virtualization Services:: Virtualization services.
  300. * Version Control Services:: Providing remote access to Git repositories.
  301. * Game Services:: Game servers.
  302. * PAM Mount Service:: Service to mount volumes when logging in.
  303. * Guix Services:: Services relating specifically to Guix.
  304. * Linux Services:: Services tied to the Linux kernel.
  305. * Hurd Services:: Services specific for a Hurd System.
  306. * Miscellaneous Services:: Other services.
  307. Defining Services
  308. * Service Composition:: The model for composing services.
  309. * Service Types and Services:: Types and services.
  310. * Service Reference:: API reference.
  311. * Shepherd Services:: A particular type of service.
  312. Installing Debugging Files
  313. * Separate Debug Info:: Installing 'debug' outputs.
  314. * Rebuilding Debug Info:: Building missing debug info.
  315. Bootstrapping
  316. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  317. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  318. @end detailmenu
  319. @end menu
  320. @c *********************************************************************
  321. @node Introduction
  322. @chapter Introduction
  323. @cindex purpose
  324. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  325. using the international phonetic alphabet (IPA).} is a package
  326. management tool for and distribution of the GNU system.
  327. Guix makes it easy for unprivileged
  328. users to install, upgrade, or remove software packages, to roll back to a
  329. previous package set, to build packages from source, and generally
  330. assists with the creation and maintenance of software environments.
  331. @cindex Guix System
  332. @cindex GuixSD, now Guix System
  333. @cindex Guix System Distribution, now Guix System
  334. You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
  335. complements the available tools without interference (@pxref{Installation}),
  336. or you can use it as a standalone operating system distribution,
  337. @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
  338. System Distribution'' or ``GuixSD''. We now consider it makes more sense to
  339. group everything under the ``Guix'' banner since, after all, Guix System is
  340. readily available through the @command{guix system} command, even if you're
  341. using a different distro underneath!}. @xref{GNU Distribution}.
  342. @menu
  343. * Managing Software the Guix Way:: What's special.
  344. * GNU Distribution:: The packages and tools.
  345. @end menu
  346. @node Managing Software the Guix Way
  347. @section Managing Software the Guix Way
  348. @cindex user interfaces
  349. Guix provides a command-line package management interface
  350. (@pxref{Package Management}), tools to help with software development
  351. (@pxref{Development}), command-line utilities for more advanced usage
  352. (@pxref{Utilities}), as well as Scheme programming interfaces
  353. (@pxref{Programming Interface}).
  354. @cindex build daemon
  355. Its @dfn{build daemon} is responsible for building packages on behalf of
  356. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  357. binaries from authorized sources (@pxref{Substitutes}).
  358. @cindex extensibility of the distribution
  359. @cindex customization, of packages
  360. Guix includes package definitions for many GNU and non-GNU packages, all
  361. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  362. user's computing freedom}. It is @emph{extensible}: users can write
  363. their own package definitions (@pxref{Defining Packages}) and make them
  364. available as independent package modules (@pxref{Package Modules}). It
  365. is also @emph{customizable}: users can @emph{derive} specialized package
  366. definitions from existing ones, including from the command line
  367. (@pxref{Package Transformation Options}).
  368. @cindex functional package management
  369. @cindex isolation
  370. Under the hood, Guix implements the @dfn{functional package management}
  371. discipline pioneered by Nix (@pxref{Acknowledgments}).
  372. In Guix, the package build and installation process is seen
  373. as a @emph{function}, in the mathematical sense. That function takes inputs,
  374. such as build scripts, a compiler, and libraries, and
  375. returns an installed package. As a pure function, its result depends
  376. solely on its inputs---for instance, it cannot refer to software or
  377. scripts that were not explicitly passed as inputs. A build function
  378. always produces the same result when passed a given set of inputs. It
  379. cannot alter the environment of the running system in
  380. any way; for instance, it cannot create, modify, or delete files outside
  381. of its build and installation directories. This is achieved by running
  382. build processes in isolated environments (or @dfn{containers}), where only their
  383. explicit inputs are visible.
  384. @cindex store
  385. The result of package build functions is @dfn{cached} in the file
  386. system, in a special directory called @dfn{the store} (@pxref{The
  387. Store}). Each package is installed in a directory of its own in the
  388. store---by default under @file{/gnu/store}. The directory name contains
  389. a hash of all the inputs used to build that package; thus, changing an
  390. input yields a different directory name.
  391. This approach is the foundation for the salient features of Guix: support
  392. for transactional package upgrade and rollback, per-user installation, and
  393. garbage collection of packages (@pxref{Features}).
  394. @node GNU Distribution
  395. @section GNU Distribution
  396. @cindex Guix System
  397. Guix comes with a distribution of the GNU system consisting entirely of
  398. free software@footnote{The term ``free'' here refers to the
  399. @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
  400. users of that software}.}. The
  401. distribution can be installed on its own (@pxref{System Installation}),
  402. but it is also possible to install Guix as a package manager on top of
  403. an installed GNU/Linux system (@pxref{Installation}). When we need to
  404. distinguish between the two, we refer to the standalone distribution as
  405. Guix@tie{}System.
  406. The distribution provides core GNU packages such as GNU libc, GCC, and
  407. Binutils, as well as many GNU and non-GNU applications. The complete
  408. list of available packages can be browsed
  409. @url{https://www.gnu.org/software/guix/packages,on-line} or by
  410. running @command{guix package} (@pxref{Invoking guix package}):
  411. @example
  412. guix package --list-available
  413. @end example
  414. Our goal is to provide a practical 100% free software distribution of
  415. Linux-based and other variants of GNU, with a focus on the promotion and
  416. tight integration of GNU components, and an emphasis on programs and
  417. tools that help users exert that freedom.
  418. Packages are currently available on the following platforms:
  419. @table @code
  420. @item x86_64-linux
  421. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel.
  422. @item i686-linux
  423. Intel 32-bit architecture (IA32), Linux-Libre kernel.
  424. @item armhf-linux
  425. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  426. using the EABI hard-float application binary interface (ABI),
  427. and Linux-Libre kernel.
  428. @item aarch64-linux
  429. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
  430. @item i586-gnu
  431. @uref{https://hurd.gnu.org, GNU/Hurd} on the Intel 32-bit architecture
  432. (IA32).
  433. This configuration is experimental and under development. The easiest
  434. way for you to give it a try is by setting up an instance of
  435. @code{hurd-vm-service-type} on your GNU/Linux machine
  436. (@pxref{transparent-emulation-qemu, @code{hurd-vm-service-type}}).
  437. @xref{Contributing}, on how to help!
  438. @item mips64el-linux (deprecated)
  439. little-endian 64-bit MIPS processors, specifically the Loongson series,
  440. n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
  441. supported; in particular, there is no ongoing work to ensure that this
  442. architecture still works. Should someone decide they wish to revive this
  443. architecture then the code is still available.
  444. @item powerpc64le-linux
  445. little-endian 64-bit Power ISA processors, Linux-Libre kernel. This
  446. includes POWER9 systems such as the
  447. @uref{https://www.fsf.org/news/talos-ii-mainboard-and-talos-ii-lite-mainboard-now-fsf-certified-to-respect-your-freedom,
  448. RYF Talos II mainboard}. This platform is available as a "technology
  449. preview": although it is supported, substitutes are not yet available
  450. from the build farm (@pxref{Substitutes}), and some packages may fail to
  451. build (@pxref{Tracking Bugs and Patches}). That said, the Guix
  452. community is actively working on improving this support, and now is a
  453. great time to try it and get involved!
  454. @end table
  455. With Guix@tie{}System, you @emph{declare} all aspects of the operating system
  456. configuration and Guix takes care of instantiating the configuration in a
  457. transactional, reproducible, and stateless fashion (@pxref{System
  458. Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
  459. initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
  460. Manual}), the well-known GNU utilities and tool chain, as well as the
  461. graphical environment or system services of your choice.
  462. Guix System is available on all the above platforms except
  463. @code{mips64el-linux} and @code{powerpc64le-linux}.
  464. @noindent
  465. For information on porting to other architectures or kernels,
  466. @pxref{Porting}.
  467. Building this distribution is a cooperative effort, and you are invited
  468. to join! @xref{Contributing}, for information about how you can help.
  469. @c *********************************************************************
  470. @node Installation
  471. @chapter Installation
  472. @cindex installing Guix
  473. @quotation Note
  474. We recommend the use of this
  475. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  476. shell installer script} to install Guix on top of a running GNU/Linux system,
  477. thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
  478. with the installation of the package manager, which can be done on top of a
  479. running GNU/Linux system. If, instead, you want to install the complete GNU
  480. operating system, @pxref{System Installation}.} The script automates the
  481. download, installation, and initial configuration of Guix. It should be run
  482. as the root user.
  483. @end quotation
  484. @cindex foreign distro
  485. @cindex directories related to foreign distro
  486. When installed on a foreign distro, GNU@tie{}Guix complements the available
  487. tools without interference. Its data lives exclusively in two directories,
  488. usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
  489. such as @file{/etc}, are left untouched.
  490. Once installed, Guix can be updated by running @command{guix pull}
  491. (@pxref{Invoking guix pull}).
  492. If you prefer to perform the installation steps manually or want to tweak
  493. them, you may find the following subsections useful. They describe the
  494. software requirements of Guix, as well as how to install it manually and get
  495. ready to use it.
  496. @menu
  497. * Binary Installation:: Getting Guix running in no time!
  498. * Requirements:: Software needed to build and run Guix.
  499. * Running the Test Suite:: Testing Guix.
  500. * Setting Up the Daemon:: Preparing the build daemon's environment.
  501. * Invoking guix-daemon:: Running the build daemon.
  502. * Application Setup:: Application-specific setup.
  503. * Upgrading Guix:: Upgrading Guix and its build daemon.
  504. @end menu
  505. @node Binary Installation
  506. @section Binary Installation
  507. @cindex installing Guix from binaries
  508. @cindex installer script
  509. This section describes how to install Guix on an arbitrary system from a
  510. self-contained tarball providing binaries for Guix and for all its
  511. dependencies. This is often quicker than installing from source, which
  512. is described in the next sections. The only requirement is to have
  513. GNU@tie{}tar and Xz.
  514. @c Note duplicated from the ``Installation'' node.
  515. @quotation Note
  516. We recommend the use of this
  517. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  518. shell installer script}. The script automates the download, installation, and
  519. initial configuration steps described below. It should be run as the root
  520. user. As root, you can thus run this:
  521. @example
  522. cd /tmp
  523. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  524. chmod +x guix-install.sh
  525. ./guix-install.sh
  526. @end example
  527. When you're done, @pxref{Application Setup} for extra configuration you
  528. might need, and @ref{Getting Started} for your first steps!
  529. @end quotation
  530. Installing goes along these lines:
  531. @enumerate
  532. @item
  533. @cindex downloading Guix binary
  534. Download the binary tarball from
  535. @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
  536. where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
  537. @code{i686} (32-bits) machine already running the kernel Linux, and so on
  538. (@pxref{GNU Distribution}).
  539. @c The following is somewhat duplicated in ``System Installation''.
  540. Make sure to download the associated @file{.sig} file and to verify the
  541. authenticity of the tarball against it, along these lines:
  542. @example
  543. $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  544. $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  545. @end example
  546. If that command fails because you do not have the required public key,
  547. then run this command to import it:
  548. @example
  549. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  550. -qO - | gpg --import -
  551. @end example
  552. @noindent
  553. and rerun the @code{gpg --verify} command.
  554. Take note that a warning like ``This key is not certified with a trusted
  555. signature!'' is normal.
  556. @c end authentication part
  557. @item
  558. Now, you need to become the @code{root} user. Depending on your distribution,
  559. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  560. @example
  561. # cd /tmp
  562. # tar --warning=no-timestamp -xf \
  563. /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
  564. # mv var/guix /var/ && mv gnu /
  565. @end example
  566. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  567. The latter contains a ready-to-use profile for @code{root} (see next
  568. step).
  569. Do @emph{not} unpack the tarball on a working Guix system since that
  570. would overwrite its own essential files.
  571. The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  572. not emit warnings about ``implausibly old time stamps'' (such
  573. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  574. versions are fine).
  575. They stem from the fact that all the
  576. files in the archive have their modification time set to 1 (which
  577. means January 1st, 1970). This is done on purpose to make sure the
  578. archive content is independent of its creation time, thus making it
  579. reproducible.
  580. @item
  581. Make the profile available under @file{~root/.config/guix/current}, which is
  582. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  583. @example
  584. # mkdir -p ~root/.config/guix
  585. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  586. ~root/.config/guix/current
  587. @end example
  588. Source @file{etc/profile} to augment @env{PATH} and other relevant
  589. environment variables:
  590. @example
  591. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  592. source $GUIX_PROFILE/etc/profile
  593. @end example
  594. @item
  595. Create the group and user accounts for build users as explained below
  596. (@pxref{Build Environment Setup}).
  597. @item
  598. Run the daemon, and set it to automatically start on boot.
  599. If your host distro uses the systemd init system, this can be achieved
  600. with these commands:
  601. @c Versions of systemd that supported symlinked service files are not
  602. @c yet widely deployed, so we should suggest that users copy the service
  603. @c files into place.
  604. @c
  605. @c See this thread for more information:
  606. @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  607. @example
  608. # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  609. ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  610. /etc/systemd/system/
  611. # systemctl enable --now gnu-store.mount guix-daemon
  612. @end example
  613. If your host distro uses the Upstart init system:
  614. @example
  615. # initctl reload-configuration
  616. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  617. /etc/init/
  618. # start guix-daemon
  619. @end example
  620. Otherwise, you can still start the daemon manually with:
  621. @example
  622. # ~root/.config/guix/current/bin/guix-daemon \
  623. --build-users-group=guixbuild
  624. @end example
  625. @item
  626. Make the @command{guix} command available to other users on the machine,
  627. for instance with:
  628. @example
  629. # mkdir -p /usr/local/bin
  630. # cd /usr/local/bin
  631. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  632. @end example
  633. It is also a good idea to make the Info version of this manual available
  634. there:
  635. @example
  636. # mkdir -p /usr/local/share/info
  637. # cd /usr/local/share/info
  638. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  639. do ln -s $i ; done
  640. @end example
  641. That way, assuming @file{/usr/local/share/info} is in the search path,
  642. running @command{info guix} will open this manual (@pxref{Other Info
  643. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  644. Info search path).
  645. @item
  646. @cindex substitutes, authorization thereof
  647. To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors
  648. (@pxref{Substitutes}), authorize them:
  649. @example
  650. # guix archive --authorize < \
  651. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub
  652. @end example
  653. @item
  654. Each user may need to perform a few additional steps to make their Guix
  655. environment ready for use, @pxref{Application Setup}.
  656. @end enumerate
  657. Voilà, the installation is complete!
  658. You can confirm that Guix is working by installing a sample package into
  659. the root profile:
  660. @example
  661. # guix install hello
  662. @end example
  663. The binary installation tarball can be (re)produced and verified simply
  664. by running the following command in the Guix source tree:
  665. @example
  666. make guix-binary.@var{system}.tar.xz
  667. @end example
  668. @noindent
  669. ...@: which, in turn, runs:
  670. @example
  671. guix pack -s @var{system} --localstatedir \
  672. --profile-name=current-guix guix
  673. @end example
  674. @xref{Invoking guix pack}, for more info on this handy tool.
  675. @node Requirements
  676. @section Requirements
  677. This section lists requirements when building Guix from source. The
  678. build procedure for Guix is the same as for other GNU software, and is
  679. not covered here. Please see the files @file{README} and @file{INSTALL}
  680. in the Guix source tree for additional details.
  681. @cindex official website
  682. GNU Guix is available for download from its website at
  683. @url{https://www.gnu.org/software/guix/}.
  684. GNU Guix depends on the following packages:
  685. @itemize
  686. @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x or
  687. 2.2.x;
  688. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  689. 0.1.0 or later;
  690. @item
  691. @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
  692. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  693. Guile,, gnutls-guile, GnuTLS-Guile});
  694. @item
  695. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  696. or later;
  697. @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib},
  698. version 0.1.0 or later;
  699. @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
  700. @item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi};
  701. @item
  702. @c FIXME: Specify a version number once a release has been made.
  703. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.3.0
  704. or later;
  705. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
  706. 4.3.0 or later;
  707. @item @url{https://www.gnu.org/software/make/, GNU Make}.
  708. @end itemize
  709. The following dependencies are optional:
  710. @itemize
  711. @item
  712. @c Note: We need at least 0.13.0 for #:nodelay.
  713. Support for build offloading (@pxref{Daemon Offload Setup}) and
  714. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  715. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  716. version 0.13.0 or later.
  717. @item
  718. @uref{https://notabug.org/guile-zstd/guile-zstd, Guile-zstd}, for zstd
  719. compression and decompression in @command{guix publish} and for
  720. substitutes (@pxref{Invoking guix publish}).
  721. @item
  722. @uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for
  723. the @code{crate} importer (@pxref{Invoking guix import}).
  724. @item
  725. @uref{https://www.nongnu.org/guile-lib/doc/ref/htmlprag/, Guile-Lib} for
  726. the @code{go} importer (@pxref{Invoking guix import}) and for some of
  727. the ``updaters'' (@pxref{Invoking guix refresh}).
  728. @item
  729. When @url{http://www.bzip.org, libbz2} is available,
  730. @command{guix-daemon} can use it to compress build logs.
  731. @end itemize
  732. Unless @option{--disable-daemon} was passed to @command{configure}, the
  733. following packages are also needed:
  734. @itemize
  735. @item @url{https://gnupg.org/, GNU libgcrypt};
  736. @item @url{https://sqlite.org, SQLite 3};
  737. @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
  738. C++11 standard.
  739. @end itemize
  740. @cindex state directory
  741. When configuring Guix on a system that already has a Guix installation,
  742. be sure to specify the same state directory as the existing installation
  743. using the @option{--localstatedir} option of the @command{configure}
  744. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  745. GNU Coding Standards}). Usually, this @var{localstatedir} option is
  746. set to the value @file{/var}. The @command{configure} script protects
  747. against unintended misconfiguration of @var{localstatedir} so you do not
  748. inadvertently corrupt your store (@pxref{The Store}).
  749. @node Running the Test Suite
  750. @section Running the Test Suite
  751. @cindex test suite
  752. After a successful @command{configure} and @code{make} run, it is a good
  753. idea to run the test suite. It can help catch issues with the setup or
  754. environment, or bugs in Guix itself---and really, reporting test
  755. failures is a good way to help improve the software. To run the test
  756. suite, type:
  757. @example
  758. make check
  759. @end example
  760. Test cases can run in parallel: you can use the @code{-j} option of
  761. GNU@tie{}make to speed things up. The first run may take a few minutes
  762. on a recent machine; subsequent runs will be faster because the store
  763. that is created for test purposes will already have various things in
  764. cache.
  765. It is also possible to run a subset of the tests by defining the
  766. @code{TESTS} makefile variable as in this example:
  767. @example
  768. make check TESTS="tests/store.scm tests/cpio.scm"
  769. @end example
  770. By default, tests results are displayed at a file level. In order to
  771. see the details of every individual test cases, it is possible to define
  772. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  773. @example
  774. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  775. @end example
  776. The underlying SRFI 64 custom Automake test driver used for the 'check'
  777. test suite (located at @file{build-aux/test-driver.scm}) also allows
  778. selecting which test cases to run at a finer level, via its
  779. @option{--select} and @option{--exclude} options. Here's an example, to
  780. run all the test cases from the @file{tests/packages.scm} test file
  781. whose names start with ``transaction-upgrade-entry'':
  782. @example
  783. export SCM_LOG_DRIVER_FLAGS="--select=^transaction-upgrade-entry"
  784. make check TESTS="tests/packages.scm"
  785. @end example
  786. Those wishing to inspect the results of failed tests directly from the
  787. command line can add the @option{--errors-only=yes} option to the
  788. @code{SCM_LOG_DRIVER_FLAGS} makefile variable and set the @code{VERBOSE}
  789. Automake makefile variable, as in:
  790. @example
  791. make check SCM_LOG_DRIVER_FLAGS="--brief=no --errors-only=yes" VERBOSE=1
  792. @end example
  793. The @option{--show-duration=yes} option can be used to print the
  794. duration of the individual test cases, when used in combination with
  795. @option{--brief=no}:
  796. @example
  797. make check SCM_LOG_DRIVER_FLAGS="--brief=no --show-duration=yes"
  798. @end example
  799. @xref{Parallel Test Harness,,,automake,GNU Automake} for more
  800. information about the Automake Parallel Test Harness.
  801. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  802. @file{test-suite.log} file. Please specify the Guix version being used
  803. as well as version numbers of the dependencies (@pxref{Requirements}) in
  804. your message.
  805. Guix also comes with a whole-system test suite that tests complete
  806. Guix System instances. It can only run on systems where
  807. Guix is already installed, using:
  808. @example
  809. make check-system
  810. @end example
  811. @noindent
  812. or, again, by defining @code{TESTS} to select a subset of tests to run:
  813. @example
  814. make check-system TESTS="basic mcron"
  815. @end example
  816. These system tests are defined in the @code{(gnu tests @dots{})}
  817. modules. They work by running the operating systems under test with
  818. lightweight instrumentation in a virtual machine (VM). They can be
  819. computationally intensive or rather cheap, depending on whether
  820. substitutes are available for their dependencies (@pxref{Substitutes}).
  821. Some of them require a lot of storage space to hold VM images.
  822. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  823. all the details.
  824. @node Setting Up the Daemon
  825. @section Setting Up the Daemon
  826. @cindex daemon
  827. Operations such as building a package or running the garbage collector
  828. are all performed by a specialized process, the @dfn{build daemon}, on
  829. behalf of clients. Only the daemon may access the store and its
  830. associated database. Thus, any operation that manipulates the store
  831. goes through the daemon. For instance, command-line tools such as
  832. @command{guix package} and @command{guix build} communicate with the
  833. daemon (@i{via} remote procedure calls) to instruct it what to do.
  834. The following sections explain how to prepare the build daemon's
  835. environment. See also @ref{Substitutes}, for information on how to allow
  836. the daemon to download pre-built binaries.
  837. @menu
  838. * Build Environment Setup:: Preparing the isolated build environment.
  839. * Daemon Offload Setup:: Offloading builds to remote machines.
  840. * SELinux Support:: Using an SELinux policy for the daemon.
  841. @end menu
  842. @node Build Environment Setup
  843. @subsection Build Environment Setup
  844. @cindex build environment
  845. In a standard multi-user setup, Guix and its daemon---the
  846. @command{guix-daemon} program---are installed by the system
  847. administrator; @file{/gnu/store} is owned by @code{root} and
  848. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  849. Guix tools to build packages or otherwise access the store, and the
  850. daemon will do it on their behalf, ensuring that the store is kept in a
  851. consistent state, and allowing built packages to be shared among users.
  852. @cindex build users
  853. When @command{guix-daemon} runs as @code{root}, you may not want package
  854. build processes themselves to run as @code{root} too, for obvious
  855. security reasons. To avoid that, a special pool of @dfn{build users}
  856. should be created for use by build processes started by the daemon.
  857. These build users need not have a shell and a home directory: they will
  858. just be used when the daemon drops @code{root} privileges in build
  859. processes. Having several such users allows the daemon to launch
  860. distinct build processes under separate UIDs, which guarantees that they
  861. do not interfere with each other---an essential feature since builds are
  862. regarded as pure functions (@pxref{Introduction}).
  863. On a GNU/Linux system, a build user pool may be created like this (using
  864. Bash syntax and the @code{shadow} commands):
  865. @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  866. @c for why `-G' is needed.
  867. @example
  868. # groupadd --system guixbuild
  869. # for i in $(seq -w 1 10);
  870. do
  871. useradd -g guixbuild -G guixbuild \
  872. -d /var/empty -s $(which nologin) \
  873. -c "Guix build user $i" --system \
  874. guixbuilder$i;
  875. done
  876. @end example
  877. @noindent
  878. The number of build users determines how many build jobs may run in
  879. parallel, as specified by the @option{--max-jobs} option
  880. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  881. @command{guix system vm} and related commands, you may need to add the
  882. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  883. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  884. (@pxref{Invoking guix system}).
  885. The @code{guix-daemon} program may then be run as @code{root} with the
  886. following command@footnote{If your machine uses the systemd init system,
  887. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  888. file in @file{/etc/systemd/system} will ensure that
  889. @command{guix-daemon} is automatically started. Similarly, if your
  890. machine uses the Upstart init system, drop the
  891. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  892. file in @file{/etc/init}.}:
  893. @example
  894. # guix-daemon --build-users-group=guixbuild
  895. @end example
  896. @cindex chroot
  897. @noindent
  898. This way, the daemon starts build processes in a chroot, under one of
  899. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  900. environment contains nothing but:
  901. @c Keep this list in sync with libstore/build.cc! -----------------------
  902. @itemize
  903. @item
  904. a minimal @code{/dev} directory, created mostly independently from the
  905. host @code{/dev}@footnote{``Mostly'', because while the set of files
  906. that appear in the chroot's @code{/dev} is fixed, most of these files
  907. can only be created if the host has them.};
  908. @item
  909. the @code{/proc} directory; it only shows the processes of the container
  910. since a separate PID name space is used;
  911. @item
  912. @file{/etc/passwd} with an entry for the current user and an entry for
  913. user @file{nobody};
  914. @item
  915. @file{/etc/group} with an entry for the user's group;
  916. @item
  917. @file{/etc/hosts} with an entry that maps @code{localhost} to
  918. @code{127.0.0.1};
  919. @item
  920. a writable @file{/tmp} directory.
  921. @end itemize
  922. You can influence the directory where the daemon stores build trees
  923. @i{via} the @env{TMPDIR} environment variable. However, the build tree
  924. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  925. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  926. This way, the value of @env{TMPDIR} does not leak inside build
  927. environments, which avoids discrepancies in cases where build processes
  928. capture the name of their build tree.
  929. @vindex http_proxy
  930. @vindex https_proxy
  931. The daemon also honors the @env{http_proxy} and @env{https_proxy}
  932. environment variables for HTTP and HTTPS downloads it performs, be it
  933. for fixed-output derivations (@pxref{Derivations}) or for substitutes
  934. (@pxref{Substitutes}).
  935. If you are installing Guix as an unprivileged user, it is still possible
  936. to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
  937. However, build processes will not be isolated from one another, and not
  938. from the rest of the system. Thus, build processes may interfere with
  939. each other, and may access programs, libraries, and other files
  940. available on the system---making it much harder to view them as
  941. @emph{pure} functions.
  942. @node Daemon Offload Setup
  943. @subsection Using the Offload Facility
  944. @cindex offloading
  945. @cindex build hook
  946. When desired, the build daemon can @dfn{offload} derivation builds to
  947. other machines running Guix, using the @code{offload} @dfn{build
  948. hook}@footnote{This feature is available only when
  949. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  950. present.}. When that feature is enabled, a list of user-specified build
  951. machines is read from @file{/etc/guix/machines.scm}; every time a build
  952. is requested, for instance via @code{guix build}, the daemon attempts to
  953. offload it to one of the machines that satisfy the constraints of the
  954. derivation, in particular its system types---e.g., @code{x86_64-linux}.
  955. A single machine can have multiple system types, either because its
  956. architecture natively supports it, via emulation
  957. (@pxref{transparent-emulation-qemu, Transparent Emulation with QEMU}),
  958. or both. Missing prerequisites for the build are
  959. copied over SSH to the target machine, which then proceeds with the
  960. build; upon success the output(s) of the build are copied back to the
  961. initial machine. The offload facility comes with a basic scheduler that
  962. attempts to select the best machine. The best machine is chosen among
  963. the available machines based on criteria such as:
  964. @enumerate
  965. @item
  966. The availability of a build slot. A build machine can have as many
  967. build slots (connections) as the value of the @code{parallel-builds}
  968. field of its @code{build-machine} object.
  969. @item
  970. Its relative speed, as defined via the @code{speed} field of its
  971. @code{build-machine} object.
  972. @item
  973. Its load. The normalized machine load must be lower than a threshold
  974. value, configurable via the @code{overload-threshold} field of its
  975. @code{build-machine} object.
  976. @item
  977. Disk space availability. More than a 100 MiB must be available.
  978. @end enumerate
  979. The @file{/etc/guix/machines.scm} file typically looks like this:
  980. @lisp
  981. (list (build-machine
  982. (name "eightysix.example.org")
  983. (systems (list "x86_64-linux" "i686-linux"))
  984. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  985. (user "bob")
  986. (speed 2.)) ;incredibly fast!
  987. (build-machine
  988. (name "armeight.example.org")
  989. (systems (list "aarch64-linux"))
  990. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  991. (user "alice")
  992. (private-key
  993. (string-append (getenv "HOME")
  994. "/.ssh/identity-for-guix"))))
  995. @end lisp
  996. @noindent
  997. In the example above we specify a list of two build machines, one for
  998. the @code{x86_64} and @code{i686} architectures and one for the
  999. @code{aarch64} architecture.
  1000. In fact, this file is---not surprisingly!---a Scheme file that is
  1001. evaluated when the @code{offload} hook is started. Its return value
  1002. must be a list of @code{build-machine} objects. While this example
  1003. shows a fixed list of build machines, one could imagine, say, using
  1004. DNS-SD to return a list of potential build machines discovered in the
  1005. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  1006. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  1007. detailed below.
  1008. @deftp {Data Type} build-machine
  1009. This data type represents build machines to which the daemon may offload
  1010. builds. The important fields are:
  1011. @table @code
  1012. @item name
  1013. The host name of the remote machine.
  1014. @item systems
  1015. The system types the remote machine supports---e.g., @code{(list
  1016. "x86_64-linux" "i686-linux")}.
  1017. @item user
  1018. The user account to use when connecting to the remote machine over SSH.
  1019. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  1020. allow non-interactive logins.
  1021. @item host-key
  1022. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  1023. This is used to authenticate the machine when we connect to it. It is a
  1024. long string that looks like this:
  1025. @example
  1026. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  1027. @end example
  1028. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  1029. key can be found in a file such as
  1030. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  1031. If the machine is running the SSH daemon of GNU@tie{}lsh,
  1032. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  1033. similar file. It can be converted to the OpenSSH format using
  1034. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  1035. @example
  1036. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  1037. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  1038. @end example
  1039. @end table
  1040. A number of optional fields may be specified:
  1041. @table @asis
  1042. @item @code{port} (default: @code{22})
  1043. Port number of SSH server on the machine.
  1044. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  1045. The SSH private key file to use when connecting to the machine, in
  1046. OpenSSH format. This key must not be protected with a passphrase.
  1047. Note that the default value is the private key @emph{of the root
  1048. account}. Make sure it exists if you use the default.
  1049. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  1050. @itemx @code{compression-level} (default: @code{3})
  1051. The SSH-level compression methods and compression level requested.
  1052. Note that offloading relies on SSH compression to reduce bandwidth usage
  1053. when transferring files to and from build machines.
  1054. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  1055. File name of the Unix-domain socket @command{guix-daemon} is listening
  1056. to on that machine.
  1057. @item @code{overload-threshold} (default: @code{0.6})
  1058. The load threshold above which a potential offload machine is
  1059. disregarded by the offload scheduler. The value roughly translates to
  1060. the total processor usage of the build machine, ranging from 0.0 (0%) to
  1061. 1.0 (100%). It can also be disabled by setting
  1062. @code{overload-threshold} to @code{#f}.
  1063. @item @code{parallel-builds} (default: @code{1})
  1064. The number of builds that may run in parallel on the machine.
  1065. @item @code{speed} (default: @code{1.0})
  1066. A ``relative speed factor''. The offload scheduler will tend to prefer
  1067. machines with a higher speed factor.
  1068. @item @code{features} (default: @code{'()})
  1069. A list of strings denoting specific features supported by the machine.
  1070. An example is @code{"kvm"} for machines that have the KVM Linux modules
  1071. and corresponding hardware support. Derivations can request features by
  1072. name, and they will be scheduled on matching build machines.
  1073. @end table
  1074. @end deftp
  1075. The @command{guix} command must be in the search path on the build
  1076. machines. You can check whether this is the case by running:
  1077. @example
  1078. ssh build-machine guix repl --version
  1079. @end example
  1080. There is one last thing to do once @file{machines.scm} is in place. As
  1081. explained above, when offloading, files are transferred back and forth
  1082. between the machine stores. For this to work, you first need to
  1083. generate a key pair on each machine to allow the daemon to export signed
  1084. archives of files from the store (@pxref{Invoking guix archive}):
  1085. @example
  1086. # guix archive --generate-key
  1087. @end example
  1088. @noindent
  1089. Each build machine must authorize the key of the master machine so that
  1090. it accepts store items it receives from the master:
  1091. @example
  1092. # guix archive --authorize < master-public-key.txt
  1093. @end example
  1094. @noindent
  1095. Likewise, the master machine must authorize the key of each build machine.
  1096. All the fuss with keys is here to express pairwise mutual trust
  1097. relations between the master and the build machines. Concretely, when
  1098. the master receives files from a build machine (and @i{vice versa}), its
  1099. build daemon can make sure they are genuine, have not been tampered
  1100. with, and that they are signed by an authorized key.
  1101. @cindex offload test
  1102. To test whether your setup is operational, run this command on the
  1103. master node:
  1104. @example
  1105. # guix offload test
  1106. @end example
  1107. This will attempt to connect to each of the build machines specified in
  1108. @file{/etc/guix/machines.scm}, make sure Guix is
  1109. available on each machine, attempt to export to the machine and import
  1110. from it, and report any error in the process.
  1111. If you want to test a different machine file, just specify it on the
  1112. command line:
  1113. @example
  1114. # guix offload test machines-qualif.scm
  1115. @end example
  1116. Last, you can test the subset of the machines whose name matches a
  1117. regular expression like this:
  1118. @example
  1119. # guix offload test machines.scm '\.gnu\.org$'
  1120. @end example
  1121. @cindex offload status
  1122. To display the current load of all build hosts, run this command on the
  1123. main node:
  1124. @example
  1125. # guix offload status
  1126. @end example
  1127. @node SELinux Support
  1128. @subsection SELinux Support
  1129. @cindex SELinux, daemon policy
  1130. @cindex mandatory access control, SELinux
  1131. @cindex security, guix-daemon
  1132. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  1133. can be installed on a system where SELinux is enabled, in order to label
  1134. Guix files and to specify the expected behavior of the daemon. Since
  1135. Guix System does not provide an SELinux base policy, the daemon policy cannot
  1136. be used on Guix System.
  1137. @subsubsection Installing the SELinux policy
  1138. @cindex SELinux, policy installation
  1139. To install the policy run this command as root:
  1140. @example
  1141. semodule -i etc/guix-daemon.cil
  1142. @end example
  1143. Then relabel the file system with @code{restorecon} or by a different
  1144. mechanism provided by your system.
  1145. Once the policy is installed, the file system has been relabeled, and
  1146. the daemon has been restarted, it should be running in the
  1147. @code{guix_daemon_t} context. You can confirm this with the following
  1148. command:
  1149. @example
  1150. ps -Zax | grep guix-daemon
  1151. @end example
  1152. Monitor the SELinux log files as you run a command like @code{guix build
  1153. hello} to convince yourself that SELinux permits all necessary
  1154. operations.
  1155. @subsubsection Limitations
  1156. @cindex SELinux, limitations
  1157. This policy is not perfect. Here is a list of limitations or quirks
  1158. that should be considered when deploying the provided SELinux policy for
  1159. the Guix daemon.
  1160. @enumerate
  1161. @item
  1162. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  1163. operations involve contexts that have anything to do with
  1164. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  1165. but it would be preferrable to define socket rules for only this label.
  1166. @item
  1167. @code{guix gc} cannot access arbitrary links to profiles. By design,
  1168. the file label of the destination of a symlink is independent of the
  1169. file label of the link itself. Although all profiles under
  1170. $localstatedir are labelled, the links to these profiles inherit the
  1171. label of the directory they are in. For links in the user’s home
  1172. directory this will be @code{user_home_t}. But for links from the root
  1173. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  1174. directory, etc, this won’t work. @code{guix gc} would be prevented from
  1175. reading and following these links.
  1176. @item
  1177. The daemon’s feature to listen for TCP connections might no longer work.
  1178. This might require extra rules, because SELinux treats network sockets
  1179. differently from files.
  1180. @item
  1181. Currently all files with a name matching the regular expression
  1182. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  1183. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  1184. that name in any profile would be permitted to run in the
  1185. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  1186. build a package that provides this executable and convince a user to
  1187. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  1188. At that point SELinux could not prevent it from accessing files that are
  1189. allowed for processes in that domain.
  1190. You will need to relabel the store directory after all upgrades to
  1191. @file{guix-daemon}, such as after running @code{guix pull}. Assuming the
  1192. store is in @file{/gnu}, you can do this with @code{restorecon -vR /gnu},
  1193. or by other means provided by your operating system.
  1194. We could generate a much more restrictive policy at installation time,
  1195. so that only the @emph{exact} file name of the currently installed
  1196. @code{guix-daemon} executable would be labelled with
  1197. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  1198. The downside is that root would have to install or upgrade the policy at
  1199. installation time whenever the Guix package that provides the
  1200. effectively running @code{guix-daemon} executable is upgraded.
  1201. @end enumerate
  1202. @node Invoking guix-daemon
  1203. @section Invoking @command{guix-daemon}
  1204. The @command{guix-daemon} program implements all the functionality to
  1205. access the store. This includes launching build processes, running the
  1206. garbage collector, querying the availability of a build result, etc. It
  1207. is normally run as @code{root} like this:
  1208. @example
  1209. # guix-daemon --build-users-group=guixbuild
  1210. @end example
  1211. @noindent
  1212. For details on how to set it up, @pxref{Setting Up the Daemon}.
  1213. @cindex chroot
  1214. @cindex container, build environment
  1215. @cindex build environment
  1216. @cindex reproducible builds
  1217. By default, @command{guix-daemon} launches build processes under
  1218. different UIDs, taken from the build group specified with
  1219. @option{--build-users-group}. In addition, each build process is run in a
  1220. chroot environment that only contains the subset of the store that the
  1221. build process depends on, as specified by its derivation
  1222. (@pxref{Programming Interface, derivation}), plus a set of specific
  1223. system directories. By default, the latter contains @file{/dev} and
  1224. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1225. @dfn{container}: in addition to having its own file system tree, it has
  1226. a separate mount name space, its own PID name space, network name space,
  1227. etc. This helps achieve reproducible builds (@pxref{Features}).
  1228. When the daemon performs a build on behalf of the user, it creates a
  1229. build directory under @file{/tmp} or under the directory specified by
  1230. its @env{TMPDIR} environment variable. This directory is shared with
  1231. the container for the duration of the build, though within the container,
  1232. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1233. The build directory is automatically deleted upon completion, unless the
  1234. build failed and the client specified @option{--keep-failed}
  1235. (@pxref{Common Build Options, @option{--keep-failed}}).
  1236. The daemon listens for connections and spawns one sub-process for each session
  1237. started by a client (one of the @command{guix} sub-commands). The
  1238. @command{guix processes} command allows you to get an overview of the activity
  1239. on your system by viewing each of the active sessions and clients.
  1240. @xref{Invoking guix processes}, for more information.
  1241. The following command-line options are supported:
  1242. @table @code
  1243. @item --build-users-group=@var{group}
  1244. Take users from @var{group} to run build processes (@pxref{Setting Up
  1245. the Daemon, build users}).
  1246. @item --no-substitutes
  1247. @cindex substitutes
  1248. Do not use substitutes for build products. That is, always build things
  1249. locally instead of allowing downloads of pre-built binaries
  1250. (@pxref{Substitutes}).
  1251. When the daemon runs with @option{--no-substitutes}, clients can still
  1252. explicitly enable substitution @i{via} the @code{set-build-options}
  1253. remote procedure call (@pxref{The Store}).
  1254. @anchor{daemon-substitute-urls}
  1255. @item --substitute-urls=@var{urls}
  1256. Consider @var{urls} the default whitespace-separated list of substitute
  1257. source URLs. When this option is omitted,
  1258. @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
  1259. This means that substitutes may be downloaded from @var{urls}, as long
  1260. as they are signed by a trusted signature (@pxref{Substitutes}).
  1261. @xref{Getting Substitutes from Other Servers}, for more information on
  1262. how to configure the daemon to get substitutes from other servers.
  1263. @cindex offloading
  1264. @item --no-offload
  1265. Do not use offload builds to other machines (@pxref{Daemon Offload
  1266. Setup}). That is, always build things locally instead of offloading
  1267. builds to remote machines.
  1268. @item --cache-failures
  1269. Cache build failures. By default, only successful builds are cached.
  1270. When this option is used, @command{guix gc --list-failures} can be used
  1271. to query the set of store items marked as failed; @command{guix gc
  1272. --clear-failures} removes store items from the set of cached failures.
  1273. @xref{Invoking guix gc}.
  1274. @item --cores=@var{n}
  1275. @itemx -c @var{n}
  1276. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1277. as available.
  1278. The default value is @code{0}, but it may be overridden by clients, such
  1279. as the @option{--cores} option of @command{guix build} (@pxref{Invoking
  1280. guix build}).
  1281. The effect is to define the @env{NIX_BUILD_CORES} environment variable
  1282. in the build process, which can then use it to exploit internal
  1283. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1284. @item --max-jobs=@var{n}
  1285. @itemx -M @var{n}
  1286. Allow at most @var{n} build jobs in parallel. The default value is
  1287. @code{1}. Setting it to @code{0} means that no builds will be performed
  1288. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1289. Setup}), or simply fail.
  1290. @item --max-silent-time=@var{seconds}
  1291. When the build or substitution process remains silent for more than
  1292. @var{seconds}, terminate it and report a build failure.
  1293. The default value is @code{0}, which disables the timeout.
  1294. The value specified here can be overridden by clients (@pxref{Common
  1295. Build Options, @option{--max-silent-time}}).
  1296. @item --timeout=@var{seconds}
  1297. Likewise, when the build or substitution process lasts for more than
  1298. @var{seconds}, terminate it and report a build failure.
  1299. The default value is @code{0}, which disables the timeout.
  1300. The value specified here can be overridden by clients (@pxref{Common
  1301. Build Options, @option{--timeout}}).
  1302. @item --rounds=@var{N}
  1303. Build each derivation @var{n} times in a row, and raise an error if
  1304. consecutive build results are not bit-for-bit identical. Note that this
  1305. setting can be overridden by clients such as @command{guix build}
  1306. (@pxref{Invoking guix build}).
  1307. When used in conjunction with @option{--keep-failed}, the differing
  1308. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1309. This makes it easy to look for differences between the two results.
  1310. @item --debug
  1311. Produce debugging output.
  1312. This is useful to debug daemon start-up issues, but then it may be
  1313. overridden by clients, for example the @option{--verbosity} option of
  1314. @command{guix build} (@pxref{Invoking guix build}).
  1315. @item --chroot-directory=@var{dir}
  1316. Add @var{dir} to the build chroot.
  1317. Doing this may change the result of build processes---for instance if
  1318. they use optional dependencies found in @var{dir} when it is available,
  1319. and not otherwise. For that reason, it is not recommended to do so.
  1320. Instead, make sure that each derivation declares all the inputs that it
  1321. needs.
  1322. @item --disable-chroot
  1323. Disable chroot builds.
  1324. Using this option is not recommended since, again, it would allow build
  1325. processes to gain access to undeclared dependencies. It is necessary,
  1326. though, when @command{guix-daemon} is running under an unprivileged user
  1327. account.
  1328. @item --log-compression=@var{type}
  1329. Compress build logs according to @var{type}, one of @code{gzip},
  1330. @code{bzip2}, or @code{none}.
  1331. Unless @option{--lose-logs} is used, all the build logs are kept in the
  1332. @var{localstatedir}. To save space, the daemon automatically compresses
  1333. them with Bzip2 by default.
  1334. @item --discover[=yes|no]
  1335. Whether to discover substitute servers on the local network using mDNS
  1336. and DNS-SD.
  1337. This feature is still experimental. However, here are a few
  1338. considerations.
  1339. @enumerate
  1340. @item
  1341. It might be faster/less expensive than fetching from remote servers;
  1342. @item
  1343. There are no security risks, only genuine substitutes will be used
  1344. (@pxref{Substitute Authentication});
  1345. @item
  1346. An attacker advertising @command{guix publish} on your LAN cannot serve
  1347. you malicious binaries, but they can learn what software you’re
  1348. installing;
  1349. @item
  1350. Servers may serve substitute over HTTP, unencrypted, so anyone on the
  1351. LAN can see what software you’re installing.
  1352. @end enumerate
  1353. It is also possible to enable or disable substitute server discovery at
  1354. run-time by running:
  1355. @example
  1356. herd discover guix-daemon on
  1357. herd discover guix-daemon off
  1358. @end example
  1359. @item --disable-deduplication
  1360. @cindex deduplication
  1361. Disable automatic file ``deduplication'' in the store.
  1362. By default, files added to the store are automatically ``deduplicated'':
  1363. if a newly added file is identical to another one found in the store,
  1364. the daemon makes the new file a hard link to the other file. This can
  1365. noticeably reduce disk usage, at the expense of slightly increased
  1366. input/output load at the end of a build process. This option disables
  1367. this optimization.
  1368. @item --gc-keep-outputs[=yes|no]
  1369. Tell whether the garbage collector (GC) must keep outputs of live
  1370. derivations.
  1371. @cindex GC roots
  1372. @cindex garbage collector roots
  1373. When set to @code{yes}, the GC will keep the outputs of any live
  1374. derivation available in the store---the @file{.drv} files. The default
  1375. is @code{no}, meaning that derivation outputs are kept only if they are
  1376. reachable from a GC root. @xref{Invoking guix gc}, for more on GC
  1377. roots.
  1378. @item --gc-keep-derivations[=yes|no]
  1379. Tell whether the garbage collector (GC) must keep derivations
  1380. corresponding to live outputs.
  1381. When set to @code{yes}, as is the case by default, the GC keeps
  1382. derivations---i.e., @file{.drv} files---as long as at least one of their
  1383. outputs is live. This allows users to keep track of the origins of
  1384. items in their store. Setting it to @code{no} saves a bit of disk
  1385. space.
  1386. In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
  1387. liveness to flow from outputs to derivations, and setting
  1388. @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
  1389. derivations to outputs. When both are set to @code{yes}, the effect is
  1390. to keep all the build prerequisites (the sources, compiler, libraries,
  1391. and other build-time tools) of live objects in the store, regardless of
  1392. whether these prerequisites are reachable from a GC root. This is
  1393. convenient for developers since it saves rebuilds or downloads.
  1394. @item --impersonate-linux-2.6
  1395. On Linux-based systems, impersonate Linux 2.6. This means that the
  1396. kernel's @command{uname} system call will report 2.6 as the release number.
  1397. This might be helpful to build programs that (usually wrongfully) depend
  1398. on the kernel version number.
  1399. @item --lose-logs
  1400. Do not keep build logs. By default they are kept under
  1401. @file{@var{localstatedir}/guix/log}.
  1402. @item --system=@var{system}
  1403. Assume @var{system} as the current system type. By default it is the
  1404. architecture/kernel pair found at configure time, such as
  1405. @code{x86_64-linux}.
  1406. @item --listen=@var{endpoint}
  1407. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1408. as the file name of a Unix-domain socket if it starts with
  1409. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1410. host name or host name and port to listen to. Here are a few examples:
  1411. @table @code
  1412. @item --listen=/gnu/var/daemon
  1413. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1414. creating it if needed.
  1415. @item --listen=localhost
  1416. @cindex daemon, remote access
  1417. @cindex remote access to the daemon
  1418. @cindex daemon, cluster setup
  1419. @cindex clusters, daemon setup
  1420. Listen for TCP connections on the network interface corresponding to
  1421. @code{localhost}, on port 44146.
  1422. @item --listen=128.0.0.42:1234
  1423. Listen for TCP connections on the network interface corresponding to
  1424. @code{128.0.0.42}, on port 1234.
  1425. @end table
  1426. This option can be repeated multiple times, in which case
  1427. @command{guix-daemon} accepts connections on all the specified
  1428. endpoints. Users can tell client commands what endpoint to connect to
  1429. by setting the @env{GUIX_DAEMON_SOCKET} environment variable
  1430. (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
  1431. @quotation Note
  1432. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1433. @option{--listen=@var{host}} is suitable on local networks, such as
  1434. clusters, where only trusted nodes may connect to the build daemon. In
  1435. other cases where remote access to the daemon is needed, we recommend
  1436. using Unix-domain sockets along with SSH.
  1437. @end quotation
  1438. When @option{--listen} is omitted, @command{guix-daemon} listens for
  1439. connections on the Unix-domain socket located at
  1440. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1441. @end table
  1442. @node Application Setup
  1443. @section Application Setup
  1444. @cindex foreign distro
  1445. When using Guix on top of GNU/Linux distribution other than Guix System---a
  1446. so-called @dfn{foreign distro}---a few additional steps are needed to
  1447. get everything in place. Here are some of them.
  1448. @subsection Locales
  1449. @anchor{locales-and-locpath}
  1450. @cindex locales, when not on Guix System
  1451. @vindex LOCPATH
  1452. @vindex GUIX_LOCPATH
  1453. Packages installed @i{via} Guix will not use the locale data of the
  1454. host system. Instead, you must first install one of the locale packages
  1455. available with Guix and then define the @env{GUIX_LOCPATH} environment
  1456. variable:
  1457. @example
  1458. $ guix install glibc-locales
  1459. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1460. @end example
  1461. Note that the @code{glibc-locales} package contains data for all the
  1462. locales supported by the GNU@tie{}libc and weighs in at around
  1463. 917@tie{}MiB@. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1464. limited to a few UTF-8 locales.
  1465. The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
  1466. (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
  1467. Manual}). There are two important differences though:
  1468. @enumerate
  1469. @item
  1470. @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1471. provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
  1472. to make sure the programs of the foreign distro will not end up loading
  1473. incompatible locale data.
  1474. @item
  1475. libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
  1476. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1477. should your Guix profile contain a mixture of programs linked against
  1478. different libc version, each libc version will only try to load locale
  1479. data in the right format.
  1480. @end enumerate
  1481. This is important because the locale data format used by different libc
  1482. versions may be incompatible.
  1483. @subsection Name Service Switch
  1484. @cindex name service switch, glibc
  1485. @cindex NSS (name service switch), glibc
  1486. @cindex nscd (name service caching daemon)
  1487. @cindex name service caching daemon (nscd)
  1488. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1489. the system run the GNU C library's @dfn{name service cache daemon},
  1490. @command{nscd}, which should be listening on the
  1491. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1492. installed with Guix may fail to look up host names or user accounts, or
  1493. may even crash. The next paragraphs explain why.
  1494. @cindex @file{nsswitch.conf}
  1495. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1496. an extensible mechanism for ``name lookups'' in general: host name
  1497. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1498. The GNU C Library Reference Manual}).
  1499. @cindex Network information service (NIS)
  1500. @cindex NIS (Network information service)
  1501. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1502. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1503. resolution of @code{.local} host names, the @code{nis} plugin allows
  1504. user account lookup using the Network information service (NIS), and so
  1505. on. These extra ``lookup services'' are configured system-wide in
  1506. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1507. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1508. Reference Manual}).
  1509. When they perform a name lookup---for instance by calling the
  1510. @code{getaddrinfo} function in C---applications first try to connect to
  1511. the nscd; on success, nscd performs name lookups on their behalf. If
  1512. the nscd is not running, then they perform the name lookup by
  1513. themselves, by loading the name lookup services into their own address
  1514. space and running it. These name lookup services---the
  1515. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1516. the host system's C library, rather than from the C library the
  1517. application is linked against (the C library coming from Guix).
  1518. And this is where the problem is: if your application is linked against
  1519. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1520. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1521. likely crash or have its name lookups fail unexpectedly.
  1522. Running @command{nscd} on the system, among other advantages, eliminates
  1523. this binary incompatibility problem because those @code{libnss_*.so}
  1524. files are loaded in the @command{nscd} process, not in applications
  1525. themselves.
  1526. @subsection X11 Fonts
  1527. @cindex fonts
  1528. The majority of graphical applications use Fontconfig to locate and
  1529. load fonts and perform X11-client-side rendering. The @code{fontconfig}
  1530. package in Guix looks for fonts in @file{$HOME/.guix-profile}
  1531. by default. Thus, to allow graphical applications installed with Guix
  1532. to display fonts, you have to install fonts with Guix as well.
  1533. Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
  1534. @code{font-gnu-freefont}.
  1535. @cindex @code{fc-cache}
  1536. @cindex font cache
  1537. Once you have installed or removed fonts, or when you notice an
  1538. application that does not find fonts, you may need to install Fontconfig
  1539. and to force an update of its font cache by running:
  1540. @example
  1541. guix install fontconfig
  1542. fc-cache -rv
  1543. @end example
  1544. To display text written in Chinese languages, Japanese, or Korean in
  1545. graphical applications, consider installing
  1546. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1547. has multiple outputs, one per language family (@pxref{Packages with
  1548. Multiple Outputs}). For instance, the following command installs fonts
  1549. for Chinese languages:
  1550. @example
  1551. guix install font-adobe-source-han-sans:cn
  1552. @end example
  1553. @cindex @code{xterm}
  1554. Older programs such as @command{xterm} do not use Fontconfig and instead
  1555. rely on server-side font rendering. Such programs require to specify a
  1556. full name of a font using XLFD (X Logical Font Description), like this:
  1557. @example
  1558. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1559. @end example
  1560. To be able to use such full names for the TrueType fonts installed in
  1561. your Guix profile, you need to extend the font path of the X server:
  1562. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1563. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1564. @example
  1565. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1566. @end example
  1567. @cindex @code{xlsfonts}
  1568. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1569. to make sure your TrueType fonts are listed there.
  1570. @subsection X.509 Certificates
  1571. @cindex @code{nss-certs}
  1572. The @code{nss-certs} package provides X.509 certificates, which allow
  1573. programs to authenticate Web servers accessed over HTTPS.
  1574. When using Guix on a foreign distro, you can install this package and
  1575. define the relevant environment variables so that packages know where to
  1576. look for certificates. @xref{X.509 Certificates}, for detailed
  1577. information.
  1578. @subsection Emacs Packages
  1579. @cindex @code{emacs}
  1580. When you install Emacs packages with Guix, the Elisp files are placed
  1581. under the @file{share/emacs/site-lisp/} directory of the profile in
  1582. which they are installed. The Elisp libraries are made available to
  1583. Emacs through the @env{EMACSLOADPATH} environment variable, which is
  1584. set when installing Emacs itself.
  1585. Additionally, autoload definitions are automatically evaluated at the
  1586. initialization of Emacs, by the Guix-specific
  1587. @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
  1588. want to avoid auto-loading the Emacs packages installed with Guix, you
  1589. can do so by running Emacs with the @option{--no-site-file} option
  1590. (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1591. @node Upgrading Guix
  1592. @section Upgrading Guix
  1593. @cindex Upgrading Guix, on a foreign distro
  1594. To upgrade Guix, run:
  1595. @example
  1596. guix pull
  1597. @end example
  1598. @xref{Invoking guix pull}, for more information.
  1599. @cindex upgrading Guix for the root user, on a foreign distro
  1600. @cindex upgrading the Guix daemon, on a foreign distro
  1601. @cindex @command{guix pull} for the root user, on a foreign distro
  1602. On a foreign distro, you can upgrade the build daemon by running:
  1603. @example
  1604. sudo -i guix pull
  1605. @end example
  1606. @noindent
  1607. followed by (assuming your distro uses the systemd service management
  1608. tool):
  1609. @example
  1610. systemctl restart guix-daemon.service
  1611. @end example
  1612. On Guix System, upgrading the daemon is achieved by reconfiguring the
  1613. system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
  1614. @c TODO What else?
  1615. @c *********************************************************************
  1616. @node System Installation
  1617. @chapter System Installation
  1618. @cindex installing Guix System
  1619. @cindex Guix System, installation
  1620. This section explains how to install Guix System
  1621. on a machine. Guix, as a package manager, can
  1622. also be installed on top of a running GNU/Linux system,
  1623. @pxref{Installation}.
  1624. @ifinfo
  1625. @quotation Note
  1626. @c This paragraph is for people reading this from tty2 of the
  1627. @c installation image.
  1628. You are reading this documentation with an Info reader. For details on
  1629. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  1630. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  1631. Info}. Hit @kbd{l} afterwards to come back here.
  1632. Alternatively, run @command{info info} in another tty to keep the manual
  1633. available.
  1634. @end quotation
  1635. @end ifinfo
  1636. @menu
  1637. * Limitations:: What you can expect.
  1638. * Hardware Considerations:: Supported hardware.
  1639. * USB Stick and DVD Installation:: Preparing the installation medium.
  1640. * Preparing for Installation:: Networking, partitioning, etc.
  1641. * Guided Graphical Installation:: Easy graphical installation.
  1642. * Manual Installation:: Manual installation for wizards.
  1643. * After System Installation:: When installation succeeded.
  1644. * Installing Guix in a VM:: Guix System playground.
  1645. * Building the Installation Image:: How this comes to be.
  1646. @end menu
  1647. @node Limitations
  1648. @section Limitations
  1649. We consider Guix System to be ready for a wide range of ``desktop'' and server
  1650. use cases. The reliability guarantees it provides---transactional upgrades
  1651. and rollbacks, reproducibility---make it a solid foundation.
  1652. Nevertheless, before you proceed with the installation, be aware of the
  1653. following noteworthy limitations applicable to version @value{VERSION}:
  1654. @itemize
  1655. @item
  1656. More and more system services are provided (@pxref{Services}), but some
  1657. may be missing.
  1658. @item
  1659. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  1660. as well as a number of X11 window managers. However, KDE is currently
  1661. missing.
  1662. @end itemize
  1663. More than a disclaimer, this is an invitation to report issues (and success
  1664. stories!), and to join us in improving it. @xref{Contributing}, for more
  1665. info.
  1666. @node Hardware Considerations
  1667. @section Hardware Considerations
  1668. @cindex hardware support on Guix System
  1669. GNU@tie{}Guix focuses on respecting the user's computing freedom. It
  1670. builds around the kernel Linux-libre, which means that only hardware for
  1671. which free software drivers and firmware exist is supported. Nowadays,
  1672. a wide range of off-the-shelf hardware is supported on
  1673. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  1674. Ethernet controllers. Unfortunately, there are still areas where
  1675. hardware vendors deny users control over their own computing, and such
  1676. hardware is not supported on Guix System.
  1677. @cindex WiFi, hardware support
  1678. One of the main areas where free drivers or firmware are lacking is WiFi
  1679. devices. WiFi devices known to work include those using Atheros chips
  1680. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  1681. driver, and those using Broadcom/AirForce chips (BCM43xx with
  1682. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  1683. Linux-libre driver. Free firmware exists for both and is available
  1684. out-of-the-box on Guix System, as part of @code{%base-firmware}
  1685. (@pxref{operating-system Reference, @code{firmware}}).
  1686. @cindex RYF, Respects Your Freedom
  1687. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  1688. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  1689. certification program for hardware products that respect your freedom
  1690. and your privacy and ensure that you have control over your device. We
  1691. encourage you to check the list of RYF-certified devices.
  1692. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  1693. web site. It contains a catalog of hardware devices with information
  1694. about their support in GNU/Linux.
  1695. @node USB Stick and DVD Installation
  1696. @section USB Stick and DVD Installation
  1697. An ISO-9660 installation image that can be written to a USB stick or
  1698. burnt to a DVD can be downloaded from
  1699. @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.xz},
  1700. where you can replace @code{x86_64-linux} with one of:
  1701. @table @code
  1702. @item x86_64-linux
  1703. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  1704. @item i686-linux
  1705. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  1706. @end table
  1707. @c start duplication of authentication part from ``Binary Installation''
  1708. Make sure to download the associated @file{.sig} file and to verify the
  1709. authenticity of the image against it, along these lines:
  1710. @example
  1711. $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.xz.sig
  1712. $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.xz.sig
  1713. @end example
  1714. If that command fails because you do not have the required public key,
  1715. then run this command to import it:
  1716. @example
  1717. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  1718. -qO - | gpg --import -
  1719. @end example
  1720. @noindent
  1721. and rerun the @code{gpg --verify} command.
  1722. Take note that a warning like ``This key is not certified with a trusted
  1723. signature!'' is normal.
  1724. @c end duplication
  1725. This image contains the tools necessary for an installation.
  1726. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  1727. @unnumberedsubsec Copying to a USB Stick
  1728. To copy the image to a USB stick, follow these steps:
  1729. @enumerate
  1730. @item
  1731. Decompress the image using the @command{xz} command:
  1732. @example
  1733. xz -d guix-system-install-@value{VERSION}.x86_64-linux.iso.xz
  1734. @end example
  1735. @item
  1736. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  1737. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  1738. copy the image with:
  1739. @example
  1740. dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
  1741. sync
  1742. @end example
  1743. Access to @file{/dev/sdX} usually requires root privileges.
  1744. @end enumerate
  1745. @unnumberedsubsec Burning on a DVD
  1746. To copy the image to a DVD, follow these steps:
  1747. @enumerate
  1748. @item
  1749. Decompress the image using the @command{xz} command:
  1750. @example
  1751. xz -d guix-system-install-@value{VERSION}.x86_64-linux.iso.xz
  1752. @end example
  1753. @item
  1754. Insert a blank DVD into your machine, and determine
  1755. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  1756. copy the image with:
  1757. @example
  1758. growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
  1759. @end example
  1760. Access to @file{/dev/srX} usually requires root privileges.
  1761. @end enumerate
  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 GNU Zile (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 target
  2067. you want to install GRUB on. It should mention @code{grub-bootloader} if
  2068. you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
  2069. for newer UEFI systems. For legacy systems, the @code{target} field
  2070. names a device, like @code{/dev/sda}; for UEFI systems it names a path
  2071. to a mounted EFI partition, like @code{/boot/efi}; do make sure the path is
  2072. currently mounted and a @code{file-system} entry is specified in your
  2073. configuration.
  2074. @item
  2075. Be sure that your file system labels match the value of their respective
  2076. @code{device} fields in your @code{file-system} configuration, assuming
  2077. your @code{file-system} configuration uses the @code{file-system-label}
  2078. procedure in its @code{device} field.
  2079. @item
  2080. If there are encrypted or RAID partitions, make sure to add a
  2081. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  2082. @end itemize
  2083. Once you are done preparing the configuration file, the new system must
  2084. be initialized (remember that the target root file system is mounted
  2085. under @file{/mnt}):
  2086. @example
  2087. guix system init /mnt/etc/config.scm /mnt
  2088. @end example
  2089. @noindent
  2090. This copies all the necessary files and installs GRUB on
  2091. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  2092. more information, @pxref{Invoking guix system}. This command may trigger
  2093. downloads or builds of missing packages, which can take some time.
  2094. Once that command has completed---and hopefully succeeded!---you can run
  2095. @command{reboot} and boot into the new system. The @code{root} password
  2096. in the new system is initially empty; other users' passwords need to be
  2097. initialized by running the @command{passwd} command as @code{root},
  2098. unless your configuration specifies otherwise
  2099. (@pxref{user-account-password, user account passwords}).
  2100. @xref{After System Installation}, for what's next!
  2101. @node After System Installation
  2102. @section After System Installation
  2103. Success, you've now booted into Guix System! From then on, you can update the
  2104. system whenever you want by running, say:
  2105. @example
  2106. guix pull
  2107. sudo guix system reconfigure /etc/config.scm
  2108. @end example
  2109. @noindent
  2110. This builds a new system generation with the latest packages and services
  2111. (@pxref{Invoking guix system}). We recommend doing that regularly so that
  2112. your system includes the latest security updates (@pxref{Security Updates}).
  2113. @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
  2114. @quotation Note
  2115. @cindex sudo vs. @command{guix pull}
  2116. Note that @command{sudo guix} runs your user's @command{guix} command and
  2117. @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
  2118. explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
  2119. The difference matters here, because @command{guix pull} updates
  2120. the @command{guix} command and package definitions only for the user it is run
  2121. as. This means that if you choose to use @command{guix system reconfigure} in
  2122. root's login shell, you'll need to @command{guix pull} separately.
  2123. @end quotation
  2124. Now, @pxref{Getting Started}, and
  2125. join us on @code{#guix} on the Freenode IRC network or on
  2126. @email{guix-devel@@gnu.org} to share your experience!
  2127. @node Installing Guix in a VM
  2128. @section Installing Guix in a Virtual Machine
  2129. @cindex virtual machine, Guix System installation
  2130. @cindex virtual private server (VPS)
  2131. @cindex VPS (virtual private server)
  2132. If you'd like to install Guix System in a virtual machine (VM) or on a
  2133. virtual private server (VPS) rather than on your beloved machine, this
  2134. section is for you.
  2135. To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
  2136. disk image, follow these steps:
  2137. @enumerate
  2138. @item
  2139. First, retrieve and decompress the Guix system installation image as
  2140. described previously (@pxref{USB Stick and DVD Installation}).
  2141. @item
  2142. Create a disk image that will hold the installed system. To make a
  2143. qcow2-formatted disk image, use the @command{qemu-img} command:
  2144. @example
  2145. qemu-img create -f qcow2 guix-system.img 50G
  2146. @end example
  2147. The resulting file will be much smaller than 50 GB (typically less than
  2148. 1 MB), but it will grow as the virtualized storage device is filled up.
  2149. @item
  2150. Boot the USB installation image in an VM:
  2151. @example
  2152. qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
  2153. -nic user,model=virtio-net-pci -boot menu=on,order=d \
  2154. -drive file=guix-system.img \
  2155. -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
  2156. @end example
  2157. @code{-enable-kvm} is optional, but significantly improves performance,
  2158. @pxref{Running Guix in a VM}.
  2159. @item
  2160. You're now root in the VM, proceed with the installation process.
  2161. @xref{Preparing for Installation}, and follow the instructions.
  2162. @end enumerate
  2163. Once installation is complete, you can boot the system that's on your
  2164. @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
  2165. that.
  2166. @node Building the Installation Image
  2167. @section Building the Installation Image
  2168. @cindex installation image
  2169. The installation image described above was built using the @command{guix
  2170. system} command, specifically:
  2171. @example
  2172. guix system image -t iso9660 gnu/system/install.scm
  2173. @end example
  2174. Have a look at @file{gnu/system/install.scm} in the source tree,
  2175. and see also @ref{Invoking guix system} for more information
  2176. about the installation image.
  2177. @section Building the Installation Image for ARM Boards
  2178. Many ARM boards require a specific variant of the
  2179. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  2180. If you build a disk image and the bootloader is not available otherwise
  2181. (on another boot drive etc), it's advisable to build an image that
  2182. includes the bootloader, specifically:
  2183. @example
  2184. guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  2185. @end example
  2186. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  2187. board, a list of possible boards will be printed.
  2188. @c *********************************************************************
  2189. @node Getting Started
  2190. @chapter Getting Started
  2191. Presumably, you've reached this section because either you have
  2192. installed Guix on top of another distribution (@pxref{Installation}), or
  2193. you've installed the standalone Guix System (@pxref{System
  2194. Installation}). It's time for you to get started using Guix and this
  2195. section aims to help you do that and give you a feel of what it's like.
  2196. Guix is about installing software, so probably the first thing you'll
  2197. want to do is to actually look for software. Let's say you're looking
  2198. for a text editor, you can run:
  2199. @example
  2200. guix search text editor
  2201. @end example
  2202. This command shows you a number of matching @dfn{packages}, each time
  2203. showing the package's name, version, a description, and additional info.
  2204. Once you've found out the one you want to use, let's say Emacs (ah ha!),
  2205. you can go ahead and install it (run this command as a regular user,
  2206. @emph{no need for root privileges}!):
  2207. @example
  2208. guix install emacs
  2209. @end example
  2210. @cindex profile
  2211. You've installed your first package, congrats! The package is now
  2212. visible in your default @dfn{profile}, @file{$HOME/.guix-profile}---a
  2213. profile is a directory containing installed packages.
  2214. In the process, you've
  2215. probably noticed that Guix downloaded pre-built binaries; or, if you
  2216. explicitly chose to @emph{not} use pre-built binaries, then probably
  2217. Guix is still building software (@pxref{Substitutes}, for more info).
  2218. Unless you're using Guix System, the @command{guix install} command must
  2219. have printed this hint:
  2220. @example
  2221. hint: Consider setting the necessary environment variables by running:
  2222. GUIX_PROFILE="$HOME/.guix-profile"
  2223. . "$GUIX_PROFILE/etc/profile"
  2224. Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
  2225. @end example
  2226. Indeed, you must now tell your shell where @command{emacs} and other
  2227. programs installed with Guix are to be found. Pasting the two lines
  2228. above will do just that: it will add
  2229. @code{$HOME/.guix-profile/bin}---which is where the installed package
  2230. is---to the @code{PATH} environment variable. You can paste these two
  2231. lines in your shell so they take effect right away, but more importantly
  2232. you should add them to @file{~/.bash_profile} (or equivalent file if you
  2233. do not use Bash) so that environment variables are set next time you
  2234. spawn a shell. You only need to do this once and other search paths
  2235. environment variables will be taken care of similarly---e.g., if you
  2236. eventually install @code{python} and Python libraries, @code{PYTHONPATH}
  2237. will be defined.
  2238. You can go on installing packages at your will. To list installed
  2239. packages, run:
  2240. @example
  2241. guix package --list-installed
  2242. @end example
  2243. To remove a package, you would unsurprisingly run @command{guix remove}.
  2244. A distinguishing feature is the ability to @dfn{roll back} any operation
  2245. you made---installation, removal, upgrade---by simply typing:
  2246. @example
  2247. guix package --roll-back
  2248. @end example
  2249. This is because each operation is in fact a @dfn{transaction} that
  2250. creates a new @dfn{generation}. These generations and the difference
  2251. between them can be displayed by running:
  2252. @example
  2253. guix package --list-generations
  2254. @end example
  2255. Now you know the basics of package management!
  2256. @quotation Going further
  2257. @xref{Package Management}, for more about package management. You may
  2258. like @dfn{declarative} package management with @command{guix package
  2259. --manifest}, managing separate @dfn{profiles} with @option{--profile},
  2260. deleting old generations, collecting garbage, and other nifty features
  2261. that will come in handy as you become more familiar with Guix. If you
  2262. are a developer, @pxref{Development} for additional tools. And if
  2263. you're curious, @pxref{Features}, to peek under the hood.
  2264. @end quotation
  2265. Once you've installed a set of packages, you will want to periodically
  2266. @emph{upgrade} them to the latest and greatest version. To do that, you
  2267. will first pull the latest revision of Guix and its package collection:
  2268. @example
  2269. guix pull
  2270. @end example
  2271. The end result is a new @command{guix} command, under
  2272. @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
  2273. first time you run @command{guix pull}, be sure to follow the hint that
  2274. the command prints and, similar to what we saw above, paste these two
  2275. lines in your terminal and @file{.bash_profile}:
  2276. @example
  2277. GUIX_PROFILE="$HOME/.config/guix/current"
  2278. . "$GUIX_PROFILE/etc/profile"
  2279. @end example
  2280. @noindent
  2281. You must also instruct your shell to point to this new @command{guix}:
  2282. @example
  2283. hash guix
  2284. @end example
  2285. At this point, you're running a brand new Guix. You can thus go ahead
  2286. and actually upgrade all the packages you previously installed:
  2287. @example
  2288. guix upgrade
  2289. @end example
  2290. As you run this command, you will see that binaries are downloaded (or
  2291. perhaps some packages are built), and eventually you end up with the
  2292. upgraded packages. Should one of these upgraded packages not be to your
  2293. liking, remember you can always roll back!
  2294. You can display the exact revision of Guix you're currently using by
  2295. running:
  2296. @example
  2297. guix describe
  2298. @end example
  2299. The information it displays is @emph{all it takes to reproduce the exact
  2300. same Guix}, be it at a different point in time or on a different
  2301. machine.
  2302. @quotation Going further
  2303. @xref{Invoking guix pull}, for more information. @xref{Channels}, on
  2304. how to specify additional @dfn{channels} to pull packages from, how to
  2305. replicate Guix, and more. You may also find @command{time-machine}
  2306. handy (@pxref{Invoking guix time-machine}).
  2307. @end quotation
  2308. If you installed Guix System, one of the first things you'll want to do
  2309. is to upgrade your system. Once you've run @command{guix pull} to get
  2310. the latest Guix, you can upgrade the system like this:
  2311. @example
  2312. sudo guix system reconfigure /etc/config.scm
  2313. @end example
  2314. Upon completion, the system runs the latest versions of its software
  2315. packages. When you eventually reboot, you'll notice a sub-menu in the
  2316. bootloader that reads ``Old system generations'': it's what allows you
  2317. to boot @emph{an older generation of your system}, should the latest
  2318. generation be ``broken'' or otherwise unsatisfying. Just like for
  2319. packages, you can always @emph{roll back} to a previous generation
  2320. @emph{of the whole system}:
  2321. @example
  2322. sudo guix system roll-back
  2323. @end example
  2324. There are many things you'll probably want to tweak on your system:
  2325. adding new user accounts, adding new system services, fiddling with the
  2326. configuration of those services, etc. The system configuration is
  2327. @emph{entirely} described in the @file{/etc/config.scm} file.
  2328. @xref{Using the Configuration System}, to learn how to change it.
  2329. Now you know enough to get started!
  2330. @quotation Resources
  2331. The rest of this manual provides a reference for all things Guix. Here
  2332. are some additional resources you may find useful:
  2333. @itemize
  2334. @item
  2335. @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
  2336. ``how-to'' style of recipes for a variety of applications.
  2337. @item
  2338. The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
  2339. Card} lists in two pages most of the commands and options you'll ever
  2340. need.
  2341. @item
  2342. The web site contains @uref{https://guix.gnu.org/en/videos/,
  2343. instructional videos} covering topics such as everyday use of Guix, how
  2344. to get help, and how to become a contributor.
  2345. @item
  2346. @xref{Documentation}, to learn how to access documentation on your
  2347. computer.
  2348. @end itemize
  2349. We hope you will enjoy Guix as much as the community enjoys building it!
  2350. @end quotation
  2351. @c *********************************************************************
  2352. @node Package Management
  2353. @chapter Package Management
  2354. @cindex packages
  2355. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  2356. remove software packages, without having to know about their build
  2357. procedures or dependencies. Guix also goes beyond this obvious set of
  2358. features.
  2359. This chapter describes the main features of Guix, as well as the
  2360. package management tools it provides. Along with the command-line
  2361. interface described below (@pxref{Invoking guix package, @code{guix
  2362. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  2363. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  2364. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  2365. with it):
  2366. @example
  2367. guix install emacs-guix
  2368. @end example
  2369. @menu
  2370. * Features:: How Guix will make your life brighter.
  2371. * Invoking guix package:: Package installation, removal, etc.
  2372. * Substitutes:: Downloading pre-built binaries.
  2373. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  2374. * Invoking guix gc:: Running the garbage collector.
  2375. * Invoking guix pull:: Fetching the latest Guix and distribution.
  2376. * Invoking guix time-machine:: Running an older revision of Guix.
  2377. * Inferiors:: Interacting with another revision of Guix.
  2378. * Invoking guix describe:: Display information about your Guix revision.
  2379. * Invoking guix archive:: Exporting and importing store files.
  2380. @end menu
  2381. @node Features
  2382. @section Features
  2383. Here we assume you've already made your first steps with Guix
  2384. (@pxref{Getting Started}) and would like to get an overview about what's
  2385. going on under the hood.
  2386. When using Guix, each package ends up in the @dfn{package store}, in its
  2387. own directory---something that resembles
  2388. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  2389. Instead of referring to these directories, users have their own
  2390. @dfn{profile}, which points to the packages that they actually want to
  2391. use. These profiles are stored within each user's home directory, at
  2392. @code{$HOME/.guix-profile}.
  2393. For example, @code{alice} installs GCC 4.7.2. As a result,
  2394. @file{/home/alice/.guix-profile/bin/gcc} points to
  2395. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  2396. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  2397. simply continues to point to
  2398. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  2399. coexist on the same system without any interference.
  2400. The @command{guix package} command is the central tool to manage
  2401. packages (@pxref{Invoking guix package}). It operates on the per-user
  2402. profiles, and can be used @emph{with normal user privileges}.
  2403. @cindex transactions
  2404. The command provides the obvious install, remove, and upgrade
  2405. operations. Each invocation is actually a @emph{transaction}: either
  2406. the specified operation succeeds, or nothing happens. Thus, if the
  2407. @command{guix package} process is terminated during the transaction,
  2408. or if a power outage occurs during the transaction, then the user's
  2409. profile remains in its previous state, and remains usable.
  2410. In addition, any package transaction may be @emph{rolled back}. So, if,
  2411. for example, an upgrade installs a new version of a package that turns
  2412. out to have a serious bug, users may roll back to the previous instance
  2413. of their profile, which was known to work well. Similarly, the global
  2414. system configuration on Guix is subject to
  2415. transactional upgrades and roll-back
  2416. (@pxref{Using the Configuration System}).
  2417. All packages in the package store may be @emph{garbage-collected}.
  2418. Guix can determine which packages are still referenced by user
  2419. profiles, and remove those that are provably no longer referenced
  2420. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  2421. generations of their profile so that the packages they refer to can be
  2422. collected.
  2423. @cindex reproducibility
  2424. @cindex reproducible builds
  2425. Guix takes a @dfn{purely functional} approach to package
  2426. management, as described in the introduction (@pxref{Introduction}).
  2427. Each @file{/gnu/store} package directory name contains a hash of all the
  2428. inputs that were used to build that package---compiler, libraries, build
  2429. scripts, etc. This direct correspondence allows users to make sure a
  2430. given package installation matches the current state of their
  2431. distribution. It also helps maximize @dfn{build reproducibility}:
  2432. thanks to the isolated build environments that are used, a given build
  2433. is likely to yield bit-identical files when performed on different
  2434. machines (@pxref{Invoking guix-daemon, container}).
  2435. @cindex substitutes
  2436. This foundation allows Guix to support @dfn{transparent binary/source
  2437. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  2438. available from an external source---a @dfn{substitute}, Guix just
  2439. downloads it and unpacks it;
  2440. otherwise, it builds the package from source, locally
  2441. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  2442. reproducible, users do not have to trust servers that provide
  2443. substitutes: they can force a local build and @emph{challenge} providers
  2444. (@pxref{Invoking guix challenge}).
  2445. Control over the build environment is a feature that is also useful for
  2446. developers. The @command{guix environment} command allows developers of
  2447. a package to quickly set up the right development environment for their
  2448. package, without having to manually install the dependencies of the
  2449. package into their profile (@pxref{Invoking guix environment}).
  2450. @cindex replication, of software environments
  2451. @cindex provenance tracking, of software artifacts
  2452. All of Guix and its package definitions is version-controlled, and
  2453. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  2454. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  2455. Guix instance on a different machine or at a later point in time, which in
  2456. turn allows you to @emph{replicate complete software environments}, while
  2457. retaining precise @dfn{provenance tracking} of the software.
  2458. @node Invoking guix package
  2459. @section Invoking @command{guix package}
  2460. @cindex installing packages
  2461. @cindex removing packages
  2462. @cindex package installation
  2463. @cindex package removal
  2464. @cindex profile
  2465. The @command{guix package} command is the tool that allows users to
  2466. install, upgrade, and remove packages, as well as rolling back to
  2467. previous configurations. These operations work on a user
  2468. @dfn{profile}---a directory of installed packages. Each user has a
  2469. default profile in @file{$HOME/.guix-profile}.
  2470. The command operates only on the user's own profile,
  2471. and works with normal user privileges (@pxref{Features}). Its syntax
  2472. is:
  2473. @example
  2474. guix package @var{options}
  2475. @end example
  2476. @cindex transactions
  2477. Primarily, @var{options} specifies the operations to be performed during
  2478. the transaction. Upon completion, a new profile is created, but
  2479. previous @dfn{generations} of the profile remain available, should the user
  2480. want to roll back.
  2481. For example, to remove @code{lua} and install @code{guile} and
  2482. @code{guile-cairo} in a single transaction:
  2483. @example
  2484. guix package -r lua -i guile guile-cairo
  2485. @end example
  2486. @cindex aliases, for @command{guix package}
  2487. For your convenience, we also provide the following aliases:
  2488. @itemize
  2489. @item
  2490. @command{guix search} is an alias for @command{guix package -s},
  2491. @item
  2492. @command{guix install} is an alias for @command{guix package -i},
  2493. @item
  2494. @command{guix remove} is an alias for @command{guix package -r},
  2495. @item
  2496. @command{guix upgrade} is an alias for @command{guix package -u},
  2497. @item
  2498. and @command{guix show} is an alias for @command{guix package --show=}.
  2499. @end itemize
  2500. These aliases are less expressive than @command{guix package} and provide
  2501. fewer options, so in some cases you'll probably want to use @command{guix
  2502. package} directly.
  2503. @command{guix package} also supports a @dfn{declarative approach}
  2504. whereby the user specifies the exact set of packages to be available and
  2505. passes it @i{via} the @option{--manifest} option
  2506. (@pxref{profile-manifest, @option{--manifest}}).
  2507. @cindex profile
  2508. For each user, a symlink to the user's default profile is automatically
  2509. created in @file{$HOME/.guix-profile}. This symlink always points to the
  2510. current generation of the user's default profile. Thus, users can add
  2511. @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
  2512. variable, and so on.
  2513. @cindex search paths
  2514. If you are not using Guix System, consider adding the
  2515. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  2516. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  2517. shells get all the right environment variable definitions:
  2518. @example
  2519. GUIX_PROFILE="$HOME/.guix-profile" ; \
  2520. source "$GUIX_PROFILE/etc/profile"
  2521. @end example
  2522. In a multi-user setup, user profiles are stored in a place registered as
  2523. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  2524. to (@pxref{Invoking guix gc}). That directory is normally
  2525. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  2526. @var{localstatedir} is the value passed to @code{configure} as
  2527. @option{--localstatedir}, and @var{user} is the user name. The
  2528. @file{per-user} directory is created when @command{guix-daemon} is
  2529. started, and the @var{user} sub-directory is created by @command{guix
  2530. package}.
  2531. The @var{options} can be among the following:
  2532. @table @code
  2533. @item --install=@var{package} @dots{}
  2534. @itemx -i @var{package} @dots{}
  2535. Install the specified @var{package}s.
  2536. Each @var{package} may specify either a simple package name, such as
  2537. @code{guile}, or a package name followed by an at-sign and version number,
  2538. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  2539. case, the newest version prefixed by @code{1.8} is selected).
  2540. If no version number is specified, the
  2541. newest available version will be selected. In addition, @var{package}
  2542. may contain a colon, followed by the name of one of the outputs of the
  2543. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  2544. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  2545. name (and optionally version) are searched for among the GNU
  2546. distribution modules (@pxref{Package Modules}).
  2547. @cindex propagated inputs
  2548. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  2549. that automatically get installed along with the required package
  2550. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  2551. @code{package} objects}, for information about propagated inputs in
  2552. package definitions).
  2553. @anchor{package-cmd-propagated-inputs}
  2554. An example is the GNU MPC library: its C header files refer to those of
  2555. the GNU MPFR library, which in turn refer to those of the GMP library.
  2556. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  2557. in the profile; removing MPC also removes MPFR and GMP---unless they had
  2558. also been explicitly installed by the user.
  2559. Besides, packages sometimes rely on the definition of environment
  2560. variables for their search paths (see explanation of
  2561. @option{--search-paths} below). Any missing or possibly incorrect
  2562. environment variable definitions are reported here.
  2563. @item --install-from-expression=@var{exp}
  2564. @itemx -e @var{exp}
  2565. Install the package @var{exp} evaluates to.
  2566. @var{exp} must be a Scheme expression that evaluates to a
  2567. @code{<package>} object. This option is notably useful to disambiguate
  2568. between same-named variants of a package, with expressions such as
  2569. @code{(@@ (gnu packages base) guile-final)}.
  2570. Note that this option installs the first output of the specified
  2571. package, which may be insufficient when needing a specific output of a
  2572. multiple-output package.
  2573. @item --install-from-file=@var{file}
  2574. @itemx -f @var{file}
  2575. Install the package that the code within @var{file} evaluates to.
  2576. As an example, @var{file} might contain a definition like this
  2577. (@pxref{Defining Packages}):
  2578. @lisp
  2579. @include package-hello.scm
  2580. @end lisp
  2581. Developers may find it useful to include such a @file{guix.scm} file
  2582. in the root of their project source tree that can be used to test
  2583. development snapshots and create reproducible development environments
  2584. (@pxref{Invoking guix environment}).
  2585. The @var{file} may also contain a JSON representation of one or more
  2586. package definitions. Running @code{guix package -f} on
  2587. @file{hello.json} with the following contents would result in installing
  2588. the package @code{greeter} after building @code{myhello}:
  2589. @example
  2590. @verbatiminclude package-hello.json
  2591. @end example
  2592. @item --remove=@var{package} @dots{}
  2593. @itemx -r @var{package} @dots{}
  2594. Remove the specified @var{package}s.
  2595. As for @option{--install}, each @var{package} may specify a version number
  2596. and/or output name in addition to the package name. For instance,
  2597. @samp{-r glibc:debug} would remove the @code{debug} output of
  2598. @code{glibc}.
  2599. @item --upgrade[=@var{regexp} @dots{}]
  2600. @itemx -u [@var{regexp} @dots{}]
  2601. @cindex upgrading packages
  2602. Upgrade all the installed packages. If one or more @var{regexp}s are
  2603. specified, upgrade only installed packages whose name matches a
  2604. @var{regexp}. Also see the @option{--do-not-upgrade} option below.
  2605. Note that this upgrades package to the latest version of packages found
  2606. in the distribution currently installed. To update your distribution,
  2607. you should regularly run @command{guix pull} (@pxref{Invoking guix
  2608. pull}).
  2609. @cindex package transformations, upgrades
  2610. When upgrading, package transformations that were originally applied
  2611. when creating the profile are automatically re-applied (@pxref{Package
  2612. Transformation Options}). For example, assume you first installed Emacs
  2613. from the tip of its development branch with:
  2614. @example
  2615. guix install emacs-next --with-branch=emacs-next=master
  2616. @end example
  2617. Next time you run @command{guix upgrade}, Guix will again pull the tip
  2618. of the Emacs development branch and build @code{emacs-next} from that
  2619. checkout.
  2620. Note that transformation options such as @option{--with-branch} and
  2621. @option{--with-source} depend on external state; it is up to you to
  2622. ensure that they work as expected. You can also discard a
  2623. transformations that apply to a package by running:
  2624. @example
  2625. guix install @var{package}
  2626. @end example
  2627. @item --do-not-upgrade[=@var{regexp} @dots{}]
  2628. When used together with the @option{--upgrade} option, do @emph{not}
  2629. upgrade any packages whose name matches a @var{regexp}. For example, to
  2630. upgrade all packages in the current profile except those containing the
  2631. substring ``emacs'':
  2632. @example
  2633. $ guix package --upgrade . --do-not-upgrade emacs
  2634. @end example
  2635. @item @anchor{profile-manifest}--manifest=@var{file}
  2636. @itemx -m @var{file}
  2637. @cindex profile declaration
  2638. @cindex profile manifest
  2639. Create a new generation of the profile from the manifest object
  2640. returned by the Scheme code in @var{file}. This option can be repeated
  2641. several times, in which case the manifests are concatenated.
  2642. This allows you to @emph{declare} the profile's contents rather than
  2643. constructing it through a sequence of @option{--install} and similar
  2644. commands. The advantage is that @var{file} can be put under version
  2645. control, copied to different machines to reproduce the same profile, and
  2646. so on.
  2647. @c FIXME: Add reference to (guix profile) documentation when available.
  2648. @var{file} must return a @dfn{manifest} object, which is roughly a list
  2649. of packages:
  2650. @findex packages->manifest
  2651. @lisp
  2652. (use-package-modules guile emacs)
  2653. (packages->manifest
  2654. (list emacs
  2655. guile-2.0
  2656. ;; Use a specific package output.
  2657. (list guile-2.0 "debug")))
  2658. @end lisp
  2659. @findex specifications->manifest
  2660. In this example we have to know which modules define the @code{emacs}
  2661. and @code{guile-2.0} variables to provide the right
  2662. @code{use-package-modules} line, which can be cumbersome. We can
  2663. instead provide regular package specifications and let
  2664. @code{specifications->manifest} look up the corresponding package
  2665. objects, like this:
  2666. @lisp
  2667. (specifications->manifest
  2668. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  2669. @end lisp
  2670. @xref{export-manifest, @option{--export-manifest}}, to learn how to
  2671. obtain a manifest file from an existing profile.
  2672. @item --roll-back
  2673. @cindex rolling back
  2674. @cindex undoing transactions
  2675. @cindex transactions, undoing
  2676. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  2677. the last transaction.
  2678. When combined with options such as @option{--install}, roll back occurs
  2679. before any other actions.
  2680. When rolling back from the first generation that actually contains
  2681. installed packages, the profile is made to point to the @dfn{zeroth
  2682. generation}, which contains no files apart from its own metadata.
  2683. After having rolled back, installing, removing, or upgrading packages
  2684. overwrites previous future generations. Thus, the history of the
  2685. generations in a profile is always linear.
  2686. @item --switch-generation=@var{pattern}
  2687. @itemx -S @var{pattern}
  2688. @cindex generations
  2689. Switch to a particular generation defined by @var{pattern}.
  2690. @var{pattern} may be either a generation number or a number prefixed
  2691. with ``+'' or ``-''. The latter means: move forward/backward by a
  2692. specified number of generations. For example, if you want to return to
  2693. the latest generation after @option{--roll-back}, use
  2694. @option{--switch-generation=+1}.
  2695. The difference between @option{--roll-back} and
  2696. @option{--switch-generation=-1} is that @option{--switch-generation} will
  2697. not make a zeroth generation, so if a specified generation does not
  2698. exist, the current generation will not be changed.
  2699. @item --search-paths[=@var{kind}]
  2700. @cindex search paths
  2701. Report environment variable definitions, in Bash syntax, that may be
  2702. needed in order to use the set of installed packages. These environment
  2703. variables are used to specify @dfn{search paths} for files used by some
  2704. of the installed packages.
  2705. For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
  2706. environment variables to be defined so it can look for headers and
  2707. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  2708. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  2709. library are installed in the profile, then @option{--search-paths} will
  2710. suggest setting these variables to @file{@var{profile}/include} and
  2711. @file{@var{profile}/lib}, respectively.
  2712. The typical use case is to define these environment variables in the
  2713. shell:
  2714. @example
  2715. $ eval `guix package --search-paths`
  2716. @end example
  2717. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  2718. meaning that the returned environment variable definitions will either
  2719. be exact settings, or prefixes or suffixes of the current value of these
  2720. variables. When omitted, @var{kind} defaults to @code{exact}.
  2721. This option can also be used to compute the @emph{combined} search paths
  2722. of several profiles. Consider this example:
  2723. @example
  2724. $ guix package -p foo -i guile
  2725. $ guix package -p bar -i guile-json
  2726. $ guix package -p foo -p bar --search-paths
  2727. @end example
  2728. The last command above reports about the @env{GUILE_LOAD_PATH}
  2729. variable, even though, taken individually, neither @file{foo} nor
  2730. @file{bar} would lead to that recommendation.
  2731. @cindex profile, choosing
  2732. @item --profile=@var{profile}
  2733. @itemx -p @var{profile}
  2734. Use @var{profile} instead of the user's default profile.
  2735. @var{profile} must be the name of a file that will be created upon
  2736. completion. Concretely, @var{profile} will be a mere symbolic link
  2737. (``symlink'') pointing to the actual profile where packages are
  2738. installed:
  2739. @example
  2740. $ guix install hello -p ~/code/my-profile
  2741. @dots{}
  2742. $ ~/code/my-profile/bin/hello
  2743. Hello, world!
  2744. @end example
  2745. All it takes to get rid of the profile is to remove this symlink and its
  2746. siblings that point to specific generations:
  2747. @example
  2748. $ rm ~/code/my-profile ~/code/my-profile-*-link
  2749. @end example
  2750. @item --list-profiles
  2751. List all the user's profiles:
  2752. @example
  2753. $ guix package --list-profiles
  2754. /home/charlie/.guix-profile
  2755. /home/charlie/code/my-profile
  2756. /home/charlie/code/devel-profile
  2757. /home/charlie/tmp/test
  2758. @end example
  2759. When running as root, list all the profiles of all the users.
  2760. @cindex collisions, in a profile
  2761. @cindex colliding packages in profiles
  2762. @cindex profile collisions
  2763. @item --allow-collisions
  2764. Allow colliding packages in the new profile. Use at your own risk!
  2765. By default, @command{guix package} reports as an error @dfn{collisions}
  2766. in the profile. Collisions happen when two or more different versions
  2767. or variants of a given package end up in the profile.
  2768. @item --bootstrap
  2769. Use the bootstrap Guile to build the profile. This option is only
  2770. useful to distribution developers.
  2771. @end table
  2772. In addition to these actions, @command{guix package} supports the
  2773. following options to query the current state of a profile, or the
  2774. availability of packages:
  2775. @table @option
  2776. @item --search=@var{regexp}
  2777. @itemx -s @var{regexp}
  2778. @anchor{guix-search}
  2779. @cindex searching for packages
  2780. List the available packages whose name, synopsis, or description matches
  2781. @var{regexp} (in a case-insensitive fashion), sorted by relevance.
  2782. Print all the metadata of matching packages in
  2783. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  2784. GNU recutils manual}).
  2785. This allows specific fields to be extracted using the @command{recsel}
  2786. command, for instance:
  2787. @example
  2788. $ guix package -s malloc | recsel -p name,version,relevance
  2789. name: jemalloc
  2790. version: 4.5.0
  2791. relevance: 6
  2792. name: glibc
  2793. version: 2.25
  2794. relevance: 1
  2795. name: libgc
  2796. version: 7.6.0
  2797. relevance: 1
  2798. @end example
  2799. Similarly, to show the name of all the packages available under the
  2800. terms of the GNU@tie{}LGPL version 3:
  2801. @example
  2802. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  2803. name: elfutils
  2804. name: gmp
  2805. @dots{}
  2806. @end example
  2807. It is also possible to refine search results using several @code{-s} flags to
  2808. @command{guix package}, or several arguments to @command{guix search}. For
  2809. example, the following command returns a list of board games (this time using
  2810. the @command{guix search} alias):
  2811. @example
  2812. $ guix search '\<board\>' game | recsel -p name
  2813. name: gnubg
  2814. @dots{}
  2815. @end example
  2816. If we were to omit @code{-s game}, we would also get software packages
  2817. that deal with printed circuit boards; removing the angle brackets
  2818. around @code{board} would further add packages that have to do with
  2819. keyboards.
  2820. And now for a more elaborate example. The following command searches
  2821. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  2822. libraries, and prints the name and synopsis of the matching packages:
  2823. @example
  2824. $ guix search crypto library | \
  2825. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  2826. @end example
  2827. @noindent
  2828. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  2829. information on @dfn{selection expressions} for @code{recsel -e}.
  2830. @item --show=@var{package}
  2831. Show details about @var{package}, taken from the list of available packages, in
  2832. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  2833. recutils manual}).
  2834. @example
  2835. $ guix package --show=python | recsel -p name,version
  2836. name: python
  2837. version: 2.7.6
  2838. name: python
  2839. version: 3.3.5
  2840. @end example
  2841. You may also specify the full name of a package to only get details about a
  2842. specific version of it (this time using the @command{guix show} alias):
  2843. @example
  2844. $ guix show python@@3.4 | recsel -p name,version
  2845. name: python
  2846. version: 3.4.3
  2847. @end example
  2848. @item --list-installed[=@var{regexp}]
  2849. @itemx -I [@var{regexp}]
  2850. List the currently installed packages in the specified profile, with the
  2851. most recently installed packages shown last. When @var{regexp} is
  2852. specified, list only installed packages whose name matches @var{regexp}.
  2853. For each installed package, print the following items, separated by
  2854. tabs: the package name, its version string, the part of the package that
  2855. is installed (for instance, @code{out} for the default output,
  2856. @code{include} for its headers, etc.), and the path of this package in
  2857. the store.
  2858. @item --list-available[=@var{regexp}]
  2859. @itemx -A [@var{regexp}]
  2860. List packages currently available in the distribution for this system
  2861. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  2862. available packages whose name matches @var{regexp}.
  2863. For each package, print the following items separated by tabs: its name,
  2864. its version string, the parts of the package (@pxref{Packages with
  2865. Multiple Outputs}), and the source location of its definition.
  2866. @item --list-generations[=@var{pattern}]
  2867. @itemx -l [@var{pattern}]
  2868. @cindex generations
  2869. Return a list of generations along with their creation dates; for each
  2870. generation, show the installed packages, with the most recently
  2871. installed packages shown last. Note that the zeroth generation is never
  2872. shown.
  2873. For each installed package, print the following items, separated by
  2874. tabs: the name of a package, its version string, the part of the package
  2875. that is installed (@pxref{Packages with Multiple Outputs}), and the
  2876. location of this package in the store.
  2877. When @var{pattern} is used, the command returns only matching
  2878. generations. Valid patterns include:
  2879. @itemize
  2880. @item @emph{Integers and comma-separated integers}. Both patterns denote
  2881. generation numbers. For instance, @option{--list-generations=1} returns
  2882. the first one.
  2883. And @option{--list-generations=1,8,2} outputs three generations in the
  2884. specified order. Neither spaces nor trailing commas are allowed.
  2885. @item @emph{Ranges}. @option{--list-generations=2..9} prints the
  2886. specified generations and everything in between. Note that the start of
  2887. a range must be smaller than its end.
  2888. It is also possible to omit the endpoint. For example,
  2889. @option{--list-generations=2..}, returns all generations starting from the
  2890. second one.
  2891. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  2892. or months by passing an integer along with the first letter of the
  2893. duration. For example, @option{--list-generations=20d} lists generations
  2894. that are up to 20 days old.
  2895. @end itemize
  2896. @item --delete-generations[=@var{pattern}]
  2897. @itemx -d [@var{pattern}]
  2898. When @var{pattern} is omitted, delete all generations except the current
  2899. one.
  2900. This command accepts the same patterns as @option{--list-generations}.
  2901. When @var{pattern} is specified, delete the matching generations. When
  2902. @var{pattern} specifies a duration, generations @emph{older} than the
  2903. specified duration match. For instance, @option{--delete-generations=1m}
  2904. deletes generations that are more than one month old.
  2905. If the current generation matches, it is @emph{not} deleted. Also, the
  2906. zeroth generation is never deleted.
  2907. Note that deleting generations prevents rolling back to them.
  2908. Consequently, this command must be used with care.
  2909. @cindex manifest, exporting
  2910. @anchor{export-manifest}
  2911. @item --export-manifest
  2912. Write to standard output a manifest suitable for @option{--manifest}
  2913. corresponding to the chosen profile(s).
  2914. This option is meant to help you migrate from the ``imperative''
  2915. operating mode---running @command{guix install}, @command{guix upgrade},
  2916. etc.---to the declarative mode that @option{--manifest} offers.
  2917. Be aware that the resulting manifest @emph{approximates} what your
  2918. profile actually contains; for instance, depending on how your profile
  2919. was created, it can refer to packages or package versions that are not
  2920. exactly what you specified.
  2921. Keep in mind that a manifest is purely symbolic: it only contains
  2922. package names and possibly versions, and their meaning varies over time.
  2923. If you wish to ``pin'' channels to the revisions that were used to build
  2924. the profile(s), see @option{--export-channels} below.
  2925. @cindex pinning, channel revisions of a profile
  2926. @item --export-channels
  2927. Write to standard output the list of channels used by the chosen
  2928. profile(s), in a format suitable for @command{guix pull --channels} or
  2929. @command{guix time-machine --channels} (@pxref{Channels}).
  2930. Together with @option{--export-manifest}, this option provides
  2931. information allowing you to replicate the current profile
  2932. (@pxref{Replicating Guix}).
  2933. However, note that the output of this command @emph{approximates} what
  2934. was actually used to build this profile. In particular, a single
  2935. profile might have been built from several different revisions of the
  2936. same channel. In that case, @option{--export-manifest} chooses the last
  2937. one and writes the list of other revisions in a comment. If you really
  2938. need to pick packages from different channel revisions, you can use
  2939. inferiors in your manifest to do so (@pxref{Inferiors}).
  2940. Together with @option{--export-manifest}, this is a good starting point
  2941. if you are willing to migrate from the ``imperative'' model to the fully
  2942. declarative model consisting of a manifest file along with a channels
  2943. file pinning the exact channel revision(s) you want.
  2944. @end table
  2945. Finally, since @command{guix package} may actually start build
  2946. processes, it supports all the common build options (@pxref{Common Build
  2947. Options}). It also supports package transformation options, such as
  2948. @option{--with-source}, and preserves them across upgrades
  2949. (@pxref{Package Transformation Options}).
  2950. @node Substitutes
  2951. @section Substitutes
  2952. @cindex substitutes
  2953. @cindex pre-built binaries
  2954. Guix supports transparent source/binary deployment, which means that it
  2955. can either build things locally, or download pre-built items from a
  2956. server, or both. We call these pre-built items @dfn{substitutes}---they
  2957. are substitutes for local build results. In many cases, downloading a
  2958. substitute is much faster than building things locally.
  2959. Substitutes can be anything resulting from a derivation build
  2960. (@pxref{Derivations}). Of course, in the common case, they are
  2961. pre-built package binaries, but source tarballs, for instance, which
  2962. also result from derivation builds, can be available as substitutes.
  2963. @menu
  2964. * Official Substitute Server:: One particular source of substitutes.
  2965. * Substitute Server Authorization:: How to enable or disable substitutes.
  2966. * Getting Substitutes from Other Servers:: Substitute diversity.
  2967. * Substitute Authentication:: How Guix verifies substitutes.
  2968. * Proxy Settings:: How to get substitutes via proxy.
  2969. * Substitution Failure:: What happens when substitution fails.
  2970. * On Trusting Binaries:: How can you trust that binary blob?
  2971. @end menu
  2972. @node Official Substitute Server
  2973. @subsection Official Substitute Server
  2974. @cindex build farm
  2975. The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
  2976. that builds packages from Guix continuously for some
  2977. architectures, and makes them available as substitutes. This is the
  2978. default source of substitutes; it can be overridden by passing the
  2979. @option{--substitute-urls} option either to @command{guix-daemon}
  2980. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  2981. or to client tools such as @command{guix package}
  2982. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  2983. option}).
  2984. Substitute URLs can be either HTTP or HTTPS.
  2985. HTTPS is recommended because communications are encrypted; conversely,
  2986. using HTTP makes all communications visible to an eavesdropper, who
  2987. could use the information gathered to determine, for instance, whether
  2988. your system has unpatched security vulnerabilities.
  2989. Substitutes from the official build farm are enabled by default when
  2990. using Guix System (@pxref{GNU Distribution}). However,
  2991. they are disabled by default when using Guix on a foreign distribution,
  2992. unless you have explicitly enabled them via one of the recommended
  2993. installation steps (@pxref{Installation}). The following paragraphs
  2994. describe how to enable or disable substitutes for the official build
  2995. farm; the same procedure can also be used to enable substitutes for any
  2996. other substitute server.
  2997. @node Substitute Server Authorization
  2998. @subsection Substitute Server Authorization
  2999. @cindex security
  3000. @cindex substitutes, authorization thereof
  3001. @cindex access control list (ACL), for substitutes
  3002. @cindex ACL (access control list), for substitutes
  3003. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
  3004. mirror thereof, you
  3005. must add its public key to the access control list (ACL) of archive
  3006. imports, using the @command{guix archive} command (@pxref{Invoking guix
  3007. archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
  3008. be compromised and to serve genuine substitutes.
  3009. @quotation Note
  3010. If you are using Guix System, you can skip this section: Guix System
  3011. authorizes substitutes from @code{@value{SUBSTITUTE-SERVER}} by default.
  3012. @end quotation
  3013. The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
  3014. @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
  3015. the installation prefix of Guix. If you installed Guix from source,
  3016. make sure you checked the GPG signature of
  3017. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  3018. Then, you can run something like this:
  3019. @example
  3020. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
  3021. @end example
  3022. Once this is in place, the output of a command like @code{guix build}
  3023. should change from something like:
  3024. @example
  3025. $ guix build emacs --dry-run
  3026. The following derivations would be built:
  3027. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  3028. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  3029. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  3030. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  3031. @dots{}
  3032. @end example
  3033. @noindent
  3034. to something like:
  3035. @example
  3036. $ guix build emacs --dry-run
  3037. 112.3 MB would be downloaded:
  3038. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  3039. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  3040. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  3041. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  3042. @dots{}
  3043. @end example
  3044. @noindent
  3045. The text changed from ``The following derivations would be built'' to
  3046. ``112.3 MB would be downloaded''. This indicates that substitutes from
  3047. @code{@value{SUBSTITUTE-SERVER}} are usable and will be downloaded, when
  3048. possible, for future builds.
  3049. @cindex substitutes, how to disable
  3050. The substitute mechanism can be disabled globally by running
  3051. @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
  3052. guix-daemon}). It can also be disabled temporarily by passing the
  3053. @option{--no-substitutes} option to @command{guix package},
  3054. @command{guix build}, and other command-line tools.
  3055. @node Getting Substitutes from Other Servers
  3056. @subsection Getting Substitutes from Other Servers
  3057. @cindex substitute servers, adding more
  3058. Guix can look up and fetch substitutes from several servers. This is
  3059. useful when you are using packages from additional channels for which
  3060. the official server does not have substitutes but another server
  3061. provides them. Another situation where this is useful is when you would
  3062. prefer to download from your organization's substitute server, resorting
  3063. to the official server only as a fallback or dismissing it altogether.
  3064. You can give Guix a list of substitute server URLs and it will check
  3065. them in the specified order. You also need to explicitly authorize the
  3066. public keys of substitute servers to instruct Guix to accept the
  3067. substitutes they sign.
  3068. On Guix System, this is achieved by modifying the configuration of the
  3069. @code{guix} service. Since the @code{guix} service is part of the
  3070. default lists of services, @code{%base-services} and
  3071. @code{%desktop-services}, you can use @code{modify-services} to change
  3072. its configuration and add the URLs and substitute keys that you want
  3073. (@pxref{Service Reference, @code{modify-services}}).
  3074. As an example, suppose you want to fetch substitutes from
  3075. @code{guix.example.org} and to authorize the signing key of that server,
  3076. in addition to the default @code{@value{SUBSTITUTE-SERVER}}. The
  3077. resulting operating system configuration will look something like:
  3078. @lisp
  3079. (operating-system
  3080. ;; @dots{}
  3081. (services
  3082. ;; Assume we're starting from '%desktop-services'. Replace it
  3083. ;; with the list of services you're actually using.
  3084. (modify-services %desktop-services
  3085. (guix-service-type config =>
  3086. (guix-configuration
  3087. (inherit config)
  3088. (substitute-urls
  3089. (append (list "https://guix.example.org")
  3090. %default-substitute-urls))
  3091. (authorized-keys
  3092. (append (list (local-file "./key.pub"))
  3093. %default-authorized-guix-keys)))))))
  3094. @end lisp
  3095. This assumes that the file @file{key.pub} contains the signing key of
  3096. @code{guix.example.org}. With this change in place in your operating
  3097. system configuration file (say @file{/etc/config.scm}), you can
  3098. reconfigure and restart the @code{guix-daemon} service or reboot so the
  3099. changes take effect:
  3100. @example
  3101. $ sudo guix system reconfigure /etc/config.scm
  3102. $ sudo herd restart guix-daemon
  3103. @end example
  3104. If you're running Guix on a ``foreign distro'', you would instead take
  3105. the following steps to get substitutes from additional servers:
  3106. @enumerate
  3107. @item
  3108. Edit the service configuration file for @code{guix-daemon}; when using
  3109. systemd, this is normally
  3110. @file{/etc/systemd/system/guix-daemon.service}. Add the
  3111. @option{--substitute-urls} option on the @command{guix-daemon} command
  3112. line and list the URLs of interest (@pxref{daemon-substitute-urls,
  3113. @code{guix-daemon --substitute-urls}}):
  3114. @example
  3115. @dots{} --substitute-urls='https://guix.example.org https://@value{SUBSTITUTE-SERVER}'
  3116. @end example
  3117. @item
  3118. Restart the daemon. For systemd, it goes like this:
  3119. @example
  3120. systemctl daemon-reload
  3121. systemctl restart guix-daemon.service
  3122. @end example
  3123. @item
  3124. Authorize the key of the new server (@pxref{Invoking guix archive}):
  3125. @example
  3126. guix archive --authorize < key.pub
  3127. @end example
  3128. Again this assumes @file{key.pub} contains the public key that
  3129. @code{guix.example.org} uses to sign substitutes.
  3130. @end enumerate
  3131. Now you're all set! Substitutes will be preferably taken from
  3132. @code{https://guix.example.org}, using @code{@value{SUBSTITUTE-SERVER}}
  3133. as a fallback. Of course you can list as many substitute servers as you
  3134. like, with the caveat that substitute lookup can be slowed down if too
  3135. many servers need to be contacted.
  3136. Note that there are also situations where one may want to add the URL of
  3137. a substitute server @emph{without} authorizing its key.
  3138. @xref{Substitute Authentication}, to understand this fine point.
  3139. @node Substitute Authentication
  3140. @subsection Substitute Authentication
  3141. @cindex digital signatures
  3142. Guix detects and raises an error when attempting to use a substitute
  3143. that has been tampered with. Likewise, it ignores substitutes that are
  3144. not signed, or that are not signed by one of the keys listed in the ACL.
  3145. There is one exception though: if an unauthorized server provides
  3146. substitutes that are @emph{bit-for-bit identical} to those provided by
  3147. an authorized server, then the unauthorized server becomes eligible for
  3148. downloads. For example, assume we have chosen two substitute servers
  3149. with this option:
  3150. @example
  3151. --substitute-urls="https://a.example.org https://b.example.org"
  3152. @end example
  3153. @noindent
  3154. @cindex reproducible builds
  3155. If the ACL contains only the key for @samp{b.example.org}, and if
  3156. @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
  3157. then Guix will download substitutes from @samp{a.example.org} because it
  3158. comes first in the list and can be considered a mirror of
  3159. @samp{b.example.org}. In practice, independent build machines usually
  3160. produce the same binaries, thanks to bit-reproducible builds (see
  3161. below).
  3162. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  3163. (in other words, the server is not authenticated), contrary to what
  3164. HTTPS clients such as Web browsers usually do. This is because Guix
  3165. authenticates substitute information itself, as explained above, which
  3166. is what we care about (whereas X.509 certificates are about
  3167. authenticating bindings between domain names and public keys).
  3168. @node Proxy Settings
  3169. @subsection Proxy Settings
  3170. @vindex http_proxy
  3171. @vindex https_proxy
  3172. Substitutes are downloaded over HTTP or HTTPS@. The @env{http_proxy} and
  3173. @env{https_proxy} environment variables can be set in the environment of
  3174. @command{guix-daemon} and are honored for downloads of substitutes.
  3175. Note that the value of those environment variables in the environment
  3176. where @command{guix build}, @command{guix package}, and other client
  3177. commands are run has @emph{absolutely no effect}.
  3178. @node Substitution Failure
  3179. @subsection Substitution Failure
  3180. Even when a substitute for a derivation is available, sometimes the
  3181. substitution attempt will fail. This can happen for a variety of
  3182. reasons: the substitute server might be offline, the substitute may
  3183. recently have been deleted, the connection might have been interrupted,
  3184. etc.
  3185. When substitutes are enabled and a substitute for a derivation is
  3186. available, but the substitution attempt fails, Guix will attempt to
  3187. build the derivation locally depending on whether or not
  3188. @option{--fallback} was given (@pxref{fallback-option,, common build
  3189. option @option{--fallback}}). Specifically, if @option{--fallback} was
  3190. omitted, then no local build will be performed, and the derivation is
  3191. considered to have failed. However, if @option{--fallback} was given,
  3192. then Guix will attempt to build the derivation locally, and the success
  3193. or failure of the derivation depends on the success or failure of the
  3194. local build. Note that when substitutes are disabled or no substitute
  3195. is available for the derivation in question, a local build will
  3196. @emph{always} be performed, regardless of whether or not
  3197. @option{--fallback} was given.
  3198. To get an idea of how many substitutes are available right now, you can
  3199. try running the @command{guix weather} command (@pxref{Invoking guix
  3200. weather}). This command provides statistics on the substitutes provided
  3201. by a server.
  3202. @node On Trusting Binaries
  3203. @subsection On Trusting Binaries
  3204. @cindex trust, of pre-built binaries
  3205. Today, each individual's control over their own computing is at the
  3206. mercy of institutions, corporations, and groups with enough power and
  3207. determination to subvert the computing infrastructure and exploit its
  3208. weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
  3209. convenient, we encourage users to also build on their own, or even run
  3210. their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
  3211. interesting target. One way to help is by publishing the software you
  3212. build using @command{guix publish} so that others have one more choice
  3213. of server to download substitutes from (@pxref{Invoking guix publish}).
  3214. Guix has the foundations to maximize build reproducibility
  3215. (@pxref{Features}). In most cases, independent builds of a given
  3216. package or derivation should yield bit-identical results. Thus, through
  3217. a diverse set of independent package builds, we can strengthen the
  3218. integrity of our systems. The @command{guix challenge} command aims to
  3219. help users assess substitute servers, and to assist developers in
  3220. finding out about non-deterministic package builds (@pxref{Invoking guix
  3221. challenge}). Similarly, the @option{--check} option of @command{guix
  3222. build} allows users to check whether previously-installed substitutes
  3223. are genuine by rebuilding them locally (@pxref{build-check,
  3224. @command{guix build --check}}).
  3225. In the future, we want Guix to have support to publish and retrieve
  3226. binaries to/from other users, in a peer-to-peer fashion. If you would
  3227. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  3228. @node Packages with Multiple Outputs
  3229. @section Packages with Multiple Outputs
  3230. @cindex multiple-output packages
  3231. @cindex package outputs
  3232. @cindex outputs
  3233. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  3234. source package leads to exactly one directory in the store. When running
  3235. @command{guix install glibc}, one installs the default output of the
  3236. GNU libc package; the default output is called @code{out}, but its name
  3237. can be omitted as shown in this command. In this particular case, the
  3238. default output of @code{glibc} contains all the C header files, shared
  3239. libraries, static libraries, Info documentation, and other supporting
  3240. files.
  3241. Sometimes it is more appropriate to separate the various types of files
  3242. produced from a single source package into separate outputs. For
  3243. instance, the GLib C library (used by GTK+ and related packages)
  3244. installs more than 20 MiB of reference documentation as HTML pages.
  3245. To save space for users who do not need it, the documentation goes to a
  3246. separate output, called @code{doc}. To install the main GLib output,
  3247. which contains everything but the documentation, one would run:
  3248. @example
  3249. guix install glib
  3250. @end example
  3251. @cindex documentation
  3252. The command to install its documentation is:
  3253. @example
  3254. guix install glib:doc
  3255. @end example
  3256. Some packages install programs with different ``dependency footprints''.
  3257. For instance, the WordNet package installs both command-line tools and
  3258. graphical user interfaces (GUIs). The former depend solely on the C
  3259. library, whereas the latter depend on Tcl/Tk and the underlying X
  3260. libraries. In this case, we leave the command-line tools in the default
  3261. output, whereas the GUIs are in a separate output. This allows users
  3262. who do not need the GUIs to save space. The @command{guix size} command
  3263. can help find out about such situations (@pxref{Invoking guix size}).
  3264. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  3265. There are several such multiple-output packages in the GNU distribution.
  3266. Other conventional output names include @code{lib} for libraries and
  3267. possibly header files, @code{bin} for stand-alone programs, and
  3268. @code{debug} for debugging information (@pxref{Installing Debugging
  3269. Files}). The outputs of a packages are listed in the third column of
  3270. the output of @command{guix package --list-available} (@pxref{Invoking
  3271. guix package}).
  3272. @node Invoking guix gc
  3273. @section Invoking @command{guix gc}
  3274. @cindex garbage collector
  3275. @cindex disk space
  3276. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  3277. The @command{guix gc} command allows users to explicitly run the garbage
  3278. collector to reclaim space from the @file{/gnu/store} directory. It is
  3279. the @emph{only} way to remove files from @file{/gnu/store}---removing
  3280. files or directories manually may break it beyond repair!
  3281. @cindex GC roots
  3282. @cindex garbage collector roots
  3283. The garbage collector has a set of known @dfn{roots}: any file under
  3284. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  3285. cannot be deleted; any other file is considered @dfn{dead} and may be
  3286. deleted. The set of garbage collector roots (``GC roots'' for short)
  3287. includes default user profiles; by default, the symlinks under
  3288. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  3289. added with @command{guix build --root}, for example (@pxref{Invoking
  3290. guix build}). The @command{guix gc --list-roots} command lists them.
  3291. Prior to running @code{guix gc --collect-garbage} to make space, it is
  3292. often useful to remove old generations from user profiles; that way, old
  3293. package builds referenced by those generations can be reclaimed. This
  3294. is achieved by running @code{guix package --delete-generations}
  3295. (@pxref{Invoking guix package}).
  3296. Our recommendation is to run a garbage collection periodically, or when
  3297. you are short on disk space. For instance, to guarantee that at least
  3298. 5@tie{}GB are available on your disk, simply run:
  3299. @example
  3300. guix gc -F 5G
  3301. @end example
  3302. It is perfectly safe to run as a non-interactive periodic job
  3303. (@pxref{Scheduled Job Execution}, for how to set up such a job).
  3304. Running @command{guix gc} with no arguments will collect as
  3305. much garbage as it can, but that is often inconvenient: you may find
  3306. yourself having to rebuild or re-download software that is ``dead'' from
  3307. the GC viewpoint but that is necessary to build other pieces of
  3308. software---e.g., the compiler tool chain.
  3309. The @command{guix gc} command has three modes of operation: it can be
  3310. used to garbage-collect any dead files (the default), to delete specific
  3311. files (the @option{--delete} option), to print garbage-collector
  3312. information, or for more advanced queries. The garbage collection
  3313. options are as follows:
  3314. @table @code
  3315. @item --collect-garbage[=@var{min}]
  3316. @itemx -C [@var{min}]
  3317. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  3318. sub-directories. This is the default operation when no option is
  3319. specified.
  3320. When @var{min} is given, stop once @var{min} bytes have been collected.
  3321. @var{min} may be a number of bytes, or it may include a unit as a
  3322. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  3323. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  3324. When @var{min} is omitted, collect all the garbage.
  3325. @item --free-space=@var{free}
  3326. @itemx -F @var{free}
  3327. Collect garbage until @var{free} space is available under
  3328. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  3329. as @code{500MiB}, as described above.
  3330. When @var{free} or more is already available in @file{/gnu/store}, do
  3331. nothing and exit immediately.
  3332. @item --delete-generations[=@var{duration}]
  3333. @itemx -d [@var{duration}]
  3334. Before starting the garbage collection process, delete all the generations
  3335. older than @var{duration}, for all the user profiles; when run as root, this
  3336. applies to all the profiles @emph{of all the users}.
  3337. For example, this command deletes all the generations of all your profiles
  3338. that are older than 2 months (except generations that are current), and then
  3339. proceeds to free space until at least 10 GiB are available:
  3340. @example
  3341. guix gc -d 2m -F 10G
  3342. @end example
  3343. @item --delete
  3344. @itemx -D
  3345. Attempt to delete all the store files and directories specified as
  3346. arguments. This fails if some of the files are not in the store, or if
  3347. they are still live.
  3348. @item --list-failures
  3349. List store items corresponding to cached build failures.
  3350. This prints nothing unless the daemon was started with
  3351. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  3352. @option{--cache-failures}}).
  3353. @item --list-roots
  3354. List the GC roots owned by the user; when run as root, list @emph{all} the GC
  3355. roots.
  3356. @item --list-busy
  3357. List store items in use by currently running processes. These store
  3358. items are effectively considered GC roots: they cannot be deleted.
  3359. @item --clear-failures
  3360. Remove the specified store items from the failed-build cache.
  3361. Again, this option only makes sense when the daemon is started with
  3362. @option{--cache-failures}. Otherwise, it does nothing.
  3363. @item --list-dead
  3364. Show the list of dead files and directories still present in the
  3365. store---i.e., files and directories no longer reachable from any root.
  3366. @item --list-live
  3367. Show the list of live store files and directories.
  3368. @end table
  3369. In addition, the references among existing store files can be queried:
  3370. @table @code
  3371. @item --references
  3372. @itemx --referrers
  3373. @cindex package dependencies
  3374. List the references (respectively, the referrers) of store files given
  3375. as arguments.
  3376. @item --requisites
  3377. @itemx -R
  3378. @cindex closure
  3379. List the requisites of the store files passed as arguments. Requisites
  3380. include the store files themselves, their references, and the references
  3381. of these, recursively. In other words, the returned list is the
  3382. @dfn{transitive closure} of the store files.
  3383. @xref{Invoking guix size}, for a tool to profile the size of the closure
  3384. of an element. @xref{Invoking guix graph}, for a tool to visualize
  3385. the graph of references.
  3386. @item --derivers
  3387. @cindex derivation
  3388. Return the derivation(s) leading to the given store items
  3389. (@pxref{Derivations}).
  3390. For example, this command:
  3391. @example
  3392. guix gc --derivers $(guix package -I ^emacs$ | cut -f4)
  3393. @end example
  3394. @noindent
  3395. returns the @file{.drv} file(s) leading to the @code{emacs} package
  3396. installed in your profile.
  3397. Note that there may be zero matching @file{.drv} files, for instance
  3398. because these files have been garbage-collected. There can also be more
  3399. than one matching @file{.drv} due to fixed-output derivations.
  3400. @end table
  3401. Lastly, the following options allow you to check the integrity of the
  3402. store and to control disk usage.
  3403. @table @option
  3404. @item --verify[=@var{options}]
  3405. @cindex integrity, of the store
  3406. @cindex integrity checking
  3407. Verify the integrity of the store.
  3408. By default, make sure that all the store items marked as valid in the
  3409. database of the daemon actually exist in @file{/gnu/store}.
  3410. When provided, @var{options} must be a comma-separated list containing one
  3411. or more of @code{contents} and @code{repair}.
  3412. When passing @option{--verify=contents}, the daemon computes the
  3413. content hash of each store item and compares it against its hash in the
  3414. database. Hash mismatches are reported as data corruptions. Because it
  3415. traverses @emph{all the files in the store}, this command can take a
  3416. long time, especially on systems with a slow disk drive.
  3417. @cindex repairing the store
  3418. @cindex corruption, recovering from
  3419. Using @option{--verify=repair} or @option{--verify=contents,repair}
  3420. causes the daemon to try to repair corrupt store items by fetching
  3421. substitutes for them (@pxref{Substitutes}). Because repairing is not
  3422. atomic, and thus potentially dangerous, it is available only to the
  3423. system administrator. A lightweight alternative, when you know exactly
  3424. which items in the store are corrupt, is @command{guix build --repair}
  3425. (@pxref{Invoking guix build}).
  3426. @item --optimize
  3427. @cindex deduplication
  3428. Optimize the store by hard-linking identical files---this is
  3429. @dfn{deduplication}.
  3430. The daemon performs deduplication after each successful build or archive
  3431. import, unless it was started with @option{--disable-deduplication}
  3432. (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
  3433. this option is primarily useful when the daemon was running with
  3434. @option{--disable-deduplication}.
  3435. @end table
  3436. @node Invoking guix pull
  3437. @section Invoking @command{guix pull}
  3438. @cindex upgrading Guix
  3439. @cindex updating Guix
  3440. @cindex @command{guix pull}
  3441. @cindex pull
  3442. @cindex security, @command{guix pull}
  3443. @cindex authenticity, of code obtained with @command{guix pull}
  3444. Packages are installed or upgraded to the latest version available in
  3445. the distribution currently available on your local machine. To update
  3446. that distribution, along with the Guix tools, you must run @command{guix
  3447. pull}: the command downloads the latest Guix source code and package
  3448. descriptions, and deploys it. Source code is downloaded from a
  3449. @uref{https://git-scm.com, Git} repository, by default the official
  3450. GNU@tie{}Guix repository, though this can be customized. @command{guix
  3451. pull} ensures that the code it downloads is @emph{authentic} by
  3452. verifying that commits are signed by Guix developers.
  3453. Specifically, @command{guix pull} downloads code from the @dfn{channels}
  3454. (@pxref{Channels}) specified by one of the followings, in this order:
  3455. @enumerate
  3456. @item
  3457. the @option{--channels} option;
  3458. @item
  3459. the user's @file{~/.config/guix/channels.scm} file;
  3460. @item
  3461. the system-wide @file{/etc/guix/channels.scm} file;
  3462. @item
  3463. the built-in default channels specified in the @code{%default-channels}
  3464. variable.
  3465. @end enumerate
  3466. On completion, @command{guix package} will use packages and package
  3467. versions from this just-retrieved copy of Guix. Not only that, but all
  3468. the Guix commands and Scheme modules will also be taken from that latest
  3469. version. New @command{guix} sub-commands added by the update also
  3470. become available.
  3471. Any user can update their Guix copy using @command{guix pull}, and the
  3472. effect is limited to the user who ran @command{guix pull}. For
  3473. instance, when user @code{root} runs @command{guix pull}, this has no
  3474. effect on the version of Guix that user @code{alice} sees, and vice
  3475. versa.
  3476. The result of running @command{guix pull} is a @dfn{profile} available
  3477. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  3478. make sure to add it to the beginning of your search path so that you use
  3479. the latest version, and similarly for the Info manual
  3480. (@pxref{Documentation}):
  3481. @example
  3482. export PATH="$HOME/.config/guix/current/bin:$PATH"
  3483. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  3484. @end example
  3485. The @option{--list-generations} or @option{-l} option lists past generations
  3486. produced by @command{guix pull}, along with details about their provenance:
  3487. @example
  3488. $ guix pull -l
  3489. Generation 1 Jun 10 2018 00:18:18
  3490. guix 65956ad
  3491. repository URL: https://git.savannah.gnu.org/git/guix.git
  3492. branch: origin/master
  3493. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  3494. Generation 2 Jun 11 2018 11:02:49
  3495. guix e0cc7f6
  3496. repository URL: https://git.savannah.gnu.org/git/guix.git
  3497. branch: origin/master
  3498. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  3499. 2 new packages: keepalived, libnfnetlink
  3500. 6 packages upgraded: emacs-nix-mode@@2.0.4,
  3501. guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
  3502. heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
  3503. Generation 3 Jun 13 2018 23:31:07 (current)
  3504. guix 844cc1c
  3505. repository URL: https://git.savannah.gnu.org/git/guix.git
  3506. branch: origin/master
  3507. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  3508. 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
  3509. 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
  3510. @end example
  3511. @xref{Invoking guix describe, @command{guix describe}}, for other ways to
  3512. describe the current status of Guix.
  3513. This @code{~/.config/guix/current} profile works exactly like the profiles
  3514. created by @command{guix package} (@pxref{Invoking guix package}). That
  3515. is, you can list generations, roll back to the previous
  3516. generation---i.e., the previous Guix---and so on:
  3517. @example
  3518. $ guix pull --roll-back
  3519. switched from generation 3 to 2
  3520. $ guix pull --delete-generations=1
  3521. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3522. @end example
  3523. You can also use @command{guix package} (@pxref{Invoking guix package})
  3524. to manage the profile by naming it explicitly:
  3525. @example
  3526. $ guix package -p ~/.config/guix/current --roll-back
  3527. switched from generation 3 to 2
  3528. $ guix package -p ~/.config/guix/current --delete-generations=1
  3529. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3530. @end example
  3531. The @command{guix pull} command is usually invoked with no arguments,
  3532. but it supports the following options:
  3533. @table @code
  3534. @item --url=@var{url}
  3535. @itemx --commit=@var{commit}
  3536. @itemx --branch=@var{branch}
  3537. Download code for the @code{guix} channel from the specified @var{url}, at the
  3538. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3539. string), or @var{branch}.
  3540. @cindex @file{channels.scm}, configuration file
  3541. @cindex configuration file for channels
  3542. These options are provided for convenience, but you can also specify your
  3543. configuration in the @file{~/.config/guix/channels.scm} file or using the
  3544. @option{--channels} option (see below).
  3545. @item --channels=@var{file}
  3546. @itemx -C @var{file}
  3547. Read the list of channels from @var{file} instead of
  3548. @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
  3549. @var{file} must contain Scheme code that
  3550. evaluates to a list of channel objects. @xref{Channels}, for more
  3551. information.
  3552. @cindex channel news
  3553. @item --news
  3554. @itemx -N
  3555. Display the list of packages added or upgraded since the previous
  3556. generation, as well as, occasionally, news written by channel authors
  3557. for their users (@pxref{Channels, Writing Channel News}).
  3558. The package information is the same as displayed upon @command{guix
  3559. pull} completion, but without ellipses; it is also similar to the output
  3560. of @command{guix pull -l} for the last generation (see below).
  3561. @item --list-generations[=@var{pattern}]
  3562. @itemx -l [@var{pattern}]
  3563. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  3564. is provided, the subset of generations that match @var{pattern}.
  3565. The syntax of @var{pattern} is the same as with @code{guix package
  3566. --list-generations} (@pxref{Invoking guix package}).
  3567. @item --roll-back
  3568. @cindex rolling back
  3569. @cindex undoing transactions
  3570. @cindex transactions, undoing
  3571. Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
  3572. undo the last transaction.
  3573. @item --switch-generation=@var{pattern}
  3574. @itemx -S @var{pattern}
  3575. @cindex generations
  3576. Switch to a particular generation defined by @var{pattern}.
  3577. @var{pattern} may be either a generation number or a number prefixed
  3578. with ``+'' or ``-''. The latter means: move forward/backward by a
  3579. specified number of generations. For example, if you want to return to
  3580. the latest generation after @option{--roll-back}, use
  3581. @option{--switch-generation=+1}.
  3582. @item --delete-generations[=@var{pattern}]
  3583. @itemx -d [@var{pattern}]
  3584. When @var{pattern} is omitted, delete all generations except the current
  3585. one.
  3586. This command accepts the same patterns as @option{--list-generations}.
  3587. When @var{pattern} is specified, delete the matching generations. When
  3588. @var{pattern} specifies a duration, generations @emph{older} than the
  3589. specified duration match. For instance, @option{--delete-generations=1m}
  3590. deletes generations that are more than one month old.
  3591. If the current generation matches, it is @emph{not} deleted.
  3592. Note that deleting generations prevents rolling back to them.
  3593. Consequently, this command must be used with care.
  3594. @xref{Invoking guix describe}, for a way to display information about the
  3595. current generation only.
  3596. @item --profile=@var{profile}
  3597. @itemx -p @var{profile}
  3598. Use @var{profile} instead of @file{~/.config/guix/current}.
  3599. @item --dry-run
  3600. @itemx -n
  3601. Show which channel commit(s) would be used and what would be built or
  3602. substituted but do not actually do it.
  3603. @item --allow-downgrades
  3604. Allow pulling older or unrelated revisions of channels than those
  3605. currently in use.
  3606. @cindex downgrade attacks, protection against
  3607. By default, @command{guix pull} protects against so-called ``downgrade
  3608. attacks'' whereby the Git repository of a channel would be reset to an
  3609. earlier or unrelated revision of itself, potentially leading you to
  3610. install older, known-vulnerable versions of software packages.
  3611. @quotation Note
  3612. Make sure you understand its security implications before using
  3613. @option{--allow-downgrades}.
  3614. @end quotation
  3615. @item --disable-authentication
  3616. Allow pulling channel code without authenticating it.
  3617. @cindex authentication, of channel code
  3618. By default, @command{guix pull} authenticates code downloaded from
  3619. channels by verifying that its commits are signed by authorized
  3620. developers, and raises an error if this is not the case. This option
  3621. instructs it to not perform any such verification.
  3622. @quotation Note
  3623. Make sure you understand its security implications before using
  3624. @option{--disable-authentication}.
  3625. @end quotation
  3626. @item --system=@var{system}
  3627. @itemx -s @var{system}
  3628. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  3629. the system type of the build host.
  3630. @item --bootstrap
  3631. Use the bootstrap Guile to build the latest Guix. This option is only
  3632. useful to Guix developers.
  3633. @end table
  3634. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  3635. repository and branch to pull from, as well as @emph{additional} repositories
  3636. containing package modules that should be deployed. @xref{Channels}, for more
  3637. information.
  3638. In addition, @command{guix pull} supports all the common build options
  3639. (@pxref{Common Build Options}).
  3640. @node Invoking guix time-machine
  3641. @section Invoking @command{guix time-machine}
  3642. @cindex @command{guix time-machine}
  3643. @cindex pinning, channels
  3644. @cindex replicating Guix
  3645. @cindex reproducibility, of Guix
  3646. The @command{guix time-machine} command provides access to other
  3647. revisions of Guix, for example to install older versions of packages,
  3648. or to reproduce a computation in an identical environment. The revision
  3649. of Guix to be used is defined by a commit or by a channel
  3650. description file created by @command{guix describe}
  3651. (@pxref{Invoking guix describe}).
  3652. The general syntax is:
  3653. @example
  3654. guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
  3655. @end example
  3656. where @var{command} and @var{arg}@dots{} are passed unmodified to the
  3657. @command{guix} command of the specified revision. The @var{options} that define
  3658. this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
  3659. @table @code
  3660. @item --url=@var{url}
  3661. @itemx --commit=@var{commit}
  3662. @itemx --branch=@var{branch}
  3663. Use the @code{guix} channel from the specified @var{url}, at the
  3664. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3665. string), or @var{branch}.
  3666. @item --channels=@var{file}
  3667. @itemx -C @var{file}
  3668. Read the list of channels from @var{file}. @var{file} must contain
  3669. Scheme code that evaluates to a list of channel objects.
  3670. @xref{Channels} for more information.
  3671. @end table
  3672. As for @command{guix pull}, the absence of any options means that the
  3673. latest commit on the master branch will be used. The command
  3674. @example
  3675. guix time-machine -- build hello
  3676. @end example
  3677. will thus build the package @code{hello} as defined in the master branch,
  3678. which is in general a newer revision of Guix than you have installed.
  3679. Time travel works in both directions!
  3680. Note that @command{guix time-machine} can trigger builds of channels and
  3681. their dependencies, and these are controlled by the standard build
  3682. options (@pxref{Common Build Options}).
  3683. @node Inferiors
  3684. @section Inferiors
  3685. @c TODO: Remove this once we're more confident about API stability.
  3686. @quotation Note
  3687. The functionality described here is a ``technology preview'' as of version
  3688. @value{VERSION}. As such, the interface is subject to change.
  3689. @end quotation
  3690. @cindex inferiors
  3691. @cindex composition of Guix revisions
  3692. Sometimes you might need to mix packages from the revision of Guix you're
  3693. currently running with packages available in a different revision of Guix.
  3694. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  3695. revisions in arbitrary ways.
  3696. @cindex inferior packages
  3697. Technically, an ``inferior'' is essentially a separate Guix process connected
  3698. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  3699. @code{(guix inferior)} module allows you to create inferiors and to
  3700. communicate with them. It also provides a high-level interface to browse and
  3701. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  3702. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  3703. to interact with a separate revision of Guix. For example, let's assume you
  3704. want to install in your profile the current @code{guile} package, along with
  3705. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  3706. because the newer @code{guile-json} has an incompatible API and you want to
  3707. run your code against the old API@. To do that, you could write a manifest for
  3708. use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
  3709. manifest, you would create an inferior for that old Guix revision you care
  3710. about, and you would look up the @code{guile-json} package in the inferior:
  3711. @lisp
  3712. (use-modules (guix inferior) (guix channels)
  3713. (srfi srfi-1)) ;for 'first'
  3714. (define channels
  3715. ;; This is the old revision from which we want to
  3716. ;; extract guile-json.
  3717. (list (channel
  3718. (name 'guix)
  3719. (url "https://git.savannah.gnu.org/git/guix.git")
  3720. (commit
  3721. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  3722. (define inferior
  3723. ;; An inferior representing the above revision.
  3724. (inferior-for-channels channels))
  3725. ;; Now create a manifest with the current "guile" package
  3726. ;; and the old "guile-json" package.
  3727. (packages->manifest
  3728. (list (first (lookup-inferior-packages inferior "guile-json"))
  3729. (specification->package "guile")))
  3730. @end lisp
  3731. On its first run, @command{guix package --manifest} might have to build the
  3732. channel you specified before it can create the inferior; subsequent runs will
  3733. be much faster because the Guix revision will be cached.
  3734. The @code{(guix inferior)} module provides the following procedures to open an
  3735. inferior:
  3736. @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
  3737. [#:cache-directory] [#:ttl]
  3738. Return an inferior for @var{channels}, a list of channels. Use the cache at
  3739. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  3740. This procedure opens a new connection to the build daemon.
  3741. As a side effect, this procedure may build or substitute binaries for
  3742. @var{channels}, which can take time.
  3743. @end deffn
  3744. @deffn {Scheme Procedure} open-inferior @var{directory} @
  3745. [#:command "bin/guix"]
  3746. Open the inferior Guix in @var{directory}, running
  3747. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  3748. the inferior could not be launched.
  3749. @end deffn
  3750. @cindex inferior packages
  3751. The procedures listed below allow you to obtain and manipulate inferior
  3752. packages.
  3753. @deffn {Scheme Procedure} inferior-packages @var{inferior}
  3754. Return the list of packages known to @var{inferior}.
  3755. @end deffn
  3756. @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
  3757. [@var{version}]
  3758. Return the sorted list of inferior packages matching @var{name} in
  3759. @var{inferior}, with highest version numbers first. If @var{version} is true,
  3760. return only packages with a version number prefixed by @var{version}.
  3761. @end deffn
  3762. @deffn {Scheme Procedure} inferior-package? @var{obj}
  3763. Return true if @var{obj} is an inferior package.
  3764. @end deffn
  3765. @deffn {Scheme Procedure} inferior-package-name @var{package}
  3766. @deffnx {Scheme Procedure} inferior-package-version @var{package}
  3767. @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
  3768. @deffnx {Scheme Procedure} inferior-package-description @var{package}
  3769. @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
  3770. @deffnx {Scheme Procedure} inferior-package-location @var{package}
  3771. @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
  3772. @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
  3773. @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
  3774. @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
  3775. @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
  3776. @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
  3777. @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
  3778. These procedures are the counterpart of package record accessors
  3779. (@pxref{package Reference}). Most of them work by querying the inferior
  3780. @var{package} comes from, so the inferior must still be live when you call
  3781. these procedures.
  3782. @end deffn
  3783. Inferior packages can be used transparently like any other package or
  3784. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  3785. transparently handled by the @code{packages->manifest} procedure, which is
  3786. commonly used in manifests (@pxref{Invoking guix package, the
  3787. @option{--manifest} option of @command{guix package}}). Thus you can insert
  3788. an inferior package pretty much anywhere you would insert a regular package:
  3789. in manifests, in the @code{packages} field of your @code{operating-system}
  3790. declaration, and so on.
  3791. @node Invoking guix describe
  3792. @section Invoking @command{guix describe}
  3793. @cindex reproducibility
  3794. @cindex replicating Guix
  3795. Often you may want to answer questions like: ``Which revision of Guix am I
  3796. using?'' or ``Which channels am I using?'' This is useful information in many
  3797. situations: if you want to @emph{replicate} an environment on a different
  3798. machine or user account, if you want to report a bug or to determine what
  3799. change in the channels you are using caused it, or if you want to record your
  3800. system state for reproducibility purposes. The @command{guix describe}
  3801. command answers these questions.
  3802. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  3803. displays the channel(s) that it was built from, including their repository URL
  3804. and commit IDs (@pxref{Channels}):
  3805. @example
  3806. $ guix describe
  3807. Generation 10 Sep 03 2018 17:32:44 (current)
  3808. guix e0fa68c
  3809. repository URL: https://git.savannah.gnu.org/git/guix.git
  3810. branch: master
  3811. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  3812. @end example
  3813. If you're familiar with the Git version control system, this is similar in
  3814. spirit to @command{git describe}; the output is also similar to that of
  3815. @command{guix pull --list-generations}, but limited to the current generation
  3816. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  3817. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  3818. information is all it takes to describe the revision of Guix you're using, and
  3819. also to replicate it.
  3820. To make it easier to replicate Guix, @command{guix describe} can also be asked
  3821. to return a list of channels instead of the human-readable description above:
  3822. @example
  3823. $ guix describe -f channels
  3824. (list (channel
  3825. (name 'guix)
  3826. (url "https://git.savannah.gnu.org/git/guix.git")
  3827. (commit
  3828. "e0fa68c7718fffd33d81af415279d6ddb518f727")
  3829. (introduction
  3830. (make-channel-introduction
  3831. "9edb3f66fd807b096b48283debdcddccfea34bad"
  3832. (openpgp-fingerprint
  3833. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
  3834. @end example
  3835. @noindent
  3836. You can save this to a file and feed it to @command{guix pull -C} on some
  3837. other machine or at a later point in time, which will instantiate @emph{this
  3838. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  3839. From there on, since you're able to deploy the same revision of Guix, you can
  3840. just as well @emph{replicate a complete software environment}. We humbly
  3841. think that this is @emph{awesome}, and we hope you'll like it too!
  3842. The details of the options supported by @command{guix describe} are as
  3843. follows:
  3844. @table @code
  3845. @item --format=@var{format}
  3846. @itemx -f @var{format}
  3847. Produce output in the specified @var{format}, one of:
  3848. @table @code
  3849. @item human
  3850. produce human-readable output;
  3851. @item channels
  3852. produce a list of channel specifications that can be passed to @command{guix
  3853. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  3854. guix pull});
  3855. @item channels-sans-intro
  3856. like @code{channels}, but omit the @code{introduction} field; use it to
  3857. produce a channel specification suitable for Guix version 1.1.0 or
  3858. earlier---the @code{introduction} field has to do with channel
  3859. authentication (@pxref{Channels, Channel Authentication}) and is not
  3860. supported by these older versions;
  3861. @item json
  3862. @cindex JSON
  3863. produce a list of channel specifications in JSON format;
  3864. @item recutils
  3865. produce a list of channel specifications in Recutils format.
  3866. @end table
  3867. @item --list-formats
  3868. Display available formats for @option{--format} option.
  3869. @item --profile=@var{profile}
  3870. @itemx -p @var{profile}
  3871. Display information about @var{profile}.
  3872. @end table
  3873. @node Invoking guix archive
  3874. @section Invoking @command{guix archive}
  3875. @cindex @command{guix archive}
  3876. @cindex archive
  3877. The @command{guix archive} command allows users to @dfn{export} files
  3878. from the store into a single archive, and to later @dfn{import} them on
  3879. a machine that runs Guix.
  3880. In particular, it allows store files to be transferred from one machine
  3881. to the store on another machine.
  3882. @quotation Note
  3883. If you're looking for a way to produce archives in a format suitable for
  3884. tools other than Guix, @pxref{Invoking guix pack}.
  3885. @end quotation
  3886. @cindex exporting store items
  3887. To export store files as an archive to standard output, run:
  3888. @example
  3889. guix archive --export @var{options} @var{specifications}...
  3890. @end example
  3891. @var{specifications} may be either store file names or package
  3892. specifications, as for @command{guix package} (@pxref{Invoking guix
  3893. package}). For instance, the following command creates an archive
  3894. containing the @code{gui} output of the @code{git} package and the main
  3895. output of @code{emacs}:
  3896. @example
  3897. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  3898. @end example
  3899. If the specified packages are not built yet, @command{guix archive}
  3900. automatically builds them. The build process may be controlled with the
  3901. common build options (@pxref{Common Build Options}).
  3902. To transfer the @code{emacs} package to a machine connected over SSH,
  3903. one would run:
  3904. @example
  3905. guix archive --export -r emacs | ssh the-machine guix archive --import
  3906. @end example
  3907. @noindent
  3908. Similarly, a complete user profile may be transferred from one machine
  3909. to another like this:
  3910. @example
  3911. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  3912. ssh the-machine guix archive --import
  3913. @end example
  3914. @noindent
  3915. However, note that, in both examples, all of @code{emacs} and the
  3916. profile as well as all of their dependencies are transferred (due to
  3917. @option{-r}), regardless of what is already available in the store on
  3918. the target machine. The @option{--missing} option can help figure out
  3919. which items are missing from the target store. The @command{guix copy}
  3920. command simplifies and optimizes this whole process, so this is probably
  3921. what you should use in this case (@pxref{Invoking guix copy}).
  3922. @cindex nar, archive format
  3923. @cindex normalized archive (nar)
  3924. @cindex nar bundle, archive format
  3925. Each store item is written in the @dfn{normalized archive} or @dfn{nar}
  3926. format (described below), and the output of @command{guix archive
  3927. --export} (and input of @command{guix archive --import}) is a @dfn{nar
  3928. bundle}.
  3929. The nar format is
  3930. comparable in spirit to `tar', but with differences
  3931. that make it more appropriate for our purposes. First, rather than
  3932. recording all Unix metadata for each file, the nar format only mentions
  3933. the file type (regular, directory, or symbolic link); Unix permissions
  3934. and owner/group are dismissed. Second, the order in which directory
  3935. entries are stored always follows the order of file names according to
  3936. the C locale collation order. This makes archive production fully
  3937. deterministic.
  3938. That nar bundle format is essentially the concatenation of zero or more
  3939. nars along with metadata for each store item it contains: its file name,
  3940. references, corresponding derivation, and a digital signature.
  3941. When exporting, the daemon digitally signs the contents of the archive,
  3942. and that digital signature is appended. When importing, the daemon
  3943. verifies the signature and rejects the import in case of an invalid
  3944. signature or if the signing key is not authorized.
  3945. @c FIXME: Add xref to daemon doc about signatures.
  3946. The main options are:
  3947. @table @code
  3948. @item --export
  3949. Export the specified store files or packages (see below). Write the
  3950. resulting archive to the standard output.
  3951. Dependencies are @emph{not} included in the output, unless
  3952. @option{--recursive} is passed.
  3953. @item -r
  3954. @itemx --recursive
  3955. When combined with @option{--export}, this instructs @command{guix archive}
  3956. to include dependencies of the given items in the archive. Thus, the
  3957. resulting archive is self-contained: it contains the closure of the
  3958. exported store items.
  3959. @item --import
  3960. Read an archive from the standard input, and import the files listed
  3961. therein into the store. Abort if the archive has an invalid digital
  3962. signature, or if it is signed by a public key not among the authorized
  3963. keys (see @option{--authorize} below).
  3964. @item --missing
  3965. Read a list of store file names from the standard input, one per line,
  3966. and write on the standard output the subset of these files missing from
  3967. the store.
  3968. @item --generate-key[=@var{parameters}]
  3969. @cindex signing, archives
  3970. Generate a new key pair for the daemon. This is a prerequisite before
  3971. archives can be exported with @option{--export}. This
  3972. operation is usually instantaneous but it can take time if the system's
  3973. entropy pool needs to be refilled. On Guix System,
  3974. @code{guix-service-type} takes care of generating this key pair the
  3975. first boot.
  3976. The generated key pair is typically stored under @file{/etc/guix}, in
  3977. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  3978. key, which must be kept secret). When @var{parameters} is omitted,
  3979. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  3980. versions before 1.6.0, it is a 4096-bit RSA key.
  3981. Alternatively, @var{parameters} can specify
  3982. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  3983. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  3984. Libgcrypt Reference Manual}).
  3985. @item --authorize
  3986. @cindex authorizing, archives
  3987. Authorize imports signed by the public key passed on standard input.
  3988. The public key must be in ``s-expression advanced format''---i.e., the
  3989. same format as the @file{signing-key.pub} file.
  3990. The list of authorized keys is kept in the human-editable file
  3991. @file{/etc/guix/acl}. The file contains
  3992. @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  3993. s-expressions''} and is structured as an access-control list in the
  3994. @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  3995. (SPKI)}.
  3996. @item --extract=@var{directory}
  3997. @itemx -x @var{directory}
  3998. Read a single-item archive as served by substitute servers
  3999. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  4000. low-level operation needed in only very narrow use cases; see below.
  4001. For example, the following command extracts the substitute for Emacs
  4002. served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
  4003. @example
  4004. $ wget -O - \
  4005. https://@value{SUBSTITUTE-SERVER}/nar/gzip/@dots{}-emacs-24.5 \
  4006. | gunzip | guix archive -x /tmp/emacs
  4007. @end example
  4008. Single-item archives are different from multiple-item archives produced
  4009. by @command{guix archive --export}; they contain a single store item,
  4010. and they do @emph{not} embed a signature. Thus this operation does
  4011. @emph{no} signature verification and its output should be considered
  4012. unsafe.
  4013. The primary purpose of this operation is to facilitate inspection of
  4014. archive contents coming from possibly untrusted substitute servers
  4015. (@pxref{Invoking guix challenge}).
  4016. @item --list
  4017. @itemx -t
  4018. Read a single-item archive as served by substitute servers
  4019. (@pxref{Substitutes}) and print the list of files it contains, as in
  4020. this example:
  4021. @example
  4022. $ wget -O - \
  4023. https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-emacs-26.3 \
  4024. | lzip -d | guix archive -t
  4025. @end example
  4026. @end table
  4027. @c *********************************************************************
  4028. @node Channels
  4029. @chapter Channels
  4030. @cindex channels
  4031. @cindex @file{channels.scm}, configuration file
  4032. @cindex configuration file for channels
  4033. @cindex @command{guix pull}, configuration file
  4034. @cindex configuration of @command{guix pull}
  4035. Guix and its package collection are updated by running @command{guix pull}
  4036. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  4037. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  4038. customized by defining @dfn{channels} in the
  4039. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  4040. of a Git repository to be deployed, and @command{guix pull} can be instructed
  4041. to pull from one or more channels. In other words, channels can be used
  4042. to @emph{customize} and to @emph{extend} Guix, as we will see below.
  4043. Guix is able to take into account security concerns and deal with authenticated
  4044. updates.
  4045. @menu
  4046. * Specifying Additional Channels:: Extending the package collection.
  4047. * Using a Custom Guix Channel:: Using a customized Guix.
  4048. * Replicating Guix:: Running the @emph{exact same} Guix.
  4049. * Channel Authentication:: How Guix verifies what it fetches.
  4050. * Channels with Substitutes:: Using channels with available substitutes.
  4051. * Creating a Channel:: How to write your custom channel.
  4052. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  4053. * Declaring Channel Dependencies:: How to depend on other channels.
  4054. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  4055. * Primary URL:: Distinguishing mirror to original.
  4056. * Writing Channel News:: Communicating information to channel's users.
  4057. @end menu
  4058. @node Specifying Additional Channels
  4059. @section Specifying Additional Channels
  4060. @cindex extending the package collection (channels)
  4061. @cindex variant packages (channels)
  4062. You can specify @emph{additional channels} to pull from. To use a channel, write
  4063. @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
  4064. @emph{in addition} to the default Guix channel(s):
  4065. @vindex %default-channels
  4066. @lisp
  4067. ;; Add variant packages to those Guix provides.
  4068. (cons (channel
  4069. (name 'variant-packages)
  4070. (url "https://example.org/variant-packages.git"))
  4071. %default-channels)
  4072. @end lisp
  4073. @noindent
  4074. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  4075. add a channel the list of channels that the variable @code{%default-channels}
  4076. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  4077. Manual}). With this file in place, @command{guix pull} builds not only Guix
  4078. but also the package modules from your own repository. The result in
  4079. @file{~/.config/guix/current} is the union of Guix with your own package
  4080. modules:
  4081. @example
  4082. $ guix pull --list-generations
  4083. @dots{}
  4084. Generation 19 Aug 27 2018 16:20:48
  4085. guix d894ab8
  4086. repository URL: https://git.savannah.gnu.org/git/guix.git
  4087. branch: master
  4088. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  4089. variant-packages dd3df5e
  4090. repository URL: https://example.org/variant-packages.git
  4091. branch: master
  4092. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  4093. 11 new packages: variant-gimp, variant-emacs-with-cool-features, @dots{}
  4094. 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
  4095. @end example
  4096. @noindent
  4097. The output of @command{guix pull} above shows that Generation@tie{}19 includes
  4098. both Guix and packages from the @code{variant-personal-packages} channel. Among
  4099. the new and upgraded packages that are listed, some like @code{variant-gimp} and
  4100. @code{variant-emacs-with-cool-features} might come from
  4101. @code{variant-packages}, while others come from the Guix default channel.
  4102. @node Using a Custom Guix Channel
  4103. @section Using a Custom Guix Channel
  4104. The channel called @code{guix} specifies where Guix itself---its command-line
  4105. tools as well as its package collection---should be downloaded. For instance,
  4106. suppose you want to update from another copy of the Guix repository at
  4107. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  4108. write in @code{~/.config/guix/channels.scm} this specification:
  4109. @lisp
  4110. ;; Tell 'guix pull' to use another repo.
  4111. (list (channel
  4112. (name 'guix)
  4113. (url "https://example.org/another-guix.git")
  4114. (branch "super-hacks")))
  4115. @end lisp
  4116. @noindent
  4117. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  4118. branch of the repository at @code{example.org}. The authentication concern is
  4119. addressed below ((@pxref{Channel Authentication}).
  4120. @node Replicating Guix
  4121. @section Replicating Guix
  4122. @cindex pinning, channels
  4123. @cindex replicating Guix
  4124. @cindex reproducibility, of Guix
  4125. The @command{guix pull --list-generations} output above shows precisely which
  4126. commits were used to build this instance of Guix. We can thus replicate it,
  4127. say, on another machine, by providing a channel specification in
  4128. @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
  4129. @lisp
  4130. ;; Deploy specific commits of my channels of interest.
  4131. (list (channel
  4132. (name 'guix)
  4133. (url "https://git.savannah.gnu.org/git/guix.git")
  4134. (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
  4135. (channel
  4136. (name 'variant-packages)
  4137. (url "https://example.org/variant-packages.git")
  4138. (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  4139. @end lisp
  4140. The @command{guix describe --format=channels} command can even generate this
  4141. list of channels directly (@pxref{Invoking guix describe}). The resulting
  4142. file can be used with the -C options of @command{guix pull}
  4143. (@pxref{Invoking guix pull}) or @command{guix time-machine}
  4144. (@pxref{Invoking guix time-machine}).
  4145. At this point the two machines run the @emph{exact same Guix}, with access to
  4146. the @emph{exact same packages}. The output of @command{guix build gimp} on
  4147. one machine will be exactly the same, bit for bit, as the output of the same
  4148. command on the other machine. It also means both machines have access to all
  4149. the source code of Guix and, transitively, to all the source code of every
  4150. package it defines.
  4151. This gives you super powers, allowing you to track the provenance of binary
  4152. artifacts with very fine grain, and to reproduce software environments at
  4153. will---some sort of ``meta reproducibility'' capabilities, if you will.
  4154. @xref{Inferiors}, for another way to take advantage of these super powers.
  4155. @node Channel Authentication
  4156. @section Channel Authentication
  4157. @anchor{channel-authentication}
  4158. @cindex authentication, of channel code
  4159. The @command{guix pull} and @command{guix time-machine} commands
  4160. @dfn{authenticate} the code retrieved from channels: they make sure each
  4161. commit that is fetched is signed by an authorized developer. The goal
  4162. is to protect from unauthorized modifications to the channel that would
  4163. lead users to run malicious code.
  4164. As a user, you must provide a @dfn{channel introduction} in your
  4165. channels file so that Guix knows how to authenticate its first commit.
  4166. A channel specification, including its introduction, looks something
  4167. along these lines:
  4168. @lisp
  4169. (channel
  4170. (name 'some-channel)
  4171. (url "https://example.org/some-channel.git")
  4172. (introduction
  4173. (make-channel-introduction
  4174. "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
  4175. (openpgp-fingerprint
  4176. "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4177. @end lisp
  4178. The specification above shows the name and URL of the channel. The call
  4179. to @code{make-channel-introduction} above specifies that authentication
  4180. of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
  4181. by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
  4182. For the main channel, called @code{guix}, you automatically get that
  4183. information from your Guix installation. For other channels, include
  4184. the channel introduction provided by the channel authors in your
  4185. @file{channels.scm} file. Make sure you retrieve the channel
  4186. introduction from a trusted source since that is the root of your trust.
  4187. If you're curious about the authentication mechanics, read on!
  4188. @node Channels with Substitutes
  4189. @section Channels with Substitutes
  4190. When running @command{guix pull}, Guix will first compile the
  4191. definitions of every available package. This is an expensive operation
  4192. for which substitutes (@pxref{Substitutes}) may be available. The
  4193. following snippet in @file{channels.scm} will ensure that @command{guix
  4194. pull} uses the latest commit with available substitutes for the package
  4195. definitions: this is done by querying the continuous integration
  4196. server at @url{https://ci.guix.gnu.org}.
  4197. @lisp
  4198. (use-modules (guix ci))
  4199. (list (channel-with-substitutes-available
  4200. %default-guix-channel
  4201. "https://ci.guix.gnu.org"))
  4202. @end lisp
  4203. Note that this does not mean that all the packages that you will
  4204. install after running @command{guix pull} will have available
  4205. substitutes. It only ensures that @command{guix pull} will not try to
  4206. compile package definitions. This is particularly useful when using
  4207. machines with limited resources.
  4208. @node Creating a Channel
  4209. @section Creating a Channel
  4210. @cindex personal packages (channels)
  4211. @cindex channels, for personal packages
  4212. Let's say you have a bunch of custom package variants or personal packages
  4213. that you think would make little sense to contribute to the Guix project, but
  4214. would like to have these packages transparently available to you at the
  4215. command line. You would first write modules containing those package
  4216. definitions (@pxref{Package Modules}), maintain them in a Git repository, and
  4217. then you and anyone else can use it as an additional channel to get packages
  4218. from. Neat, no?
  4219. @c What follows stems from discussions at
  4220. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  4221. @c earlier discussions on guix-devel@gnu.org.
  4222. @quotation Warning
  4223. Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
  4224. publish your personal channel to the world, we would like to share a few words
  4225. of caution:
  4226. @itemize
  4227. @item
  4228. Before publishing a channel, please consider contributing your package
  4229. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  4230. to free software of all sorts, and packages in Guix proper are readily
  4231. available to all Guix users and benefit from the project's quality assurance
  4232. process.
  4233. @item
  4234. When you maintain package definitions outside Guix, we, Guix developers,
  4235. consider that @emph{the compatibility burden is on you}. Remember that
  4236. package modules and package definitions are just Scheme code that uses various
  4237. programming interfaces (APIs). We want to remain free to change these APIs to
  4238. keep improving Guix, possibly in ways that break your channel. We never
  4239. change APIs gratuitously, but we will @emph{not} commit to freezing APIs
  4240. either.
  4241. @item
  4242. Corollary: if you're using an external channel and that channel breaks, please
  4243. @emph{report the issue to the channel authors}, not to the Guix project.
  4244. @end itemize
  4245. You've been warned! Having said this, we believe external channels are a
  4246. practical way to exert your freedom to augment Guix' package collection and to
  4247. share your improvements, which are basic tenets of
  4248. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  4249. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  4250. @end quotation
  4251. To create a channel, create a Git repository containing your own package
  4252. modules and make it available. The repository can contain anything, but a
  4253. useful channel will contain Guile modules that export packages. Once you
  4254. start using a channel, Guix will behave as if the root directory of that
  4255. channel's Git repository has been added to the Guile load path (@pxref{Load
  4256. Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
  4257. contains a file at @file{my-packages/my-tools.scm} that defines a Guile
  4258. module, then the module will be available under the name @code{(my-packages
  4259. my-tools)}, and you will be able to use it like any other module
  4260. (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
  4261. As a channel author, consider bundling authentication material with your
  4262. channel so that users can authenticate it. @xref{Channel
  4263. Authentication}, and @ref{Specifying Channel Authorizations}, for info
  4264. on how to do it.
  4265. @node Package Modules in a Sub-directory
  4266. @section Package Modules in a Sub-directory
  4267. @cindex subdirectory, channels
  4268. As a channel author, you may want to keep your channel modules in a
  4269. sub-directory. If your modules are in the sub-directory @file{guix}, you must
  4270. add a meta-data file @file{.guix-channel} that contains:
  4271. @lisp
  4272. (channel
  4273. (version 0)
  4274. (directory "guix"))
  4275. @end lisp
  4276. @node Declaring Channel Dependencies
  4277. @section Declaring Channel Dependencies
  4278. @cindex dependencies, channels
  4279. @cindex meta-data, channels
  4280. Channel authors may decide to augment a package collection provided by other
  4281. channels. They can declare their channel to be dependent on other channels in
  4282. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  4283. the channel repository.
  4284. The meta-data file should contain a simple S-expression like this:
  4285. @lisp
  4286. (channel
  4287. (version 0)
  4288. (dependencies
  4289. (channel
  4290. (name some-collection)
  4291. (url "https://example.org/first-collection.git")
  4292. ;; The 'introduction' bit below is optional: you would
  4293. ;; provide it for dependencies that can be authenticated.
  4294. (introduction
  4295. (channel-introduction
  4296. (version 0)
  4297. (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
  4298. (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4299. (channel
  4300. (name some-other-collection)
  4301. (url "https://example.org/second-collection.git")
  4302. (branch "testing"))))
  4303. @end lisp
  4304. In the above example this channel is declared to depend on two other channels,
  4305. which will both be fetched automatically. The modules provided by the channel
  4306. will be compiled in an environment where the modules of all these declared
  4307. channels are available.
  4308. For the sake of reliability and maintainability, you should avoid dependencies
  4309. on channels that you don't control, and you should aim to keep the number of
  4310. dependencies to a minimum.
  4311. @node Specifying Channel Authorizations
  4312. @section Specifying Channel Authorizations
  4313. @cindex channel authorizations
  4314. @anchor{channel-authorizations}
  4315. As we saw above, Guix ensures the source code it pulls from channels
  4316. comes from authorized developers. As a channel author, you need to
  4317. specify the list of authorized developers in the
  4318. @file{.guix-authorizations} file in the channel's Git repository. The
  4319. authentication rule is simple: each commit must be signed by a key
  4320. listed in the @file{.guix-authorizations} file of its parent
  4321. commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
  4322. (DAG). Each commit can have zero or more parents; ``regular'' commits
  4323. have one parent and merge commits have two parent commits. Read
  4324. @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
  4325. for Computer Scientists}} for a great overview.} The
  4326. @file{.guix-authorizations} file looks like this:
  4327. @lisp
  4328. ;; Example '.guix-authorizations' file.
  4329. (authorizations
  4330. (version 0) ;current file format version
  4331. (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
  4332. (name "alice"))
  4333. ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
  4334. (name "bob"))
  4335. ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
  4336. (name "charlie"))))
  4337. @end lisp
  4338. Each fingerprint is followed by optional key/value pairs, as in the
  4339. example above. Currently these key/value pairs are ignored.
  4340. This authentication rule creates a chicken-and-egg issue: how do we
  4341. authenticate the first commit? Related to that: how do we deal with
  4342. channels whose repository history contains unsigned commits and lack
  4343. @file{.guix-authorizations}? And how do we fork existing channels?
  4344. @cindex channel introduction
  4345. Channel introductions answer these questions by describing the first
  4346. commit of a channel that should be authenticated. The first time a
  4347. channel is fetched with @command{guix pull} or @command{guix
  4348. time-machine}, the command looks up the introductory commit and verifies
  4349. that it is signed by the specified OpenPGP key. From then on, it
  4350. authenticates commits according to the rule above.
  4351. Additionally, your channel must provide all the OpenPGP keys that were
  4352. ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
  4353. files, which can be either binary or ``ASCII-armored''. By default,
  4354. those @file{.key} files are searched for in the branch named
  4355. @code{keyring} but you can specify a different branch name in
  4356. @code{.guix-channel} like so:
  4357. @lisp
  4358. (channel
  4359. (version 0)
  4360. (keyring-reference "my-keyring-branch"))
  4361. @end lisp
  4362. To summarize, as the author of a channel, there are three things you have
  4363. to do to allow users to authenticate your code:
  4364. @enumerate
  4365. @item
  4366. Export the OpenPGP keys of past and present committers with @command{gpg
  4367. --export} and store them in @file{.key} files, by default in a branch
  4368. named @code{keyring} (we recommend making it an @dfn{orphan branch}).
  4369. @item
  4370. Introduce an initial @file{.guix-authorizations} in the channel's
  4371. repository. Do that in a signed commit (@pxref{Commit Access}, for
  4372. information on how to sign Git commits.)
  4373. @item
  4374. Advertise the channel introduction, for instance on your channel's web
  4375. page. The channel introduction, as we saw above, is the commit/key
  4376. pair---i.e., the commit that introduced @file{.guix-authorizations}, and
  4377. the fingerprint of the OpenPGP used to sign it.
  4378. @end enumerate
  4379. Before pushing to your public Git repository, you can run @command{guix
  4380. git-authenticate} to verify that you did sign all the commits you are
  4381. about to push with an authorized key:
  4382. @example
  4383. guix git authenticate @var{commit} @var{signer}
  4384. @end example
  4385. @noindent
  4386. where @var{commit} and @var{signer} are your channel introduction.
  4387. @xref{Invoking guix git authenticate}, for details.
  4388. Publishing a signed channel requires discipline: any mistake, such as an
  4389. unsigned commit or a commit signed by an unauthorized key, will prevent
  4390. users from pulling from your channel---well, that's the whole point of
  4391. authentication! Pay attention to merges in particular: merge commits
  4392. are considered authentic if and only if they are signed by a key present
  4393. in the @file{.guix-authorizations} file of @emph{both} branches.
  4394. @node Primary URL
  4395. @section Primary URL
  4396. @cindex primary URL, channels
  4397. Channel authors can indicate the primary URL of their channel's Git
  4398. repository in the @file{.guix-channel} file, like so:
  4399. @lisp
  4400. (channel
  4401. (version 0)
  4402. (url "https://example.org/guix.git"))
  4403. @end lisp
  4404. This allows @command{guix pull} to determine whether it is pulling code
  4405. from a mirror of the channel; when that is the case, it warns the user
  4406. that the mirror might be stale and displays the primary URL@. That way,
  4407. users cannot be tricked into fetching code from a stale mirror that does
  4408. not receive security updates.
  4409. This feature only makes sense for authenticated repositories, such as
  4410. the official @code{guix} channel, for which @command{guix pull} ensures
  4411. the code it fetches is authentic.
  4412. @node Writing Channel News
  4413. @section Writing Channel News
  4414. @cindex news, for channels
  4415. Channel authors may occasionally want to communicate to their users
  4416. information about important changes in the channel. You'd send them all
  4417. an email, but that's not convenient.
  4418. Instead, channels can provide a @dfn{news file}; when the channel users
  4419. run @command{guix pull}, that news file is automatically read and
  4420. @command{guix pull --news} can display the announcements that correspond
  4421. to the new commits that have been pulled, if any.
  4422. To do that, channel authors must first declare the name of the news file
  4423. in their @file{.guix-channel} file:
  4424. @lisp
  4425. (channel
  4426. (version 0)
  4427. (news-file "etc/news.txt"))
  4428. @end lisp
  4429. The news file itself, @file{etc/news.txt} in this example, must look
  4430. something like this:
  4431. @lisp
  4432. (channel-news
  4433. (version 0)
  4434. (entry (tag "the-bug-fix")
  4435. (title (en "Fixed terrible bug")
  4436. (fr "Oh la la"))
  4437. (body (en "@@emph@{Good news@}! It's fixed!")
  4438. (eo "Certe ĝi pli bone funkcias nun!")))
  4439. (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
  4440. (title (en "Added a great package")
  4441. (ca "Què vol dir guix?"))
  4442. (body (en "Don't miss the @@code@{hello@} package!"))))
  4443. @end lisp
  4444. While the news file is using the Scheme syntax, avoid naming it with a
  4445. @file{.scm} extension or else it will get picked up when building the
  4446. channel and yield an error since it is not a valid module.
  4447. Alternatively, you can move the channel module to a subdirectory and
  4448. store the news file in another directory.
  4449. The file consists of a list of @dfn{news entries}. Each entry is
  4450. associated with a commit or tag: it describes changes made in this
  4451. commit, possibly in preceding commits as well. Users see entries only
  4452. the first time they obtain the commit the entry refers to.
  4453. The @code{title} field should be a one-line summary while @code{body}
  4454. can be arbitrarily long, and both can contain Texinfo markup
  4455. (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
  4456. a list of language tag/message tuples, which allows @command{guix pull}
  4457. to display news in the language that corresponds to the user's locale.
  4458. If you want to translate news using a gettext-based workflow, you can
  4459. extract translatable strings with @command{xgettext} (@pxref{xgettext
  4460. Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
  4461. you write news entries in English first, the command below creates a PO
  4462. file containing the strings to translate:
  4463. @example
  4464. xgettext -o news.po -l scheme -ken etc/news.txt
  4465. @end example
  4466. To sum up, yes, you could use your channel as a blog. But beware, this
  4467. is @emph{not quite} what your users might expect.
  4468. @c *********************************************************************
  4469. @node Development
  4470. @chapter Development
  4471. @cindex software development
  4472. If you are a software developer, Guix provides tools that you should find
  4473. helpful---independently of the language you're developing in. This is what
  4474. this chapter is about.
  4475. The @command{guix environment} command provides a convenient way to set up
  4476. @dfn{development environments} containing all the dependencies and tools
  4477. necessary to work on the software package of your choice. The @command{guix
  4478. pack} command allows you to create @dfn{application bundles} that can be
  4479. easily distributed to users who do not run Guix.
  4480. @menu
  4481. * Invoking guix environment:: Setting up development environments.
  4482. * Invoking guix pack:: Creating software bundles.
  4483. * The GCC toolchain:: Working with languages supported by GCC.
  4484. * Invoking guix git authenticate:: Authenticating Git repositories.
  4485. @end menu
  4486. @node Invoking guix environment
  4487. @section Invoking @command{guix environment}
  4488. @cindex reproducible build environments
  4489. @cindex development environments
  4490. @cindex @command{guix environment}
  4491. @cindex environment, package build environment
  4492. The purpose of @command{guix environment} is to assist hackers in
  4493. creating reproducible development environments without polluting their
  4494. package profile. The @command{guix environment} tool takes one or more
  4495. packages, builds all of their inputs, and creates a shell
  4496. environment to use them.
  4497. The general syntax is:
  4498. @example
  4499. guix environment @var{options} @var{package}@dots{}
  4500. @end example
  4501. The following example spawns a new shell set up for the development of
  4502. GNU@tie{}Guile:
  4503. @example
  4504. guix environment guile
  4505. @end example
  4506. If the needed dependencies are not built yet, @command{guix environment}
  4507. automatically builds them. The environment of the new shell is an
  4508. augmented version of the environment that @command{guix environment} was
  4509. run in. It contains the necessary search paths for building the given
  4510. package added to the existing environment variables. To create
  4511. a ``pure'' environment, in which the original environment variables have
  4512. been unset, use the @option{--pure} option@footnote{Users sometimes
  4513. wrongfully augment environment variables such as @env{PATH} in their
  4514. @file{~/.bashrc} file. As a consequence, when @command{guix
  4515. environment} launches it, Bash may read @file{~/.bashrc}, thereby
  4516. introducing ``impurities'' in these environment variables. It is an
  4517. error to define such environment variables in @file{.bashrc}; instead,
  4518. they should be defined in @file{.bash_profile}, which is sourced only by
  4519. log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
  4520. Manual}, for details on Bash start-up files.}.
  4521. Exiting from a Guix environment is the same as exiting from the shell,
  4522. and will place the user back in the old environment before @command{guix
  4523. environment} was invoked. The next garbage collection (@pxref{Invoking
  4524. guix gc}) will clean up packages that were installed from within the
  4525. environment and are no longer used outside of it.
  4526. @vindex GUIX_ENVIRONMENT
  4527. @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
  4528. variable in the shell it spawns; its value is the file name of the
  4529. profile of this environment. This allows users to, say, define a
  4530. specific prompt for development environments in their @file{.bashrc}
  4531. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4532. @example
  4533. if [ -n "$GUIX_ENVIRONMENT" ]
  4534. then
  4535. export PS1="\u@@\h \w [dev]\$ "
  4536. fi
  4537. @end example
  4538. @noindent
  4539. ...@: or to browse the profile:
  4540. @example
  4541. $ ls "$GUIX_ENVIRONMENT/bin"
  4542. @end example
  4543. Additionally, more than one package may be specified, in which case the
  4544. union of the inputs for the given packages are used. For example, the
  4545. command below spawns a shell where all of the dependencies of both Guile
  4546. and Emacs are available:
  4547. @example
  4548. guix environment guile emacs
  4549. @end example
  4550. Sometimes an interactive shell session is not desired. An arbitrary
  4551. command may be invoked by placing the @code{--} token to separate the
  4552. command from the rest of the arguments:
  4553. @example
  4554. guix environment guile -- make -j4
  4555. @end example
  4556. In other situations, it is more convenient to specify the list of
  4557. packages needed in the environment. For example, the following command
  4558. runs @command{python} from an environment containing Python@tie{}2.7 and
  4559. NumPy:
  4560. @example
  4561. guix environment --ad-hoc python2-numpy python-2.7 -- python
  4562. @end example
  4563. Furthermore, one might want the dependencies of a package and also some
  4564. additional packages that are not build-time or runtime dependencies, but
  4565. are useful when developing nonetheless. Because of this, the
  4566. @option{--ad-hoc} flag is positional. Packages appearing before
  4567. @option{--ad-hoc} are interpreted as packages whose dependencies will be
  4568. added to the environment. Packages appearing after are interpreted as
  4569. packages that will be added to the environment directly. For example,
  4570. the following command creates a Guix development environment that
  4571. additionally includes Git and strace:
  4572. @example
  4573. guix environment --pure guix --ad-hoc git strace
  4574. @end example
  4575. @cindex container
  4576. Sometimes it is desirable to isolate the environment as much as
  4577. possible, for maximal purity and reproducibility. In particular, when
  4578. using Guix on a host distro that is not Guix System, it is desirable to
  4579. prevent access to @file{/usr/bin} and other system-wide resources from
  4580. the development environment. For example, the following command spawns
  4581. a Guile REPL in a ``container'' where only the store and the current
  4582. working directory are mounted:
  4583. @example
  4584. guix environment --ad-hoc --container guile -- guile
  4585. @end example
  4586. @quotation Note
  4587. The @option{--container} option requires Linux-libre 3.19 or newer.
  4588. @end quotation
  4589. @cindex certificates
  4590. Another typical use case for containers is to run security-sensitive
  4591. applications such as a web browser. To run Eolie, we must expose and
  4592. share some files and directories; we include @code{nss-certs} and expose
  4593. @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
  4594. @env{DISPLAY} environment variable since containerized graphical
  4595. applications won't display without it.
  4596. @example
  4597. guix environment --preserve='^DISPLAY$' --container --network \
  4598. --expose=/etc/machine-id \
  4599. --expose=/etc/ssl/certs/ \
  4600. --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
  4601. --ad-hoc eolie nss-certs dbus -- eolie
  4602. @end example
  4603. The available options are summarized below.
  4604. @table @code
  4605. @item --root=@var{file}
  4606. @itemx -r @var{file}
  4607. @cindex persistent environment
  4608. @cindex garbage collector root, for environments
  4609. Make @var{file} a symlink to the profile for this environment, and
  4610. register it as a garbage collector root.
  4611. This is useful if you want to protect your environment from garbage
  4612. collection, to make it ``persistent''.
  4613. When this option is omitted, the environment is protected from garbage
  4614. collection only for the duration of the @command{guix environment}
  4615. session. This means that next time you recreate the same environment,
  4616. you could have to rebuild or re-download packages. @xref{Invoking guix
  4617. gc}, for more on GC roots.
  4618. @item --expression=@var{expr}
  4619. @itemx -e @var{expr}
  4620. Create an environment for the package or list of packages that
  4621. @var{expr} evaluates to.
  4622. For example, running:
  4623. @example
  4624. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  4625. @end example
  4626. starts a shell with the environment for this specific variant of the
  4627. PETSc package.
  4628. Running:
  4629. @example
  4630. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  4631. @end example
  4632. starts a shell with all the base system packages available.
  4633. The above commands only use the default output of the given packages.
  4634. To select other outputs, two element tuples can be specified:
  4635. @example
  4636. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  4637. @end example
  4638. @item --load=@var{file}
  4639. @itemx -l @var{file}
  4640. Create an environment for the package or list of packages that the code
  4641. within @var{file} evaluates to.
  4642. As an example, @var{file} might contain a definition like this
  4643. (@pxref{Defining Packages}):
  4644. @lisp
  4645. @verbatiminclude environment-gdb.scm
  4646. @end lisp
  4647. @item --manifest=@var{file}
  4648. @itemx -m @var{file}
  4649. Create an environment for the packages contained in the manifest object
  4650. returned by the Scheme code in @var{file}. This option can be repeated
  4651. several times, in which case the manifests are concatenated.
  4652. This is similar to the same-named option in @command{guix package}
  4653. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  4654. manifest files.
  4655. @item --ad-hoc
  4656. Include all specified packages in the resulting environment, as if an
  4657. @i{ad hoc} package were defined with them as inputs. This option is
  4658. useful for quickly creating an environment without having to write a
  4659. package expression to contain the desired inputs.
  4660. For instance, the command:
  4661. @example
  4662. guix environment --ad-hoc guile guile-sdl -- guile
  4663. @end example
  4664. runs @command{guile} in an environment where Guile and Guile-SDL are
  4665. available.
  4666. Note that this example implicitly asks for the default output of
  4667. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  4668. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  4669. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  4670. This option may be composed with the default behavior of @command{guix
  4671. environment}. Packages appearing before @option{--ad-hoc} are
  4672. interpreted as packages whose dependencies will be added to the
  4673. environment, the default behavior. Packages appearing after are
  4674. interpreted as packages that will be added to the environment directly.
  4675. @item --pure
  4676. Unset existing environment variables when building the new environment, except
  4677. those specified with @option{--preserve} (see below). This has the effect of
  4678. creating an environment in which search paths only contain package inputs.
  4679. @item --preserve=@var{regexp}
  4680. @itemx -E @var{regexp}
  4681. When used alongside @option{--pure}, preserve the environment variables
  4682. matching @var{regexp}---in other words, put them on a ``white list'' of
  4683. environment variables that must be preserved. This option can be repeated
  4684. several times.
  4685. @example
  4686. guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
  4687. -- mpirun @dots{}
  4688. @end example
  4689. This example runs @command{mpirun} in a context where the only environment
  4690. variables defined are @env{PATH}, environment variables whose name starts
  4691. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  4692. @env{USER}, etc.).
  4693. @item --search-paths
  4694. Display the environment variable definitions that make up the
  4695. environment.
  4696. @item --system=@var{system}
  4697. @itemx -s @var{system}
  4698. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  4699. @item --container
  4700. @itemx -C
  4701. @cindex container
  4702. Run @var{command} within an isolated container. The current working
  4703. directory outside the container is mapped inside the container.
  4704. Additionally, unless overridden with @option{--user}, a dummy home
  4705. directory is created that matches the current user's home directory, and
  4706. @file{/etc/passwd} is configured accordingly.
  4707. The spawned process runs as the current user outside the container. Inside
  4708. the container, it has the same UID and GID as the current user, unless
  4709. @option{--user} is passed (see below).
  4710. @item --network
  4711. @itemx -N
  4712. For containers, share the network namespace with the host system.
  4713. Containers created without this flag only have access to the loopback
  4714. device.
  4715. @item --link-profile
  4716. @itemx -P
  4717. For containers, link the environment profile to @file{~/.guix-profile}
  4718. within the container and set @code{GUIX_ENVIRONMENT} to that.
  4719. This is equivalent to making @file{~/.guix-profile} a symlink to the
  4720. actual profile within the container.
  4721. Linking will fail and abort the environment if the directory already
  4722. exists, which will certainly be the case if @command{guix environment}
  4723. was invoked in the user's home directory.
  4724. Certain packages are configured to look in @file{~/.guix-profile} for
  4725. configuration files and data;@footnote{For example, the
  4726. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  4727. for additional fonts.} @option{--link-profile} allows these programs to
  4728. behave as expected within the environment.
  4729. @item --user=@var{user}
  4730. @itemx -u @var{user}
  4731. For containers, use the username @var{user} in place of the current
  4732. user. The generated @file{/etc/passwd} entry within the container will
  4733. contain the name @var{user}, the home directory will be
  4734. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  4735. the UID and GID inside the container are 1000. @var{user}
  4736. need not exist on the system.
  4737. Additionally, any shared or exposed path (see @option{--share} and
  4738. @option{--expose} respectively) whose target is within the current user's
  4739. home directory will be remapped relative to @file{/home/USER}; this
  4740. includes the automatic mapping of the current working directory.
  4741. @example
  4742. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  4743. cd $HOME/wd
  4744. guix environment --container --user=foo \
  4745. --expose=$HOME/test \
  4746. --expose=/tmp/target=$HOME/target
  4747. @end example
  4748. While this will limit the leaking of user identity through home paths
  4749. and each of the user fields, this is only one useful component of a
  4750. broader privacy/anonymity solution---not one in and of itself.
  4751. @item --no-cwd
  4752. For containers, the default behavior is to share the current working
  4753. directory with the isolated container and immediately change to that
  4754. directory within the container. If this is undesirable,
  4755. @option{--no-cwd} will cause the current working directory to @emph{not}
  4756. be automatically shared and will change to the user's home directory
  4757. within the container instead. See also @option{--user}.
  4758. @item --expose=@var{source}[=@var{target}]
  4759. @itemx --share=@var{source}[=@var{target}]
  4760. For containers, @option{--expose} (resp. @option{--share}) exposes the
  4761. file system @var{source} from the host system as the read-only
  4762. (resp. writable) file system @var{target} within the container. If
  4763. @var{target} is not specified, @var{source} is used as the target mount
  4764. point in the container.
  4765. The example below spawns a Guile REPL in a container in which the user's
  4766. home directory is accessible read-only via the @file{/exchange}
  4767. directory:
  4768. @example
  4769. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  4770. @end example
  4771. @end table
  4772. @command{guix environment}
  4773. also supports all of the common build options that @command{guix
  4774. build} supports (@pxref{Common Build Options}) as well as package
  4775. transformation options (@pxref{Package Transformation Options}).
  4776. @node Invoking guix pack
  4777. @section Invoking @command{guix pack}
  4778. Occasionally you want to pass software to people who are not (yet!)
  4779. lucky enough to be using Guix. You'd tell them to run @command{guix
  4780. package -i @var{something}}, but that's not possible in this case. This
  4781. is where @command{guix pack} comes in.
  4782. @quotation Note
  4783. If you are looking for ways to exchange binaries among machines that
  4784. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  4785. publish}, and @ref{Invoking guix archive}.
  4786. @end quotation
  4787. @cindex pack
  4788. @cindex bundle
  4789. @cindex application bundle
  4790. @cindex software bundle
  4791. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  4792. @dfn{software bundle}: it creates a tarball or some other archive
  4793. containing the binaries of the software you're interested in, and all
  4794. its dependencies. The resulting archive can be used on any machine that
  4795. does not have Guix, and people can run the exact same binaries as those
  4796. you have with Guix. The pack itself is created in a bit-reproducible
  4797. fashion, so anyone can verify that it really contains the build results
  4798. that you pretend to be shipping.
  4799. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  4800. their dependencies, you can run:
  4801. @example
  4802. $ guix pack guile emacs geiser
  4803. @dots{}
  4804. /gnu/store/@dots{}-pack.tar.gz
  4805. @end example
  4806. The result here is a tarball containing a @file{/gnu/store} directory
  4807. with all the relevant packages. The resulting tarball contains a
  4808. @dfn{profile} with the three packages of interest; the profile is the
  4809. same as would be created by @command{guix package -i}. It is this
  4810. mechanism that is used to create Guix's own standalone binary tarball
  4811. (@pxref{Binary Installation}).
  4812. Users of this pack would have to run
  4813. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  4814. find inconvenient. To work around it, you can create, say, a
  4815. @file{/opt/gnu/bin} symlink to the profile:
  4816. @example
  4817. guix pack -S /opt/gnu/bin=bin guile emacs geiser
  4818. @end example
  4819. @noindent
  4820. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  4821. @cindex relocatable binaries, with @command{guix pack}
  4822. What if the recipient of your pack does not have root privileges on
  4823. their machine, and thus cannot unpack it in the root file system? In
  4824. that case, you will want to use the @option{--relocatable} option (see
  4825. below). This option produces @dfn{relocatable binaries}, meaning they
  4826. they can be placed anywhere in the file system hierarchy: in the example
  4827. above, users can unpack your tarball in their home directory and
  4828. directly run @file{./opt/gnu/bin/guile}.
  4829. @cindex Docker, build an image with guix pack
  4830. Alternatively, you can produce a pack in the Docker image format using
  4831. the following command:
  4832. @example
  4833. guix pack -f docker -S /bin=bin guile guile-readline
  4834. @end example
  4835. @noindent
  4836. The result is a tarball that can be passed to the @command{docker load}
  4837. command, followed by @code{docker run}:
  4838. @example
  4839. docker load < @var{file}
  4840. docker run -ti guile-guile-readline /bin/guile
  4841. @end example
  4842. @noindent
  4843. where @var{file} is the image returned by @var{guix pack}, and
  4844. @code{guile-guile-readline} is its ``image tag''. See the
  4845. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  4846. documentation} for more information.
  4847. @cindex Singularity, build an image with guix pack
  4848. @cindex SquashFS, build an image with guix pack
  4849. Yet another option is to produce a SquashFS image with the following
  4850. command:
  4851. @example
  4852. guix pack -f squashfs bash guile emacs geiser
  4853. @end example
  4854. @noindent
  4855. The result is a SquashFS file system image that can either be mounted or
  4856. directly be used as a file system container image with the
  4857. @uref{https://www.sylabs.io/docs/, Singularity container execution
  4858. environment}, using commands like @command{singularity shell} or
  4859. @command{singularity exec}.
  4860. Several command-line options allow you to customize your pack:
  4861. @table @code
  4862. @item --format=@var{format}
  4863. @itemx -f @var{format}
  4864. Produce a pack in the given @var{format}.
  4865. The available formats are:
  4866. @table @code
  4867. @item tarball
  4868. This is the default format. It produces a tarball containing all the
  4869. specified binaries and symlinks.
  4870. @item docker
  4871. This produces a tarball that follows the
  4872. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  4873. Docker Image Specification}. The ``repository name'' as it appears in
  4874. the output of the @command{docker images} command is computed from
  4875. package names passed on the command line or in the manifest file.
  4876. @item squashfs
  4877. This produces a SquashFS image containing all the specified binaries and
  4878. symlinks, as well as empty mount points for virtual file systems like
  4879. procfs.
  4880. @quotation Note
  4881. Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
  4882. For that reason, @command{guix pack -f squashfs} always implies @code{-S
  4883. /bin=bin}. Thus, your @command{guix pack} invocation must always start
  4884. with something like:
  4885. @example
  4886. guix pack -f squashfs bash @dots{}
  4887. @end example
  4888. If you forget the @code{bash} (or similar) package, @command{singularity
  4889. run} and @command{singularity exec} will fail with an unhelpful ``no
  4890. such file or directory'' message.
  4891. @end quotation
  4892. @end table
  4893. @cindex relocatable binaries
  4894. @item --relocatable
  4895. @itemx -R
  4896. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  4897. anywhere in the file system hierarchy and run from there.
  4898. When this option is passed once, the resulting binaries require support for
  4899. @dfn{user namespaces} in the kernel Linux; when passed
  4900. @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
  4901. PRoot support, can be thought of as the abbreviation of ``Really
  4902. Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
  4903. other techniques if user namespaces are unavailable, and essentially
  4904. work anywhere---see below for the implications.
  4905. For example, if you create a pack containing Bash with:
  4906. @example
  4907. guix pack -RR -S /mybin=bin bash
  4908. @end example
  4909. @noindent
  4910. ...@: you can copy that pack to a machine that lacks Guix, and from your
  4911. home directory as a normal user, run:
  4912. @example
  4913. tar xf pack.tar.gz
  4914. ./mybin/sh
  4915. @end example
  4916. @noindent
  4917. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  4918. @file{/gnu/store} shows up and contains all the dependencies of
  4919. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  4920. altogether! That is probably the simplest way to deploy Guix-built
  4921. software on a non-Guix machine.
  4922. @quotation Note
  4923. By default, relocatable binaries rely on the @dfn{user namespace} feature of
  4924. the kernel Linux, which allows unprivileged users to mount or change root.
  4925. Old versions of Linux did not support it, and some GNU/Linux distributions
  4926. turn it off.
  4927. To produce relocatable binaries that work even in the absence of user
  4928. namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
  4929. case, binaries will try user namespace support and fall back to another
  4930. @dfn{execution engine} if user namespaces are not supported. The
  4931. following execution engines are supported:
  4932. @table @code
  4933. @item default
  4934. Try user namespaces and fall back to PRoot if user namespaces are not
  4935. supported (see below).
  4936. @item performance
  4937. Try user namespaces and fall back to Fakechroot if user namespaces are
  4938. not supported (see below).
  4939. @item userns
  4940. Run the program through user namespaces and abort if they are not
  4941. supported.
  4942. @item proot
  4943. Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
  4944. provides the necessary
  4945. support for file system virtualization. It achieves that by using the
  4946. @code{ptrace} system call on the running program. This approach has the
  4947. advantage to work without requiring special kernel support, but it incurs
  4948. run-time overhead every time a system call is made.
  4949. @item fakechroot
  4950. Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
  4951. Fakechroot} virtualizes file system accesses by intercepting calls to C
  4952. library functions such as @code{open}, @code{stat}, @code{exec}, and so
  4953. on. Unlike PRoot, it incurs very little overhead. However, it does not
  4954. always work: for example, some file system accesses made from within the
  4955. C library are not intercepted, and file system accesses made @i{via}
  4956. direct syscalls are not intercepted either, leading to erratic behavior.
  4957. @end table
  4958. @vindex GUIX_EXECUTION_ENGINE
  4959. When running a wrapped program, you can explicitly request one of the
  4960. execution engines listed above by setting the
  4961. @env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
  4962. @end quotation
  4963. @cindex entry point, for Docker images
  4964. @item --entry-point=@var{command}
  4965. Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
  4966. format supports it---currently @code{docker} and @code{squashfs} (Singularity)
  4967. support it. @var{command} must be relative to the profile contained in the
  4968. pack.
  4969. The entry point specifies the command that tools like @code{docker run} or
  4970. @code{singularity run} automatically start by default. For example, you can
  4971. do:
  4972. @example
  4973. guix pack -f docker --entry-point=bin/guile guile
  4974. @end example
  4975. The resulting pack can easily be loaded and @code{docker run} with no extra
  4976. arguments will spawn @code{bin/guile}:
  4977. @example
  4978. docker load -i pack.tar.gz
  4979. docker run @var{image-id}
  4980. @end example
  4981. @item --expression=@var{expr}
  4982. @itemx -e @var{expr}
  4983. Consider the package @var{expr} evaluates to.
  4984. This has the same purpose as the same-named option in @command{guix
  4985. build} (@pxref{Additional Build Options, @option{--expression} in
  4986. @command{guix build}}).
  4987. @item --manifest=@var{file}
  4988. @itemx -m @var{file}
  4989. Use the packages contained in the manifest object returned by the Scheme
  4990. code in @var{file}. This option can be repeated several times, in which
  4991. case the manifests are concatenated.
  4992. This has a similar purpose as the same-named option in @command{guix
  4993. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  4994. same manifest files. It allows you to define a collection of packages
  4995. once and use it both for creating profiles and for creating archives
  4996. for use on machines that do not have Guix installed. Note that you can
  4997. specify @emph{either} a manifest file @emph{or} a list of packages,
  4998. but not both.
  4999. @item --system=@var{system}
  5000. @itemx -s @var{system}
  5001. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  5002. the system type of the build host.
  5003. @item --target=@var{triplet}
  5004. @cindex cross-compilation
  5005. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  5006. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  5007. configuration triplets,, autoconf, Autoconf}).
  5008. @item --compression=@var{tool}
  5009. @itemx -C @var{tool}
  5010. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  5011. @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
  5012. compression.
  5013. @item --symlink=@var{spec}
  5014. @itemx -S @var{spec}
  5015. Add the symlinks specified by @var{spec} to the pack. This option can
  5016. appear several times.
  5017. @var{spec} has the form @code{@var{source}=@var{target}}, where
  5018. @var{source} is the symlink that will be created and @var{target} is the
  5019. symlink target.
  5020. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  5021. symlink pointing to the @file{bin} sub-directory of the profile.
  5022. @item --save-provenance
  5023. Save provenance information for the packages passed on the command line.
  5024. Provenance information includes the URL and commit of the channels in use
  5025. (@pxref{Channels}).
  5026. Provenance information is saved in the
  5027. @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
  5028. usual package metadata---the name and version of each package, their
  5029. propagated inputs, and so on. It is useful information to the recipient of
  5030. the pack, who then knows how the pack was (supposedly) obtained.
  5031. This option is not enabled by default because, like timestamps, provenance
  5032. information contributes nothing to the build process. In other words, there
  5033. is an infinity of channel URLs and commit IDs that can lead to the same pack.
  5034. Recording such ``silent'' metadata in the output thus potentially breaks the
  5035. source-to-binary bitwise reproducibility property.
  5036. @item --root=@var{file}
  5037. @itemx -r @var{file}
  5038. @cindex garbage collector root, for packs
  5039. Make @var{file} a symlink to the resulting pack, and register it as a garbage
  5040. collector root.
  5041. @item --localstatedir
  5042. @itemx --profile-name=@var{name}
  5043. Include the ``local state directory'', @file{/var/guix}, in the resulting
  5044. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  5045. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  5046. @file{~root/.guix-profile}.
  5047. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  5048. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  5049. the pack means that the store is ``complete'' and manageable by Guix;
  5050. not providing it pack means that the store is ``dead'': items cannot be
  5051. added to it or removed from it after extraction of the pack.
  5052. One use case for this is the Guix self-contained binary tarball
  5053. (@pxref{Binary Installation}).
  5054. @item --derivation
  5055. @itemx -d
  5056. Print the name of the derivation that builds the pack.
  5057. @item --bootstrap
  5058. Use the bootstrap binaries to build the pack. This option is only
  5059. useful to Guix developers.
  5060. @end table
  5061. In addition, @command{guix pack} supports all the common build options
  5062. (@pxref{Common Build Options}) and all the package transformation
  5063. options (@pxref{Package Transformation Options}).
  5064. @node The GCC toolchain
  5065. @section The GCC toolchain
  5066. @cindex GCC
  5067. @cindex ld-wrapper
  5068. @cindex linker wrapper
  5069. @cindex toolchain, for C development
  5070. @cindex toolchain, for Fortran development
  5071. If you need a complete toolchain for compiling and linking C or C++
  5072. source code, use the @code{gcc-toolchain} package. This package
  5073. provides a complete GCC toolchain for C/C++ development, including GCC
  5074. itself, the GNU C Library (headers and binaries, plus debugging symbols
  5075. in the @code{debug} output), Binutils, and a linker wrapper.
  5076. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  5077. passed to the linker, add corresponding @code{-rpath} arguments, and
  5078. invoke the actual linker with this new set of arguments. You can instruct the
  5079. wrapper to refuse to link against libraries not in the store by setting the
  5080. @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
  5081. The package @code{gfortran-toolchain} provides a complete GCC toolchain
  5082. for Fortran development. For other languages, please use
  5083. @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
  5084. @node Invoking guix git authenticate
  5085. @section Invoking @command{guix git authenticate}
  5086. The @command{guix git authenticate} command authenticates a Git checkout
  5087. following the same rule as for channels (@pxref{channel-authentication,
  5088. channel authentication}). That is, starting from a given commit, it
  5089. ensures that all subsequent commits are signed by an OpenPGP key whose
  5090. fingerprint appears in the @file{.guix-authorizations} file of its
  5091. parent commit(s).
  5092. You will find this command useful if you maintain a channel. But in
  5093. fact, this authentication mechanism is useful in a broader context, so
  5094. you might want to use it for Git repositories that have nothing to do
  5095. with Guix.
  5096. The general syntax is:
  5097. @example
  5098. guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
  5099. @end example
  5100. By default, this command authenticates the Git checkout in the current
  5101. directory; it outputs nothing and exits with exit code zero on success
  5102. and non-zero on failure. @var{commit} above denotes the first commit
  5103. where authentication takes place, and @var{signer} is the OpenPGP
  5104. fingerprint of public key used to sign @var{commit}. Together, they
  5105. form a ``channel introduction'' (@pxref{channel-authentication, channel
  5106. introduction}). The options below allow you to fine-tune the process.
  5107. @table @code
  5108. @item --repository=@var{directory}
  5109. @itemx -r @var{directory}
  5110. Open the Git repository in @var{directory} instead of the current
  5111. directory.
  5112. @item --keyring=@var{reference}
  5113. @itemx -k @var{reference}
  5114. Load OpenPGP keyring from @var{reference}, the reference of a branch
  5115. such as @code{origin/keyring} or @code{my-keyring}. The branch must
  5116. contain OpenPGP public keys in @file{.key} files, either in binary form
  5117. or ``ASCII-armored''. By default the keyring is loaded from the branch
  5118. named @code{keyring}.
  5119. @item --stats
  5120. Display commit signing statistics upon completion.
  5121. @item --cache-key=@var{key}
  5122. Previously-authenticated commits are cached in a file under
  5123. @file{~/.cache/guix/authentication}. This option forces the cache to be
  5124. stored in file @var{key} in that directory.
  5125. @item --historical-authorizations=@var{file}
  5126. By default, any commit whose parent commit(s) lack the
  5127. @file{.guix-authorizations} file is considered inauthentic. In
  5128. contrast, this option considers the authorizations in @var{file} for any
  5129. commit that lacks @file{.guix-authorizations}. The format of @var{file}
  5130. is the same as that of @file{.guix-authorizations}
  5131. (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
  5132. @end table
  5133. @c *********************************************************************
  5134. @node Programming Interface
  5135. @chapter Programming Interface
  5136. GNU Guix provides several Scheme programming interfaces (APIs) to
  5137. define, build, and query packages. The first interface allows users to
  5138. write high-level package definitions. These definitions refer to
  5139. familiar packaging concepts, such as the name and version of a package,
  5140. its build system, and its dependencies. These definitions can then be
  5141. turned into concrete build actions.
  5142. Build actions are performed by the Guix daemon, on behalf of users. In a
  5143. standard setup, the daemon has write access to the store---the
  5144. @file{/gnu/store} directory---whereas users do not. The recommended
  5145. setup also has the daemon perform builds in chroots, under specific
  5146. build users, to minimize interference with the rest of the system.
  5147. @cindex derivation
  5148. Lower-level APIs are available to interact with the daemon and the
  5149. store. To instruct the daemon to perform a build action, users actually
  5150. provide it with a @dfn{derivation}. A derivation is a low-level
  5151. representation of the build actions to be taken, and the environment in
  5152. which they should occur---derivations are to package definitions what
  5153. assembly is to C programs. The term ``derivation'' comes from the fact
  5154. that build results @emph{derive} from them.
  5155. This chapter describes all these APIs in turn, starting from high-level
  5156. package definitions.
  5157. @menu
  5158. * Package Modules:: Packages from the programmer's viewpoint.
  5159. * Defining Packages:: Defining new packages.
  5160. * Defining Package Variants:: Customizing packages.
  5161. * Build Systems:: Specifying how packages are built.
  5162. * Build Phases:: Phases of the build process of a package.
  5163. * Build Utilities:: Helpers for your package definitions and more.
  5164. * The Store:: Manipulating the package store.
  5165. * Derivations:: Low-level interface to package derivations.
  5166. * The Store Monad:: Purely functional interface to the store.
  5167. * G-Expressions:: Manipulating build expressions.
  5168. * Invoking guix repl:: Programming Guix in Guile
  5169. @end menu
  5170. @node Package Modules
  5171. @section Package Modules
  5172. From a programming viewpoint, the package definitions of the
  5173. GNU distribution are provided by Guile modules in the @code{(gnu packages
  5174. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  5175. packages @dots{})} module name space are not necessarily ``GNU
  5176. packages''. This module naming scheme follows the usual Guile module
  5177. naming convention: @code{gnu} means that these modules are distributed
  5178. as part of the GNU system, and @code{packages} identifies modules that
  5179. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  5180. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  5181. module exports a variable named @code{emacs}, which is bound to a
  5182. @code{<package>} object (@pxref{Defining Packages}).
  5183. The @code{(gnu packages @dots{})} module name space is
  5184. automatically scanned for packages by the command-line tools. For
  5185. instance, when running @code{guix install emacs}, all the @code{(gnu
  5186. packages @dots{})} modules are scanned until one that exports a package
  5187. object whose name is @code{emacs} is found. This package search
  5188. facility is implemented in the @code{(gnu packages)} module.
  5189. @cindex customization, of packages
  5190. @cindex package module search path
  5191. Users can store package definitions in modules with different
  5192. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  5193. name and module name must match. For instance, the @code{(my-packages
  5194. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  5195. relative to the load path specified with @option{--load-path} or
  5196. @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  5197. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  5198. these package definitions visible to the user interfaces:
  5199. @enumerate
  5200. @item
  5201. By adding the directory containing your package modules to the search path
  5202. with the @code{-L} flag of @command{guix package} and other commands
  5203. (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
  5204. environment variable described below.
  5205. @item
  5206. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  5207. pulls from it. A channel is essentially a Git repository containing package
  5208. modules. @xref{Channels}, for more information on how to define and use
  5209. channels.
  5210. @end enumerate
  5211. @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  5212. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  5213. This is a colon-separated list of directories to search for additional
  5214. package modules. Directories listed in this variable take precedence
  5215. over the own modules of the distribution.
  5216. @end defvr
  5217. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  5218. each package is built based solely on other packages in the
  5219. distribution. The root of this dependency graph is a small set of
  5220. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  5221. bootstrap)} module. For more information on bootstrapping,
  5222. @pxref{Bootstrapping}.
  5223. @node Defining Packages
  5224. @section Defining Packages
  5225. The high-level interface to package definitions is implemented in the
  5226. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  5227. example, the package definition, or @dfn{recipe}, for the GNU Hello
  5228. package looks like this:
  5229. @lisp
  5230. (define-module (gnu packages hello)
  5231. #:use-module (guix packages)
  5232. #:use-module (guix download)
  5233. #:use-module (guix build-system gnu)
  5234. #:use-module (guix licenses)
  5235. #:use-module (gnu packages gawk))
  5236. (define-public hello
  5237. (package
  5238. (name "hello")
  5239. (version "2.10")
  5240. (source (origin
  5241. (method url-fetch)
  5242. (uri (string-append "mirror://gnu/hello/hello-" version
  5243. ".tar.gz"))
  5244. (sha256
  5245. (base32
  5246. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  5247. (build-system gnu-build-system)
  5248. (arguments '(#:configure-flags '("--enable-silent-rules")))
  5249. (inputs `(("gawk" ,gawk)))
  5250. (synopsis "Hello, GNU world: An example GNU package")
  5251. (description "Guess what GNU Hello prints!")
  5252. (home-page "https://www.gnu.org/software/hello/")
  5253. (license gpl3+)))
  5254. @end lisp
  5255. @noindent
  5256. Without being a Scheme expert, the reader may have guessed the meaning
  5257. of the various fields here. This expression binds the variable
  5258. @code{hello} to a @code{<package>} object, which is essentially a record
  5259. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  5260. This package object can be inspected using procedures found in the
  5261. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  5262. returns---surprise!---@code{"hello"}.
  5263. With luck, you may be able to import part or all of the definition of
  5264. the package you are interested in from another repository, using the
  5265. @code{guix import} command (@pxref{Invoking guix import}).
  5266. In the example above, @code{hello} is defined in a module of its own,
  5267. @code{(gnu packages hello)}. Technically, this is not strictly
  5268. necessary, but it is convenient to do so: all the packages defined in
  5269. modules under @code{(gnu packages @dots{})} are automatically known to
  5270. the command-line tools (@pxref{Package Modules}).
  5271. There are a few points worth noting in the above package definition:
  5272. @itemize
  5273. @item
  5274. The @code{source} field of the package is an @code{<origin>} object
  5275. (@pxref{origin Reference}, for the complete reference).
  5276. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  5277. meaning that the source is a file to be downloaded over FTP or HTTP.
  5278. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  5279. the GNU mirrors defined in @code{(guix download)}.
  5280. The @code{sha256} field specifies the expected SHA256 hash of the file
  5281. being downloaded. It is mandatory, and allows Guix to check the
  5282. integrity of the file. The @code{(base32 @dots{})} form introduces the
  5283. base32 representation of the hash. You can obtain this information with
  5284. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  5285. hash} (@pxref{Invoking guix hash}).
  5286. @cindex patches
  5287. When needed, the @code{origin} form can also have a @code{patches} field
  5288. listing patches to be applied, and a @code{snippet} field giving a
  5289. Scheme expression to modify the source code.
  5290. @item
  5291. @cindex GNU Build System
  5292. The @code{build-system} field specifies the procedure to build the
  5293. package (@pxref{Build Systems}). Here, @code{gnu-build-system}
  5294. represents the familiar GNU Build System, where packages may be
  5295. configured, built, and installed with the usual @code{./configure &&
  5296. make && make check && make install} command sequence.
  5297. When you start packaging non-trivial software, you may need tools to
  5298. manipulate those build phases, manipulate files, and so on. @xref{Build
  5299. Utilities}, for more on this.
  5300. @item
  5301. The @code{arguments} field specifies options for the build system
  5302. (@pxref{Build Systems}). Here it is interpreted by
  5303. @code{gnu-build-system} as a request run @file{configure} with the
  5304. @option{--enable-silent-rules} flag.
  5305. @cindex quote
  5306. @cindex quoting
  5307. @findex '
  5308. @findex quote
  5309. What about these quote (@code{'}) characters? They are Scheme syntax to
  5310. introduce a literal list; @code{'} is synonymous with @code{quote}.
  5311. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  5312. for details. Here the value of the @code{arguments} field is a list of
  5313. arguments passed to the build system down the road, as with @code{apply}
  5314. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  5315. Manual}).
  5316. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  5317. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  5318. @code{#:configure-flags} is a keyword used to pass a keyword argument
  5319. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  5320. Reference Manual}).
  5321. @item
  5322. The @code{inputs} field specifies inputs to the build process---i.e.,
  5323. build-time or run-time dependencies of the package. Here, we define an
  5324. input called @code{"gawk"} whose value is that of the @code{gawk}
  5325. variable; @code{gawk} is itself bound to a @code{<package>} object.
  5326. @cindex backquote (quasiquote)
  5327. @findex `
  5328. @findex quasiquote
  5329. @cindex comma (unquote)
  5330. @findex ,
  5331. @findex unquote
  5332. @findex ,@@
  5333. @findex unquote-splicing
  5334. Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
  5335. us to introduce a literal list in the @code{inputs} field, while
  5336. @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
  5337. value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
  5338. Reference Manual}).
  5339. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  5340. be specified as inputs here. Instead, @code{gnu-build-system} takes care
  5341. of ensuring that they are present (@pxref{Build Systems}).
  5342. However, any other dependencies need to be specified in the
  5343. @code{inputs} field. Any dependency not specified here will simply be
  5344. unavailable to the build process, possibly leading to a build failure.
  5345. @end itemize
  5346. @xref{package Reference}, for a full description of possible fields.
  5347. Once a package definition is in place, the
  5348. package may actually be built using the @code{guix build} command-line
  5349. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  5350. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  5351. package definition using the @command{guix edit} command
  5352. (@pxref{Invoking guix edit}).
  5353. @xref{Packaging Guidelines}, for
  5354. more information on how to test package definitions, and
  5355. @ref{Invoking guix lint}, for information on how to check a definition
  5356. for style conformance.
  5357. @vindex GUIX_PACKAGE_PATH
  5358. Lastly, @pxref{Channels}, for information
  5359. on how to extend the distribution by adding your own package definitions
  5360. in a ``channel''.
  5361. Finally, updating the package definition to a new upstream version
  5362. can be partly automated by the @command{guix refresh} command
  5363. (@pxref{Invoking guix refresh}).
  5364. Behind the scenes, a derivation corresponding to the @code{<package>}
  5365. object is first computed by the @code{package-derivation} procedure.
  5366. That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
  5367. The build actions it prescribes may then be realized by using the
  5368. @code{build-derivations} procedure (@pxref{The Store}).
  5369. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  5370. Return the @code{<derivation>} object of @var{package} for @var{system}
  5371. (@pxref{Derivations}).
  5372. @var{package} must be a valid @code{<package>} object, and @var{system}
  5373. must be a string denoting the target system type---e.g.,
  5374. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  5375. must be a connection to the daemon, which operates on the store
  5376. (@pxref{The Store}).
  5377. @end deffn
  5378. @noindent
  5379. @cindex cross-compilation
  5380. Similarly, it is possible to compute a derivation that cross-builds a
  5381. package for some other system:
  5382. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  5383. @var{package} @var{target} [@var{system}]
  5384. Return the @code{<derivation>} object of @var{package} cross-built from
  5385. @var{system} to @var{target}.
  5386. @var{target} must be a valid GNU triplet denoting the target hardware
  5387. and operating system, such as @code{"aarch64-linux-gnu"}
  5388. (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
  5389. @end deffn
  5390. Once you have package definitions, you can easily define @emph{variants}
  5391. of those packages. @xref{Defining Package Variants}, for more on that.
  5392. @menu
  5393. * package Reference:: The package data type.
  5394. * origin Reference:: The origin data type.
  5395. @end menu
  5396. @node package Reference
  5397. @subsection @code{package} Reference
  5398. This section summarizes all the options available in @code{package}
  5399. declarations (@pxref{Defining Packages}).
  5400. @deftp {Data Type} package
  5401. This is the data type representing a package recipe.
  5402. @table @asis
  5403. @item @code{name}
  5404. The name of the package, as a string.
  5405. @item @code{version}
  5406. The version of the package, as a string.
  5407. @item @code{source}
  5408. An object telling how the source code for the package should be
  5409. acquired. Most of the time, this is an @code{origin} object, which
  5410. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  5411. can also be any other ``file-like'' object such as a @code{local-file},
  5412. which denotes a file from the local file system (@pxref{G-Expressions,
  5413. @code{local-file}}).
  5414. @item @code{build-system}
  5415. The build system that should be used to build the package (@pxref{Build
  5416. Systems}).
  5417. @item @code{arguments} (default: @code{'()})
  5418. The arguments that should be passed to the build system. This is a
  5419. list, typically containing sequential keyword-value pairs.
  5420. @item @code{inputs} (default: @code{'()})
  5421. @itemx @code{native-inputs} (default: @code{'()})
  5422. @itemx @code{propagated-inputs} (default: @code{'()})
  5423. @cindex inputs, of packages
  5424. These fields list dependencies of the package. Each one is a list of
  5425. tuples, where each tuple has a label for the input (a string) as its
  5426. first element, a package, origin, or derivation as its second element,
  5427. and optionally the name of the output thereof that should be used, which
  5428. defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
  5429. more on package outputs). For example, the list below specifies three
  5430. inputs:
  5431. @lisp
  5432. `(("libffi" ,libffi)
  5433. ("libunistring" ,libunistring)
  5434. ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
  5435. @end lisp
  5436. @cindex cross compilation, package dependencies
  5437. The distinction between @code{native-inputs} and @code{inputs} is
  5438. necessary when considering cross-compilation. When cross-compiling,
  5439. dependencies listed in @code{inputs} are built for the @emph{target}
  5440. architecture; conversely, dependencies listed in @code{native-inputs}
  5441. are built for the architecture of the @emph{build} machine.
  5442. @code{native-inputs} is typically used to list tools needed at
  5443. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  5444. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  5445. this area (@pxref{Invoking guix lint}).
  5446. @anchor{package-propagated-inputs}
  5447. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  5448. specified packages will be automatically installed to profiles
  5449. (@pxref{Features, the role of profiles in Guix}) alongside the package
  5450. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  5451. package}}, for information on how @command{guix package} deals with
  5452. propagated inputs).
  5453. For example this is necessary when packaging a C/C++ library that needs
  5454. headers of another library to compile, or when a pkg-config file refers
  5455. to another one @i{via} its @code{Requires} field.
  5456. Another example where @code{propagated-inputs} is useful is for languages
  5457. that lack a facility to record the run-time search path akin to the
  5458. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  5459. more. When packaging libraries written in those languages, ensure they
  5460. can find library code they depend on at run time by listing run-time
  5461. dependencies in @code{propagated-inputs} rather than @code{inputs}.
  5462. @item @code{outputs} (default: @code{'("out")})
  5463. The list of output names of the package. @xref{Packages with Multiple
  5464. Outputs}, for typical uses of additional outputs.
  5465. @item @code{native-search-paths} (default: @code{'()})
  5466. @itemx @code{search-paths} (default: @code{'()})
  5467. A list of @code{search-path-specification} objects describing
  5468. search-path environment variables honored by the package.
  5469. @item @code{replacement} (default: @code{#f})
  5470. This must be either @code{#f} or a package object that will be used as a
  5471. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  5472. for details.
  5473. @item @code{synopsis}
  5474. A one-line description of the package.
  5475. @item @code{description}
  5476. A more elaborate description of the package.
  5477. @item @code{license}
  5478. @cindex license, of packages
  5479. The license of the package; a value from @code{(guix licenses)},
  5480. or a list of such values.
  5481. @item @code{home-page}
  5482. The URL to the home-page of the package, as a string.
  5483. @item @code{supported-systems} (default: @code{%supported-systems})
  5484. The list of systems supported by the package, as strings of the form
  5485. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  5486. @item @code{location} (default: source location of the @code{package} form)
  5487. The source location of the package. It is useful to override this when
  5488. inheriting from another package, in which case this field is not
  5489. automatically corrected.
  5490. @end table
  5491. @end deftp
  5492. @deffn {Scheme Syntax} this-package
  5493. When used in the @emph{lexical scope} of a package field definition, this
  5494. identifier resolves to the package being defined.
  5495. The example below shows how to add a package as a native input of itself when
  5496. cross-compiling:
  5497. @lisp
  5498. (package
  5499. (name "guile")
  5500. ;; ...
  5501. ;; When cross-compiled, Guile, for example, depends on
  5502. ;; a native version of itself. Add it here.
  5503. (native-inputs (if (%current-target-system)
  5504. `(("self" ,this-package))
  5505. '())))
  5506. @end lisp
  5507. It is an error to refer to @code{this-package} outside a package definition.
  5508. @end deffn
  5509. Because packages are regular Scheme objects that capture a complete
  5510. dependency graph and associated build procedures, it is often useful to
  5511. write procedures that take a package and return a modified version
  5512. thereof according to some parameters. Below are a few examples.
  5513. @cindex tool chain, choosing a package's tool chain
  5514. @deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain}
  5515. Return a variant of @var{package} that uses @var{toolchain} instead of
  5516. the default GNU C/C++ toolchain. @var{toolchain} must be a list of
  5517. inputs (label/package tuples) providing equivalent functionality, such
  5518. as the @code{gcc-toolchain} package.
  5519. The example below returns a variant of the @code{hello} package built
  5520. with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the
  5521. GNU C Library) instead of the default tool chain:
  5522. @lisp
  5523. (let ((toolchain (specification->package "gcc-toolchain@@10")))
  5524. (package-with-c-toolchain hello `(("toolchain" ,toolchain))))
  5525. @end lisp
  5526. The build tool chain is part of the @dfn{implicit inputs} of
  5527. packages---it's usually not listed as part of the various ``inputs''
  5528. fields and is instead pulled in by the build system. Consequently, this
  5529. procedure works by changing the build system of @var{package} so that it
  5530. pulls in @var{toolchain} instead of the defaults. @ref{Build Systems},
  5531. for more on build systems.
  5532. @end deffn
  5533. @node origin Reference
  5534. @subsection @code{origin} Reference
  5535. This section documents @dfn{origins}. An @code{origin} declaration
  5536. specifies data that must be ``produced''---downloaded, usually---and
  5537. whose content hash is known in advance. Origins are primarily used to
  5538. represent the source code of packages (@pxref{Defining Packages}). For
  5539. that reason, the @code{origin} form allows you to declare patches to
  5540. apply to the original source code as well as code snippets to modify it.
  5541. @deftp {Data Type} origin
  5542. This is the data type representing a source code origin.
  5543. @table @asis
  5544. @item @code{uri}
  5545. An object containing the URI of the source. The object type depends on
  5546. the @code{method} (see below). For example, when using the
  5547. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  5548. values are: a URL represented as a string, or a list thereof.
  5549. @cindex fixed-output derivations, for download
  5550. @item @code{method}
  5551. A monadic procedure that handles the given URI@. The procedure must
  5552. accept at least three arguments: the value of the @code{uri} field and
  5553. the hash algorithm and hash value specified by the @code{hash} field.
  5554. It must return a store item or a derivation in the store monad
  5555. (@pxref{The Store Monad}); most methods return a fixed-output derivation
  5556. (@pxref{Derivations}).
  5557. Commonly used methods include @code{url-fetch}, which fetches data from
  5558. a URL, and @code{git-fetch}, which fetches data from a Git repository
  5559. (see below).
  5560. @item @code{sha256}
  5561. A bytevector containing the SHA-256 hash of the source. This is
  5562. equivalent to providing a @code{content-hash} SHA256 object in the
  5563. @code{hash} field described below.
  5564. @item @code{hash}
  5565. The @code{content-hash} object of the source---see below for how to use
  5566. @code{content-hash}.
  5567. You can obtain this information using @code{guix download}
  5568. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  5569. guix hash}).
  5570. @item @code{file-name} (default: @code{#f})
  5571. The file name under which the source code should be saved. When this is
  5572. @code{#f}, a sensible default value will be used in most cases. In case
  5573. the source is fetched from a URL, the file name from the URL will be
  5574. used. For version control checkouts, it is recommended to provide the
  5575. file name explicitly because the default is not very descriptive.
  5576. @item @code{patches} (default: @code{'()})
  5577. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  5578. file-like objects}) pointing to patches to be applied to the source.
  5579. This list of patches must be unconditional. In particular, it cannot
  5580. depend on the value of @code{%current-system} or
  5581. @code{%current-target-system}.
  5582. @item @code{snippet} (default: @code{#f})
  5583. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  5584. in the source directory. This is a convenient way to modify the source,
  5585. sometimes more convenient than a patch.
  5586. @item @code{patch-flags} (default: @code{'("-p1")})
  5587. A list of command-line flags that should be passed to the @code{patch}
  5588. command.
  5589. @item @code{patch-inputs} (default: @code{#f})
  5590. Input packages or derivations to the patching process. When this is
  5591. @code{#f}, the usual set of inputs necessary for patching are provided,
  5592. such as GNU@tie{}Patch.
  5593. @item @code{modules} (default: @code{'()})
  5594. A list of Guile modules that should be loaded during the patching
  5595. process and while running the code in the @code{snippet} field.
  5596. @item @code{patch-guile} (default: @code{#f})
  5597. The Guile package that should be used in the patching process. When
  5598. this is @code{#f}, a sensible default is used.
  5599. @end table
  5600. @end deftp
  5601. @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
  5602. Construct a content hash object for the given @var{algorithm}, and with
  5603. @var{value} as its hash value. When @var{algorithm} is omitted, assume
  5604. it is @code{sha256}.
  5605. @var{value} can be a literal string, in which case it is base32-decoded,
  5606. or it can be a bytevector.
  5607. The following forms are all equivalent:
  5608. @lisp
  5609. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
  5610. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
  5611. sha256)
  5612. (content-hash (base32
  5613. "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
  5614. (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
  5615. sha256)
  5616. @end lisp
  5617. Technically, @code{content-hash} is currently implemented as a macro.
  5618. It performs sanity checks at macro-expansion time, when possible, such
  5619. as ensuring that @var{value} has the right size for @var{algorithm}.
  5620. @end deftp
  5621. As we have seen above, how exactly the data an origin refers to is
  5622. retrieved is determined by its @code{method} field. The @code{(guix
  5623. download)} module provides the most common method, @code{url-fetch},
  5624. described below.
  5625. @deffn {Scheme Procedure} url-fetch @var{url} @var{hash-algo} @var{hash} @
  5626. [name] [#:executable? #f]
  5627. Return a fixed-output derivation that fetches data from @var{url} (a
  5628. string, or a list of strings denoting alternate URLs), which is expected
  5629. to have hash @var{hash} of type @var{hash-algo} (a symbol). By default,
  5630. the file name is the base name of URL; optionally, @var{name} can
  5631. specify a different file name. When @var{executable?} is true, make the
  5632. downloaded file executable.
  5633. When one of the URL starts with @code{mirror://}, then its host part is
  5634. interpreted as the name of a mirror scheme, taken from @file{%mirror-file}.
  5635. Alternatively, when URL starts with @code{file://}, return the
  5636. corresponding file name in the store.
  5637. @end deffn
  5638. Likewise, the @code{(guix git-download)} module defines the
  5639. @code{git-fetch} origin method, which fetches data from a Git version
  5640. control repository, and the @code{git-reference} data type to describe
  5641. the repository and revision to fetch.
  5642. @deffn {Scheme Procedure} git-fetch @var{ref} @var{hash-algo} @var{hash}
  5643. Return a fixed-output derivation that fetches @var{ref}, a
  5644. @code{<git-reference>} object. The output is expected to have recursive
  5645. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  5646. the file name, or a generic name if @code{#f}.
  5647. @end deffn
  5648. @deftp {Data Type} git-reference
  5649. This data type represents a Git reference for @code{git-fetch} to
  5650. retrieve.
  5651. @table @asis
  5652. @item @code{url}
  5653. The URL of the Git repository to clone.
  5654. @item @code{commit}
  5655. This string denotes either the commit to fetch (a hexadecimal string,
  5656. either the full SHA1 commit or a ``short'' commit string; the latter is
  5657. not recommended) or the tag to fetch.
  5658. @item @code{recursive?} (default: @code{#f})
  5659. This Boolean indicates whether to recursively fetch Git sub-modules.
  5660. @end table
  5661. The example below denotes the @code{v2.10} tag of the GNU@tie{}Hello
  5662. repository:
  5663. @lisp
  5664. (git-reference
  5665. (url "https://git.savannah.gnu.org/git/hello.git")
  5666. (commit "v2.10"))
  5667. @end lisp
  5668. This is equivalent to the reference below, which explicitly names the
  5669. commit:
  5670. @lisp
  5671. (git-reference
  5672. (url "https://git.savannah.gnu.org/git/hello.git")
  5673. (commit "dc7dc56a00e48fe6f231a58f6537139fe2908fb9"))
  5674. @end lisp
  5675. @end deftp
  5676. For Mercurial repositories, the module @code{(guix hg-download)} defines
  5677. the @code{hg-fetch} origin method and @code{hg-reference} data type for
  5678. support of the Mercurial version control system.
  5679. @deffn {Scheme Procedure} hg-fetch @var{ref} @var{hash-algo} @var{hash} @
  5680. [name]
  5681. Return a fixed-output derivation that fetches @var{ref}, a
  5682. @code{<hg-reference>} object. The output is expected to have recursive
  5683. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  5684. the file name, or a generic name if @code{#false}.
  5685. @end deffn
  5686. @node Defining Package Variants
  5687. @section Defining Package Variants
  5688. @cindex customizing packages
  5689. @cindex variants, of packages
  5690. One of the nice things with Guix is that, given a package definition,
  5691. you can easily @emph{derive} variants of that package---for a different
  5692. upstream version, with different dependencies, different compilation
  5693. options, and so on. Some of these custom packages can be defined
  5694. straight from the command line (@pxref{Package Transformation Options}).
  5695. This section describes how to define package variants in code. This can
  5696. be useful in ``manifests'' (@pxref{profile-manifest,
  5697. @option{--manifest}}) and in your own package collection
  5698. (@pxref{Creating a Channel}), among others!
  5699. @cindex inherit, for package definitions
  5700. As discussed earlier, packages are first-class objects in the Scheme
  5701. language. The @code{(guix packages)} module provides the @code{package}
  5702. construct to define new package objects (@pxref{package Reference}).
  5703. The easiest way to define a package variant is using the @code{inherit}
  5704. keyword together with @code{package}. This allows you to inherit from a
  5705. package definition while overriding the fields you want.
  5706. For example, given the @code{hello} variable, which contains a
  5707. definition for the current version of GNU@tie{}Hello, here's how you
  5708. would define a variant for version 2.2 (released in 2006, it's
  5709. vintage!):
  5710. @lisp
  5711. (use-modules (gnu packages base)) ;for 'hello'
  5712. (define hello-2.2
  5713. (package
  5714. (inherit hello)
  5715. (version "2.2")
  5716. (source (origin
  5717. (method url-fetch)
  5718. (uri (string-append "mirror://gnu/hello/hello-" version
  5719. ".tar.gz"))
  5720. (sha256
  5721. (base32
  5722. "0lappv4slgb5spyqbh6yl5r013zv72yqg2pcl30mginf3wdqd8k9"))))))
  5723. @end lisp
  5724. The example above corresponds to what the @option{--with-source} package
  5725. transformation option does. Essentially @code{hello-2.2} preserves all
  5726. the fields of @code{hello}, except @code{version} and @code{source},
  5727. which it overrides. Note that the original @code{hello} variable is
  5728. still there, in the @code{(gnu packages base)} module, unchanged. When
  5729. you define a custom package like this, you are really @emph{adding} a
  5730. new package definition; the original one remains available.
  5731. You can just as well define variants with a different set of
  5732. dependencies than the original package. For example, the default
  5733. @code{gdb} package depends on @code{guile}, but since that is an
  5734. optional dependency, you can define a variant that removes that
  5735. dependency like so:
  5736. @lisp
  5737. (use-modules (gnu packages gdb) ;for 'gdb'
  5738. (srfi srfi-1)) ;for 'alist-delete'
  5739. (define gdb-sans-guile
  5740. (package
  5741. (inherit gdb)
  5742. (inputs (alist-delete "guile"
  5743. (package-inputs gdb)))))
  5744. @end lisp
  5745. The @code{alist-delete} call above removes the tuple from the
  5746. @code{inputs} field that has @code{"guile"} as its first element
  5747. (@pxref{SRFI-1 Association Lists,,, guile, GNU Guile Reference
  5748. Manual}).
  5749. In some cases, you may find it useful to write functions
  5750. (``procedures'', in Scheme parlance) that return a package based on some
  5751. parameters. For example, consider the @code{luasocket} library for the
  5752. Lua programming language. We want to create @code{luasocket} packages
  5753. for major versions of Lua. One way to do that is to define a procedure
  5754. that takes a Lua package and returns a @code{luasocket} package that
  5755. depends on it:
  5756. @lisp
  5757. (define (make-lua-socket name lua)
  5758. ;; Return a luasocket package built with LUA.
  5759. (package
  5760. (name name)
  5761. (version "3.0")
  5762. ;; several fields omitted
  5763. (inputs
  5764. `(("lua" ,lua)))
  5765. (synopsis "Socket library for Lua")))
  5766. (define-public lua5.1-socket
  5767. (make-lua-socket "lua5.1-socket" lua-5.1))
  5768. (define-public lua5.2-socket
  5769. (make-lua-socket "lua5.2-socket" lua-5.2))
  5770. @end lisp
  5771. Here we have defined packages @code{lua5.1-socket} and
  5772. @code{lua5.2-socket} by calling @code{make-lua-socket} with different
  5773. arguments. @xref{Procedures,,, guile, GNU Guile Reference Manual}, for
  5774. more info on procedures. Having top-level public definitions for these
  5775. two packages means that they can be referred to from the command line
  5776. (@pxref{Package Modules}).
  5777. @cindex package transformations
  5778. These are pretty simple package variants. As a convenience, the
  5779. @code{(guix transformations)} module provides a high-level interface
  5780. that directly maps to the more sophisticated package transformation
  5781. options (@pxref{Package Transformation Options}):
  5782. @deffn {Scheme Procedure} options->transformation @var{opts}
  5783. Return a procedure that, when passed an object to build (package,
  5784. derivation, etc.), applies the transformations specified by @var{opts} and returns
  5785. the resulting objects. @var{opts} must be a list of symbol/string pairs such as:
  5786. @lisp
  5787. ((with-branch . "guile-gcrypt=master")
  5788. (without-tests . "libgcrypt"))
  5789. @end lisp
  5790. Each symbol names a transformation and the corresponding string is an argument
  5791. to that transformation.
  5792. @end deffn
  5793. For instance, a manifest equivalent to this command:
  5794. @example
  5795. guix build guix \
  5796. --with-branch=guile-gcrypt=master \
  5797. --with-debug-info=zlib
  5798. @end example
  5799. @noindent
  5800. ... would look like this:
  5801. @lisp
  5802. (use-modules (guix transformations))
  5803. (define transform
  5804. ;; The package transformation procedure.
  5805. (options->transformation
  5806. '((with-branch . "guile-gcrypt=master")
  5807. (with-debug-info . "zlib"))))
  5808. (packages->manifest
  5809. (list (transform (specification->package "guix"))))
  5810. @end lisp
  5811. @cindex input rewriting
  5812. @cindex dependency graph rewriting
  5813. The @code{options->transformation} procedure is convenient, but it's
  5814. perhaps also not as flexible as you may like. How is it implemented?
  5815. The astute reader probably noticed that most package transformation
  5816. options go beyond the superficial changes shown in the first examples of
  5817. this section: they involve @dfn{input rewriting}, whereby the dependency
  5818. graph of a package is rewritten by replacing specific inputs by others.
  5819. Dependency graph rewriting, for the purposes of swapping packages in the
  5820. graph, is what the @code{package-input-rewriting} procedure in
  5821. @code{(guix packages)} implements.
  5822. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  5823. [@var{rewrite-name}] [#:deep? #t]
  5824. Return a procedure that, when passed a package, replaces its direct and
  5825. indirect dependencies, including implicit inputs when @var{deep?} is
  5826. true, according to @var{replacements}. @var{replacements} is a list of
  5827. package pairs; the first element of each pair is the package to replace,
  5828. and the second one is the replacement.
  5829. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  5830. the name of a package and returns its new name after rewrite.
  5831. @end deffn
  5832. @noindent
  5833. Consider this example:
  5834. @lisp
  5835. (define libressl-instead-of-openssl
  5836. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  5837. ;; recursively.
  5838. (package-input-rewriting `((,openssl . ,libressl))))
  5839. (define git-with-libressl
  5840. (libressl-instead-of-openssl git))
  5841. @end lisp
  5842. @noindent
  5843. Here we first define a rewriting procedure that replaces @var{openssl}
  5844. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  5845. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  5846. This is exactly what the @option{--with-input} command-line option does
  5847. (@pxref{Package Transformation Options, @option{--with-input}}).
  5848. The following variant of @code{package-input-rewriting} can match packages to
  5849. be replaced by name rather than by identity.
  5850. @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
  5851. Return a procedure that, given a package, applies the given
  5852. @var{replacements} to all the package graph, including implicit inputs
  5853. unless @var{deep?} is false. @var{replacements} is a list of
  5854. spec/procedures pair; each spec is a package specification such as
  5855. @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching
  5856. package and returns a replacement for that package.
  5857. @end deffn
  5858. The example above could be rewritten this way:
  5859. @lisp
  5860. (define libressl-instead-of-openssl
  5861. ;; Replace all the packages called "openssl" with LibreSSL.
  5862. (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
  5863. @end lisp
  5864. The key difference here is that, this time, packages are matched by spec and
  5865. not by identity. In other words, any package in the graph that is called
  5866. @code{openssl} will be replaced.
  5867. A more generic procedure to rewrite a package dependency graph is
  5868. @code{package-mapping}: it supports arbitrary changes to nodes in the
  5869. graph.
  5870. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f]
  5871. Return a procedure that, given a package, applies @var{proc} to all the packages
  5872. depended on and returns the resulting package. The procedure stops recursion
  5873. when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
  5874. applied to implicit inputs as well.
  5875. @end deffn
  5876. @node Build Systems
  5877. @section Build Systems
  5878. @cindex build system
  5879. Each package definition specifies a @dfn{build system} and arguments for
  5880. that build system (@pxref{Defining Packages}). This @code{build-system}
  5881. field represents the build procedure of the package, as well as implicit
  5882. dependencies of that build procedure.
  5883. Build systems are @code{<build-system>} objects. The interface to
  5884. create and manipulate them is provided by the @code{(guix build-system)}
  5885. module, and actual build systems are exported by specific modules.
  5886. @cindex bag (low-level package representation)
  5887. Under the hood, build systems first compile package objects to
  5888. @dfn{bags}. A @dfn{bag} is like a package, but with less
  5889. ornamentation---in other words, a bag is a lower-level representation of
  5890. a package, which includes all the inputs of that package, including some
  5891. that were implicitly added by the build system. This intermediate
  5892. representation is then compiled to a derivation (@pxref{Derivations}).
  5893. The @code{package-with-c-toolchain} is an example of a way to change the
  5894. implicit inputs that a package's build system pulls in (@pxref{package
  5895. Reference, @code{package-with-c-toolchain}}).
  5896. Build systems accept an optional list of @dfn{arguments}. In package
  5897. definitions, these are passed @i{via} the @code{arguments} field
  5898. (@pxref{Defining Packages}). They are typically keyword arguments
  5899. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  5900. Guile Reference Manual}). The value of these arguments is usually
  5901. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  5902. by the daemon (@pxref{Derivations}).
  5903. The main build system is @code{gnu-build-system}, which implements the
  5904. standard build procedure for GNU and many other packages. It
  5905. is provided by the @code{(guix build-system gnu)} module.
  5906. @defvr {Scheme Variable} gnu-build-system
  5907. @code{gnu-build-system} represents the GNU Build System, and variants
  5908. thereof (@pxref{Configuration, configuration and makefile conventions,,
  5909. standards, GNU Coding Standards}).
  5910. @cindex build phases
  5911. In a nutshell, packages using it are configured, built, and installed with
  5912. the usual @code{./configure && make && make check && make install}
  5913. command sequence. In practice, a few additional steps are often needed.
  5914. All these steps are split up in separate @dfn{phases},
  5915. notably@footnote{Please see the @code{(guix build gnu-build-system)}
  5916. modules for more details about the build phases.}:
  5917. @table @code
  5918. @item unpack
  5919. Unpack the source tarball, and change the current directory to the
  5920. extracted source tree. If the source is actually a directory, copy it
  5921. to the build tree, and enter that directory.
  5922. @item patch-source-shebangs
  5923. Patch shebangs encountered in source files so they refer to the right
  5924. store file names. For instance, this changes @code{#!/bin/sh} to
  5925. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  5926. @item configure
  5927. Run the @file{configure} script with a number of default options, such
  5928. as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
  5929. by the @code{#:configure-flags} argument.
  5930. @item build
  5931. Run @code{make} with the list of flags specified with
  5932. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  5933. (the default), build with @code{make -j}.
  5934. @item check
  5935. Run @code{make check}, or some other target specified with
  5936. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  5937. @code{#:parallel-tests?} argument is true (the default), run @code{make
  5938. check -j}.
  5939. @item install
  5940. Run @code{make install} with the flags listed in @code{#:make-flags}.
  5941. @item patch-shebangs
  5942. Patch shebangs on the installed executable files.
  5943. @item strip
  5944. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  5945. is false), copying them to the @code{debug} output when available
  5946. (@pxref{Installing Debugging Files}).
  5947. @end table
  5948. @vindex %standard-phases
  5949. The build-side module @code{(guix build gnu-build-system)} defines
  5950. @code{%standard-phases} as the default list of build phases.
  5951. @code{%standard-phases} is a list of symbol/procedure pairs, where the
  5952. procedure implements the actual phase.
  5953. @xref{Build Phases}, for more info on build phases and ways to customize
  5954. them.
  5955. In addition, this build system ensures that the ``standard'' environment
  5956. for GNU packages is available. This includes tools such as GCC, libc,
  5957. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  5958. build-system gnu)} module for a complete list). We call these the
  5959. @dfn{implicit inputs} of a package, because package definitions do not
  5960. have to mention them.
  5961. @end defvr
  5962. Other @code{<build-system>} objects are defined to support other
  5963. conventions and tools used by free software packages. They inherit most
  5964. of @code{gnu-build-system}, and differ mainly in the set of inputs
  5965. implicitly added to the build process, and in the list of phases
  5966. executed. Some of these build systems are listed below.
  5967. @defvr {Scheme Variable} ant-build-system
  5968. This variable is exported by @code{(guix build-system ant)}. It
  5969. implements the build procedure for Java packages that can be built with
  5970. @url{https://ant.apache.org/, Ant build tool}.
  5971. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  5972. provided by the @code{icedtea} package to the set of inputs. Different
  5973. packages can be specified with the @code{#:ant} and @code{#:jdk}
  5974. parameters, respectively.
  5975. When the original package does not provide a suitable Ant build file,
  5976. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  5977. build file @file{build.xml} with tasks to build the specified jar
  5978. archive. In this case the parameter @code{#:source-dir} can be used to
  5979. specify the source sub-directory, defaulting to ``src''.
  5980. The @code{#:main-class} parameter can be used with the minimal ant
  5981. buildfile to specify the main class of the resulting jar. This makes the
  5982. jar file executable. The @code{#:test-include} parameter can be used to
  5983. specify the list of junit tests to run. It defaults to
  5984. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  5985. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  5986. because abstract classes cannot be run as tests.
  5987. The parameter @code{#:build-target} can be used to specify the Ant task
  5988. that should be run during the @code{build} phase. By default the
  5989. ``jar'' task will be run.
  5990. @end defvr
  5991. @defvr {Scheme Variable} android-ndk-build-system
  5992. @cindex Android distribution
  5993. @cindex Android NDK build system
  5994. This variable is exported by @code{(guix build-system android-ndk)}. It
  5995. implements a build procedure for Android NDK (native development kit)
  5996. packages using a Guix-specific build process.
  5997. The build system assumes that packages install their public interface
  5998. (header) files to the subdirectory @file{include} of the @code{out} output and
  5999. their libraries to the subdirectory @file{lib} the @code{out} output.
  6000. It's also assumed that the union of all the dependencies of a package
  6001. has no conflicting files.
  6002. For the time being, cross-compilation is not supported - so right now
  6003. the libraries and header files are assumed to be host tools.
  6004. @end defvr
  6005. @defvr {Scheme Variable} asdf-build-system/source
  6006. @defvrx {Scheme Variable} asdf-build-system/sbcl
  6007. @defvrx {Scheme Variable} asdf-build-system/ecl
  6008. These variables, exported by @code{(guix build-system asdf)}, implement
  6009. build procedures for Common Lisp packages using
  6010. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  6011. definition facility for Common Lisp programs and libraries.
  6012. The @code{asdf-build-system/source} system installs the packages in
  6013. source form, and can be loaded using any common lisp implementation, via
  6014. ASDF@. The others, such as @code{asdf-build-system/sbcl}, install binary
  6015. systems in the format which a particular implementation understands.
  6016. These build systems can also be used to produce executable programs, or
  6017. lisp images which contain a set of packages pre-loaded.
  6018. The build system uses naming conventions. For binary packages, the
  6019. package name should be prefixed with the lisp implementation, such as
  6020. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  6021. Additionally, the corresponding source package should be labeled using
  6022. the same convention as python packages (see @ref{Python Modules}), using
  6023. the @code{cl-} prefix.
  6024. In order to create executable programs and images, the build-side
  6025. procedures @code{build-program} and @code{build-image} can be used.
  6026. They should be called in a build phase after the
  6027. @code{create-asdf-configuration} phase, so that the system which was
  6028. just built can be used within the resulting image. @code{build-program}
  6029. requires a list of Common Lisp expressions to be passed as the
  6030. @code{#:entry-program} argument.
  6031. By default, all the @file{.asd} files present in the sources are read to
  6032. find system definitions. The @code{#:asd-files} parameter can be used
  6033. to specify the list of @file{.asd} files to read. Furthermore, if the
  6034. package defines a system for its tests in a separate file, it will be
  6035. loaded before the tests are run if it is specified by the
  6036. @code{#:test-asd-file} parameter. If it is not set, the files
  6037. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  6038. and @code{test.asd} will be tried if they exist.
  6039. If for some reason the package must be named in a different way than the
  6040. naming conventions suggest, or if several systems must be compiled, the
  6041. @code{#:asd-systems} parameter can be used to specify the list of system
  6042. names.
  6043. @end defvr
  6044. @defvr {Scheme Variable} cargo-build-system
  6045. @cindex Rust programming language
  6046. @cindex Cargo (Rust build system)
  6047. This variable is exported by @code{(guix build-system cargo)}. It
  6048. supports builds of packages using Cargo, the build tool of the
  6049. @uref{https://www.rust-lang.org, Rust programming language}.
  6050. It adds @code{rustc} and @code{cargo} to the set of inputs.
  6051. A different Rust package can be specified with the @code{#:rust} parameter.
  6052. Regular cargo dependencies should be added to the package definition similarly
  6053. to other packages; those needed only at build time to native-inputs, others to
  6054. inputs. If you need to add source-only crates then you should add them to via
  6055. the @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
  6056. spec can be a package or a source definition. Note that the spec must
  6057. evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
  6058. file at its root, or it will be ignored. Similarly, cargo dev-dependencies
  6059. should be added to the package definition via the
  6060. @code{#:cargo-development-inputs} parameter.
  6061. In its @code{configure} phase, this build system will make any source inputs
  6062. specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
  6063. parameters available to cargo. It will also remove an included
  6064. @code{Cargo.lock} file to be recreated by @code{cargo} during the
  6065. @code{build} phase. The @code{package} phase will run @code{cargo package}
  6066. to create a source crate for future use. The @code{install} phase installs
  6067. the binaries defined by the crate. Unless @code{install-source? #f} is
  6068. defined it will also install a source crate repository of itself and unpacked
  6069. sources, to ease in future hacking on rust packages.
  6070. @end defvr
  6071. @defvr {Scheme Variable} chicken-build-system
  6072. This variable is exported by @code{(guix build-system chicken)}. It
  6073. builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called
  6074. ``eggs'' or ``extensions''. CHICKEN generates C source code, which then
  6075. gets compiled by a C compiler, in this case GCC.
  6076. This build system adds @code{chicken} to the package inputs, as well as
  6077. the packages of @code{gnu-build-system}.
  6078. The build system can't (yet) deduce the egg's name automatically, so just like
  6079. with @code{go-build-system} and its @code{#:import-path}, you should define
  6080. @code{#:egg-name} in the package's @code{arguments} field.
  6081. For example, if you are packaging the @code{srfi-1} egg:
  6082. @lisp
  6083. (arguments '(#:egg-name "srfi-1"))
  6084. @end lisp
  6085. Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs}
  6086. because CHICKEN doesn't embed absolute references in compiled eggs.
  6087. Test dependencies should go to @code{native-inputs}, as usual.
  6088. @end defvr
  6089. @defvr {Scheme Variable} copy-build-system
  6090. This variable is exported by @code{(guix build-system copy)}. It
  6091. supports builds of simple packages that don't require much compiling,
  6092. mostly just moving files around.
  6093. It adds much of the @code{gnu-build-system} packages to the set of
  6094. inputs. Because of this, the @code{copy-build-system} does not require
  6095. all the boilerplate code often needed for the
  6096. @code{trivial-build-system}.
  6097. To further simplify the file installation process, an
  6098. @code{#:install-plan} argument is exposed to let the packager specify
  6099. which files go where. The install plan is a list of @code{(@var{source}
  6100. @var{target} [@var{filters}])}. @var{filters} are optional.
  6101. @itemize
  6102. @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
  6103. @itemize
  6104. @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
  6105. @item Otherwise install @var{source} as @var{target}.
  6106. @end itemize
  6107. @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
  6108. the trailing slash of @var{target} is implied with the same meaning
  6109. as above.
  6110. @itemize
  6111. @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
  6112. @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
  6113. @code{#:exclude-regexp}, only select files are installed depending on
  6114. the filters. Each filters is specified by a list of strings.
  6115. @itemize
  6116. @item With @code{#:include}, install all the files which the path suffix matches
  6117. at least one of the elements in the given list.
  6118. @item With @code{#:include-regexp}, install all the files which the
  6119. subpaths match at least one of the regular expressions in the given
  6120. list.
  6121. @item The @code{#:exclude} and @code{#:exclude-regexp} filters
  6122. are the complement of their inclusion counterpart. Without @code{#:include} flags,
  6123. install all files but those matching the exclusion filters.
  6124. If both inclusions and exclusions are specified, the exclusions are done
  6125. on top of the inclusions.
  6126. @end itemize
  6127. @end itemize
  6128. In all cases, the paths relative to @var{source} are preserved within
  6129. @var{target}.
  6130. @end itemize
  6131. Examples:
  6132. @itemize
  6133. @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
  6134. @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
  6135. @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
  6136. e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
  6137. @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
  6138. @file{share/my-app/sub/file}.
  6139. @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
  6140. @file{share/my-app/file}.
  6141. @end itemize
  6142. @end defvr
  6143. @cindex Clojure (programming language)
  6144. @cindex simple Clojure build system
  6145. @defvr {Scheme Variable} clojure-build-system
  6146. This variable is exported by @code{(guix build-system clojure)}. It implements
  6147. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  6148. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  6149. yet.
  6150. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  6151. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  6152. @code{#:zip} parameters, respectively.
  6153. A list of source directories, test directories and jar names can be specified
  6154. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  6155. parameters, respectively. Compile directory and main class can be specified
  6156. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  6157. Other parameters are documented below.
  6158. This build system is an extension of @code{ant-build-system}, but with the
  6159. following phases changed:
  6160. @table @code
  6161. @item build
  6162. This phase calls @code{compile} in Clojure to compile source files and runs
  6163. @command{jar} to create jars from both source files and compiled files
  6164. according to the include list and exclude list specified in
  6165. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  6166. has priority over the include list. These lists consist of symbols
  6167. representing Clojure libraries or the special keyword @code{#:all} representing
  6168. all Clojure libraries found under the source directories. The parameter
  6169. @code{#:omit-source?} decides if source should be included into the jars.
  6170. @item check
  6171. This phase runs tests according to the include list and exclude list specified
  6172. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  6173. meanings are analogous to that of @code{#:aot-include} and
  6174. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  6175. stands for all Clojure libraries found under the test directories. The
  6176. parameter @code{#:tests?} decides if tests should be run.
  6177. @item install
  6178. This phase installs all jars built previously.
  6179. @end table
  6180. Apart from the above, this build system also contains an additional phase:
  6181. @table @code
  6182. @item install-doc
  6183. This phase installs all top-level files with base name matching
  6184. @code{%doc-regex}. A different regex can be specified with the
  6185. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  6186. directories specified in @code{#:doc-dirs} are installed as well.
  6187. @end table
  6188. @end defvr
  6189. @defvr {Scheme Variable} cmake-build-system
  6190. This variable is exported by @code{(guix build-system cmake)}. It
  6191. implements the build procedure for packages using the
  6192. @url{https://www.cmake.org, CMake build tool}.
  6193. It automatically adds the @code{cmake} package to the set of inputs.
  6194. Which package is used can be specified with the @code{#:cmake}
  6195. parameter.
  6196. The @code{#:configure-flags} parameter is taken as a list of flags
  6197. passed to the @command{cmake} command. The @code{#:build-type}
  6198. parameter specifies in abstract terms the flags passed to the compiler;
  6199. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  6200. debugging information''), which roughly means that code is compiled with
  6201. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  6202. @end defvr
  6203. @defvr {Scheme Variable} dune-build-system
  6204. This variable is exported by @code{(guix build-system dune)}. It
  6205. supports builds of packages using @uref{https://dune.build/, Dune}, a build
  6206. tool for the OCaml programming language. It is implemented as an extension
  6207. of the @code{ocaml-build-system} which is described below. As such, the
  6208. @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
  6209. system.
  6210. It automatically adds the @code{dune} package to the set of inputs.
  6211. Which package is used can be specified with the @code{#:dune}
  6212. parameter.
  6213. There is no @code{configure} phase because dune packages typically don't
  6214. need to be configured. The @code{#:build-flags} parameter is taken as a
  6215. list of flags passed to the @code{dune} command during the build.
  6216. The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
  6217. command instead of the more recent @code{dune} command while building
  6218. a package. Its default value is @code{#f}.
  6219. The @code{#:package} parameter can be passed to specify a package name, which
  6220. is useful when a package contains multiple packages and you want to build
  6221. only one of them. This is equivalent to passing the @code{-p} argument to
  6222. @code{dune}.
  6223. @end defvr
  6224. @defvr {Scheme Variable} go-build-system
  6225. This variable is exported by @code{(guix build-system go)}. It
  6226. implements a build procedure for Go packages using the standard
  6227. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  6228. Go build mechanisms}.
  6229. The user is expected to provide a value for the key @code{#:import-path}
  6230. and, in some cases, @code{#:unpack-path}. The
  6231. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  6232. corresponds to the file system path expected by the package's build
  6233. scripts and any referring packages, and provides a unique way to
  6234. refer to a Go package. It is typically based on a combination of the
  6235. package source code's remote URI and file system hierarchy structure. In
  6236. some cases, you will need to unpack the package's source code to a
  6237. different directory structure than the one indicated by the import path,
  6238. and @code{#:unpack-path} should be used in such cases.
  6239. Packages that provide Go libraries should install their source code into
  6240. the built output. The key @code{#:install-source?}, which defaults to
  6241. @code{#t}, controls whether or not the source code is installed. It can
  6242. be set to @code{#f} for packages that only provide executable files.
  6243. @end defvr
  6244. @defvr {Scheme Variable} glib-or-gtk-build-system
  6245. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  6246. is intended for use with packages making use of GLib or GTK+.
  6247. This build system adds the following two phases to the ones defined by
  6248. @code{gnu-build-system}:
  6249. @table @code
  6250. @item glib-or-gtk-wrap
  6251. The phase @code{glib-or-gtk-wrap} ensures that programs in
  6252. @file{bin/} are able to find GLib ``schemas'' and
  6253. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  6254. modules}. This is achieved by wrapping the programs in launch scripts
  6255. that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
  6256. environment variables.
  6257. It is possible to exclude specific package outputs from that wrapping
  6258. process by listing their names in the
  6259. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  6260. when an output is known not to contain any GLib or GTK+ binaries, and
  6261. where wrapping would gratuitously add a dependency of that output on
  6262. GLib and GTK+.
  6263. @item glib-or-gtk-compile-schemas
  6264. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  6265. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  6266. GSettings schemas} of GLib are compiled. Compilation is performed by the
  6267. @command{glib-compile-schemas} program. It is provided by the package
  6268. @code{glib:bin} which is automatically imported by the build system.
  6269. The @code{glib} package providing @command{glib-compile-schemas} can be
  6270. specified with the @code{#:glib} parameter.
  6271. @end table
  6272. Both phases are executed after the @code{install} phase.
  6273. @end defvr
  6274. @defvr {Scheme Variable} guile-build-system
  6275. This build system is for Guile packages that consist exclusively of Scheme
  6276. code and that are so lean that they don't even have a makefile, let alone a
  6277. @file{configure} script. It compiles Scheme code using @command{guild
  6278. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  6279. installs the @file{.scm} and @file{.go} files in the right place. It also
  6280. installs documentation.
  6281. This build system supports cross-compilation by using the
  6282. @option{--target} option of @samp{guild compile}.
  6283. Packages built with @code{guile-build-system} must provide a Guile package in
  6284. their @code{native-inputs} field.
  6285. @end defvr
  6286. @defvr {Scheme Variable} julia-build-system
  6287. This variable is exported by @code{(guix build-system julia)}. It
  6288. implements the build procedure used by @uref{https://julialang.org/,
  6289. julia} packages, which essentially is similar to running @samp{julia -e
  6290. 'using Pkg; Pkg.add(package)'} in an environment where
  6291. @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
  6292. Tests are run by calling @code{/test/runtests.jl}.
  6293. The Julia package name is read from the file @file{Project.toml}. This
  6294. value can be overridden by passing the argument @code{#:julia-package-name}
  6295. (which must be correctly capitalized).
  6296. Julia packages usually manage their binary dependencies via
  6297. @code{JLLWrappers.jl}, a Julia package that creates a module (named
  6298. after the wrapped library followed by @code{_jll.jl}.
  6299. To add the binary path @code{_jll.jl} packages, you need to patch the
  6300. files under @file{src/wrappers/}, replacing the call to the macro
  6301. @code{JLLWrappers.@@generate_wrapper_header}, adding as a secound
  6302. argument containing the store path the binary.
  6303. As an example, in the MbedTLS Julia package, we add a build phase
  6304. (@pxref{Build Phases}) to insert the absolute file name of the wrapped
  6305. MbedTLS package:
  6306. @lisp
  6307. (add-after 'unpack 'override-binary-path
  6308. (lambda* (#:key inputs #:allow-other-keys)
  6309. (for-each (lambda (wrapper)
  6310. (substitute* wrapper
  6311. (("generate_wrapper_header.*")
  6312. (string-append
  6313. "generate_wrapper_header(\"MbedTLS\", \""
  6314. (assoc-ref inputs "mbedtls-apache") "\")\n"))))
  6315. ;; There's a Julia file for each platform, override them all.
  6316. (find-files "src/wrappers/" "\\.jl$"))))
  6317. @end lisp
  6318. Some older packages that aren't using @file{Package.toml} yet, will require
  6319. this file to be created, too. The function @code{julia-create-package-toml}
  6320. helps creating the file. You need to pass the outputs and the source of the
  6321. package, it's name (the same as the @code{file-name} parameter), the package
  6322. uuid, the package version, and a list of dependencies specified by their name
  6323. and their uuid.
  6324. @end defvr
  6325. @defvr {Scheme Variable} maven-build-system
  6326. This variable is exported by @code{(guix build-system maven)}. It implements
  6327. a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
  6328. is a dependency and lifecycle management tool for Java. A user of Maven
  6329. specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
  6330. When Maven does not have one of the dependencies or plugins in its repository,
  6331. it will download them and use them to build the package.
  6332. The maven build system ensures that maven will not try to download any
  6333. dependency by running in offline mode. Maven will fail if a dependency is
  6334. missing. Before running Maven, the @file{pom.xml} (and subprojects) are
  6335. modified to specify the version of dependencies and plugins that match the
  6336. versions available in the guix build environment. Dependencies and plugins
  6337. must be installed in the fake maven repository at @file{lib/m2}, and are
  6338. symlinked into a proper repository before maven is run. Maven is instructed
  6339. to use that repository for the build and installs built artifacts there.
  6340. Changed files are copied to the @file{lib/m2} directory of the package output.
  6341. You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
  6342. or let the build system use the default @file{pom.xml} file in the sources.
  6343. In case you need to specify a dependency's version manually, you can use the
  6344. @code{#:local-packages} argument. It takes an association list where the key
  6345. is the groupId of the package and its value is an association list where the
  6346. key is the artifactId of the package and its value is the version you want to
  6347. override in the @file{pom.xml}.
  6348. Some packages use dependencies or plugins that are not useful at runtime nor
  6349. at build time in Guix. You can alter the @file{pom.xml} file to remove them
  6350. using the @code{#:exclude} argument. Its value is an association list where
  6351. the key is the groupId of the plugin or dependency you want to remove, and
  6352. the value is a list of artifactId you want to remove.
  6353. You can override the default @code{jdk} and @code{maven} packages with the
  6354. corresponding argument, @code{#:jdk} and @code{#:maven}.
  6355. The @code{#:maven-plugins} argument is a list of maven plugins used during
  6356. the build, with the same format as the @code{inputs} fields of the package
  6357. declaration. Its default value is @code{(default-maven-plugins)} which is
  6358. also exported.
  6359. @end defvr
  6360. @defvr {Scheme Variable} minify-build-system
  6361. This variable is exported by @code{(guix build-system minify)}. It
  6362. implements a minification procedure for simple JavaScript packages.
  6363. It adds @code{uglify-js} to the set of inputs and uses it to compress
  6364. all JavaScript files in the @file{src} directory. A different minifier
  6365. package can be specified with the @code{#:uglify-js} parameter, but it
  6366. is expected that the package writes the minified code to the standard
  6367. output.
  6368. When the input JavaScript files are not all located in the @file{src}
  6369. directory, the parameter @code{#:javascript-files} can be used to
  6370. specify a list of file names to feed to the minifier.
  6371. @end defvr
  6372. @defvr {Scheme Variable} ocaml-build-system
  6373. This variable is exported by @code{(guix build-system ocaml)}. It implements
  6374. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  6375. of choosing the correct set of commands to run for each package. OCaml
  6376. packages can expect many different commands to be run. This build system will
  6377. try some of them.
  6378. When the package has a @file{setup.ml} file present at the top-level, it will
  6379. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  6380. @code{ocaml setup.ml -install}. The build system will assume that this file
  6381. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  6382. care of setting the prefix and enabling tests if they are not disabled. You
  6383. can pass configure and build flags with the @code{#:configure-flags} and
  6384. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  6385. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  6386. bypass this system in the build and install phases.
  6387. When the package has a @file{configure} file, it is assumed that it is a
  6388. hand-made configure script that requires a different argument format than
  6389. in the @code{gnu-build-system}. You can add more flags with the
  6390. @code{#:configure-flags} key.
  6391. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  6392. @code{#t}), it will be used and more flags can be passed to the build and
  6393. install phases with the @code{#:make-flags} key.
  6394. Finally, some packages do not have these files and use a somewhat standard
  6395. location for its build system. In that case, the build system will run
  6396. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  6397. providing the path to the required findlib module. Additional flags can
  6398. be passed via the @code{#:build-flags} key. Install is taken care of by
  6399. @command{opam-installer}. In this case, the @code{opam} package must
  6400. be added to the @code{native-inputs} field of the package definition.
  6401. Note that most OCaml packages assume they will be installed in the same
  6402. directory as OCaml, which is not what we want in guix. In particular, they
  6403. will install @file{.so} files in their module's directory, which is usually
  6404. fine because it is in the OCaml compiler directory. In guix though, these
  6405. libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
  6406. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  6407. @file{.so} libraries should be installed.
  6408. @end defvr
  6409. @defvr {Scheme Variable} python-build-system
  6410. This variable is exported by @code{(guix build-system python)}. It
  6411. implements the more or less standard build procedure used by Python
  6412. packages, which consists in running @code{python setup.py build} and
  6413. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  6414. For packages that install stand-alone Python programs under @code{bin/},
  6415. it takes care of wrapping these programs so that their @env{PYTHONPATH}
  6416. environment variable points to all the Python libraries they depend on.
  6417. Which Python package is used to perform the build can be specified with
  6418. the @code{#:python} parameter. This is a useful way to force a package
  6419. to be built for a specific version of the Python interpreter, which
  6420. might be necessary if the package is only compatible with a single
  6421. interpreter version.
  6422. By default guix calls @code{setup.py} under control of
  6423. @code{setuptools}, much like @command{pip} does. Some packages are not
  6424. compatible with setuptools (and pip), thus you can disable this by
  6425. setting the @code{#:use-setuptools?} parameter to @code{#f}.
  6426. @end defvr
  6427. @defvr {Scheme Variable} perl-build-system
  6428. This variable is exported by @code{(guix build-system perl)}. It
  6429. implements the standard build procedure for Perl packages, which either
  6430. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  6431. followed by @code{Build} and @code{Build install}; or in running
  6432. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  6433. @code{make} and @code{make install}, depending on which of
  6434. @code{Build.PL} or @code{Makefile.PL} is present in the package
  6435. distribution. Preference is given to the former if both @code{Build.PL}
  6436. and @code{Makefile.PL} exist in the package distribution. This
  6437. preference can be reversed by specifying @code{#t} for the
  6438. @code{#:make-maker?} parameter.
  6439. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  6440. passes flags specified by the @code{#:make-maker-flags} or
  6441. @code{#:module-build-flags} parameter, respectively.
  6442. Which Perl package is used can be specified with @code{#:perl}.
  6443. @end defvr
  6444. @defvr {Scheme Variable} renpy-build-system
  6445. This variable is exported by @code{(guix build-system renpy)}. It implements
  6446. the more or less standard build procedure used by Ren'py games, which consists
  6447. of loading @code{#:game} once, thereby creating bytecode for it.
  6448. It further creates a wrapper script in @code{bin/} and a desktop entry in
  6449. @code{share/applications}, both of which can be used to launch the game.
  6450. Which Ren'py package is used can be specified with @code{#:renpy}.
  6451. Games can also be installed in outputs other than ``out'' by using
  6452. @code{#:output}.
  6453. @end defvr
  6454. @defvr {Scheme Variable} qt-build-system
  6455. This variable is exported by @code{(guix build-system qt)}. It
  6456. is intended for use with applications using Qt or KDE.
  6457. This build system adds the following two phases to the ones defined by
  6458. @code{cmake-build-system}:
  6459. @table @code
  6460. @item check-setup
  6461. The phase @code{check-setup} prepares the environment for running
  6462. the checks as commonly used by Qt test programs.
  6463. For now this only sets some environment variables:
  6464. @code{QT_QPA_PLATFORM=offscreen},
  6465. @code{DBUS_FATAL_WARNINGS=0} and
  6466. @code{CTEST_OUTPUT_ON_FAILURE=1}.
  6467. This phase is added before the @code{check} phase.
  6468. It's a separate phase to ease adjusting if necessary.
  6469. @item qt-wrap
  6470. The phase @code{qt-wrap}
  6471. searches for Qt5 plugin paths, QML paths and some XDG in the inputs
  6472. and output. In case some path is found, all programs in the output's
  6473. @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
  6474. are wrapped in scripts defining the necessary environment variables.
  6475. It is possible to exclude specific package outputs from that wrapping process
  6476. by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
  6477. This is useful when an output is known not to contain any Qt binaries, and
  6478. where wrapping would gratuitously add a dependency of that output on Qt, KDE,
  6479. or such.
  6480. This phase is added after the @code{install} phase.
  6481. @end table
  6482. @end defvr
  6483. @defvr {Scheme Variable} r-build-system
  6484. This variable is exported by @code{(guix build-system r)}. It
  6485. implements the build procedure used by @uref{https://r-project.org, R}
  6486. packages, which essentially is little more than running @samp{R CMD
  6487. INSTALL --library=/gnu/store/@dots{}} in an environment where
  6488. @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
  6489. run after installation using the R function
  6490. @code{tools::testInstalledPackage}.
  6491. @end defvr
  6492. @defvr {Scheme Variable} rakudo-build-system
  6493. This variable is exported by @code{(guix build-system rakudo)}. It
  6494. implements the build procedure used by @uref{https://rakudo.org/,
  6495. Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
  6496. package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
  6497. installs the binaries, library files and the resources, as well as wrap
  6498. the files under the @code{bin/} directory. Tests can be skipped by
  6499. passing @code{#f} to the @code{tests?} parameter.
  6500. Which rakudo package is used can be specified with @code{rakudo}.
  6501. Which perl6-tap-harness package used for the tests can be specified with
  6502. @code{#:prove6} or removed by passing @code{#f} to the
  6503. @code{with-prove6?} parameter.
  6504. Which perl6-zef package used for tests and installing can be specified
  6505. with @code{#:zef} or removed by passing @code{#f} to the
  6506. @code{with-zef?} parameter.
  6507. @end defvr
  6508. @defvr {Scheme Variable} texlive-build-system
  6509. This variable is exported by @code{(guix build-system texlive)}. It is
  6510. used to build TeX packages in batch mode with a specified engine. The
  6511. build system sets the @env{TEXINPUTS} variable to find all TeX source
  6512. files in the inputs.
  6513. By default it runs @code{luatex} on all files ending on @code{ins}. A
  6514. different engine and format can be specified with the
  6515. @code{#:tex-format} argument. Different build targets can be specified
  6516. with the @code{#:build-targets} argument, which expects a list of file
  6517. names. The build system adds only @code{texlive-bin} and
  6518. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  6519. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  6520. and @code{#:texlive-latex-base}, respectively.
  6521. The @code{#:tex-directory} parameter tells the build system where to
  6522. install the built files under the texmf tree.
  6523. @end defvr
  6524. @defvr {Scheme Variable} ruby-build-system
  6525. This variable is exported by @code{(guix build-system ruby)}. It
  6526. implements the RubyGems build procedure used by Ruby packages, which
  6527. involves running @code{gem build} followed by @code{gem install}.
  6528. The @code{source} field of a package that uses this build system
  6529. typically references a gem archive, since this is the format that Ruby
  6530. developers use when releasing their software. The build system unpacks
  6531. the gem archive, potentially patches the source, runs the test suite,
  6532. repackages the gem, and installs it. Additionally, directories and
  6533. tarballs may be referenced to allow building unreleased gems from Git or
  6534. a traditional source release tarball.
  6535. Which Ruby package is used can be specified with the @code{#:ruby}
  6536. parameter. A list of additional flags to be passed to the @command{gem}
  6537. command can be specified with the @code{#:gem-flags} parameter.
  6538. @end defvr
  6539. @defvr {Scheme Variable} waf-build-system
  6540. This variable is exported by @code{(guix build-system waf)}. It
  6541. implements a build procedure around the @code{waf} script. The common
  6542. phases---@code{configure}, @code{build}, and @code{install}---are
  6543. implemented by passing their names as arguments to the @code{waf}
  6544. script.
  6545. The @code{waf} script is executed by the Python interpreter. Which
  6546. Python package is used to run the script can be specified with the
  6547. @code{#:python} parameter.
  6548. @end defvr
  6549. @defvr {Scheme Variable} scons-build-system
  6550. This variable is exported by @code{(guix build-system scons)}. It
  6551. implements the build procedure used by the SCons software construction
  6552. tool. This build system runs @code{scons} to build the package,
  6553. @code{scons test} to run tests, and then @code{scons install} to install
  6554. the package.
  6555. Additional flags to be passed to @code{scons} can be specified with the
  6556. @code{#:scons-flags} parameter. The default build and install targets
  6557. can be overridden with @code{#:build-targets} and
  6558. @code{#:install-targets} respectively. The version of Python used to
  6559. run SCons can be specified by selecting the appropriate SCons package
  6560. with the @code{#:scons} parameter.
  6561. @end defvr
  6562. @defvr {Scheme Variable} haskell-build-system
  6563. This variable is exported by @code{(guix build-system haskell)}. It
  6564. implements the Cabal build procedure used by Haskell packages, which
  6565. involves running @code{runhaskell Setup.hs configure
  6566. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  6567. Instead of installing the package by running @code{runhaskell Setup.hs
  6568. install}, to avoid trying to register libraries in the read-only
  6569. compiler store directory, the build system uses @code{runhaskell
  6570. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  6571. addition, the build system generates the package documentation by
  6572. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  6573. is passed. Optional Haddock parameters can be passed with the help of
  6574. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  6575. not found, the build system looks for @code{Setup.lhs} instead.
  6576. Which Haskell compiler is used can be specified with the @code{#:haskell}
  6577. parameter which defaults to @code{ghc}.
  6578. @end defvr
  6579. @defvr {Scheme Variable} dub-build-system
  6580. This variable is exported by @code{(guix build-system dub)}. It
  6581. implements the Dub build procedure used by D packages, which
  6582. involves running @code{dub build} and @code{dub run}.
  6583. Installation is done by copying the files manually.
  6584. Which D compiler is used can be specified with the @code{#:ldc}
  6585. parameter which defaults to @code{ldc}.
  6586. @end defvr
  6587. @anchor{emacs-build-system}
  6588. @defvr {Scheme Variable} emacs-build-system
  6589. This variable is exported by @code{(guix build-system emacs)}. It
  6590. implements an installation procedure similar to the packaging system
  6591. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  6592. It first creates the @code{@code{package}-autoloads.el} file, then it
  6593. byte compiles all Emacs Lisp files. Differently from the Emacs
  6594. packaging system, the Info documentation files are moved to the standard
  6595. documentation directory and the @file{dir} file is deleted. The Elisp
  6596. package files are installed directly under @file{share/emacs/site-lisp}.
  6597. @end defvr
  6598. @defvr {Scheme Variable} font-build-system
  6599. This variable is exported by @code{(guix build-system font)}. It
  6600. implements an installation procedure for font packages where upstream
  6601. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  6602. need to be copied into place. It copies font files to standard
  6603. locations in the output directory.
  6604. @end defvr
  6605. @defvr {Scheme Variable} meson-build-system
  6606. This variable is exported by @code{(guix build-system meson)}. It
  6607. implements the build procedure for packages that use
  6608. @url{https://mesonbuild.com, Meson} as their build system.
  6609. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  6610. of inputs, and they can be changed with the parameters @code{#:meson}
  6611. and @code{#:ninja} if needed. The default Meson is
  6612. @code{meson-for-build}, which is special because it doesn't clear the
  6613. @code{RUNPATH} of binaries and libraries when they are installed.
  6614. This build system is an extension of @code{gnu-build-system}, but with the
  6615. following phases changed to some specific for Meson:
  6616. @table @code
  6617. @item configure
  6618. The phase runs @code{meson} with the flags specified in
  6619. @code{#:configure-flags}. The flag @option{--buildtype} is always set to
  6620. @code{debugoptimized} unless something else is specified in
  6621. @code{#:build-type}.
  6622. @item build
  6623. The phase runs @code{ninja} to build the package in parallel by default, but
  6624. this can be changed with @code{#:parallel-build?}.
  6625. @item check
  6626. The phase runs @code{ninja} with the target specified in @code{#:test-target},
  6627. which is @code{"test"} by default.
  6628. @item install
  6629. The phase runs @code{ninja install} and can not be changed.
  6630. @end table
  6631. Apart from that, the build system also adds the following phases:
  6632. @table @code
  6633. @item fix-runpath
  6634. This phase ensures that all binaries can find the libraries they need.
  6635. It searches for required libraries in subdirectories of the package being
  6636. built, and adds those to @code{RUNPATH} where needed. It also removes
  6637. references to libraries left over from the build phase by
  6638. @code{meson-for-build}, such as test dependencies, that aren't actually
  6639. required for the program to run.
  6640. @item glib-or-gtk-wrap
  6641. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6642. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6643. @item glib-or-gtk-compile-schemas
  6644. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  6645. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  6646. @end table
  6647. @end defvr
  6648. @defvr {Scheme Variable} linux-module-build-system
  6649. @code{linux-module-build-system} allows building Linux kernel modules.
  6650. @cindex build phases
  6651. This build system is an extension of @code{gnu-build-system}, but with the
  6652. following phases changed:
  6653. @table @code
  6654. @item configure
  6655. This phase configures the environment so that the Linux kernel's Makefile
  6656. can be used to build the external kernel module.
  6657. @item build
  6658. This phase uses the Linux kernel's Makefile in order to build the external
  6659. kernel module.
  6660. @item install
  6661. This phase uses the Linux kernel's Makefile in order to install the external
  6662. kernel module.
  6663. @end table
  6664. It is possible and useful to specify the Linux kernel to use for building
  6665. the module (in the @code{arguments} form of a package using the
  6666. @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
  6667. @end defvr
  6668. @defvr {Scheme Variable} node-build-system
  6669. This variable is exported by @code{(guix build-system node)}. It
  6670. implements the build procedure used by @uref{https://nodejs.org,
  6671. Node.js}, which implements an approximation of the @code{npm install}
  6672. command, followed by an @code{npm test} command.
  6673. Which Node.js package is used to interpret the @code{npm} commands can
  6674. be specified with the @code{#:node} parameter which defaults to
  6675. @code{node}.
  6676. @end defvr
  6677. Lastly, for packages that do not need anything as sophisticated, a
  6678. ``trivial'' build system is provided. It is trivial in the sense that
  6679. it provides basically no support: it does not pull any implicit inputs,
  6680. and does not have a notion of build phases.
  6681. @defvr {Scheme Variable} trivial-build-system
  6682. This variable is exported by @code{(guix build-system trivial)}.
  6683. This build system requires a @code{#:builder} argument. This argument
  6684. must be a Scheme expression that builds the package output(s)---as
  6685. with @code{build-expression->derivation} (@pxref{Derivations,
  6686. @code{build-expression->derivation}}).
  6687. @end defvr
  6688. @node Build Phases
  6689. @section Build Phases
  6690. @cindex build phases, for packages
  6691. Almost all package build systems implement a notion @dfn{build phases}:
  6692. a sequence of actions that the build system executes, when you build the
  6693. package, leading to the installed byproducts in the store. A notable
  6694. exception is the ``bare-bones'' @code{trivial-build-system}
  6695. (@pxref{Build Systems}).
  6696. As discussed in the previous section, those build systems provide a
  6697. standard list of phases. For @code{gnu-build-system}, the standard
  6698. phases include an @code{unpack} phase to unpack the source code tarball,
  6699. a @command{configure} phase to run @code{./configure}, a @code{build}
  6700. phase to run @command{make}, and (among others) an @code{install} phase
  6701. to run @command{make install}; @pxref{Build Systems}, for a more
  6702. detailed view of these phases. Likewise, @code{cmake-build-system}
  6703. inherits these phases, but its @code{configure} phase runs
  6704. @command{cmake} instead of @command{./configure}. Other build systems,
  6705. such as @code{python-build-system}, have a wholly different list of
  6706. standard phases. All this code runs on the @dfn{build side}: it is
  6707. evaluated when you actually build the package, in a dedicated build
  6708. process spawned by the build daemon (@pxref{Invoking guix-daemon}).
  6709. Build phases are represented as association lists or ``alists''
  6710. (@pxref{Association Lists,,, guile, GNU Guile Reference Manual}) where
  6711. each key is a symbol for the name of the phase and the associated value
  6712. is a procedure that accepts an arbitrary number of arguments. By
  6713. convention, those procedures receive information about the build in the
  6714. form of @dfn{keyword parameters}, which they can use or ignore.
  6715. For example, here is how @code{(guix build gnu-build-system)} defines
  6716. @code{%standard-phases}, the variable holding its alist of build
  6717. phases@footnote{We present a simplified view of those build phases, but
  6718. do take a look at @code{(guix build gnu-build-system)} to see all the
  6719. details!}:
  6720. @lisp
  6721. ;; The build phases of 'gnu-build-system'.
  6722. (define* (unpack #:key source #:allow-other-keys)
  6723. ;; Extract the source tarball.
  6724. (invoke "tar" "xvf" source))
  6725. (define* (configure #:key outputs #:allow-other-keys)
  6726. ;; Run the 'configure' script. Install to output "out".
  6727. (let ((out (assoc-ref outputs "out")))
  6728. (invoke "./configure"
  6729. (string-append "--prefix=" out))))
  6730. (define* (build #:allow-other-keys)
  6731. ;; Compile.
  6732. (invoke "make"))
  6733. (define* (check #:key (test-target "check") (tests? #true)
  6734. #:allow-other-keys)
  6735. ;; Run the test suite.
  6736. (if tests?
  6737. (invoke "make" test-target)
  6738. (display "test suite not run\n")))
  6739. (define* (install #:allow-other-keys)
  6740. ;; Install files to the prefix 'configure' specified.
  6741. (invoke "make" "install"))
  6742. (define %standard-phases
  6743. ;; The list of standard phases (quite a few are omitted
  6744. ;; for brevity). Each element is a symbol/procedure pair.
  6745. (list (cons 'unpack unpack)
  6746. (cons 'configure configure)
  6747. (cons 'build build)
  6748. (cons 'check check)
  6749. (cons 'install install)))
  6750. @end lisp
  6751. This shows how @code{%standard-phases} is defined as a list of
  6752. symbol/procedure pairs (@pxref{Pairs,,, guile, GNU Guile Reference
  6753. Manual}). The first pair associates the @code{unpack} procedure with
  6754. the @code{unpack} symbol---a name; the second pair defines the
  6755. @code{configure} phase similarly, and so on. When building a package
  6756. that uses @code{gnu-build-system} with its default list of phases, those
  6757. phases are executed sequentially. You can see the name of each phase
  6758. started and completed in the build log of packages that you build.
  6759. Let's now look at the procedures themselves. Each one is defined with
  6760. @code{define*}: @code{#:key} lists keyword parameters the procedure
  6761. accepts, possibly with a default value, and @code{#:allow-other-keys}
  6762. specifies that other keyword parameters are ignored (@pxref{Optional
  6763. Arguments,,, guile, GNU Guile Reference Manual}).
  6764. The @code{unpack} procedure honors the @code{source} parameter, which
  6765. the build system uses to pass the file name of the source tarball (or
  6766. version control checkout), and it ignores other parameters. The
  6767. @code{configure} phase only cares about the @code{outputs} parameter, an
  6768. alist mapping package output names to their store file name
  6769. (@pxref{Packages with Multiple Outputs}). It extracts the file name of
  6770. for @code{out}, the default output, and passes it to
  6771. @command{./configure} as the installation prefix, meaning that
  6772. @command{make install} will eventually copy all the files in that
  6773. directory (@pxref{Configuration, configuration and makefile
  6774. conventions,, standards, GNU Coding Standards}). @code{build} and
  6775. @code{install} ignore all their arguments. @code{check} honors the
  6776. @code{test-target} argument, which specifies the name of the Makefile
  6777. target to run tests; it prints a message and skips tests when
  6778. @code{tests?} is false.
  6779. @cindex build phases, customizing
  6780. The list of phases used for a particular package can be changed with the
  6781. @code{#:phases} parameter of the build system. Changing the set of
  6782. build phases boils down to building a new alist of phases based on the
  6783. @code{%standard-phases} alist described above. This can be done with
  6784. standard alist procedures such as @code{alist-delete} (@pxref{SRFI-1
  6785. Association Lists,,, guile, GNU Guile Reference Manual}); however, it is
  6786. more convenient to do so with @code{modify-phases} (@pxref{Build
  6787. Utilities, @code{modify-phases}}).
  6788. Here is an example of a package definition that removes the
  6789. @code{configure} phase of @code{%standard-phases} and inserts a new
  6790. phase before the @code{build} phase, called
  6791. @code{set-prefix-in-makefile}:
  6792. @lisp
  6793. (define-public example
  6794. (package
  6795. (name "example")
  6796. ;; other fields omitted
  6797. (build-system gnu-build-system)
  6798. (arguments
  6799. '(#:phases (modify-phases %standard-phases
  6800. (delete 'configure)
  6801. (add-before 'build 'set-prefix-in-makefile
  6802. (lambda* (#:key outputs #:allow-other-keys)
  6803. ;; Modify the makefile so that its
  6804. ;; 'PREFIX' variable points to "out".
  6805. (let ((out (assoc-ref outputs "out")))
  6806. (substitute* "Makefile"
  6807. (("PREFIX =.*")
  6808. (string-append "PREFIX = "
  6809. out "\n")))
  6810. #true))))))))
  6811. @end lisp
  6812. The new phase that is inserted is written as an anonymous procedure,
  6813. introduced with @code{lambda*}; it honors the @code{outputs} parameter
  6814. we have seen before. @xref{Build Utilities}, for more about the helpers
  6815. used by this phase, and for more examples of @code{modify-phases}.
  6816. @cindex code staging
  6817. @cindex staging, of code
  6818. Keep in mind that build phases are code evaluated at the time the
  6819. package is actually built. This explains why the whole
  6820. @code{modify-phases} expression above is quoted (it comes after the
  6821. @code{'} or apostrophe): it is @dfn{staged} for later execution.
  6822. @xref{G-Expressions}, for an explanation of code staging and the
  6823. @dfn{code strata} involved.
  6824. @node Build Utilities
  6825. @section Build Utilities
  6826. As soon as you start writing non-trivial package definitions
  6827. (@pxref{Defining Packages}) or other build actions
  6828. (@pxref{G-Expressions}), you will likely start looking for helpers for
  6829. ``shell-like'' actions---creating directories, copying and deleting
  6830. files recursively, manipulating build phases, and so on. The
  6831. @code{(guix build utils)} module provides such utility procedures.
  6832. Most build systems load @code{(guix build utils)} (@pxref{Build
  6833. Systems}). Thus, when writing custom build phases for your package
  6834. definitions, you can usually assume those procedures are in scope.
  6835. When writing G-expressions, you can import @code{(guix build utils)} on
  6836. the ``build side'' using @code{with-imported-modules} and then put it in
  6837. scope with the @code{use-modules} form (@pxref{Using Guile Modules,,,
  6838. guile, GNU Guile Reference Manual}):
  6839. @lisp
  6840. (with-imported-modules '((guix build utils)) ;import it
  6841. (computed-file "empty-tree"
  6842. #~(begin
  6843. ;; Put it in scope.
  6844. (use-modules (guix build utils))
  6845. ;; Happily use its 'mkdir-p' procedure.
  6846. (mkdir-p (string-append #$output "/a/b/c")))))
  6847. @end lisp
  6848. The remainder of this section is the reference for most of the utility
  6849. procedures provided by @code{(guix build utils)}.
  6850. @c TODO Document what's missing.
  6851. @subsection Dealing with Store File Names
  6852. This section documents procedures that deal with store file names.
  6853. @deffn {Scheme Procedure} %store-directory
  6854. Return the directory name of the store.
  6855. @end deffn
  6856. @deffn {Scheme Procedure} store-file-name? @var{file}
  6857. Return true if @var{file} is in the store.
  6858. @end deffn
  6859. @deffn {Scheme Procedure} strip-store-file-name @var{file}
  6860. Strip the @file{/gnu/store} and hash from @var{file}, a store file name.
  6861. The result is typically a @code{"@var{package}-@var{version}"} string.
  6862. @end deffn
  6863. @deffn {Scheme Procedure} package-name->name+version @var{name}
  6864. Given @var{name}, a package name like @code{"foo-0.9.1b"}, return two
  6865. values: @code{"foo"} and @code{"0.9.1b"}. When the version part is
  6866. unavailable, @var{name} and @code{#f} are returned. The first hyphen
  6867. followed by a digit is considered to introduce the version part.
  6868. @end deffn
  6869. @subsection File Types
  6870. The procedures below deal with files and file types.
  6871. @deffn {Scheme Procedure} directory-exists? @var{dir}
  6872. Return @code{#t} if @var{dir} exists and is a directory.
  6873. @end deffn
  6874. @deffn {Scheme Procedure} executable-file? @var{file}
  6875. Return @code{#t} if @var{file} exists and is executable.
  6876. @end deffn
  6877. @deffn {Scheme Procedure} symbolic-link? @var{file}
  6878. Return @code{#t} if @var{file} is a symbolic link (aka. a ``symlink'').
  6879. @end deffn
  6880. @deffn {Scheme Procedure} elf-file? @var{file}
  6881. @deffnx {Scheme Procedure} ar-file? @var{file}
  6882. @deffnx {Scheme Procedure} gzip-file? @var{file}
  6883. Return @code{#t} if @var{file} is, respectively, an ELF file, an
  6884. @code{ar} archive (such as a @file{.a} static library), or a gzip file.
  6885. @end deffn
  6886. @deffn {Scheme Procedure} reset-gzip-timestamp @var{file} [#:keep-mtime? #t]
  6887. If @var{file} is a gzip file, reset its embedded timestamp (as with
  6888. @command{gzip --no-name}) and return true. Otherwise return @code{#f}.
  6889. When @var{keep-mtime?} is true, preserve @var{file}'s modification time.
  6890. @end deffn
  6891. @subsection File Manipulation
  6892. The following procedures and macros help create, modify, and delete
  6893. files. They provide functionality comparable to common shell utilities
  6894. such as @command{mkdir -p}, @command{cp -r}, @command{rm -r}, and
  6895. @command{sed}. They complement Guile's extensive, but low-level, file
  6896. system interface (@pxref{POSIX,,, guile, GNU Guile Reference Manual}).
  6897. @deffn {Scheme Syntax} with-directory-excursion @var{directory} @var{body}@dots{}
  6898. Run @var{body} with @var{directory} as the process's current directory.
  6899. Essentially, this macro changes the current directory to @var{directory}
  6900. before evaluating @var{body}, using @code{chdir} (@pxref{Processes,,,
  6901. guile, GNU Guile Reference Manual}). It changes back to the initial
  6902. directory when the dynamic extent of @var{body} is left, be it @i{via}
  6903. normal procedure return or @i{via} a non-local exit such as an
  6904. exception.
  6905. @end deffn
  6906. @deffn {Scheme Procedure} mkdir-p @var{dir}
  6907. Create directory @var{dir} and all its ancestors.
  6908. @end deffn
  6909. @deffn {Scheme Procedure} install-file @var{file} @var{directory}
  6910. Create @var{directory} if it does not exist and copy @var{file} in there
  6911. under the same name.
  6912. @end deffn
  6913. @deffn {Scheme Procedure} make-file-writable @var{file}
  6914. Make @var{file} writable for its owner.
  6915. @end deffn
  6916. @deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
  6917. [#:log (current-output-port)] [#:follow-symlinks? #f] [#:keep-mtime? #f]
  6918. Copy @var{source} directory to @var{destination}. Follow symlinks if
  6919. @var{follow-symlinks?} is true; otherwise, just preserve them. When
  6920. @var{keep-mtime?} is true, keep the modification time of the files in
  6921. @var{source} on those of @var{destination}. Write verbose output to the
  6922. @var{log} port.
  6923. @end deffn
  6924. @deffn {Scheme Procedure} delete-file-recursively @var{dir} @
  6925. [#:follow-mounts? #f]
  6926. Delete @var{dir} recursively, like @command{rm -rf}, without following
  6927. symlinks. Don't follow mount points either, unless @var{follow-mounts?}
  6928. is true. Report but ignore errors.
  6929. @end deffn
  6930. @deffn {Scheme Syntax} substitute* @var{file} @
  6931. ((@var{regexp} @var{match-var}@dots{}) @var{body}@dots{}) @dots{}
  6932. Substitute @var{regexp} in @var{file} by the string returned by
  6933. @var{body}. @var{body} is evaluated with each @var{match-var} bound to
  6934. the corresponding positional regexp sub-expression. For example:
  6935. @lisp
  6936. (substitute* file
  6937. (("hello")
  6938. "good morning\n")
  6939. (("foo([a-z]+)bar(.*)$" all letters end)
  6940. (string-append "baz" letter end)))
  6941. @end lisp
  6942. Here, anytime a line of @var{file} contains @code{hello}, it is replaced
  6943. by @code{good morning}. Anytime a line of @var{file} matches the second
  6944. regexp, @code{all} is bound to the complete match, @code{letters} is bound
  6945. to the first sub-expression, and @code{end} is bound to the last one.
  6946. When one of the @var{match-var} is @code{_}, no variable is bound to the
  6947. corresponding match substring.
  6948. Alternatively, @var{file} may be a list of file names, in which case
  6949. they are all subject to the substitutions.
  6950. Be careful about using @code{$} to match the end of a line; by itself it
  6951. won't match the terminating newline of a line.
  6952. @end deffn
  6953. @subsection File Search
  6954. @cindex file, searching
  6955. This section documents procedures to search and filter files.
  6956. @deffn {Scheme Procedure} file-name-predicate @var{regexp}
  6957. Return a predicate that returns true when passed a file name whose base
  6958. name matches @var{regexp}.
  6959. @end deffn
  6960. @deffn {Scheme Procedure} find-files @var{dir} [@var{pred}] @
  6961. [#:stat lstat] [#:directories? #f] [#:fail-on-error? #f]
  6962. Return the lexicographically sorted list of files under @var{dir} for
  6963. which @var{pred} returns true. @var{pred} is passed two arguments: the
  6964. absolute file name, and its stat buffer; the default predicate always
  6965. returns true. @var{pred} can also be a regular expression, in which
  6966. case it is equivalent to @code{(file-name-predicate @var{pred})}.
  6967. @var{stat} is used to obtain file information; using @code{lstat} means
  6968. that symlinks are not followed. If @var{directories?} is true, then
  6969. directories will also be included. If @var{fail-on-error?} is true,
  6970. raise an exception upon error.
  6971. @end deffn
  6972. Here are a few examples where we assume that the current directory is
  6973. the root of the Guix source tree:
  6974. @lisp
  6975. ;; List all the regular files in the current directory.
  6976. (find-files ".")
  6977. @result{} ("./.dir-locals.el" "./.gitignore" @dots{})
  6978. ;; List all the .scm files under gnu/services.
  6979. (find-files "gnu/services" "\\.scm$")
  6980. @result{} ("gnu/services/admin.scm" "gnu/services/audio.scm" @dots{})
  6981. ;; List ar files in the current directory.
  6982. (find-files "." (lambda (file stat) (ar-file? file)))
  6983. @result{} ("./libformat.a" "./libstore.a" @dots{})
  6984. @end lisp
  6985. @deffn {Scheme Procedure} which @var{program}
  6986. Return the complete file name for @var{program} as found in
  6987. @code{$PATH}, or @code{#f} if @var{program} could not be found.
  6988. @end deffn
  6989. @subsection Build Phases
  6990. @cindex build phases
  6991. The @code{(guix build utils)} also contains tools to manipulate build
  6992. phases as used by build systems (@pxref{Build Systems}). Build phases
  6993. are represented as association lists or ``alists'' (@pxref{Association
  6994. Lists,,, guile, GNU Guile Reference Manual}) where each key is a symbol
  6995. naming the phase and the associated value is a procedure (@pxref{Build
  6996. Phases}).
  6997. Guile core and the @code{(srfi srfi-1)} module both provide tools to
  6998. manipulate alists. The @code{(guix build utils)} module complements
  6999. those with tools written with build phases in mind.
  7000. @cindex build phases, modifying
  7001. @deffn {Scheme Syntax} modify-phases @var{phases} @var{clause}@dots{}
  7002. Modify @var{phases} sequentially as per each @var{clause}, which may
  7003. have one of the following forms:
  7004. @lisp
  7005. (delete @var{old-phase-name})
  7006. (replace @var{old-phase-name} @var{new-phase})
  7007. (add-before @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7008. (add-after @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7009. @end lisp
  7010. Where every @var{phase-name} above is an expression evaluating to a
  7011. symbol, and @var{new-phase} an expression evaluating to a procedure.
  7012. @end deffn
  7013. The example below is taken from the definition of the @code{grep}
  7014. package. It adds a phase to run after the @code{install} phase, called
  7015. @code{fix-egrep-and-fgrep}. That phase is a procedure (@code{lambda*}
  7016. is for anonymous procedures) that takes a @code{#:outputs} keyword
  7017. argument and ignores extra keyword arguments (@pxref{Optional
  7018. Arguments,,, guile, GNU Guile Reference Manual}, for more on
  7019. @code{lambda*} and optional and keyword arguments.) The phase uses
  7020. @code{substitute*} to modify the installed @file{egrep} and @file{fgrep}
  7021. scripts so that they refer to @code{grep} by its absolute file name:
  7022. @lisp
  7023. (modify-phases %standard-phases
  7024. (add-after 'install 'fix-egrep-and-fgrep
  7025. ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
  7026. ;; absolute file name instead of searching for it in $PATH.
  7027. (lambda* (#:key outputs #:allow-other-keys)
  7028. (let* ((out (assoc-ref outputs "out"))
  7029. (bin (string-append out "/bin")))
  7030. (substitute* (list (string-append bin "/egrep")
  7031. (string-append bin "/fgrep"))
  7032. (("^exec grep")
  7033. (string-append "exec " bin "/grep")))
  7034. #t))))
  7035. @end lisp
  7036. In the example below, phases are modified in two ways: the standard
  7037. @code{configure} phase is deleted, presumably because the package does
  7038. not have a @file{configure} script or anything similar, and the default
  7039. @code{install} phase is replaced by one that manually copies the
  7040. executable files to be installed:
  7041. @lisp
  7042. (modify-phases %standard-phases
  7043. (delete 'configure) ;no 'configure' script
  7044. (replace 'install
  7045. (lambda* (#:key outputs #:allow-other-keys)
  7046. ;; The package's Makefile doesn't provide an "install"
  7047. ;; rule so do it by ourselves.
  7048. (let ((bin (string-append (assoc-ref outputs "out")
  7049. "/bin")))
  7050. (install-file "footswitch" bin)
  7051. (install-file "scythe" bin)
  7052. #t))))
  7053. @end lisp
  7054. @c TODO: Add more examples.
  7055. @node The Store
  7056. @section The Store
  7057. @cindex store
  7058. @cindex store items
  7059. @cindex store paths
  7060. Conceptually, the @dfn{store} is the place where derivations that have
  7061. been built successfully are stored---by default, @file{/gnu/store}.
  7062. Sub-directories in the store are referred to as @dfn{store items} or
  7063. sometimes @dfn{store paths}. The store has an associated database that
  7064. contains information such as the store paths referred to by each store
  7065. path, and the list of @emph{valid} store items---results of successful
  7066. builds. This database resides in @file{@var{localstatedir}/guix/db},
  7067. where @var{localstatedir} is the state directory specified @i{via}
  7068. @option{--localstatedir} at configure time, usually @file{/var}.
  7069. The store is @emph{always} accessed by the daemon on behalf of its clients
  7070. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  7071. connect to the daemon over a Unix-domain socket, send requests to it,
  7072. and read the result---these are remote procedure calls, or RPCs.
  7073. @quotation Note
  7074. Users must @emph{never} modify files under @file{/gnu/store} directly.
  7075. This would lead to inconsistencies and break the immutability
  7076. assumptions of Guix's functional model (@pxref{Introduction}).
  7077. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  7078. how to check the integrity of the store and attempt recovery from
  7079. accidental modifications.
  7080. @end quotation
  7081. The @code{(guix store)} module provides procedures to connect to the
  7082. daemon, and to perform RPCs. These are described below. By default,
  7083. @code{open-connection}, and thus all the @command{guix} commands,
  7084. connect to the local daemon or to the URI specified by the
  7085. @env{GUIX_DAEMON_SOCKET} environment variable.
  7086. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  7087. When set, the value of this variable should be a file name or a URI
  7088. designating the daemon endpoint. When it is a file name, it denotes a
  7089. Unix-domain socket to connect to. In addition to file names, the
  7090. supported URI schemes are:
  7091. @table @code
  7092. @item file
  7093. @itemx unix
  7094. These are for Unix-domain sockets.
  7095. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  7096. @file{/var/guix/daemon-socket/socket}.
  7097. @item guix
  7098. @cindex daemon, remote access
  7099. @cindex remote access to the daemon
  7100. @cindex daemon, cluster setup
  7101. @cindex clusters, daemon setup
  7102. These URIs denote connections over TCP/IP, without encryption nor
  7103. authentication of the remote host. The URI must specify the host name
  7104. and optionally a port number (by default port 44146 is used):
  7105. @example
  7106. guix://master.guix.example.org:1234
  7107. @end example
  7108. This setup is suitable on local networks, such as clusters, where only
  7109. trusted nodes may connect to the build daemon at
  7110. @code{master.guix.example.org}.
  7111. The @option{--listen} option of @command{guix-daemon} can be used to
  7112. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  7113. @option{--listen}}).
  7114. @item ssh
  7115. @cindex SSH access to build daemons
  7116. These URIs allow you to connect to a remote daemon over SSH@. This
  7117. feature requires Guile-SSH (@pxref{Requirements}) and a working
  7118. @command{guile} binary in @env{PATH} on the destination machine. It
  7119. supports public key and GSSAPI authentication. A typical URL might look
  7120. like this:
  7121. @example
  7122. ssh://charlie@@guix.example.org:22
  7123. @end example
  7124. As for @command{guix copy}, the usual OpenSSH client configuration files
  7125. are honored (@pxref{Invoking guix copy}).
  7126. @end table
  7127. Additional URI schemes may be supported in the future.
  7128. @c XXX: Remove this note when the protocol incurs fewer round trips
  7129. @c and when (guix derivations) no longer relies on file system access.
  7130. @quotation Note
  7131. The ability to connect to remote build daemons is considered
  7132. experimental as of @value{VERSION}. Please get in touch with us to
  7133. share any problems or suggestions you may have (@pxref{Contributing}).
  7134. @end quotation
  7135. @end defvr
  7136. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  7137. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  7138. @var{reserve-space?} is true, instruct it to reserve a little bit of
  7139. extra space on the file system so that the garbage collector can still
  7140. operate should the disk become full. Return a server object.
  7141. @var{file} defaults to @code{%default-socket-path}, which is the normal
  7142. location given the options that were passed to @command{configure}.
  7143. @end deffn
  7144. @deffn {Scheme Procedure} close-connection @var{server}
  7145. Close the connection to @var{server}.
  7146. @end deffn
  7147. @defvr {Scheme Variable} current-build-output-port
  7148. This variable is bound to a SRFI-39 parameter, which refers to the port
  7149. where build and error logs sent by the daemon should be written.
  7150. @end defvr
  7151. Procedures that make RPCs all take a server object as their first
  7152. argument.
  7153. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  7154. @cindex invalid store items
  7155. Return @code{#t} when @var{path} designates a valid store item and
  7156. @code{#f} otherwise (an invalid item may exist on disk but still be
  7157. invalid, for instance because it is the result of an aborted or failed
  7158. build).
  7159. A @code{&store-protocol-error} condition is raised if @var{path} is not
  7160. prefixed by the store directory (@file{/gnu/store}).
  7161. @end deffn
  7162. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  7163. Add @var{text} under file @var{name} in the store, and return its store
  7164. path. @var{references} is the list of store paths referred to by the
  7165. resulting store path.
  7166. @end deffn
  7167. @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
  7168. [@var{mode}]
  7169. Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
  7170. file names, or derivation/output pairs, using the specified
  7171. @var{mode}---@code{(build-mode normal)} by default.
  7172. @end deffn
  7173. Note that the @code{(guix monads)} module provides a monad as well as
  7174. monadic versions of the above procedures, with the goal of making it
  7175. more convenient to work with code that accesses the store (@pxref{The
  7176. Store Monad}).
  7177. @c FIXME
  7178. @i{This section is currently incomplete.}
  7179. @node Derivations
  7180. @section Derivations
  7181. @cindex derivations
  7182. Low-level build actions and the environment in which they are performed
  7183. are represented by @dfn{derivations}. A derivation contains the
  7184. following pieces of information:
  7185. @itemize
  7186. @item
  7187. The outputs of the derivation---derivations produce at least one file or
  7188. directory in the store, but may produce more.
  7189. @item
  7190. @cindex build-time dependencies
  7191. @cindex dependencies, build-time
  7192. The inputs of the derivations---i.e., its build-time dependencies---which may
  7193. be other derivations or plain files in the store (patches, build scripts,
  7194. etc.).
  7195. @item
  7196. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  7197. @item
  7198. The file name of a build script in the store, along with the arguments
  7199. to be passed.
  7200. @item
  7201. A list of environment variables to be defined.
  7202. @end itemize
  7203. @cindex derivation path
  7204. Derivations allow clients of the daemon to communicate build actions to
  7205. the store. They exist in two forms: as an in-memory representation,
  7206. both on the client- and daemon-side, and as files in the store whose
  7207. name end in @file{.drv}---these files are referred to as @dfn{derivation
  7208. paths}. Derivations paths can be passed to the @code{build-derivations}
  7209. procedure to perform the build actions they prescribe (@pxref{The
  7210. Store}).
  7211. @cindex fixed-output derivations
  7212. Operations such as file downloads and version-control checkouts for
  7213. which the expected content hash is known in advance are modeled as
  7214. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  7215. of a fixed-output derivation are independent of its inputs---e.g., a
  7216. source code download produces the same result regardless of the download
  7217. method and tools being used.
  7218. @cindex references
  7219. @cindex run-time dependencies
  7220. @cindex dependencies, run-time
  7221. The outputs of derivations---i.e., the build results---have a set of
  7222. @dfn{references}, as reported by the @code{references} RPC or the
  7223. @command{guix gc --references} command (@pxref{Invoking guix gc}). References
  7224. are the set of run-time dependencies of the build results. References are a
  7225. subset of the inputs of the derivation; this subset is automatically computed
  7226. by the build daemon by scanning all the files in the outputs.
  7227. The @code{(guix derivations)} module provides a representation of
  7228. derivations as Scheme objects, along with procedures to create and
  7229. otherwise manipulate derivations. The lowest-level primitive to create
  7230. a derivation is the @code{derivation} procedure:
  7231. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  7232. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7233. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  7234. [#:system (%current-system)] [#:references-graphs #f] @
  7235. [#:allowed-references #f] [#:disallowed-references #f] @
  7236. [#:leaked-env-vars #f] [#:local-build? #f] @
  7237. [#:substitutable? #t] [#:properties '()]
  7238. Build a derivation with the given arguments, and return the resulting
  7239. @code{<derivation>} object.
  7240. When @var{hash} and @var{hash-algo} are given, a
  7241. @dfn{fixed-output derivation} is created---i.e., one whose result is
  7242. known in advance, such as a file download. If, in addition,
  7243. @var{recursive?} is true, then that fixed output may be an executable
  7244. file or a directory and @var{hash} must be the hash of an archive
  7245. containing this output.
  7246. When @var{references-graphs} is true, it must be a list of file
  7247. name/store path pairs. In that case, the reference graph of each store
  7248. path is exported in the build environment in the corresponding file, in
  7249. a simple text format.
  7250. When @var{allowed-references} is true, it must be a list of store items
  7251. or outputs that the derivation's output may refer to. Likewise,
  7252. @var{disallowed-references}, if true, must be a list of things the
  7253. outputs may @emph{not} refer to.
  7254. When @var{leaked-env-vars} is true, it must be a list of strings
  7255. denoting environment variables that are allowed to ``leak'' from the
  7256. daemon's environment to the build environment. This is only applicable
  7257. to fixed-output derivations---i.e., when @var{hash} is true. The main
  7258. use is to allow variables such as @code{http_proxy} to be passed to
  7259. derivations that download files.
  7260. When @var{local-build?} is true, declare that the derivation is not a
  7261. good candidate for offloading and should rather be built locally
  7262. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  7263. where the costs of data transfers would outweigh the benefits.
  7264. When @var{substitutable?} is false, declare that substitutes of the
  7265. derivation's output should not be used (@pxref{Substitutes}). This is
  7266. useful, for instance, when building packages that capture details of the
  7267. host CPU instruction set.
  7268. @var{properties} must be an association list describing ``properties'' of the
  7269. derivation. It is kept as-is, uninterpreted, in the derivation.
  7270. @end deffn
  7271. @noindent
  7272. Here's an example with a shell script as its builder, assuming
  7273. @var{store} is an open connection to the daemon, and @var{bash} points
  7274. to a Bash executable in the store:
  7275. @lisp
  7276. (use-modules (guix utils)
  7277. (guix store)
  7278. (guix derivations))
  7279. (let ((builder ; add the Bash script to the store
  7280. (add-text-to-store store "my-builder.sh"
  7281. "echo hello world > $out\n" '())))
  7282. (derivation store "foo"
  7283. bash `("-e" ,builder)
  7284. #:inputs `((,bash) (,builder))
  7285. #:env-vars '(("HOME" . "/homeless"))))
  7286. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  7287. @end lisp
  7288. As can be guessed, this primitive is cumbersome to use directly. A
  7289. better approach is to write build scripts in Scheme, of course! The
  7290. best course of action for that is to write the build code as a
  7291. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  7292. information, @pxref{G-Expressions}.
  7293. Once upon a time, @code{gexp->derivation} did not exist and constructing
  7294. derivations with build code written in Scheme was achieved with
  7295. @code{build-expression->derivation}, documented below. This procedure
  7296. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  7297. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  7298. @var{name} @var{exp} @
  7299. [#:system (%current-system)] [#:inputs '()] @
  7300. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  7301. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  7302. [#:references-graphs #f] [#:allowed-references #f] @
  7303. [#:disallowed-references #f] @
  7304. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  7305. Return a derivation that executes Scheme expression @var{exp} as a
  7306. builder for derivation @var{name}. @var{inputs} must be a list of
  7307. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  7308. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  7309. modules from the current search path to be copied in the store,
  7310. compiled, and made available in the load path during the execution of
  7311. @var{exp}---e.g., @code{((guix build utils) (guix build
  7312. gnu-build-system))}.
  7313. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  7314. to a list of output/path pairs, and where @code{%build-inputs} is bound
  7315. to a list of string/output-path pairs made from @var{inputs}.
  7316. Optionally, @var{env-vars} is a list of string pairs specifying the name
  7317. and value of environment variables visible to the builder. The builder
  7318. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  7319. @var{exp} returns @code{#f}, the build is considered to have failed.
  7320. @var{exp} is built using @var{guile-for-build} (a derivation). When
  7321. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  7322. @code{%guile-for-build} fluid is used instead.
  7323. See the @code{derivation} procedure for the meaning of
  7324. @var{references-graphs}, @var{allowed-references},
  7325. @var{disallowed-references}, @var{local-build?}, and
  7326. @var{substitutable?}.
  7327. @end deffn
  7328. @noindent
  7329. Here's an example of a single-output derivation that creates a directory
  7330. containing one file:
  7331. @lisp
  7332. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  7333. (mkdir out) ; create /gnu/store/@dots{}-goo
  7334. (call-with-output-file (string-append out "/test")
  7335. (lambda (p)
  7336. (display '(hello guix) p))))))
  7337. (build-expression->derivation store "goo" builder))
  7338. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  7339. @end lisp
  7340. @node The Store Monad
  7341. @section The Store Monad
  7342. @cindex monad
  7343. The procedures that operate on the store described in the previous
  7344. sections all take an open connection to the build daemon as their first
  7345. argument. Although the underlying model is functional, they either have
  7346. side effects or depend on the current state of the store.
  7347. The former is inconvenient: the connection to the build daemon has to be
  7348. carried around in all those functions, making it impossible to compose
  7349. functions that do not take that parameter with functions that do. The
  7350. latter can be problematic: since store operations have side effects
  7351. and/or depend on external state, they have to be properly sequenced.
  7352. @cindex monadic values
  7353. @cindex monadic functions
  7354. This is where the @code{(guix monads)} module comes in. This module
  7355. provides a framework for working with @dfn{monads}, and a particularly
  7356. useful monad for our uses, the @dfn{store monad}. Monads are a
  7357. construct that allows two things: associating ``context'' with values
  7358. (in our case, the context is the store), and building sequences of
  7359. computations (here computations include accesses to the store). Values
  7360. in a monad---values that carry this additional context---are called
  7361. @dfn{monadic values}; procedures that return such values are called
  7362. @dfn{monadic procedures}.
  7363. Consider this ``normal'' procedure:
  7364. @lisp
  7365. (define (sh-symlink store)
  7366. ;; Return a derivation that symlinks the 'bash' executable.
  7367. (let* ((drv (package-derivation store bash))
  7368. (out (derivation->output-path drv))
  7369. (sh (string-append out "/bin/bash")))
  7370. (build-expression->derivation store "sh"
  7371. `(symlink ,sh %output))))
  7372. @end lisp
  7373. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  7374. as a monadic function:
  7375. @lisp
  7376. (define (sh-symlink)
  7377. ;; Same, but return a monadic value.
  7378. (mlet %store-monad ((drv (package->derivation bash)))
  7379. (gexp->derivation "sh"
  7380. #~(symlink (string-append #$drv "/bin/bash")
  7381. #$output))))
  7382. @end lisp
  7383. There are several things to note in the second version: the @code{store}
  7384. parameter is now implicit and is ``threaded'' in the calls to the
  7385. @code{package->derivation} and @code{gexp->derivation} monadic
  7386. procedures, and the monadic value returned by @code{package->derivation}
  7387. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  7388. As it turns out, the call to @code{package->derivation} can even be
  7389. omitted since it will take place implicitly, as we will see later
  7390. (@pxref{G-Expressions}):
  7391. @lisp
  7392. (define (sh-symlink)
  7393. (gexp->derivation "sh"
  7394. #~(symlink (string-append #$bash "/bin/bash")
  7395. #$output)))
  7396. @end lisp
  7397. @c See
  7398. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  7399. @c for the funny quote.
  7400. Calling the monadic @code{sh-symlink} has no effect. As someone once
  7401. said, ``you exit a monad like you exit a building on fire: by running''.
  7402. So, to exit the monad and get the desired effect, one must use
  7403. @code{run-with-store}:
  7404. @lisp
  7405. (run-with-store (open-connection) (sh-symlink))
  7406. @result{} /gnu/store/...-sh-symlink
  7407. @end lisp
  7408. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  7409. new ``meta-commands'' to make it easier to deal with monadic procedures:
  7410. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  7411. to ``run'' a single monadic value through the store:
  7412. @example
  7413. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  7414. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7415. @end example
  7416. The latter enters a recursive REPL, where all the return values are
  7417. automatically run through the store:
  7418. @example
  7419. scheme@@(guile-user)> ,enter-store-monad
  7420. store-monad@@(guile-user) [1]> (package->derivation hello)
  7421. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  7422. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  7423. $3 = "/gnu/store/@dots{}-foo"
  7424. store-monad@@(guile-user) [1]> ,q
  7425. scheme@@(guile-user)>
  7426. @end example
  7427. @noindent
  7428. Note that non-monadic values cannot be returned in the
  7429. @code{store-monad} REPL.
  7430. The main syntactic forms to deal with monads in general are provided by
  7431. the @code{(guix monads)} module and are described below.
  7432. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  7433. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  7434. in @var{monad}.
  7435. @end deffn
  7436. @deffn {Scheme Syntax} return @var{val}
  7437. Return a monadic value that encapsulates @var{val}.
  7438. @end deffn
  7439. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  7440. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  7441. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  7442. referred to as ``bind'', but that name denotes an unrelated procedure in
  7443. Guile. Thus we use this somewhat cryptic symbol inherited from the
  7444. Haskell language.}. There can be one @var{mproc} or several of them, as
  7445. in this example:
  7446. @lisp
  7447. (run-with-state
  7448. (with-monad %state-monad
  7449. (>>= (return 1)
  7450. (lambda (x) (return (+ 1 x)))
  7451. (lambda (x) (return (* 2 x)))))
  7452. 'some-state)
  7453. @result{} 4
  7454. @result{} some-state
  7455. @end lisp
  7456. @end deffn
  7457. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  7458. @var{body} ...
  7459. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  7460. @var{body} ...
  7461. Bind the variables @var{var} to the monadic values @var{mval} in
  7462. @var{body}, which is a sequence of expressions. As with the bind
  7463. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  7464. value ``contained'' in @var{mval} and making @var{var} refer to that
  7465. raw, non-monadic value within the scope of the @var{body}. The form
  7466. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  7467. @var{val}, as per @code{let}. The binding operations occur in sequence
  7468. from left to right. The last expression of @var{body} must be a monadic
  7469. expression, and its result will become the result of the @code{mlet} or
  7470. @code{mlet*} when run in the @var{monad}.
  7471. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  7472. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  7473. @end deffn
  7474. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  7475. Bind @var{mexp} and the following monadic expressions in sequence,
  7476. returning the result of the last expression. Every expression in the
  7477. sequence must be a monadic expression.
  7478. This is akin to @code{mlet}, except that the return values of the
  7479. monadic expressions are ignored. In that sense, it is analogous to
  7480. @code{begin}, but applied to monadic expressions.
  7481. @end deffn
  7482. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  7483. When @var{condition} is true, evaluate the sequence of monadic
  7484. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  7485. @var{condition} is false, return @code{*unspecified*} in the current
  7486. monad. Every expression in the sequence must be a monadic expression.
  7487. @end deffn
  7488. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  7489. When @var{condition} is false, evaluate the sequence of monadic
  7490. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  7491. @var{condition} is true, return @code{*unspecified*} in the current
  7492. monad. Every expression in the sequence must be a monadic expression.
  7493. @end deffn
  7494. @cindex state monad
  7495. The @code{(guix monads)} module provides the @dfn{state monad}, which
  7496. allows an additional value---the state---to be @emph{threaded} through
  7497. monadic procedure calls.
  7498. @defvr {Scheme Variable} %state-monad
  7499. The state monad. Procedures in the state monad can access and change
  7500. the state that is threaded.
  7501. Consider the example below. The @code{square} procedure returns a value
  7502. in the state monad. It returns the square of its argument, but also
  7503. increments the current state value:
  7504. @lisp
  7505. (define (square x)
  7506. (mlet %state-monad ((count (current-state)))
  7507. (mbegin %state-monad
  7508. (set-current-state (+ 1 count))
  7509. (return (* x x)))))
  7510. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  7511. @result{} (0 1 4)
  7512. @result{} 3
  7513. @end lisp
  7514. When ``run'' through @code{%state-monad}, we obtain that additional state
  7515. value, which is the number of @code{square} calls.
  7516. @end defvr
  7517. @deffn {Monadic Procedure} current-state
  7518. Return the current state as a monadic value.
  7519. @end deffn
  7520. @deffn {Monadic Procedure} set-current-state @var{value}
  7521. Set the current state to @var{value} and return the previous state as a
  7522. monadic value.
  7523. @end deffn
  7524. @deffn {Monadic Procedure} state-push @var{value}
  7525. Push @var{value} to the current state, which is assumed to be a list,
  7526. and return the previous state as a monadic value.
  7527. @end deffn
  7528. @deffn {Monadic Procedure} state-pop
  7529. Pop a value from the current state and return it as a monadic value.
  7530. The state is assumed to be a list.
  7531. @end deffn
  7532. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  7533. Run monadic value @var{mval} starting with @var{state} as the initial
  7534. state. Return two values: the resulting value, and the resulting state.
  7535. @end deffn
  7536. The main interface to the store monad, provided by the @code{(guix
  7537. store)} module, is as follows.
  7538. @defvr {Scheme Variable} %store-monad
  7539. The store monad---an alias for @code{%state-monad}.
  7540. Values in the store monad encapsulate accesses to the store. When its
  7541. effect is needed, a value of the store monad must be ``evaluated'' by
  7542. passing it to the @code{run-with-store} procedure (see below).
  7543. @end defvr
  7544. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  7545. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  7546. open store connection.
  7547. @end deffn
  7548. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  7549. Return as a monadic value the absolute file name in the store of the file
  7550. containing @var{text}, a string. @var{references} is a list of store items that the
  7551. resulting text file refers to; it defaults to the empty list.
  7552. @end deffn
  7553. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  7554. Return as a monadic value the absolute file name in the store of the file
  7555. containing @var{data}, a bytevector. @var{references} is a list of store
  7556. items that the resulting binary file refers to; it defaults to the empty list.
  7557. @end deffn
  7558. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  7559. [#:recursive? #t] [#:select? (const #t)]
  7560. Return the name of @var{file} once interned in the store. Use
  7561. @var{name} as its store name, or the basename of @var{file} if
  7562. @var{name} is omitted.
  7563. When @var{recursive?} is true, the contents of @var{file} are added
  7564. recursively; if @var{file} designates a flat file and @var{recursive?}
  7565. is true, its contents are added, and its permission bits are kept.
  7566. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  7567. @var{stat})} for each directory entry, where @var{file} is the entry's
  7568. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  7569. entries for which @var{select?} does not return true.
  7570. The example below adds a file to the store, under two different names:
  7571. @lisp
  7572. (run-with-store (open-connection)
  7573. (mlet %store-monad ((a (interned-file "README"))
  7574. (b (interned-file "README" "LEGU-MIN")))
  7575. (return (list a b))))
  7576. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  7577. @end lisp
  7578. @end deffn
  7579. The @code{(guix packages)} module exports the following package-related
  7580. monadic procedures:
  7581. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  7582. [#:system (%current-system)] [#:target #f] @
  7583. [#:output "out"]
  7584. Return as a monadic
  7585. value in the absolute file name of @var{file} within the @var{output}
  7586. directory of @var{package}. When @var{file} is omitted, return the name
  7587. of the @var{output} directory of @var{package}. When @var{target} is
  7588. true, use it as a cross-compilation target triplet.
  7589. Note that this procedure does @emph{not} build @var{package}. Thus, the
  7590. result might or might not designate an existing file. We recommend not
  7591. using this procedure unless you know what you are doing.
  7592. @end deffn
  7593. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  7594. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  7595. @var{target} [@var{system}]
  7596. Monadic version of @code{package-derivation} and
  7597. @code{package-cross-derivation} (@pxref{Defining Packages}).
  7598. @end deffn
  7599. @node G-Expressions
  7600. @section G-Expressions
  7601. @cindex G-expression
  7602. @cindex build code quoting
  7603. So we have ``derivations'', which represent a sequence of build actions
  7604. to be performed to produce an item in the store (@pxref{Derivations}).
  7605. These build actions are performed when asking the daemon to actually
  7606. build the derivations; they are run by the daemon in a container
  7607. (@pxref{Invoking guix-daemon}).
  7608. @cindex code staging
  7609. @cindex staging, of code
  7610. @cindex strata of code
  7611. It should come as no surprise that we like to write these build actions
  7612. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  7613. code@footnote{The term @dfn{stratum} in this context was coined by
  7614. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  7615. Kiselyov, who has written insightful
  7616. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  7617. on this topic}, refers to this kind of code generation as
  7618. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  7619. to the daemon, etc.---and the ``build code''---code that actually
  7620. performs build actions, such as making directories, invoking
  7621. @command{make}, and so on (@pxref{Build Phases}).
  7622. To describe a derivation and its build actions, one typically needs to
  7623. embed build code inside host code. It boils down to manipulating build
  7624. code as data, and the homoiconicity of Scheme---code has a direct
  7625. representation as data---comes in handy for that. But we need more than
  7626. the normal @code{quasiquote} mechanism in Scheme to construct build
  7627. expressions.
  7628. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  7629. S-expressions adapted to build expressions. G-expressions, or
  7630. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  7631. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  7632. @code{#$}, and @code{#$@@}), which are comparable to
  7633. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  7634. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  7635. GNU Guile Reference Manual}). However, there are major differences:
  7636. @itemize
  7637. @item
  7638. Gexps are meant to be written to a file and run or manipulated by other
  7639. processes.
  7640. @item
  7641. When a high-level object such as a package or derivation is unquoted
  7642. inside a gexp, the result is as if its output file name had been
  7643. introduced.
  7644. @item
  7645. Gexps carry information about the packages or derivations they refer to,
  7646. and these dependencies are automatically added as inputs to the build
  7647. processes that use them.
  7648. @end itemize
  7649. @cindex lowering, of high-level objects in gexps
  7650. This mechanism is not limited to package and derivation
  7651. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  7652. derivations or files in the store can be defined,
  7653. such that these objects can also be inserted
  7654. into gexps. For example, a useful type of high-level objects that can be
  7655. inserted in a gexp is ``file-like objects'', which make it easy to
  7656. add files to the store and to refer to them in
  7657. derivations and such (see @code{local-file} and @code{plain-file}
  7658. below).
  7659. To illustrate the idea, here is an example of a gexp:
  7660. @lisp
  7661. (define build-exp
  7662. #~(begin
  7663. (mkdir #$output)
  7664. (chdir #$output)
  7665. (symlink (string-append #$coreutils "/bin/ls")
  7666. "list-files")))
  7667. @end lisp
  7668. This gexp can be passed to @code{gexp->derivation}; we obtain a
  7669. derivation that builds a directory containing exactly one symlink to
  7670. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  7671. @lisp
  7672. (gexp->derivation "the-thing" build-exp)
  7673. @end lisp
  7674. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  7675. substituted to the reference to the @var{coreutils} package in the
  7676. actual build code, and @var{coreutils} is automatically made an input to
  7677. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  7678. output)}) is replaced by a string containing the directory name of the
  7679. output of the derivation.
  7680. @cindex cross compilation
  7681. In a cross-compilation context, it is useful to distinguish between
  7682. references to the @emph{native} build of a package---that can run on the
  7683. host---versus references to cross builds of a package. To that end, the
  7684. @code{#+} plays the same role as @code{#$}, but is a reference to a
  7685. native package build:
  7686. @lisp
  7687. (gexp->derivation "vi"
  7688. #~(begin
  7689. (mkdir #$output)
  7690. (mkdir (string-append #$output "/bin"))
  7691. (system* (string-append #+coreutils "/bin/ln")
  7692. "-s"
  7693. (string-append #$emacs "/bin/emacs")
  7694. (string-append #$output "/bin/vi")))
  7695. #:target "aarch64-linux-gnu")
  7696. @end lisp
  7697. @noindent
  7698. In the example above, the native build of @var{coreutils} is used, so
  7699. that @command{ln} can actually run on the host; but then the
  7700. cross-compiled build of @var{emacs} is referenced.
  7701. @cindex imported modules, for gexps
  7702. @findex with-imported-modules
  7703. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  7704. able to use certain Guile modules from the ``host environment'' in the
  7705. gexp, so those modules should be imported in the ``build environment''.
  7706. The @code{with-imported-modules} form allows you to express that:
  7707. @lisp
  7708. (let ((build (with-imported-modules '((guix build utils))
  7709. #~(begin
  7710. (use-modules (guix build utils))
  7711. (mkdir-p (string-append #$output "/bin"))))))
  7712. (gexp->derivation "empty-dir"
  7713. #~(begin
  7714. #$build
  7715. (display "success!\n")
  7716. #t)))
  7717. @end lisp
  7718. @noindent
  7719. In this example, the @code{(guix build utils)} module is automatically
  7720. pulled into the isolated build environment of our gexp, such that
  7721. @code{(use-modules (guix build utils))} works as expected.
  7722. @cindex module closure
  7723. @findex source-module-closure
  7724. Usually you want the @emph{closure} of the module to be imported---i.e.,
  7725. the module itself and all the modules it depends on---rather than just
  7726. the module; failing to do that, attempts to use the module will fail
  7727. because of missing dependent modules. The @code{source-module-closure}
  7728. procedure computes the closure of a module by looking at its source file
  7729. headers, which comes in handy in this case:
  7730. @lisp
  7731. (use-modules (guix modules)) ;for 'source-module-closure'
  7732. (with-imported-modules (source-module-closure
  7733. '((guix build utils)
  7734. (gnu build vm)))
  7735. (gexp->derivation "something-with-vms"
  7736. #~(begin
  7737. (use-modules (guix build utils)
  7738. (gnu build vm))
  7739. @dots{})))
  7740. @end lisp
  7741. @cindex extensions, for gexps
  7742. @findex with-extensions
  7743. In the same vein, sometimes you want to import not just pure-Scheme
  7744. modules, but also ``extensions'' such as Guile bindings to C libraries
  7745. or other ``full-blown'' packages. Say you need the @code{guile-json}
  7746. package available on the build side, here's how you would do it:
  7747. @lisp
  7748. (use-modules (gnu packages guile)) ;for 'guile-json'
  7749. (with-extensions (list guile-json)
  7750. (gexp->derivation "something-with-json"
  7751. #~(begin
  7752. (use-modules (json))
  7753. @dots{})))
  7754. @end lisp
  7755. The syntactic form to construct gexps is summarized below.
  7756. @deffn {Scheme Syntax} #~@var{exp}
  7757. @deffnx {Scheme Syntax} (gexp @var{exp})
  7758. Return a G-expression containing @var{exp}. @var{exp} may contain one
  7759. or more of the following forms:
  7760. @table @code
  7761. @item #$@var{obj}
  7762. @itemx (ungexp @var{obj})
  7763. Introduce a reference to @var{obj}. @var{obj} may have one of the
  7764. supported types, for example a package or a
  7765. derivation, in which case the @code{ungexp} form is replaced by its
  7766. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  7767. If @var{obj} is a list, it is traversed and references to supported
  7768. objects are substituted similarly.
  7769. If @var{obj} is another gexp, its contents are inserted and its
  7770. dependencies are added to those of the containing gexp.
  7771. If @var{obj} is another kind of object, it is inserted as is.
  7772. @item #$@var{obj}:@var{output}
  7773. @itemx (ungexp @var{obj} @var{output})
  7774. This is like the form above, but referring explicitly to the
  7775. @var{output} of @var{obj}---this is useful when @var{obj} produces
  7776. multiple outputs (@pxref{Packages with Multiple Outputs}).
  7777. @item #+@var{obj}
  7778. @itemx #+@var{obj}:output
  7779. @itemx (ungexp-native @var{obj})
  7780. @itemx (ungexp-native @var{obj} @var{output})
  7781. Same as @code{ungexp}, but produces a reference to the @emph{native}
  7782. build of @var{obj} when used in a cross compilation context.
  7783. @item #$output[:@var{output}]
  7784. @itemx (ungexp output [@var{output}])
  7785. Insert a reference to derivation output @var{output}, or to the main
  7786. output when @var{output} is omitted.
  7787. This only makes sense for gexps passed to @code{gexp->derivation}.
  7788. @item #$@@@var{lst}
  7789. @itemx (ungexp-splicing @var{lst})
  7790. Like the above, but splices the contents of @var{lst} inside the
  7791. containing list.
  7792. @item #+@@@var{lst}
  7793. @itemx (ungexp-native-splicing @var{lst})
  7794. Like the above, but refers to native builds of the objects listed in
  7795. @var{lst}.
  7796. @end table
  7797. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  7798. of the @code{gexp?} type (see below).
  7799. @end deffn
  7800. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  7801. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  7802. in their execution environment.
  7803. Each item in @var{modules} can be the name of a module, such as
  7804. @code{(guix build utils)}, or it can be a module name, followed by an
  7805. arrow, followed by a file-like object:
  7806. @lisp
  7807. `((guix build utils)
  7808. (guix gcrypt)
  7809. ((guix config) => ,(scheme-file "config.scm"
  7810. #~(define-module @dots{}))))
  7811. @end lisp
  7812. @noindent
  7813. In the example above, the first two modules are taken from the search
  7814. path, and the last one is created from the given file-like object.
  7815. This form has @emph{lexical} scope: it has an effect on the gexps
  7816. directly defined in @var{body}@dots{}, but not on those defined, say, in
  7817. procedures called from @var{body}@dots{}.
  7818. @end deffn
  7819. @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
  7820. Mark the gexps defined in @var{body}@dots{} as requiring
  7821. @var{extensions} in their build and execution environment.
  7822. @var{extensions} is typically a list of package objects such as those
  7823. defined in the @code{(gnu packages guile)} module.
  7824. Concretely, the packages listed in @var{extensions} are added to the
  7825. load path while compiling imported modules in @var{body}@dots{}; they
  7826. are also added to the load path of the gexp returned by
  7827. @var{body}@dots{}.
  7828. @end deffn
  7829. @deffn {Scheme Procedure} gexp? @var{obj}
  7830. Return @code{#t} if @var{obj} is a G-expression.
  7831. @end deffn
  7832. G-expressions are meant to be written to disk, either as code building
  7833. some derivation, or as plain files in the store. The monadic procedures
  7834. below allow you to do that (@pxref{The Store Monad}, for more
  7835. information about monads).
  7836. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  7837. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  7838. [#:hash #f] [#:hash-algo #f] @
  7839. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  7840. [#:module-path @code{%load-path}] @
  7841. [#:effective-version "2.2"] @
  7842. [#:references-graphs #f] [#:allowed-references #f] @
  7843. [#:disallowed-references #f] @
  7844. [#:leaked-env-vars #f] @
  7845. [#:script-name (string-append @var{name} "-builder")] @
  7846. [#:deprecation-warnings #f] @
  7847. [#:local-build? #f] [#:substitutable? #t] @
  7848. [#:properties '()] [#:guile-for-build #f]
  7849. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  7850. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  7851. stored in a file called @var{script-name}. When @var{target} is true,
  7852. it is used as the cross-compilation target triplet for packages referred
  7853. to by @var{exp}.
  7854. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  7855. Its meaning is to
  7856. make @var{modules} available in the evaluation context of @var{exp};
  7857. @var{modules} is a list of names of Guile modules searched in
  7858. @var{module-path} to be copied in the store, compiled, and made available in
  7859. the load path during the execution of @var{exp}---e.g., @code{((guix
  7860. build utils) (guix build gnu-build-system))}.
  7861. @var{effective-version} determines the string to use when adding extensions of
  7862. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  7863. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  7864. applicable.
  7865. When @var{references-graphs} is true, it must be a list of tuples of one of the
  7866. following forms:
  7867. @example
  7868. (@var{file-name} @var{package})
  7869. (@var{file-name} @var{package} @var{output})
  7870. (@var{file-name} @var{derivation})
  7871. (@var{file-name} @var{derivation} @var{output})
  7872. (@var{file-name} @var{store-item})
  7873. @end example
  7874. The right-hand-side of each element of @var{references-graphs} is automatically made
  7875. an input of the build process of @var{exp}. In the build environment, each
  7876. @var{file-name} contains the reference graph of the corresponding item, in a simple
  7877. text format.
  7878. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  7879. In the latter case, the list denotes store items that the result is allowed to
  7880. refer to. Any reference to another store item will lead to a build error.
  7881. Similarly for @var{disallowed-references}, which can list items that must not be
  7882. referenced by the outputs.
  7883. @var{deprecation-warnings} determines whether to show deprecation warnings while
  7884. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  7885. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  7886. @end deffn
  7887. @cindex file-like objects
  7888. The @code{local-file}, @code{plain-file}, @code{computed-file},
  7889. @code{program-file}, and @code{scheme-file} procedures below return
  7890. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  7891. these objects lead to a file in the store. Consider this G-expression:
  7892. @lisp
  7893. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  7894. #$(local-file "/tmp/my-nscd.conf"))
  7895. @end lisp
  7896. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  7897. to the store. Once expanded, for instance @i{via}
  7898. @code{gexp->derivation}, the G-expression refers to that copy under
  7899. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  7900. does not have any effect on what the G-expression does.
  7901. @code{plain-file} can be used similarly; it differs in that the file
  7902. content is directly passed as a string.
  7903. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  7904. [#:recursive? #f] [#:select? (const #t)]
  7905. Return an object representing local file @var{file} to add to the store;
  7906. this object can be used in a gexp. If @var{file} is a literal string
  7907. denoting a relative file name, it is looked up relative to the source
  7908. file where it appears; if @var{file} is not a literal string, it is
  7909. looked up relative to the current working directory at run time.
  7910. @var{file} will be added to the store under @var{name}--by default the
  7911. base name of @var{file}.
  7912. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  7913. designates a flat file and @var{recursive?} is true, its contents are added, and its
  7914. permission bits are kept.
  7915. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  7916. @var{stat})} for each directory entry, where @var{file} is the entry's
  7917. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  7918. entries for which @var{select?} does not return true.
  7919. This is the declarative counterpart of the @code{interned-file} monadic
  7920. procedure (@pxref{The Store Monad, @code{interned-file}}).
  7921. @end deffn
  7922. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  7923. Return an object representing a text file called @var{name} with the given
  7924. @var{content} (a string or a bytevector) to be added to the store.
  7925. This is the declarative counterpart of @code{text-file}.
  7926. @end deffn
  7927. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  7928. [#:local-build? #t]
  7929. [#:options '()]
  7930. Return an object representing the store item @var{name}, a file or
  7931. directory computed by @var{gexp}. When @var{local-build?} is true (the
  7932. default), the derivation is built locally. @var{options} is a list of
  7933. additional arguments to pass to @code{gexp->derivation}.
  7934. This is the declarative counterpart of @code{gexp->derivation}.
  7935. @end deffn
  7936. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  7937. [#:guile (default-guile)] [#:module-path %load-path] @
  7938. [#:system (%current-system)] [#:target #f]
  7939. Return an executable script @var{name} that runs @var{exp} using
  7940. @var{guile}, with @var{exp}'s imported modules in its search path.
  7941. Look up @var{exp}'s modules in @var{module-path}.
  7942. The example below builds a script that simply invokes the @command{ls}
  7943. command:
  7944. @lisp
  7945. (use-modules (guix gexp) (gnu packages base))
  7946. (gexp->script "list-files"
  7947. #~(execl #$(file-append coreutils "/bin/ls")
  7948. "ls"))
  7949. @end lisp
  7950. When ``running'' it through the store (@pxref{The Store Monad,
  7951. @code{run-with-store}}), we obtain a derivation that produces an
  7952. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  7953. @example
  7954. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  7955. !#
  7956. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  7957. @end example
  7958. @end deffn
  7959. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  7960. [#:guile #f] [#:module-path %load-path]
  7961. Return an object representing the executable store item @var{name} that
  7962. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  7963. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  7964. This is the declarative counterpart of @code{gexp->script}.
  7965. @end deffn
  7966. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  7967. [#:set-load-path? #t] [#:module-path %load-path] @
  7968. [#:splice? #f] @
  7969. [#:guile (default-guile)]
  7970. Return a derivation that builds a file @var{name} containing @var{exp}.
  7971. When @var{splice?} is true, @var{exp} is considered to be a list of
  7972. expressions that will be spliced in the resulting file.
  7973. When @var{set-load-path?} is true, emit code in the resulting file to
  7974. set @code{%load-path} and @code{%load-compiled-path} to honor
  7975. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  7976. @var{module-path}.
  7977. The resulting file holds references to all the dependencies of @var{exp}
  7978. or a subset thereof.
  7979. @end deffn
  7980. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
  7981. [#:splice? #f] [#:set-load-path? #t]
  7982. Return an object representing the Scheme file @var{name} that contains
  7983. @var{exp}.
  7984. This is the declarative counterpart of @code{gexp->file}.
  7985. @end deffn
  7986. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  7987. Return as a monadic value a derivation that builds a text file
  7988. containing all of @var{text}. @var{text} may list, in addition to
  7989. strings, objects of any type that can be used in a gexp: packages,
  7990. derivations, local file objects, etc. The resulting store file holds
  7991. references to all these.
  7992. This variant should be preferred over @code{text-file} anytime the file
  7993. to create will reference items from the store. This is typically the
  7994. case when building a configuration file that embeds store file names,
  7995. like this:
  7996. @lisp
  7997. (define (profile.sh)
  7998. ;; Return the name of a shell script in the store that
  7999. ;; initializes the 'PATH' environment variable.
  8000. (text-file* "profile.sh"
  8001. "export PATH=" coreutils "/bin:"
  8002. grep "/bin:" sed "/bin\n"))
  8003. @end lisp
  8004. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  8005. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  8006. preventing them from being garbage-collected during its lifetime.
  8007. @end deffn
  8008. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  8009. Return an object representing store file @var{name} containing
  8010. @var{text}. @var{text} is a sequence of strings and file-like objects,
  8011. as in:
  8012. @lisp
  8013. (mixed-text-file "profile"
  8014. "export PATH=" coreutils "/bin:" grep "/bin")
  8015. @end lisp
  8016. This is the declarative counterpart of @code{text-file*}.
  8017. @end deffn
  8018. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  8019. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  8020. Each item in @var{files} must be a two-element list where the first element is the
  8021. file name to use in the new directory, and the second element is a gexp
  8022. denoting the target file. Here's an example:
  8023. @lisp
  8024. (file-union "etc"
  8025. `(("hosts" ,(plain-file "hosts"
  8026. "127.0.0.1 localhost"))
  8027. ("bashrc" ,(plain-file "bashrc"
  8028. "alias ls='ls --color=auto'"))))
  8029. @end lisp
  8030. This yields an @code{etc} directory containing these two files.
  8031. @end deffn
  8032. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  8033. Return a directory that is the union of @var{things}, where @var{things} is a list of
  8034. file-like objects denoting directories. For example:
  8035. @lisp
  8036. (directory-union "guile+emacs" (list guile emacs))
  8037. @end lisp
  8038. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  8039. @end deffn
  8040. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  8041. Return a file-like object that expands to the concatenation of @var{obj}
  8042. and @var{suffix}, where @var{obj} is a lowerable object and each
  8043. @var{suffix} is a string.
  8044. As an example, consider this gexp:
  8045. @lisp
  8046. (gexp->script "run-uname"
  8047. #~(system* #$(file-append coreutils
  8048. "/bin/uname")))
  8049. @end lisp
  8050. The same effect could be achieved with:
  8051. @lisp
  8052. (gexp->script "run-uname"
  8053. #~(system* (string-append #$coreutils
  8054. "/bin/uname")))
  8055. @end lisp
  8056. There is one difference though: in the @code{file-append} case, the
  8057. resulting script contains the absolute file name as a string, whereas in
  8058. the second case, the resulting script contains a @code{(string-append
  8059. @dots{})} expression to construct the file name @emph{at run time}.
  8060. @end deffn
  8061. @deffn {Scheme Syntax} let-system @var{system} @var{body}@dots{}
  8062. @deffnx {Scheme Syntax} let-system (@var{system} @var{target}) @var{body}@dots{}
  8063. Bind @var{system} to the currently targeted system---e.g.,
  8064. @code{"x86_64-linux"}---within @var{body}.
  8065. In the second case, additionally bind @var{target} to the current
  8066. cross-compilation target---a GNU triplet such as
  8067. @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
  8068. cross-compiling.
  8069. @code{let-system} is useful in the occasional case where the object
  8070. spliced into the gexp depends on the target system, as in this example:
  8071. @lisp
  8072. #~(system*
  8073. #+(let-system system
  8074. (cond ((string-prefix? "armhf-" system)
  8075. (file-append qemu "/bin/qemu-system-arm"))
  8076. ((string-prefix? "x86_64-" system)
  8077. (file-append qemu "/bin/qemu-system-x86_64"))
  8078. (else
  8079. (error "dunno!"))))
  8080. "-net" "user" #$image)
  8081. @end lisp
  8082. @end deffn
  8083. @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
  8084. This macro is similar to the @code{parameterize} form for
  8085. dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
  8086. Guile Reference Manual}). The key difference is that it takes effect
  8087. when the file-like object returned by @var{exp} is lowered to a
  8088. derivation or store item.
  8089. A typical use of @code{with-parameters} is to force the system in effect
  8090. for a given object:
  8091. @lisp
  8092. (with-parameters ((%current-system "i686-linux"))
  8093. coreutils)
  8094. @end lisp
  8095. The example above returns an object that corresponds to the i686 build
  8096. of Coreutils, regardless of the current value of @code{%current-system}.
  8097. @end deffn
  8098. Of course, in addition to gexps embedded in ``host'' code, there are
  8099. also modules containing build tools. To make it clear that they are
  8100. meant to be used in the build stratum, these modules are kept in the
  8101. @code{(guix build @dots{})} name space.
  8102. @cindex lowering, of high-level objects in gexps
  8103. Internally, high-level objects are @dfn{lowered}, using their compiler,
  8104. to either derivations or store items. For instance, lowering a package
  8105. yields a derivation, and lowering a @code{plain-file} yields a store
  8106. item. This is achieved using the @code{lower-object} monadic procedure.
  8107. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  8108. [#:target #f]
  8109. Return as a value in @code{%store-monad} the derivation or store item
  8110. corresponding to @var{obj} for @var{system}, cross-compiling for
  8111. @var{target} if @var{target} is true. @var{obj} must be an object that
  8112. has an associated gexp compiler, such as a @code{<package>}.
  8113. @end deffn
  8114. @node Invoking guix repl
  8115. @section Invoking @command{guix repl}
  8116. @cindex REPL, read-eval-print loop, script
  8117. The @command{guix repl} command makes it easier to program Guix in Guile
  8118. by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
  8119. programming (@pxref{Using Guile Interactively,,, guile,
  8120. GNU Guile Reference Manual}), or by running Guile scripts
  8121. (@pxref{Running Guile Scripts,,, guile,
  8122. GNU Guile Reference Manual}).
  8123. Compared to just launching the @command{guile}
  8124. command, @command{guix repl} guarantees that all the Guix modules and all its
  8125. dependencies are available in the search path.
  8126. The general syntax is:
  8127. @example
  8128. guix repl @var{options} [@var{file} @var{args}]
  8129. @end example
  8130. When a @var{file} argument is provided, @var{file} is
  8131. executed as a Guile scripts:
  8132. @example
  8133. guix repl my-script.scm
  8134. @end example
  8135. To pass arguments to the script, use @code{--} to prevent them from
  8136. being interpreted as arguments to @command{guix repl} itself:
  8137. @example
  8138. guix repl -- my-script.scm --input=foo.txt
  8139. @end example
  8140. To make a script executable directly from the shell, using the guix
  8141. executable that is on the user's search path, add the following two
  8142. lines at the top of the script:
  8143. @example
  8144. @code{#!/usr/bin/env -S guix repl --}
  8145. @code{!#}
  8146. @end example
  8147. Without a file name argument, a Guile REPL is started:
  8148. @example
  8149. $ guix repl
  8150. scheme@@(guile-user)> ,use (gnu packages base)
  8151. scheme@@(guile-user)> coreutils
  8152. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  8153. @end example
  8154. @cindex inferiors
  8155. In addition, @command{guix repl} implements a simple machine-readable REPL
  8156. protocol for use by @code{(guix inferior)}, a facility to interact with
  8157. @dfn{inferiors}, separate processes running a potentially different revision
  8158. of Guix.
  8159. The available options are as follows:
  8160. @table @code
  8161. @item --type=@var{type}
  8162. @itemx -t @var{type}
  8163. Start a REPL of the given @var{TYPE}, which can be one of the following:
  8164. @table @code
  8165. @item guile
  8166. This is default, and it spawns a standard full-featured Guile REPL.
  8167. @item machine
  8168. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  8169. that the @code{(guix inferior)} module speaks.
  8170. @end table
  8171. @item --listen=@var{endpoint}
  8172. By default, @command{guix repl} reads from standard input and writes to
  8173. standard output. When this option is passed, it will instead listen for
  8174. connections on @var{endpoint}. Here are examples of valid options:
  8175. @table @code
  8176. @item --listen=tcp:37146
  8177. Accept connections on localhost on port 37146.
  8178. @item --listen=unix:/tmp/socket
  8179. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  8180. @end table
  8181. @item --load-path=@var{directory}
  8182. @itemx -L @var{directory}
  8183. Add @var{directory} to the front of the package module search path
  8184. (@pxref{Package Modules}).
  8185. This allows users to define their own packages and make them visible to
  8186. the script or REPL.
  8187. @item -q
  8188. Inhibit loading of the @file{~/.guile} file. By default, that
  8189. configuration file is loaded when spawning a @code{guile} REPL.
  8190. @end table
  8191. @c *********************************************************************
  8192. @node Utilities
  8193. @chapter Utilities
  8194. This section describes Guix command-line utilities. Some of them are
  8195. primarily targeted at developers and users who write new package
  8196. definitions, while others are more generally useful. They complement
  8197. the Scheme programming interface of Guix in a convenient way.
  8198. @menu
  8199. * Invoking guix build:: Building packages from the command line.
  8200. * Invoking guix edit:: Editing package definitions.
  8201. * Invoking guix download:: Downloading a file and printing its hash.
  8202. * Invoking guix hash:: Computing the cryptographic hash of a file.
  8203. * Invoking guix import:: Importing package definitions.
  8204. * Invoking guix refresh:: Updating package definitions.
  8205. * Invoking guix lint:: Finding errors in package definitions.
  8206. * Invoking guix size:: Profiling disk usage.
  8207. * Invoking guix graph:: Visualizing the graph of packages.
  8208. * Invoking guix publish:: Sharing substitutes.
  8209. * Invoking guix challenge:: Challenging substitute servers.
  8210. * Invoking guix copy:: Copying to and from a remote store.
  8211. * Invoking guix container:: Process isolation.
  8212. * Invoking guix weather:: Assessing substitute availability.
  8213. * Invoking guix processes:: Listing client processes.
  8214. @end menu
  8215. @node Invoking guix build
  8216. @section Invoking @command{guix build}
  8217. @cindex package building
  8218. @cindex @command{guix build}
  8219. The @command{guix build} command builds packages or derivations and
  8220. their dependencies, and prints the resulting store paths. Note that it
  8221. does not modify the user's profile---this is the job of the
  8222. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  8223. it is mainly useful for distribution developers.
  8224. The general syntax is:
  8225. @example
  8226. guix build @var{options} @var{package-or-derivation}@dots{}
  8227. @end example
  8228. As an example, the following command builds the latest versions of Emacs
  8229. and of Guile, displays their build logs, and finally displays the
  8230. resulting directories:
  8231. @example
  8232. guix build emacs guile
  8233. @end example
  8234. Similarly, the following command builds all the available packages:
  8235. @example
  8236. guix build --quiet --keep-going \
  8237. $(guix package -A | cut -f1,2 --output-delimiter=@@)
  8238. @end example
  8239. @var{package-or-derivation} may be either the name of a package found in
  8240. the software distribution such as @code{coreutils} or
  8241. @code{coreutils@@8.20}, or a derivation such as
  8242. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  8243. package with the corresponding name (and optionally version) is searched
  8244. for among the GNU distribution modules (@pxref{Package Modules}).
  8245. Alternatively, the @option{--expression} option may be used to specify a
  8246. Scheme expression that evaluates to a package; this is useful when
  8247. disambiguating among several same-named packages or package variants is
  8248. needed.
  8249. There may be zero or more @var{options}. The available options are
  8250. described in the subsections below.
  8251. @menu
  8252. * Common Build Options:: Build options for most commands.
  8253. * Package Transformation Options:: Creating variants of packages.
  8254. * Additional Build Options:: Options specific to 'guix build'.
  8255. * Debugging Build Failures:: Real life packaging experience.
  8256. @end menu
  8257. @node Common Build Options
  8258. @subsection Common Build Options
  8259. A number of options that control the build process are common to
  8260. @command{guix build} and other commands that can spawn builds, such as
  8261. @command{guix package} or @command{guix archive}. These are the
  8262. following:
  8263. @table @code
  8264. @item --load-path=@var{directory}
  8265. @itemx -L @var{directory}
  8266. Add @var{directory} to the front of the package module search path
  8267. (@pxref{Package Modules}).
  8268. This allows users to define their own packages and make them visible to
  8269. the command-line tools.
  8270. @item --keep-failed
  8271. @itemx -K
  8272. Keep the build tree of failed builds. Thus, if a build fails, its build
  8273. tree is kept under @file{/tmp}, in a directory whose name is shown at
  8274. the end of the build log. This is useful when debugging build issues.
  8275. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  8276. build issues.
  8277. This option implies @option{--no-offload}, and it has no effect when
  8278. connecting to a remote daemon with a @code{guix://} URI (@pxref{The
  8279. Store, the @env{GUIX_DAEMON_SOCKET} variable}).
  8280. @item --keep-going
  8281. @itemx -k
  8282. Keep going when some of the derivations fail to build; return only once
  8283. all the builds have either completed or failed.
  8284. The default behavior is to stop as soon as one of the specified
  8285. derivations has failed.
  8286. @item --dry-run
  8287. @itemx -n
  8288. Do not build the derivations.
  8289. @anchor{fallback-option}
  8290. @item --fallback
  8291. When substituting a pre-built binary fails, fall back to building
  8292. packages locally (@pxref{Substitution Failure}).
  8293. @item --substitute-urls=@var{urls}
  8294. @anchor{client-substitute-urls}
  8295. Consider @var{urls} the whitespace-separated list of substitute source
  8296. URLs, overriding the default list of URLs of @command{guix-daemon}
  8297. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  8298. This means that substitutes may be downloaded from @var{urls}, provided
  8299. they are signed by a key authorized by the system administrator
  8300. (@pxref{Substitutes}).
  8301. When @var{urls} is the empty string, substitutes are effectively
  8302. disabled.
  8303. @item --no-substitutes
  8304. Do not use substitutes for build products. That is, always build things
  8305. locally instead of allowing downloads of pre-built binaries
  8306. (@pxref{Substitutes}).
  8307. @item --no-grafts
  8308. Do not ``graft'' packages. In practice, this means that package updates
  8309. available as grafts are not applied. @xref{Security Updates}, for more
  8310. information on grafts.
  8311. @item --rounds=@var{n}
  8312. Build each derivation @var{n} times in a row, and raise an error if
  8313. consecutive build results are not bit-for-bit identical.
  8314. This is a useful way to detect non-deterministic builds processes.
  8315. Non-deterministic build processes are a problem because they make it
  8316. practically impossible for users to @emph{verify} whether third-party
  8317. binaries are genuine. @xref{Invoking guix challenge}, for more.
  8318. When used in conjunction with @option{--keep-failed}, the differing
  8319. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8320. This makes it easy to look for differences between the two results.
  8321. @item --no-offload
  8322. Do not use offload builds to other machines (@pxref{Daemon Offload
  8323. Setup}). That is, always build things locally instead of offloading
  8324. builds to remote machines.
  8325. @item --max-silent-time=@var{seconds}
  8326. When the build or substitution process remains silent for more than
  8327. @var{seconds}, terminate it and report a build failure.
  8328. By default, the daemon's setting is honored (@pxref{Invoking
  8329. guix-daemon, @option{--max-silent-time}}).
  8330. @item --timeout=@var{seconds}
  8331. Likewise, when the build or substitution process lasts for more than
  8332. @var{seconds}, terminate it and report a build failure.
  8333. By default, the daemon's setting is honored (@pxref{Invoking
  8334. guix-daemon, @option{--timeout}}).
  8335. @c Note: This option is actually not part of %standard-build-options but
  8336. @c most programs honor it.
  8337. @cindex verbosity, of the command-line tools
  8338. @cindex build logs, verbosity
  8339. @item -v @var{level}
  8340. @itemx --verbosity=@var{level}
  8341. Use the given verbosity @var{level}, an integer. Choosing 0 means that
  8342. no output is produced, 1 is for quiet output; 2 is similar to 1 but it
  8343. additionally displays download URLs; 3 shows all the build log output on
  8344. standard error.
  8345. @item --cores=@var{n}
  8346. @itemx -c @var{n}
  8347. Allow the use of up to @var{n} CPU cores for the build. The special
  8348. value @code{0} means to use as many CPU cores as available.
  8349. @item --max-jobs=@var{n}
  8350. @itemx -M @var{n}
  8351. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  8352. guix-daemon, @option{--max-jobs}}, for details about this option and the
  8353. equivalent @command{guix-daemon} option.
  8354. @item --debug=@var{level}
  8355. Produce debugging output coming from the build daemon. @var{level} must be an
  8356. integer between 0 and 5; higher means more verbose output. Setting a level of
  8357. 4 or more may be helpful when debugging setup issues with the build daemon.
  8358. @end table
  8359. Behind the scenes, @command{guix build} is essentially an interface to
  8360. the @code{package-derivation} procedure of the @code{(guix packages)}
  8361. module, and to the @code{build-derivations} procedure of the @code{(guix
  8362. derivations)} module.
  8363. In addition to options explicitly passed on the command line,
  8364. @command{guix build} and other @command{guix} commands that support
  8365. building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
  8366. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  8367. Users can define this variable to a list of command line options that
  8368. will automatically be used by @command{guix build} and other
  8369. @command{guix} commands that can perform builds, as in the example
  8370. below:
  8371. @example
  8372. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  8373. @end example
  8374. These options are parsed independently, and the result is appended to
  8375. the parsed command-line options.
  8376. @end defvr
  8377. @node Package Transformation Options
  8378. @subsection Package Transformation Options
  8379. @cindex package variants
  8380. Another set of command-line options supported by @command{guix build}
  8381. and also @command{guix package} are @dfn{package transformation
  8382. options}. These are options that make it possible to define @dfn{package
  8383. variants}---for instance, packages built from different source code.
  8384. This is a convenient way to create customized packages on the fly
  8385. without having to type in the definitions of package variants
  8386. (@pxref{Defining Packages}).
  8387. Package transformation options are preserved across upgrades:
  8388. @command{guix upgrade} attempts to apply transformation options
  8389. initially used when creating the profile to the upgraded packages.
  8390. The available options are listed below. Most commands support them and
  8391. also support a @option{--help-transform} option that lists all the
  8392. available options and a synopsis (these options are not shown in the
  8393. @option{--help} output for brevity).
  8394. @table @code
  8395. @item --with-source=@var{source}
  8396. @itemx --with-source=@var{package}=@var{source}
  8397. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  8398. Use @var{source} as the source of @var{package}, and @var{version} as
  8399. its version number.
  8400. @var{source} must be a file name or a URL, as for @command{guix
  8401. download} (@pxref{Invoking guix download}).
  8402. When @var{package} is omitted,
  8403. it is taken to be the package name specified on the
  8404. command line that matches the base of @var{source}---e.g.,
  8405. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  8406. package is @code{guile}.
  8407. Likewise, when @var{version} is omitted, the version string is inferred from
  8408. @var{source}; in the previous example, it is @code{2.0.10}.
  8409. This option allows users to try out versions of packages other than the
  8410. one provided by the distribution. The example below downloads
  8411. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  8412. the @code{ed} package:
  8413. @example
  8414. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  8415. @end example
  8416. As a developer, @option{--with-source} makes it easy to test release
  8417. candidates:
  8418. @example
  8419. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  8420. @end example
  8421. @dots{} or to build from a checkout in a pristine environment:
  8422. @example
  8423. $ git clone git://git.sv.gnu.org/guix.git
  8424. $ guix build guix --with-source=guix@@1.0=./guix
  8425. @end example
  8426. @item --with-input=@var{package}=@var{replacement}
  8427. Replace dependency on @var{package} by a dependency on
  8428. @var{replacement}. @var{package} must be a package name, and
  8429. @var{replacement} must be a package specification such as @code{guile}
  8430. or @code{guile@@1.8}.
  8431. For instance, the following command builds Guix, but replaces its
  8432. dependency on the current stable version of Guile with a dependency on
  8433. the legacy version of Guile, @code{guile@@2.0}:
  8434. @example
  8435. guix build --with-input=guile=guile@@2.0 guix
  8436. @end example
  8437. This is a recursive, deep replacement. So in this example, both
  8438. @code{guix} and its dependency @code{guile-json} (which also depends on
  8439. @code{guile}) get rebuilt against @code{guile@@2.0}.
  8440. This is implemented using the @code{package-input-rewriting} Scheme
  8441. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  8442. @item --with-graft=@var{package}=@var{replacement}
  8443. This is similar to @option{--with-input} but with an important difference:
  8444. instead of rebuilding the whole dependency chain, @var{replacement} is
  8445. built and then @dfn{grafted} onto the binaries that were initially
  8446. referring to @var{package}. @xref{Security Updates}, for more
  8447. information on grafts.
  8448. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  8449. and all its dependencies, replacing references to the version of GnuTLS
  8450. they currently refer to:
  8451. @example
  8452. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  8453. @end example
  8454. This has the advantage of being much faster than rebuilding everything.
  8455. But there is a caveat: it works if and only if @var{package} and
  8456. @var{replacement} are strictly compatible---for example, if they provide
  8457. a library, the application binary interface (ABI) of those libraries
  8458. must be compatible. If @var{replacement} is somehow incompatible with
  8459. @var{package}, then the resulting package may be unusable. Use with
  8460. care!
  8461. @cindex debugging info, rebuilding
  8462. @item --with-debug-info=@var{package}
  8463. Build @var{package} in a way that preserves its debugging info and graft
  8464. it onto packages that depend on it. This is useful if @var{package}
  8465. does not already provide debugging info as a @code{debug} output
  8466. (@pxref{Installing Debugging Files}).
  8467. For example, suppose you're experiencing a crash in Inkscape and would
  8468. like to see what's up in GLib, a library deep down in Inkscape's
  8469. dependency graph. GLib lacks a @code{debug} output, so debugging is
  8470. tough. Fortunately, you rebuild GLib with debugging info and tack it on
  8471. Inkscape:
  8472. @example
  8473. guix install inkscape --with-debug-info=glib
  8474. @end example
  8475. Only GLib needs to be recompiled so this takes a reasonable amount of
  8476. time. @xref{Installing Debugging Files}, for more info.
  8477. @quotation Note
  8478. Under the hood, this option works by passing the @samp{#:strip-binaries?
  8479. #f} to the build system of the package of interest (@pxref{Build
  8480. Systems}). Most build systems support that option but some do not. In
  8481. that case, an error is raised.
  8482. Likewise, if a C/C++ package is built without @code{-g} (which is rarely
  8483. the case), debugging info will remain unavailable even when
  8484. @code{#:strip-binaries?} is false.
  8485. @end quotation
  8486. @cindex tool chain, changing the build tool chain of a package
  8487. @item --with-c-toolchain=@var{package}=@var{toolchain}
  8488. This option changes the compilation of @var{package} and everything that
  8489. depends on it so that they get built with @var{toolchain} instead of the
  8490. default GNU tool chain for C/C++.
  8491. Consider this example:
  8492. @example
  8493. guix build octave-cli \
  8494. --with-c-toolchain=fftw=gcc-toolchain@@10 \
  8495. --with-c-toolchain=fftwf=gcc-toolchain@@10
  8496. @end example
  8497. The command above builds a variant of the @code{fftw} and @code{fftwf}
  8498. packages using version 10 of @code{gcc-toolchain} instead of the default
  8499. tool chain, and then builds a variant of the GNU@tie{}Octave
  8500. command-line interface using them. GNU@tie{}Octave itself is also built
  8501. with @code{gcc-toolchain@@10}.
  8502. This other example builds the Hardware Locality (@code{hwloc}) library
  8503. and its dependents up to @code{intel-mpi-benchmarks} with the Clang C
  8504. compiler:
  8505. @example
  8506. guix build --with-c-toolchain=hwloc=clang-toolchain \
  8507. intel-mpi-benchmarks
  8508. @end example
  8509. @quotation Note
  8510. There can be application binary interface (ABI) incompatibilities among
  8511. tool chains. This is particularly true of the C++ standard library and
  8512. run-time support libraries such as that of OpenMP@. By rebuilding all
  8513. dependents with the same tool chain, @option{--with-c-toolchain} minimizes
  8514. the risks of incompatibility but cannot entirely eliminate them. Choose
  8515. @var{package} wisely.
  8516. @end quotation
  8517. @item --with-git-url=@var{package}=@var{url}
  8518. @cindex Git, using the latest commit
  8519. @cindex latest commit, building
  8520. Build @var{package} from the latest commit of the @code{master} branch of the
  8521. Git repository at @var{url}. Git sub-modules of the repository are fetched,
  8522. recursively.
  8523. For example, the following command builds the NumPy Python library against the
  8524. latest commit of the master branch of Python itself:
  8525. @example
  8526. guix build python-numpy \
  8527. --with-git-url=python=https://github.com/python/cpython
  8528. @end example
  8529. This option can also be combined with @option{--with-branch} or
  8530. @option{--with-commit} (see below).
  8531. @cindex continuous integration
  8532. Obviously, since it uses the latest commit of the given branch, the result of
  8533. such a command varies over time. Nevertheless it is a convenient way to
  8534. rebuild entire software stacks against the latest commit of one or more
  8535. packages. This is particularly useful in the context of continuous
  8536. integration (CI).
  8537. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  8538. consecutive accesses to the same repository. You may want to clean it up once
  8539. in a while to save disk space.
  8540. @item --with-branch=@var{package}=@var{branch}
  8541. Build @var{package} from the latest commit of @var{branch}. If the
  8542. @code{source} field of @var{package} is an origin with the @code{git-fetch}
  8543. method (@pxref{origin Reference}) or a @code{git-checkout} object, the
  8544. repository URL is taken from that @code{source}. Otherwise you have to use
  8545. @option{--with-git-url} to specify the URL of the Git repository.
  8546. For instance, the following command builds @code{guile-sqlite3} from the
  8547. latest commit of its @code{master} branch, and then builds @code{guix} (which
  8548. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  8549. specific @code{guile-sqlite3} build:
  8550. @example
  8551. guix build --with-branch=guile-sqlite3=master cuirass
  8552. @end example
  8553. @item --with-commit=@var{package}=@var{commit}
  8554. This is similar to @option{--with-branch}, except that it builds from
  8555. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  8556. Git commit SHA1 identifier or a tag.
  8557. @item --with-patch=@var{package}=@var{file}
  8558. Add @var{file} to the list of patches applied to @var{package}, where
  8559. @var{package} is a spec such as @code{python@@3.8} or @code{glibc}.
  8560. @var{file} must contain a patch; it is applied with the flags specified
  8561. in the @code{origin} of @var{package} (@pxref{origin Reference}), which
  8562. by default includes @code{-p1} (@pxref{patch Directories,,, diffutils,
  8563. Comparing and Merging Files}).
  8564. As an example, the command below rebuilds Coreutils with the GNU C
  8565. Library (glibc) patched with the given patch:
  8566. @example
  8567. guix build coreutils --with-patch=glibc=./glibc-frob.patch
  8568. @end example
  8569. In this example, glibc itself as well as everything that leads to
  8570. Coreutils in the dependency graph is rebuilt.
  8571. @cindex upstream, latest version
  8572. @item --with-latest=@var{package}
  8573. So you like living on the bleeding edge? This option is for you! It
  8574. replaces occurrences of @var{package} in the dependency graph with its
  8575. latest upstream version, as reported by @command{guix refresh}
  8576. (@pxref{Invoking guix refresh}).
  8577. It does so by determining the latest upstream release of @var{package}
  8578. (if possible), downloading it, and authenticating it @emph{if} it comes
  8579. with an OpenPGP signature.
  8580. As an example, the command below builds Guix against the latest version
  8581. of Guile-JSON:
  8582. @example
  8583. guix build guix --with-latest=guile-json
  8584. @end example
  8585. There are limitations. First, in cases where the tool cannot or does
  8586. not know how to authenticate source code, you are at risk of running
  8587. malicious code; a warning is emitted in this case. Second, this option
  8588. simply changes the source used in the existing package definitions,
  8589. which is not always sufficient: there might be additional dependencies
  8590. that need to be added, patches to apply, and more generally the quality
  8591. assurance work that Guix developers normally do will be missing.
  8592. You've been warned! In all the other cases, it's a snappy way to stay
  8593. on top. We encourage you to submit patches updating the actual package
  8594. definitions once you have successfully tested an upgrade
  8595. (@pxref{Contributing}).
  8596. @cindex test suite, skipping
  8597. @item --without-tests=@var{package}
  8598. Build @var{package} without running its tests. This can be useful in
  8599. situations where you want to skip the lengthy test suite of a
  8600. intermediate package, or if a package's test suite fails in a
  8601. non-deterministic fashion. It should be used with care because running
  8602. the test suite is a good way to ensure a package is working as intended.
  8603. Turning off tests leads to a different store item. Consequently, when
  8604. using this option, anything that depends on @var{package} must be
  8605. rebuilt, as in this example:
  8606. @example
  8607. guix install --without-tests=python python-notebook
  8608. @end example
  8609. The command above installs @code{python-notebook} on top of
  8610. @code{python} built without running its test suite. To do so, it also
  8611. rebuilds everything that depends on @code{python}, including
  8612. @code{python-notebook} itself.
  8613. Internally, @option{--without-tests} relies on changing the
  8614. @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
  8615. Systems}). Note that some packages use a customized @code{check} phase
  8616. that does not respect a @code{#:tests? #f} setting. Therefore,
  8617. @option{--without-tests} has no effect on these packages.
  8618. @end table
  8619. Wondering how to achieve the same effect using Scheme code, for example
  8620. in your manifest, or how to write your own package transformation?
  8621. @xref{Defining Package Variants}, for an overview of the programming
  8622. interfaces available.
  8623. @node Additional Build Options
  8624. @subsection Additional Build Options
  8625. The command-line options presented below are specific to @command{guix
  8626. build}.
  8627. @table @code
  8628. @item --quiet
  8629. @itemx -q
  8630. Build quietly, without displaying the build log; this is equivalent to
  8631. @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
  8632. (or similar) and can always be retrieved using the @option{--log-file} option.
  8633. @item --file=@var{file}
  8634. @itemx -f @var{file}
  8635. Build the package, derivation, or other file-like object that the code within
  8636. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  8637. As an example, @var{file} might contain a package definition like this
  8638. (@pxref{Defining Packages}):
  8639. @lisp
  8640. @include package-hello.scm
  8641. @end lisp
  8642. The @var{file} may also contain a JSON representation of one or more
  8643. package definitions. Running @code{guix build -f} on @file{hello.json}
  8644. with the following contents would result in building the packages
  8645. @code{myhello} and @code{greeter}:
  8646. @example
  8647. @verbatiminclude package-hello.json
  8648. @end example
  8649. @item --manifest=@var{manifest}
  8650. @itemx -m @var{manifest}
  8651. Build all packages listed in the given @var{manifest}
  8652. (@pxref{profile-manifest, @option{--manifest}}).
  8653. @item --expression=@var{expr}
  8654. @itemx -e @var{expr}
  8655. Build the package or derivation @var{expr} evaluates to.
  8656. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  8657. guile-1.8)}, which unambiguously designates this specific variant of
  8658. version 1.8 of Guile.
  8659. Alternatively, @var{expr} may be a G-expression, in which case it is used
  8660. as a build program passed to @code{gexp->derivation}
  8661. (@pxref{G-Expressions}).
  8662. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  8663. (@pxref{The Store Monad}). The procedure must return a derivation as a
  8664. monadic value, which is then passed through @code{run-with-store}.
  8665. @item --source
  8666. @itemx -S
  8667. Build the source derivations of the packages, rather than the packages
  8668. themselves.
  8669. For instance, @code{guix build -S gcc} returns something like
  8670. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  8671. source tarball.
  8672. The returned source tarball is the result of applying any patches and
  8673. code snippets specified in the package @code{origin} (@pxref{Defining
  8674. Packages}).
  8675. @cindex source, verification
  8676. As with other derivations, the result of building a source derivation
  8677. can be verified using the @option{--check} option (@pxref{build-check}).
  8678. This is useful to validate that a (potentially already built or
  8679. substituted, thus cached) package source matches against its declared
  8680. hash.
  8681. Note that @command{guix build -S} compiles the sources only of the
  8682. specified packages. They do not include the sources of statically
  8683. linked dependencies and by themselves are insufficient for reproducing
  8684. the packages.
  8685. @item --sources
  8686. Fetch and return the source of @var{package-or-derivation} and all their
  8687. dependencies, recursively. This is a handy way to obtain a local copy
  8688. of all the source code needed to build @var{packages}, allowing you to
  8689. eventually build them even without network access. It is an extension
  8690. of the @option{--source} option and can accept one of the following
  8691. optional argument values:
  8692. @table @code
  8693. @item package
  8694. This value causes the @option{--sources} option to behave in the same way
  8695. as the @option{--source} option.
  8696. @item all
  8697. Build the source derivations of all packages, including any source that
  8698. might be listed as @code{inputs}. This is the default value.
  8699. @example
  8700. $ guix build --sources tzdata
  8701. The following derivations will be built:
  8702. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  8703. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  8704. @end example
  8705. @item transitive
  8706. Build the source derivations of all packages, as well of all transitive
  8707. inputs to the packages. This can be used e.g.@: to
  8708. prefetch package source for later offline building.
  8709. @example
  8710. $ guix build --sources=transitive tzdata
  8711. The following derivations will be built:
  8712. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  8713. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  8714. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  8715. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  8716. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  8717. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  8718. @dots{}
  8719. @end example
  8720. @end table
  8721. @item --system=@var{system}
  8722. @itemx -s @var{system}
  8723. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  8724. the system type of the build host. The @command{guix build} command allows
  8725. you to repeat this option several times, in which case it builds for all the
  8726. specified systems; other commands ignore extraneous @option{-s} options.
  8727. @quotation Note
  8728. The @option{--system} flag is for @emph{native} compilation and must not
  8729. be confused with cross-compilation. See @option{--target} below for
  8730. information on cross-compilation.
  8731. @end quotation
  8732. An example use of this is on Linux-based systems, which can emulate
  8733. different personalities. For instance, passing
  8734. @option{--system=i686-linux} on an @code{x86_64-linux} system or
  8735. @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
  8736. you to build packages in a complete 32-bit environment.
  8737. @quotation Note
  8738. Building for an @code{armhf-linux} system is unconditionally enabled on
  8739. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  8740. allow for this functionality, notably the ThunderX.
  8741. @end quotation
  8742. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  8743. is enabled (@pxref{Virtualization Services,
  8744. @code{qemu-binfmt-service-type}}), you can build for any system for
  8745. which a QEMU @code{binfmt_misc} handler is installed.
  8746. Builds for a system other than that of the machine you are using can
  8747. also be offloaded to a remote machine of the right architecture.
  8748. @xref{Daemon Offload Setup}, for more information on offloading.
  8749. @item --target=@var{triplet}
  8750. @cindex cross-compilation
  8751. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  8752. as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
  8753. configuration triplets,, autoconf, Autoconf}).
  8754. @anchor{build-check}
  8755. @item --check
  8756. @cindex determinism, checking
  8757. @cindex reproducibility, checking
  8758. Rebuild @var{package-or-derivation}, which are already available in the
  8759. store, and raise an error if the build results are not bit-for-bit
  8760. identical.
  8761. This mechanism allows you to check whether previously installed
  8762. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  8763. of a package is deterministic. @xref{Invoking guix challenge}, for more
  8764. background information and tools.
  8765. When used in conjunction with @option{--keep-failed}, the differing
  8766. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  8767. This makes it easy to look for differences between the two results.
  8768. @item --repair
  8769. @cindex repairing store items
  8770. @cindex corruption, recovering from
  8771. Attempt to repair the specified store items, if they are corrupt, by
  8772. re-downloading or rebuilding them.
  8773. This operation is not atomic and thus restricted to @code{root}.
  8774. @item --derivations
  8775. @itemx -d
  8776. Return the derivation paths, not the output paths, of the given
  8777. packages.
  8778. @item --root=@var{file}
  8779. @itemx -r @var{file}
  8780. @cindex GC roots, adding
  8781. @cindex garbage collector roots, adding
  8782. Make @var{file} a symlink to the result, and register it as a garbage
  8783. collector root.
  8784. Consequently, the results of this @command{guix build} invocation are
  8785. protected from garbage collection until @var{file} is removed. When
  8786. that option is omitted, build results are eligible for garbage
  8787. collection as soon as the build completes. @xref{Invoking guix gc}, for
  8788. more on GC roots.
  8789. @item --log-file
  8790. @cindex build logs, access
  8791. Return the build log file names or URLs for the given
  8792. @var{package-or-derivation}, or raise an error if build logs are
  8793. missing.
  8794. This works regardless of how packages or derivations are specified. For
  8795. instance, the following invocations are equivalent:
  8796. @example
  8797. guix build --log-file $(guix build -d guile)
  8798. guix build --log-file $(guix build guile)
  8799. guix build --log-file guile
  8800. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  8801. @end example
  8802. If a log is unavailable locally, and unless @option{--no-substitutes} is
  8803. passed, the command looks for a corresponding log on one of the
  8804. substitute servers (as specified with @option{--substitute-urls}).
  8805. So for instance, imagine you want to see the build log of GDB on MIPS,
  8806. but you are actually on an @code{x86_64} machine:
  8807. @example
  8808. $ guix build --log-file gdb -s aarch64-linux
  8809. https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
  8810. @end example
  8811. You can freely access a huge library of build logs!
  8812. @end table
  8813. @node Debugging Build Failures
  8814. @subsection Debugging Build Failures
  8815. @cindex build failures, debugging
  8816. When defining a new package (@pxref{Defining Packages}), you will
  8817. probably find yourself spending some time debugging and tweaking the
  8818. build until it succeeds. To do that, you need to operate the build
  8819. commands yourself in an environment as close as possible to the one the
  8820. build daemon uses.
  8821. To that end, the first thing to do is to use the @option{--keep-failed}
  8822. or @option{-K} option of @command{guix build}, which will keep the
  8823. failed build tree in @file{/tmp} or whatever directory you specified as
  8824. @env{TMPDIR} (@pxref{Common Build Options, @option{--keep-failed}}).
  8825. From there on, you can @command{cd} to the failed build tree and source
  8826. the @file{environment-variables} file, which contains all the
  8827. environment variable definitions that were in place when the build
  8828. failed. So let's say you're debugging a build failure in package
  8829. @code{foo}; a typical session would look like this:
  8830. @example
  8831. $ guix build foo -K
  8832. @dots{} @i{build fails}
  8833. $ cd /tmp/guix-build-foo.drv-0
  8834. $ source ./environment-variables
  8835. $ cd foo-1.2
  8836. @end example
  8837. Now, you can invoke commands as if you were the daemon (almost) and
  8838. troubleshoot your build process.
  8839. Sometimes it happens that, for example, a package's tests pass when you
  8840. run them manually but they fail when the daemon runs them. This can
  8841. happen because the daemon runs builds in containers where, unlike in our
  8842. environment above, network access is missing, @file{/bin/sh} does not
  8843. exist, etc. (@pxref{Build Environment Setup}).
  8844. In such cases, you may need to run inspect the build process from within
  8845. a container similar to the one the build daemon creates:
  8846. @example
  8847. $ guix build -K foo
  8848. @dots{}
  8849. $ cd /tmp/guix-build-foo.drv-0
  8850. $ guix environment --no-grafts -C foo --ad-hoc strace gdb
  8851. [env]# source ./environment-variables
  8852. [env]# cd foo-1.2
  8853. @end example
  8854. Here, @command{guix environment -C} creates a container and spawns a new
  8855. shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
  8856. strace gdb} part adds the @command{strace} and @command{gdb} commands to
  8857. the container, which you may find handy while debugging. The
  8858. @option{--no-grafts} option makes sure we get the exact same
  8859. environment, with ungrafted packages (@pxref{Security Updates}, for more
  8860. info on grafts).
  8861. To get closer to a container like that used by the build daemon, we can
  8862. remove @file{/bin/sh}:
  8863. @example
  8864. [env]# rm /bin/sh
  8865. @end example
  8866. (Don't worry, this is harmless: this is all happening in the throw-away
  8867. container created by @command{guix environment}.)
  8868. The @command{strace} command is probably not in the search path, but we
  8869. can run:
  8870. @example
  8871. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  8872. @end example
  8873. In this way, not only you will have reproduced the environment variables
  8874. the daemon uses, you will also be running the build process in a container
  8875. similar to the one the daemon uses.
  8876. @node Invoking guix edit
  8877. @section Invoking @command{guix edit}
  8878. @cindex @command{guix edit}
  8879. @cindex package definition, editing
  8880. So many packages, so many source files! The @command{guix edit} command
  8881. facilitates the life of users and packagers by pointing their editor at
  8882. the source file containing the definition of the specified packages.
  8883. For instance:
  8884. @example
  8885. guix edit gcc@@4.9 vim
  8886. @end example
  8887. @noindent
  8888. launches the program specified in the @env{VISUAL} or in the
  8889. @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  8890. and that of Vim.
  8891. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  8892. have created your own packages on @env{GUIX_PACKAGE_PATH}
  8893. (@pxref{Package Modules}), you will be able to edit the package
  8894. recipes. In other cases, you will be able to examine the read-only recipes
  8895. for packages currently in the store.
  8896. Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
  8897. @option{--load-path=@var{directory}} (or in short @option{-L
  8898. @var{directory}}) allows you to add @var{directory} to the front of the
  8899. package module search path and so make your own packages visible.
  8900. @node Invoking guix download
  8901. @section Invoking @command{guix download}
  8902. @cindex @command{guix download}
  8903. @cindex downloading package sources
  8904. When writing a package definition, developers typically need to download
  8905. a source tarball, compute its SHA256 hash, and write that
  8906. hash in the package definition (@pxref{Defining Packages}). The
  8907. @command{guix download} tool helps with this task: it downloads a file
  8908. from the given URI, adds it to the store, and prints both its file name
  8909. in the store and its SHA256 hash.
  8910. The fact that the downloaded file is added to the store saves bandwidth:
  8911. when the developer eventually tries to build the newly defined package
  8912. with @command{guix build}, the source tarball will not have to be
  8913. downloaded again because it is already in the store. It is also a
  8914. convenient way to temporarily stash files, which may be deleted
  8915. eventually (@pxref{Invoking guix gc}).
  8916. The @command{guix download} command supports the same URIs as used in
  8917. package definitions. In particular, it supports @code{mirror://} URIs.
  8918. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  8919. Guile bindings for GnuTLS are available in the user's environment; when
  8920. they are not available, an error is raised. @xref{Guile Preparations,
  8921. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  8922. GnuTLS-Guile}, for more information.
  8923. @command{guix download} verifies HTTPS server certificates by loading
  8924. the certificates of X.509 authorities from the directory pointed to by
  8925. the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
  8926. Certificates}), unless @option{--no-check-certificate} is used.
  8927. The following options are available:
  8928. @table @code
  8929. @item --hash=@var{algorithm}
  8930. @itemx -H @var{algorithm}
  8931. Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
  8932. hash}, for more information.
  8933. @item --format=@var{fmt}
  8934. @itemx -f @var{fmt}
  8935. Write the hash in the format specified by @var{fmt}. For more
  8936. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  8937. @item --no-check-certificate
  8938. Do not validate the X.509 certificates of HTTPS servers.
  8939. When using this option, you have @emph{absolutely no guarantee} that you
  8940. are communicating with the authentic server responsible for the given
  8941. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  8942. @item --output=@var{file}
  8943. @itemx -o @var{file}
  8944. Save the downloaded file to @var{file} instead of adding it to the
  8945. store.
  8946. @end table
  8947. @node Invoking guix hash
  8948. @section Invoking @command{guix hash}
  8949. @cindex @command{guix hash}
  8950. The @command{guix hash} command computes the hash of a file.
  8951. It is primarily a convenience tool for anyone contributing to the
  8952. distribution: it computes the cryptographic hash of a file, which can be
  8953. used in the definition of a package (@pxref{Defining Packages}).
  8954. The general syntax is:
  8955. @example
  8956. guix hash @var{option} @var{file}
  8957. @end example
  8958. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  8959. hash of data read from standard input. @command{guix hash} has the
  8960. following options:
  8961. @table @code
  8962. @item --hash=@var{algorithm}
  8963. @itemx -H @var{algorithm}
  8964. Compute a hash using the specified @var{algorithm}, @code{sha256} by
  8965. default.
  8966. @var{algorithm} must the name of a cryptographic hash algorithm
  8967. supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
  8968. @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
  8969. Reference Manual}).
  8970. @item --format=@var{fmt}
  8971. @itemx -f @var{fmt}
  8972. Write the hash in the format specified by @var{fmt}.
  8973. Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
  8974. (@code{hex} and @code{hexadecimal} can be used as well).
  8975. If the @option{--format} option is not specified, @command{guix hash}
  8976. will output the hash in @code{nix-base32}. This representation is used
  8977. in the definitions of packages.
  8978. @item --recursive
  8979. @itemx -r
  8980. Compute the hash on @var{file} recursively.
  8981. In this case, the hash is computed on an archive containing @var{file},
  8982. including its children if it is a directory. Some of the metadata of
  8983. @var{file} is part of the archive; for instance, when @var{file} is a
  8984. regular file, the hash is different depending on whether @var{file} is
  8985. executable or not. Metadata such as time stamps has no impact on the
  8986. hash (@pxref{Invoking guix archive}).
  8987. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  8988. @c it exists.
  8989. @item --exclude-vcs
  8990. @itemx -x
  8991. When combined with @option{--recursive}, exclude version control system
  8992. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
  8993. @vindex git-fetch
  8994. As an example, here is how you would compute the hash of a Git checkout,
  8995. which is useful when using the @code{git-fetch} method (@pxref{origin
  8996. Reference}):
  8997. @example
  8998. $ git clone http://example.org/foo.git
  8999. $ cd foo
  9000. $ guix hash -rx .
  9001. @end example
  9002. @end table
  9003. @node Invoking guix import
  9004. @section Invoking @command{guix import}
  9005. @cindex importing packages
  9006. @cindex package import
  9007. @cindex package conversion
  9008. @cindex Invoking @command{guix import}
  9009. The @command{guix import} command is useful for people who would like to
  9010. add a package to the distribution with as little work as
  9011. possible---a legitimate demand. The command knows of a few
  9012. repositories from which it can ``import'' package metadata. The result
  9013. is a package definition, or a template thereof, in the format we know
  9014. (@pxref{Defining Packages}).
  9015. The general syntax is:
  9016. @example
  9017. guix import @var{importer} @var{options}@dots{}
  9018. @end example
  9019. @var{importer} specifies the source from which to import package
  9020. metadata, and @var{options} specifies a package identifier and other
  9021. options specific to @var{importer}.
  9022. Some of the importers rely on the ability to run the @command{gpgv} command.
  9023. For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
  9024. gnupg} if needed.
  9025. Currently, the available ``importers'' are:
  9026. @table @code
  9027. @item gnu
  9028. Import metadata for the given GNU package. This provides a template
  9029. for the latest version of that GNU package, including the hash of its
  9030. source tarball, and its canonical synopsis and description.
  9031. Additional information such as the package dependencies and its
  9032. license needs to be figured out manually.
  9033. For example, the following command returns a package definition for
  9034. GNU@tie{}Hello:
  9035. @example
  9036. guix import gnu hello
  9037. @end example
  9038. Specific command-line options are:
  9039. @table @code
  9040. @item --key-download=@var{policy}
  9041. As for @command{guix refresh}, specify the policy to handle missing
  9042. OpenPGP keys when verifying the package signature. @xref{Invoking guix
  9043. refresh, @option{--key-download}}.
  9044. @end table
  9045. @item pypi
  9046. @cindex pypi
  9047. Import metadata from the @uref{https://pypi.python.org/, Python Package
  9048. Index}. Information is taken from the JSON-formatted description
  9049. available at @code{pypi.python.org} and usually includes all the relevant
  9050. information, including package dependencies. For maximum efficiency, it
  9051. is recommended to install the @command{unzip} utility, so that the
  9052. importer can unzip Python wheels and gather data from them.
  9053. The command below imports metadata for the @code{itsdangerous} Python
  9054. package:
  9055. @example
  9056. guix import pypi itsdangerous
  9057. @end example
  9058. @table @code
  9059. @item --recursive
  9060. @itemx -r
  9061. Traverse the dependency graph of the given upstream package recursively
  9062. and generate package expressions for all those packages that are not yet
  9063. in Guix.
  9064. @end table
  9065. @item gem
  9066. @cindex gem
  9067. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  9068. is taken from the JSON-formatted description available at
  9069. @code{rubygems.org} and includes most relevant information, including
  9070. runtime dependencies. There are some caveats, however. The metadata
  9071. doesn't distinguish between synopses and descriptions, so the same string
  9072. is used for both fields. Additionally, the details of non-Ruby
  9073. dependencies required to build native extensions is unavailable and left
  9074. as an exercise to the packager.
  9075. The command below imports metadata for the @code{rails} Ruby package:
  9076. @example
  9077. guix import gem rails
  9078. @end example
  9079. @table @code
  9080. @item --recursive
  9081. @itemx -r
  9082. Traverse the dependency graph of the given upstream package recursively
  9083. and generate package expressions for all those packages that are not yet
  9084. in Guix.
  9085. @end table
  9086. @item cpan
  9087. @cindex CPAN
  9088. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  9089. Information is taken from the JSON-formatted metadata provided through
  9090. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  9091. relevant information, such as module dependencies. License information
  9092. should be checked closely. If Perl is available in the store, then the
  9093. @code{corelist} utility will be used to filter core modules out of the
  9094. list of dependencies.
  9095. The command command below imports metadata for the Acme::Boolean Perl
  9096. module:
  9097. @example
  9098. guix import cpan Acme::Boolean
  9099. @end example
  9100. @item cran
  9101. @cindex CRAN
  9102. @cindex Bioconductor
  9103. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  9104. central repository for the @uref{https://r-project.org, GNU@tie{}R
  9105. statistical and graphical environment}.
  9106. Information is extracted from the @file{DESCRIPTION} file of the package.
  9107. The command command below imports metadata for the Cairo R package:
  9108. @example
  9109. guix import cran Cairo
  9110. @end example
  9111. When @option{--recursive} is added, the importer will traverse the
  9112. dependency graph of the given upstream package recursively and generate
  9113. package expressions for all those packages that are not yet in Guix.
  9114. When @option{--style=specification} is added, the importer will generate
  9115. package definitions whose inputs are package specifications instead of
  9116. references to package variables. This is useful when generated package
  9117. definitions are to be appended to existing user modules, as the list of
  9118. used package modules need not be changed. The default is
  9119. @option{--style=variable}.
  9120. When @option{--archive=bioconductor} is added, metadata is imported from
  9121. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  9122. packages for the analysis and comprehension of high-throughput
  9123. genomic data in bioinformatics.
  9124. Information is extracted from the @file{DESCRIPTION} file contained in the
  9125. package archive.
  9126. The command below imports metadata for the GenomicRanges R package:
  9127. @example
  9128. guix import cran --archive=bioconductor GenomicRanges
  9129. @end example
  9130. Finally, you can also import R packages that have not yet been published on
  9131. CRAN or Bioconductor as long as they are in a git repository. Use
  9132. @option{--archive=git} followed by the URL of the git repository:
  9133. @example
  9134. guix import cran --archive=git https://github.com/immunogenomics/harmony
  9135. @end example
  9136. @item texlive
  9137. @cindex TeX Live
  9138. @cindex CTAN
  9139. Import metadata from @uref{https://www.ctan.org/, CTAN}, the
  9140. comprehensive TeX archive network for TeX packages that are part of the
  9141. @uref{https://www.tug.org/texlive/, TeX Live distribution}.
  9142. Information about the package is obtained through the XML API provided
  9143. by CTAN, while the source code is downloaded from the SVN repository of
  9144. the Tex Live project. This is done because the CTAN does not keep
  9145. versioned archives.
  9146. The command command below imports metadata for the @code{fontspec}
  9147. TeX package:
  9148. @example
  9149. guix import texlive fontspec
  9150. @end example
  9151. When @option{--archive=@var{directory}} is added, the source code is
  9152. downloaded not from the @file{latex} sub-directory of the
  9153. @file{texmf-dist/source} tree in the TeX Live SVN repository, but from
  9154. the specified sibling @var{directory} under the same root.
  9155. The command below imports metadata for the @code{ifxetex} package from
  9156. CTAN while fetching the sources from the directory
  9157. @file{texmf/source/generic}:
  9158. @example
  9159. guix import texlive --archive=generic ifxetex
  9160. @end example
  9161. @item json
  9162. @cindex JSON, import
  9163. Import package metadata from a local JSON file. Consider the following
  9164. example package definition in JSON format:
  9165. @example
  9166. @{
  9167. "name": "hello",
  9168. "version": "2.10",
  9169. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  9170. "build-system": "gnu",
  9171. "home-page": "https://www.gnu.org/software/hello/",
  9172. "synopsis": "Hello, GNU world: An example GNU package",
  9173. "description": "GNU Hello prints a greeting.",
  9174. "license": "GPL-3.0+",
  9175. "native-inputs": ["gettext"]
  9176. @}
  9177. @end example
  9178. The field names are the same as for the @code{<package>} record
  9179. (@xref{Defining Packages}). References to other packages are provided
  9180. as JSON lists of quoted package specification strings such as
  9181. @code{guile} or @code{guile@@2.0}.
  9182. The importer also supports a more explicit source definition using the
  9183. common fields for @code{<origin>} records:
  9184. @example
  9185. @{
  9186. @dots{}
  9187. "source": @{
  9188. "method": "url-fetch",
  9189. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  9190. "sha256": @{
  9191. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  9192. @}
  9193. @}
  9194. @dots{}
  9195. @}
  9196. @end example
  9197. The command below reads metadata from the JSON file @code{hello.json}
  9198. and outputs a package expression:
  9199. @example
  9200. guix import json hello.json
  9201. @end example
  9202. @item nix
  9203. Import metadata from a local copy of the source of the
  9204. @uref{https://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
  9205. relies on the @command{nix-instantiate} command of
  9206. @uref{https://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
  9207. typically written in a mixture of Nix-language and Bash code. This
  9208. command only imports the high-level package structure that is written in
  9209. the Nix language. It normally includes all the basic fields of a
  9210. package definition.
  9211. When importing a GNU package, the synopsis and descriptions are replaced
  9212. by their canonical upstream variant.
  9213. Usually, you will first need to do:
  9214. @example
  9215. export NIX_REMOTE=daemon
  9216. @end example
  9217. @noindent
  9218. so that @command{nix-instantiate} does not try to open the Nix database.
  9219. As an example, the command below imports the package definition of
  9220. LibreOffice (more precisely, it imports the definition of the package
  9221. bound to the @code{libreoffice} top-level attribute):
  9222. @example
  9223. guix import nix ~/path/to/nixpkgs libreoffice
  9224. @end example
  9225. @item hackage
  9226. @cindex hackage
  9227. Import metadata from the Haskell community's central package archive
  9228. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  9229. Cabal files and includes all the relevant information, including package
  9230. dependencies.
  9231. Specific command-line options are:
  9232. @table @code
  9233. @item --stdin
  9234. @itemx -s
  9235. Read a Cabal file from standard input.
  9236. @item --no-test-dependencies
  9237. @itemx -t
  9238. Do not include dependencies required only by the test suites.
  9239. @item --cabal-environment=@var{alist}
  9240. @itemx -e @var{alist}
  9241. @var{alist} is a Scheme alist defining the environment in which the
  9242. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  9243. @code{arch}, @code{impl} and a string representing the name of a flag.
  9244. The value associated with a flag has to be either the symbol
  9245. @code{true} or @code{false}. The value associated with other keys
  9246. has to conform to the Cabal file format definition. The default value
  9247. associated with the keys @code{os}, @code{arch} and @code{impl} is
  9248. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  9249. @item --recursive
  9250. @itemx -r
  9251. Traverse the dependency graph of the given upstream package recursively
  9252. and generate package expressions for all those packages that are not yet
  9253. in Guix.
  9254. @end table
  9255. The command below imports metadata for the latest version of the
  9256. HTTP Haskell package without including test dependencies and
  9257. specifying the value of the flag @samp{network-uri} as @code{false}:
  9258. @example
  9259. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  9260. @end example
  9261. A specific package version may optionally be specified by following the
  9262. package name by an at-sign and a version number as in the following example:
  9263. @example
  9264. guix import hackage mtl@@2.1.3.1
  9265. @end example
  9266. @item stackage
  9267. @cindex stackage
  9268. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  9269. It takes a package name, looks up the package version included in a
  9270. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  9271. release and uses the @code{hackage} importer to retrieve its metadata.
  9272. Note that it is up to you to select an LTS release compatible with the
  9273. GHC compiler used by Guix.
  9274. Specific command-line options are:
  9275. @table @code
  9276. @item --no-test-dependencies
  9277. @itemx -t
  9278. Do not include dependencies required only by the test suites.
  9279. @item --lts-version=@var{version}
  9280. @itemx -l @var{version}
  9281. @var{version} is the desired LTS release version. If omitted the latest
  9282. release is used.
  9283. @item --recursive
  9284. @itemx -r
  9285. Traverse the dependency graph of the given upstream package recursively
  9286. and generate package expressions for all those packages that are not yet
  9287. in Guix.
  9288. @end table
  9289. The command below imports metadata for the HTTP Haskell package
  9290. included in the LTS Stackage release version 7.18:
  9291. @example
  9292. guix import stackage --lts-version=7.18 HTTP
  9293. @end example
  9294. @item elpa
  9295. @cindex elpa
  9296. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  9297. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  9298. Specific command-line options are:
  9299. @table @code
  9300. @item --archive=@var{repo}
  9301. @itemx -a @var{repo}
  9302. @var{repo} identifies the archive repository from which to retrieve the
  9303. information. Currently the supported repositories and their identifiers
  9304. are:
  9305. @itemize -
  9306. @item
  9307. @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  9308. identifier. This is the default.
  9309. Packages from @code{elpa.gnu.org} are signed with one of the keys
  9310. contained in the GnuPG keyring at
  9311. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  9312. @code{emacs} package (@pxref{Package Installation, ELPA package
  9313. signatures,, emacs, The GNU Emacs Manual}).
  9314. @item
  9315. @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
  9316. @code{melpa-stable} identifier.
  9317. @item
  9318. @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
  9319. identifier.
  9320. @end itemize
  9321. @item --recursive
  9322. @itemx -r
  9323. Traverse the dependency graph of the given upstream package recursively
  9324. and generate package expressions for all those packages that are not yet
  9325. in Guix.
  9326. @end table
  9327. @item crate
  9328. @cindex crate
  9329. Import metadata from the crates.io Rust package repository
  9330. @uref{https://crates.io, crates.io}, as in this example:
  9331. @example
  9332. guix import crate blake2-rfc
  9333. @end example
  9334. The crate importer also allows you to specify a version string:
  9335. @example
  9336. guix import crate constant-time-eq@@0.1.0
  9337. @end example
  9338. Additional options include:
  9339. @table @code
  9340. @item --recursive
  9341. @itemx -r
  9342. Traverse the dependency graph of the given upstream package recursively
  9343. and generate package expressions for all those packages that are not yet
  9344. in Guix.
  9345. @end table
  9346. @item opam
  9347. @cindex OPAM
  9348. @cindex OCaml
  9349. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  9350. repository used by the OCaml community.
  9351. Additional options include:
  9352. @table @code
  9353. @item --recursive
  9354. @itemx -r
  9355. Traverse the dependency graph of the given upstream package recursively
  9356. and generate package expressions for all those packages that are not yet
  9357. in Guix.
  9358. @item --repo
  9359. Select the given repository (a repository name). Possible values include:
  9360. @itemize
  9361. @item @code{opam}, the default opam repository,
  9362. @item @code{coq} or @code{coq-released}, the stable repository for coq packages,
  9363. @item @code{coq-core-dev}, the repository that contains development versions of coq,
  9364. @item @code{coq-extra-dev}, the repository that contains development versions
  9365. of coq packages.
  9366. @end itemize
  9367. @end table
  9368. @item go
  9369. @cindex go
  9370. Import metadata for a Go module using
  9371. @uref{https://proxy.golang.org, proxy.golang.org}.
  9372. This importer is highly experimental. See the source code for more info
  9373. about the current state.
  9374. @example
  9375. guix import go gopkg.in/yaml.v2
  9376. @end example
  9377. Additional options include:
  9378. @table @code
  9379. @item --recursive
  9380. @itemx -r
  9381. Traverse the dependency graph of the given upstream package recursively
  9382. and generate package expressions for all those packages that are not yet
  9383. in Guix.
  9384. @end table
  9385. @end table
  9386. The structure of the @command{guix import} code is modular. It would be
  9387. useful to have more importers for other package formats, and your help
  9388. is welcome here (@pxref{Contributing}).
  9389. @node Invoking guix refresh
  9390. @section Invoking @command{guix refresh}
  9391. @cindex @command {guix refresh}
  9392. The primary audience of the @command{guix refresh} command is packagers.
  9393. As a user, you may be interested in the @option{--with-latest} option,
  9394. which can bring you package update superpowers built upon @command{guix
  9395. refresh} (@pxref{Package Transformation Options,
  9396. @option{--with-latest}}). By default, @command{guix refresh} reports
  9397. any packages provided by the distribution that are outdated compared to
  9398. the latest upstream version, like this:
  9399. @example
  9400. $ guix refresh
  9401. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  9402. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  9403. @end example
  9404. Alternatively, one can specify packages to consider, in which case a
  9405. warning is emitted for packages that lack an updater:
  9406. @example
  9407. $ guix refresh coreutils guile guile-ssh
  9408. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  9409. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  9410. @end example
  9411. @command{guix refresh} browses the upstream repository of each package and determines
  9412. the highest version number of the releases therein. The command
  9413. knows how to update specific types of packages: GNU packages, ELPA
  9414. packages, etc.---see the documentation for @option{--type} below. There
  9415. are many packages, though, for which it lacks a method to determine
  9416. whether a new upstream release is available. However, the mechanism is
  9417. extensible, so feel free to get in touch with us to add a new method!
  9418. @table @code
  9419. @item --recursive
  9420. Consider the packages specified, and all the packages upon which they depend.
  9421. @example
  9422. $ guix refresh --recursive coreutils
  9423. gnu/packages/acl.scm:40:13: acl would be upgraded from 2.2.53 to 2.3.1
  9424. gnu/packages/m4.scm:30:12: 1.4.18 is already the latest version of m4
  9425. gnu/packages/xml.scm:68:2: warning: no updater for expat
  9426. gnu/packages/multiprecision.scm:40:12: 6.1.2 is already the latest version of gmp
  9427. @dots{}
  9428. @end example
  9429. @end table
  9430. Sometimes the upstream name differs from the package name used in Guix,
  9431. and @command{guix refresh} needs a little help. Most updaters honor the
  9432. @code{upstream-name} property in package definitions, which can be used
  9433. to that effect:
  9434. @lisp
  9435. (define-public network-manager
  9436. (package
  9437. (name "network-manager")
  9438. ;; @dots{}
  9439. (properties '((upstream-name . "NetworkManager")))))
  9440. @end lisp
  9441. When passed @option{--update}, it modifies distribution source files to
  9442. update the version numbers and source tarball hashes of those package
  9443. recipes (@pxref{Defining Packages}). This is achieved by downloading
  9444. each package's latest source tarball and its associated OpenPGP
  9445. signature, authenticating the downloaded tarball against its signature
  9446. using @command{gpgv}, and finally computing its hash---note that GnuPG must be
  9447. installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
  9448. When the public
  9449. key used to sign the tarball is missing from the user's keyring, an
  9450. attempt is made to automatically retrieve it from a public key server;
  9451. when this is successful, the key is added to the user's keyring; otherwise,
  9452. @command{guix refresh} reports an error.
  9453. The following options are supported:
  9454. @table @code
  9455. @item --expression=@var{expr}
  9456. @itemx -e @var{expr}
  9457. Consider the package @var{expr} evaluates to.
  9458. This is useful to precisely refer to a package, as in this example:
  9459. @example
  9460. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  9461. @end example
  9462. This command lists the dependents of the ``final'' libc (essentially all
  9463. the packages).
  9464. @item --update
  9465. @itemx -u
  9466. Update distribution source files (package recipes) in place. This is
  9467. usually run from a checkout of the Guix source tree (@pxref{Running
  9468. Guix Before It Is Installed}):
  9469. @example
  9470. $ ./pre-inst-env guix refresh -s non-core -u
  9471. @end example
  9472. @xref{Defining Packages}, for more information on package definitions.
  9473. @item --select=[@var{subset}]
  9474. @itemx -s @var{subset}
  9475. Select all the packages in @var{subset}, one of @code{core} or
  9476. @code{non-core}.
  9477. The @code{core} subset refers to all the packages at the core of the
  9478. distribution---i.e., packages that are used to build ``everything
  9479. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  9480. changing one of these packages in the distribution entails a rebuild of
  9481. all the others. Thus, such updates are an inconvenience to users in
  9482. terms of build time or bandwidth used to achieve the upgrade.
  9483. The @code{non-core} subset refers to the remaining packages. It is
  9484. typically useful in cases where an update of the core packages would be
  9485. inconvenient.
  9486. @item --manifest=@var{file}
  9487. @itemx -m @var{file}
  9488. Select all the packages from the manifest in @var{file}. This is useful to
  9489. check if any packages of the user manifest can be updated.
  9490. @item --type=@var{updater}
  9491. @itemx -t @var{updater}
  9492. Select only packages handled by @var{updater} (may be a comma-separated
  9493. list of updaters). Currently, @var{updater} may be one of:
  9494. @table @code
  9495. @item gnu
  9496. the updater for GNU packages;
  9497. @item savannah
  9498. the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
  9499. @item gnome
  9500. the updater for GNOME packages;
  9501. @item kde
  9502. the updater for KDE packages;
  9503. @item xorg
  9504. the updater for X.org packages;
  9505. @item kernel.org
  9506. the updater for packages hosted on kernel.org;
  9507. @item elpa
  9508. the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
  9509. @item cran
  9510. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  9511. @item bioconductor
  9512. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  9513. @item cpan
  9514. the updater for @uref{https://www.cpan.org/, CPAN} packages;
  9515. @item pypi
  9516. the updater for @uref{https://pypi.python.org, PyPI} packages.
  9517. @item gem
  9518. the updater for @uref{https://rubygems.org, RubyGems} packages.
  9519. @item github
  9520. the updater for @uref{https://github.com, GitHub} packages.
  9521. @item hackage
  9522. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  9523. @item stackage
  9524. the updater for @uref{https://www.stackage.org, Stackage} packages.
  9525. @item crate
  9526. the updater for @uref{https://crates.io, Crates} packages.
  9527. @item launchpad
  9528. the updater for @uref{https://launchpad.net, Launchpad} packages.
  9529. @item generic-html
  9530. a generic updater that crawls the HTML page where the source tarball of
  9531. the package is hosted, when applicable.
  9532. @end table
  9533. For instance, the following command only checks for updates of Emacs
  9534. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  9535. @example
  9536. $ guix refresh --type=elpa,cran
  9537. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  9538. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  9539. @end example
  9540. @item --list-updaters
  9541. @itemx -L
  9542. List available updaters and exit (see @option{--type} above).
  9543. For each updater, display the fraction of packages it covers; at the
  9544. end, display the fraction of packages covered by all these updaters.
  9545. @end table
  9546. In addition, @command{guix refresh} can be passed one or more package
  9547. names, as in this example:
  9548. @example
  9549. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  9550. @end example
  9551. @noindent
  9552. The command above specifically updates the @code{emacs} and
  9553. @code{idutils} packages. The @option{--select} option would have no
  9554. effect in this case. You might also want to update definitions that
  9555. correspond to the packages installed in your profile:
  9556. @example
  9557. $ ./pre-inst-env guix refresh -u \
  9558. $(guix package --list-installed | cut -f1)
  9559. @end example
  9560. When considering whether to upgrade a package, it is sometimes
  9561. convenient to know which packages would be affected by the upgrade and
  9562. should be checked for compatibility. For this the following option may
  9563. be used when passing @command{guix refresh} one or more package names:
  9564. @table @code
  9565. @item --list-dependent
  9566. @itemx -l
  9567. List top-level dependent packages that would need to be rebuilt as a
  9568. result of upgrading one or more packages.
  9569. @xref{Invoking guix graph, the @code{reverse-package} type of
  9570. @command{guix graph}}, for information on how to visualize the list of
  9571. dependents of a package.
  9572. @end table
  9573. Be aware that the @option{--list-dependent} option only
  9574. @emph{approximates} the rebuilds that would be required as a result of
  9575. an upgrade. More rebuilds might be required under some circumstances.
  9576. @example
  9577. $ guix refresh --list-dependent flex
  9578. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  9579. hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  9580. @end example
  9581. The command above lists a set of packages that could be built to check
  9582. for compatibility with an upgraded @code{flex} package.
  9583. @table @code
  9584. @item --list-transitive
  9585. List all the packages which one or more packages depend upon.
  9586. @example
  9587. $ guix refresh --list-transitive flex
  9588. flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
  9589. 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{}
  9590. @end example
  9591. @end table
  9592. The command above lists a set of packages which, when changed, would cause
  9593. @code{flex} to be rebuilt.
  9594. The following options can be used to customize GnuPG operation:
  9595. @table @code
  9596. @item --gpg=@var{command}
  9597. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  9598. for in @code{$PATH}.
  9599. @item --keyring=@var{file}
  9600. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  9601. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  9602. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  9603. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  9604. information on a tool to manipulate keybox files).
  9605. When this option is omitted, @command{guix refresh} uses
  9606. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  9607. signing keys. OpenPGP signatures are checked against keys from this keyring;
  9608. missing keys are downloaded to this keyring as well (see
  9609. @option{--key-download} below).
  9610. You can export keys from your default GPG keyring into a keybox file using
  9611. commands like this one:
  9612. @example
  9613. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  9614. @end example
  9615. Likewise, you can fetch keys to a specific keybox file like this:
  9616. @example
  9617. gpg --no-default-keyring --keyring mykeyring.kbx \
  9618. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  9619. @end example
  9620. @xref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  9621. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  9622. @item --key-download=@var{policy}
  9623. Handle missing OpenPGP keys according to @var{policy}, which may be one
  9624. of:
  9625. @table @code
  9626. @item always
  9627. Always download missing OpenPGP keys from the key server, and add them
  9628. to the user's GnuPG keyring.
  9629. @item never
  9630. Never try to download missing OpenPGP keys. Instead just bail out.
  9631. @item interactive
  9632. When a package signed with an unknown OpenPGP key is encountered, ask
  9633. the user whether to download it or not. This is the default behavior.
  9634. @end table
  9635. @item --key-server=@var{host}
  9636. Use @var{host} as the OpenPGP key server when importing a public key.
  9637. @item --load-path=@var{directory}
  9638. Add @var{directory} to the front of the package module search path
  9639. (@pxref{Package Modules}).
  9640. This allows users to define their own packages and make them visible to
  9641. the command-line tools.
  9642. @end table
  9643. The @code{github} updater uses the
  9644. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  9645. releases. When used repeatedly e.g.@: when refreshing all packages,
  9646. GitHub will eventually refuse to answer any further API requests. By
  9647. default 60 API requests per hour are allowed, and a full refresh on all
  9648. GitHub packages in Guix requires more than this. Authentication with
  9649. GitHub through the use of an API token alleviates these limits. To use
  9650. an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
  9651. token procured from @uref{https://github.com/settings/tokens} or
  9652. otherwise.
  9653. @node Invoking guix lint
  9654. @section Invoking @command{guix lint}
  9655. @cindex @command{guix lint}
  9656. @cindex package, checking for errors
  9657. The @command{guix lint} command is meant to help package developers avoid
  9658. common errors and use a consistent style. It runs a number of checks on
  9659. a given set of packages in order to find common mistakes in their
  9660. definitions. Available @dfn{checkers} include (see
  9661. @option{--list-checkers} for a complete list):
  9662. @table @code
  9663. @item synopsis
  9664. @itemx description
  9665. Validate certain typographical and stylistic rules about package
  9666. descriptions and synopses.
  9667. @item inputs-should-be-native
  9668. Identify inputs that should most likely be native inputs.
  9669. @item source
  9670. @itemx home-page
  9671. @itemx mirror-url
  9672. @itemx github-url
  9673. @itemx source-file-name
  9674. Probe @code{home-page} and @code{source} URLs and report those that are
  9675. invalid. Suggest a @code{mirror://} URL when applicable. If the
  9676. @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
  9677. URL@. Check that the source file name is meaningful, e.g.@: is not just a
  9678. version number or ``git-checkout'', without a declared @code{file-name}
  9679. (@pxref{origin Reference}).
  9680. @item source-unstable-tarball
  9681. Parse the @code{source} URL to determine if a tarball from GitHub is
  9682. autogenerated or if it is a release tarball. Unfortunately GitHub's
  9683. autogenerated tarballs are sometimes regenerated.
  9684. @item derivation
  9685. Check that the derivation of the given packages can be successfully
  9686. computed for all the supported systems (@pxref{Derivations}).
  9687. @item profile-collisions
  9688. Check whether installing the given packages in a profile would lead to
  9689. collisions. Collisions occur when several packages with the same name
  9690. but a different version or a different store file name are propagated.
  9691. @xref{package Reference, @code{propagated-inputs}}, for more information
  9692. on propagated inputs.
  9693. @item archival
  9694. @cindex Software Heritage, source code archive
  9695. @cindex archival of source code, Software Heritage
  9696. Checks whether the package's source code is archived at
  9697. @uref{https://www.softwareheritage.org, Software Heritage}.
  9698. When the source code that is not archived comes from a version-control system
  9699. (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
  9700. ``save'' request so that it eventually archives it. This ensures that the
  9701. source will remain available in the long term, and that Guix can fall back to
  9702. Software Heritage should the source code disappear from its original host.
  9703. The status of recent ``save'' requests can be
  9704. @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
  9705. When source code is a tarball obtained with @code{url-fetch}, simply print a
  9706. message when it is not archived. As of this writing, Software Heritage does
  9707. not allow requests to save arbitrary tarballs; we are working on ways to
  9708. ensure that non-VCS source code is also archived.
  9709. Software Heritage
  9710. @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
  9711. request rate per IP address}. When the limit is reached, @command{guix lint}
  9712. prints a message and the @code{archival} checker stops doing anything until
  9713. that limit has been reset.
  9714. @item cve
  9715. @cindex security vulnerabilities
  9716. @cindex CVE, Common Vulnerabilities and Exposures
  9717. Report known vulnerabilities found in the Common Vulnerabilities and
  9718. Exposures (CVE) databases of the current and past year
  9719. @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
  9720. NIST}.
  9721. To view information about a particular vulnerability, visit pages such as:
  9722. @itemize
  9723. @item
  9724. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  9725. @item
  9726. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  9727. @end itemize
  9728. @noindent
  9729. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  9730. @code{CVE-2015-7554}.
  9731. Package developers can specify in package recipes the
  9732. @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
  9733. name and version of the package when they differ from the name or version
  9734. that Guix uses, as in this example:
  9735. @lisp
  9736. (package
  9737. (name "grub")
  9738. ;; @dots{}
  9739. ;; CPE calls this package "grub2".
  9740. (properties '((cpe-name . "grub2")
  9741. (cpe-version . "2.3"))))
  9742. @end lisp
  9743. @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
  9744. Some entries in the CVE database do not specify which version of a
  9745. package they apply to, and would thus ``stick around'' forever. Package
  9746. developers who found CVE alerts and verified they can be ignored can
  9747. declare them as in this example:
  9748. @lisp
  9749. (package
  9750. (name "t1lib")
  9751. ;; @dots{}
  9752. ;; These CVEs no longer apply and can be safely ignored.
  9753. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  9754. "CVE-2011-1553"
  9755. "CVE-2011-1554"
  9756. "CVE-2011-5244")))))
  9757. @end lisp
  9758. @item formatting
  9759. Warn about obvious source code formatting issues: trailing white space,
  9760. use of tabulations, etc.
  9761. @end table
  9762. The general syntax is:
  9763. @example
  9764. guix lint @var{options} @var{package}@dots{}
  9765. @end example
  9766. If no package is given on the command line, then all packages are checked.
  9767. The @var{options} may be zero or more of the following:
  9768. @table @code
  9769. @item --list-checkers
  9770. @itemx -l
  9771. List and describe all the available checkers that will be run on packages
  9772. and exit.
  9773. @item --checkers
  9774. @itemx -c
  9775. Only enable the checkers specified in a comma-separated list using the
  9776. names returned by @option{--list-checkers}.
  9777. @item --exclude
  9778. @itemx -x
  9779. Only disable the checkers specified in a comma-separated list using the
  9780. names returned by @option{--list-checkers}.
  9781. @item --no-network
  9782. @itemx -n
  9783. Only enable the checkers that do not depend on Internet access.
  9784. @item --load-path=@var{directory}
  9785. @itemx -L @var{directory}
  9786. Add @var{directory} to the front of the package module search path
  9787. (@pxref{Package Modules}).
  9788. This allows users to define their own packages and make them visible to
  9789. the command-line tools.
  9790. @end table
  9791. @node Invoking guix size
  9792. @section Invoking @command{guix size}
  9793. @cindex size
  9794. @cindex package size
  9795. @cindex closure
  9796. @cindex @command{guix size}
  9797. The @command{guix size} command helps package developers profile the
  9798. disk usage of packages. It is easy to overlook the impact of an
  9799. additional dependency added to a package, or the impact of using a
  9800. single output for a package that could easily be split (@pxref{Packages
  9801. with Multiple Outputs}). Such are the typical issues that
  9802. @command{guix size} can highlight.
  9803. The command can be passed one or more package specifications
  9804. such as @code{gcc@@4.8}
  9805. or @code{guile:debug}, or a file name in the store. Consider this
  9806. example:
  9807. @example
  9808. $ guix size coreutils
  9809. store item total self
  9810. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  9811. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  9812. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  9813. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  9814. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  9815. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  9816. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  9817. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  9818. total: 78.9 MiB
  9819. @end example
  9820. @cindex closure
  9821. The store items listed here constitute the @dfn{transitive closure} of
  9822. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  9823. would be returned by:
  9824. @example
  9825. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  9826. @end example
  9827. Here the output shows three columns next to store items. The first column,
  9828. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  9829. the store item---that is, its own size plus the size of all its
  9830. dependencies. The next column, labeled ``self'', shows the size of the
  9831. item itself. The last column shows the ratio of the size of the item
  9832. itself to the space occupied by all the items listed here.
  9833. In this example, we see that the closure of Coreutils weighs in at
  9834. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  9835. libraries. (That libc and GCC's libraries represent a large fraction of
  9836. the closure is not a problem @i{per se} because they are always available
  9837. on the system anyway.)
  9838. Since the command also accepts store file names, assessing the size of
  9839. a build result is straightforward:
  9840. @example
  9841. guix size $(guix system build config.scm)
  9842. @end example
  9843. When the package(s) passed to @command{guix size} are available in the
  9844. store@footnote{More precisely, @command{guix size} looks for the
  9845. @emph{ungrafted} variant of the given package(s), as returned by
  9846. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  9847. for information on grafts.}, @command{guix size} queries the daemon to determine its
  9848. dependencies, and measures its size in the store, similar to @command{du
  9849. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  9850. Coreutils}).
  9851. When the given packages are @emph{not} in the store, @command{guix size}
  9852. reports information based on the available substitutes
  9853. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  9854. store items that are not even on disk, only available remotely.
  9855. You can also specify several package names:
  9856. @example
  9857. $ guix size coreutils grep sed bash
  9858. store item total self
  9859. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  9860. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  9861. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  9862. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  9863. @dots{}
  9864. total: 102.3 MiB
  9865. @end example
  9866. @noindent
  9867. In this example we see that the combination of the four packages takes
  9868. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  9869. since they have a lot of dependencies in common.
  9870. When looking at the profile returned by @command{guix size}, you may
  9871. find yourself wondering why a given package shows up in the profile at
  9872. all. To understand it, you can use @command{guix graph --path -t
  9873. references} to display the shortest path between the two packages
  9874. (@pxref{Invoking guix graph}).
  9875. The available options are:
  9876. @table @option
  9877. @item --substitute-urls=@var{urls}
  9878. Use substitute information from @var{urls}.
  9879. @xref{client-substitute-urls, the same option for @code{guix build}}.
  9880. @item --sort=@var{key}
  9881. Sort lines according to @var{key}, one of the following options:
  9882. @table @code
  9883. @item self
  9884. the size of each item (the default);
  9885. @item closure
  9886. the total size of the item's closure.
  9887. @end table
  9888. @item --map-file=@var{file}
  9889. Write a graphical map of disk usage in PNG format to @var{file}.
  9890. For the example above, the map looks like this:
  9891. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  9892. produced by @command{guix size}}
  9893. This option requires that
  9894. @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
  9895. installed and visible in Guile's module search path. When that is not
  9896. the case, @command{guix size} fails as it tries to load it.
  9897. @item --system=@var{system}
  9898. @itemx -s @var{system}
  9899. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  9900. @item --load-path=@var{directory}
  9901. @itemx -L @var{directory}
  9902. Add @var{directory} to the front of the package module search path
  9903. (@pxref{Package Modules}).
  9904. This allows users to define their own packages and make them visible to
  9905. the command-line tools.
  9906. @end table
  9907. @node Invoking guix graph
  9908. @section Invoking @command{guix graph}
  9909. @cindex DAG
  9910. @cindex @command{guix graph}
  9911. @cindex package dependencies
  9912. Packages and their dependencies form a @dfn{graph}, specifically a
  9913. directed acyclic graph (DAG). It can quickly become difficult to have a
  9914. mental model of the package DAG, so the @command{guix graph} command
  9915. provides a visual representation of the DAG@. By default,
  9916. @command{guix graph} emits a DAG representation in the input format of
  9917. @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
  9918. directly to the @command{dot} command of Graphviz. It can also emit an
  9919. HTML page with embedded JavaScript code to display a ``chord diagram''
  9920. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  9921. emit Cypher queries to construct a graph in a graph database supporting
  9922. the @uref{https://www.opencypher.org/, openCypher} query language. With
  9923. @option{--path}, it simply displays the shortest path between two
  9924. packages. The general syntax is:
  9925. @example
  9926. guix graph @var{options} @var{package}@dots{}
  9927. @end example
  9928. For example, the following command generates a PDF file representing the
  9929. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  9930. dependencies:
  9931. @example
  9932. guix graph coreutils | dot -Tpdf > dag.pdf
  9933. @end example
  9934. The output looks like this:
  9935. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  9936. Nice little graph, no?
  9937. You may find it more pleasant to navigate the graph interactively with
  9938. @command{xdot} (from the @code{xdot} package):
  9939. @example
  9940. guix graph coreutils | xdot -
  9941. @end example
  9942. But there is more than one graph! The one above is concise: it is the
  9943. graph of package objects, omitting implicit inputs such as GCC, libc,
  9944. grep, etc. It is often useful to have such a concise graph, but
  9945. sometimes one may want to see more details. @command{guix graph} supports
  9946. several types of graphs, allowing you to choose the level of detail:
  9947. @table @code
  9948. @item package
  9949. This is the default type used in the example above. It shows the DAG of
  9950. package objects, excluding implicit dependencies. It is concise, but
  9951. filters out many details.
  9952. @item reverse-package
  9953. This shows the @emph{reverse} DAG of packages. For example:
  9954. @example
  9955. guix graph --type=reverse-package ocaml
  9956. @end example
  9957. ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
  9958. you are also interested in cases where OCaml is an implicit dependency, see
  9959. @code{reverse-bag} below).
  9960. Note that for core packages this can yield huge graphs. If all you want
  9961. is to know the number of packages that depend on a given package, use
  9962. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  9963. @option{--list-dependent}}).
  9964. @item bag-emerged
  9965. This is the package DAG, @emph{including} implicit inputs.
  9966. For instance, the following command:
  9967. @example
  9968. guix graph --type=bag-emerged coreutils
  9969. @end example
  9970. ...@: yields this bigger graph:
  9971. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  9972. At the bottom of the graph, we see all the implicit inputs of
  9973. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  9974. Now, note that the dependencies of these implicit inputs---that is, the
  9975. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  9976. here, for conciseness.
  9977. @item bag
  9978. Similar to @code{bag-emerged}, but this time including all the bootstrap
  9979. dependencies.
  9980. @item bag-with-origins
  9981. Similar to @code{bag}, but also showing origins and their dependencies.
  9982. @item reverse-bag
  9983. This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
  9984. it also takes implicit dependencies into account. For example:
  9985. @example
  9986. guix graph -t reverse-bag dune
  9987. @end example
  9988. @noindent
  9989. ...@: yields the graph of all packages that depend on Dune, directly or
  9990. indirectly. Since Dune is an @emph{implicit} dependency of many packages
  9991. @i{via} @code{dune-build-system}, this shows a large number of packages,
  9992. whereas @code{reverse-package} would show very few if any.
  9993. @item derivation
  9994. This is the most detailed representation: It shows the DAG of
  9995. derivations (@pxref{Derivations}) and plain store items. Compared to
  9996. the above representation, many additional nodes are visible, including
  9997. build scripts, patches, Guile modules, etc.
  9998. For this type of graph, it is also possible to pass a @file{.drv} file
  9999. name instead of a package name, as in:
  10000. @example
  10001. guix graph -t derivation $(guix system build -d my-config.scm)
  10002. @end example
  10003. @item module
  10004. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  10005. For example, the following command shows the graph for the package
  10006. module that defines the @code{guile} package:
  10007. @example
  10008. guix graph -t module guile | xdot -
  10009. @end example
  10010. @end table
  10011. All the types above correspond to @emph{build-time dependencies}. The
  10012. following graph type represents the @emph{run-time dependencies}:
  10013. @table @code
  10014. @item references
  10015. This is the graph of @dfn{references} of a package output, as returned
  10016. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  10017. If the given package output is not available in the store, @command{guix
  10018. graph} attempts to obtain dependency information from substitutes.
  10019. Here you can also pass a store file name instead of a package name. For
  10020. example, the command below produces the reference graph of your profile
  10021. (which can be big!):
  10022. @example
  10023. guix graph -t references $(readlink -f ~/.guix-profile)
  10024. @end example
  10025. @item referrers
  10026. This is the graph of the @dfn{referrers} of a store item, as returned by
  10027. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  10028. This relies exclusively on local information from your store. For
  10029. instance, let us suppose that the current Inkscape is available in 10
  10030. profiles on your machine; @command{guix graph -t referrers inkscape}
  10031. will show a graph rooted at Inkscape and with those 10 profiles linked
  10032. to it.
  10033. It can help determine what is preventing a store item from being garbage
  10034. collected.
  10035. @end table
  10036. @cindex shortest path, between packages
  10037. Often, the graph of the package you are interested in does not fit on
  10038. your screen, and anyway all you want to know is @emph{why} that package
  10039. actually depends on some seemingly unrelated package. The
  10040. @option{--path} option instructs @command{guix graph} to display the
  10041. shortest path between two packages (or derivations, or store items,
  10042. etc.):
  10043. @example
  10044. $ guix graph --path emacs libunistring
  10045. emacs@@26.3
  10046. mailutils@@3.9
  10047. libunistring@@0.9.10
  10048. $ guix graph --path -t derivation emacs libunistring
  10049. /gnu/store/@dots{}-emacs-26.3.drv
  10050. /gnu/store/@dots{}-mailutils-3.9.drv
  10051. /gnu/store/@dots{}-libunistring-0.9.10.drv
  10052. $ guix graph --path -t references emacs libunistring
  10053. /gnu/store/@dots{}-emacs-26.3
  10054. /gnu/store/@dots{}-libidn2-2.2.0
  10055. /gnu/store/@dots{}-libunistring-0.9.10
  10056. @end example
  10057. The available options are the following:
  10058. @table @option
  10059. @item --type=@var{type}
  10060. @itemx -t @var{type}
  10061. Produce a graph output of @var{type}, where @var{type} must be one of
  10062. the values listed above.
  10063. @item --list-types
  10064. List the supported graph types.
  10065. @item --backend=@var{backend}
  10066. @itemx -b @var{backend}
  10067. Produce a graph using the selected @var{backend}.
  10068. @item --list-backends
  10069. List the supported graph backends.
  10070. Currently, the available backends are Graphviz and d3.js.
  10071. @item --path
  10072. Display the shortest path between two nodes of the type specified by
  10073. @option{--type}. The example below shows the shortest path between
  10074. @code{libreoffice} and @code{llvm} according to the references of
  10075. @code{libreoffice}:
  10076. @example
  10077. $ guix graph --path -t references libreoffice llvm
  10078. /gnu/store/@dots{}-libreoffice-6.4.2.2
  10079. /gnu/store/@dots{}-libepoxy-1.5.4
  10080. /gnu/store/@dots{}-mesa-19.3.4
  10081. /gnu/store/@dots{}-llvm-9.0.1
  10082. @end example
  10083. @item --expression=@var{expr}
  10084. @itemx -e @var{expr}
  10085. Consider the package @var{expr} evaluates to.
  10086. This is useful to precisely refer to a package, as in this example:
  10087. @example
  10088. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  10089. @end example
  10090. @item --system=@var{system}
  10091. @itemx -s @var{system}
  10092. Display the graph for @var{system}---e.g., @code{i686-linux}.
  10093. The package dependency graph is largely architecture-independent, but there
  10094. are some architecture-dependent bits that this option allows you to visualize.
  10095. @item --load-path=@var{directory}
  10096. @itemx -L @var{directory}
  10097. Add @var{directory} to the front of the package module search path
  10098. (@pxref{Package Modules}).
  10099. This allows users to define their own packages and make them visible to
  10100. the command-line tools.
  10101. @end table
  10102. On top of that, @command{guix graph} supports all the usual package
  10103. transformation options (@pxref{Package Transformation Options}). This
  10104. makes it easy to view the effect of a graph-rewriting transformation
  10105. such as @option{--with-input}. For example, the command below outputs
  10106. the graph of @code{git} once @code{openssl} has been replaced by
  10107. @code{libressl} everywhere in the graph:
  10108. @example
  10109. guix graph git --with-input=openssl=libressl
  10110. @end example
  10111. So many possibilities, so much fun!
  10112. @node Invoking guix publish
  10113. @section Invoking @command{guix publish}
  10114. @cindex @command{guix publish}
  10115. The purpose of @command{guix publish} is to enable users to easily share
  10116. their store with others, who can then use it as a substitute server
  10117. (@pxref{Substitutes}).
  10118. When @command{guix publish} runs, it spawns an HTTP server which allows
  10119. anyone with network access to obtain substitutes from it. This means
  10120. that any machine running Guix can also act as if it were a build farm,
  10121. since the HTTP interface is compatible with Cuirass, the software behind
  10122. the @code{@value{SUBSTITUTE-SERVER}} build farm.
  10123. For security, each substitute is signed, allowing recipients to check
  10124. their authenticity and integrity (@pxref{Substitutes}). Because
  10125. @command{guix publish} uses the signing key of the system, which is only
  10126. readable by the system administrator, it must be started as root; the
  10127. @option{--user} option makes it drop root privileges early on.
  10128. The signing key pair must be generated before @command{guix publish} is
  10129. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  10130. guix archive}).
  10131. When the @option{--advertise} option is passed, the server advertises
  10132. its availability on the local network using multicast DNS (mDNS) and DNS
  10133. service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,,
  10134. guile-avahi, Using Avahi in Guile Scheme Programs}).
  10135. The general syntax is:
  10136. @example
  10137. guix publish @var{options}@dots{}
  10138. @end example
  10139. Running @command{guix publish} without any additional arguments will
  10140. spawn an HTTP server on port 8080:
  10141. @example
  10142. guix publish
  10143. @end example
  10144. Once a publishing server has been authorized, the daemon may download
  10145. substitutes from it. @xref{Getting Substitutes from Other Servers}.
  10146. By default, @command{guix publish} compresses archives on the fly as it
  10147. serves them. This ``on-the-fly'' mode is convenient in that it requires
  10148. no setup and is immediately available. However, when serving lots of
  10149. clients, we recommend using the @option{--cache} option, which enables
  10150. caching of the archives before they are sent to clients---see below for
  10151. details. The @command{guix weather} command provides a handy way to
  10152. check what a server provides (@pxref{Invoking guix weather}).
  10153. As a bonus, @command{guix publish} also serves as a content-addressed
  10154. mirror for source files referenced in @code{origin} records
  10155. (@pxref{origin Reference}). For instance, assuming @command{guix
  10156. publish} is running on @code{example.org}, the following URL returns the
  10157. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  10158. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  10159. @example
  10160. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  10161. @end example
  10162. Obviously, these URLs only work for files that are in the store; in
  10163. other cases, they return 404 (``Not Found'').
  10164. @cindex build logs, publication
  10165. Build logs are available from @code{/log} URLs like:
  10166. @example
  10167. http://example.org/log/gwspk@dots{}-guile-2.2.3
  10168. @end example
  10169. @noindent
  10170. When @command{guix-daemon} is configured to save compressed build logs,
  10171. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  10172. URLs return the compressed log as-is, with an appropriate
  10173. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  10174. running @command{guix-daemon} with @option{--log-compression=gzip} since
  10175. Web browsers can automatically decompress it, which is not the case with
  10176. Bzip2 compression.
  10177. The following options are available:
  10178. @table @code
  10179. @item --port=@var{port}
  10180. @itemx -p @var{port}
  10181. Listen for HTTP requests on @var{port}.
  10182. @item --listen=@var{host}
  10183. Listen on the network interface for @var{host}. The default is to
  10184. accept connections from any interface.
  10185. @item --user=@var{user}
  10186. @itemx -u @var{user}
  10187. Change privileges to @var{user} as soon as possible---i.e., once the
  10188. server socket is open and the signing key has been read.
  10189. @item --compression[=@var{method}[:@var{level}]]
  10190. @itemx -C [@var{method}[:@var{level}]]
  10191. Compress data using the given @var{method} and @var{level}. @var{method} is
  10192. one of @code{lzip}, @code{zstd}, and @code{gzip}; when @var{method} is
  10193. omitted, @code{gzip} is used.
  10194. When @var{level} is zero, disable compression. The range 1 to 9 corresponds
  10195. to different compression levels: 1 is the fastest, and 9 is the best
  10196. (CPU-intensive). The default is 3.
  10197. Usually, @code{lzip} compresses noticeably better than @code{gzip} for a
  10198. small increase in CPU usage; see
  10199. @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip
  10200. Web page}. However, @code{lzip} achieves low decompression throughput
  10201. (on the order of 50@tie{}MiB/s on modern hardware), which can be a
  10202. bottleneck for someone who downloads over a fast network connection.
  10203. The compression ratio of @code{zstd} is between that of @code{lzip} and
  10204. that of @code{gzip}; its main advantage is a
  10205. @uref{https://facebook.github.io/zstd/,high decompression speed}.
  10206. Unless @option{--cache} is used, compression occurs on the fly and
  10207. the compressed streams are not
  10208. cached. Thus, to reduce load on the machine that runs @command{guix
  10209. publish}, it may be a good idea to choose a low compression level, to
  10210. run @command{guix publish} behind a caching proxy, or to use
  10211. @option{--cache}. Using @option{--cache} has the advantage that it
  10212. allows @command{guix publish} to add @code{Content-Length} HTTP header
  10213. to its responses.
  10214. This option can be repeated, in which case every substitute gets compressed
  10215. using all the selected methods, and all of them are advertised. This is
  10216. useful when users may not support all the compression methods: they can select
  10217. the one they support.
  10218. @item --cache=@var{directory}
  10219. @itemx -c @var{directory}
  10220. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  10221. and only serve archives that are in cache.
  10222. When this option is omitted, archives and meta-data are created
  10223. on-the-fly. This can reduce the available bandwidth, especially when
  10224. compression is enabled, since this may become CPU-bound. Another
  10225. drawback of the default mode is that the length of archives is not known
  10226. in advance, so @command{guix publish} does not add a
  10227. @code{Content-Length} HTTP header to its responses, which in turn
  10228. prevents clients from knowing the amount of data being downloaded.
  10229. Conversely, when @option{--cache} is used, the first request for a store
  10230. item (@i{via} a @code{.narinfo} URL) triggers a
  10231. background process to @dfn{bake} the archive---computing its
  10232. @code{.narinfo} and compressing the archive, if needed. Once the
  10233. archive is cached in @var{directory}, subsequent requests succeed and
  10234. are served directly from the cache, which guarantees that clients get
  10235. the best possible bandwidth.
  10236. That first @code{.narinfo} request nonetheless returns 200, provided the
  10237. requested store item is ``small enough'', below the cache bypass
  10238. threshold---see @option{--cache-bypass-threshold} below. That way,
  10239. clients do not have to wait until the archive is baked. For larger
  10240. store items, the first @code{.narinfo} request returns 404, meaning that
  10241. clients have to wait until the archive is baked.
  10242. The ``baking'' process is performed by worker threads. By default, one
  10243. thread per CPU core is created, but this can be customized. See
  10244. @option{--workers} below.
  10245. When @option{--ttl} is used, cached entries are automatically deleted
  10246. when they have expired.
  10247. @item --workers=@var{N}
  10248. When @option{--cache} is used, request the allocation of @var{N} worker
  10249. threads to ``bake'' archives.
  10250. @item --ttl=@var{ttl}
  10251. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  10252. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  10253. days, @code{1m} means 1 month, and so on.
  10254. This allows the user's Guix to keep substitute information in cache for
  10255. @var{ttl}. However, note that @code{guix publish} does not itself
  10256. guarantee that the store items it provides will indeed remain available
  10257. for as long as @var{ttl}.
  10258. Additionally, when @option{--cache} is used, cached entries that have
  10259. not been accessed for @var{ttl} and that no longer have a corresponding
  10260. item in the store, may be deleted.
  10261. @item --cache-bypass-threshold=@var{size}
  10262. When used in conjunction with @option{--cache}, store items smaller than
  10263. @var{size} are immediately available, even when they are not yet in
  10264. cache. @var{size} is a size in bytes, or it can be suffixed by @code{M}
  10265. for megabytes and so on. The default is @code{10M}.
  10266. ``Cache bypass'' allows you to reduce the publication delay for clients
  10267. at the expense of possibly additional I/O and CPU use on the server
  10268. side: depending on the client access patterns, those store items can end
  10269. up being baked several times until a copy is available in cache.
  10270. Increasing the threshold may be useful for sites that have few users, or
  10271. to guarantee that users get substitutes even for store items that are
  10272. not popular.
  10273. @item --nar-path=@var{path}
  10274. Use @var{path} as the prefix for the URLs of ``nar'' files
  10275. (@pxref{Invoking guix archive, normalized archives}).
  10276. By default, nars are served at a URL such as
  10277. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  10278. change the @code{/nar} part to @var{path}.
  10279. @item --public-key=@var{file}
  10280. @itemx --private-key=@var{file}
  10281. Use the specific @var{file}s as the public/private key pair used to sign
  10282. the store items being published.
  10283. The files must correspond to the same key pair (the private key is used
  10284. for signing and the public key is merely advertised in the signature
  10285. metadata). They must contain keys in the canonical s-expression format
  10286. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  10287. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  10288. @file{/etc/guix/signing-key.sec} are used.
  10289. @item --repl[=@var{port}]
  10290. @itemx -r [@var{port}]
  10291. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  10292. Reference Manual}) on @var{port} (37146 by default). This is used
  10293. primarily for debugging a running @command{guix publish} server.
  10294. @end table
  10295. Enabling @command{guix publish} on Guix System is a one-liner: just
  10296. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  10297. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  10298. @code{guix-publish-service-type}}).
  10299. If you are instead running Guix on a ``foreign distro'', follow these
  10300. instructions:
  10301. @itemize
  10302. @item
  10303. If your host distro uses the systemd init system:
  10304. @example
  10305. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  10306. /etc/systemd/system/
  10307. # systemctl start guix-publish && systemctl enable guix-publish
  10308. @end example
  10309. @item
  10310. If your host distro uses the Upstart init system:
  10311. @example
  10312. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  10313. # start guix-publish
  10314. @end example
  10315. @item
  10316. Otherwise, proceed similarly with your distro's init system.
  10317. @end itemize
  10318. @node Invoking guix challenge
  10319. @section Invoking @command{guix challenge}
  10320. @cindex reproducible builds
  10321. @cindex verifiable builds
  10322. @cindex @command{guix challenge}
  10323. @cindex challenge
  10324. Do the binaries provided by this server really correspond to the source
  10325. code it claims to build? Is a package build process deterministic?
  10326. These are the questions the @command{guix challenge} command attempts to
  10327. answer.
  10328. The former is obviously an important question: Before using a substitute
  10329. server (@pxref{Substitutes}), one had better @emph{verify} that it
  10330. provides the right binaries, and thus @emph{challenge} it. The latter
  10331. is what enables the former: If package builds are deterministic, then
  10332. independent builds of the package should yield the exact same result,
  10333. bit for bit; if a server provides a binary different from the one
  10334. obtained locally, it may be either corrupt or malicious.
  10335. We know that the hash that shows up in @file{/gnu/store} file names is
  10336. the hash of all the inputs of the process that built the file or
  10337. directory---compilers, libraries, build scripts,
  10338. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  10339. one store file name should map to exactly one build output.
  10340. @command{guix challenge} checks whether there is, indeed, a single
  10341. mapping by comparing the build outputs of several independent builds of
  10342. any given store item.
  10343. The command output looks like this:
  10344. @smallexample
  10345. $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  10346. updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
  10347. updating list of substitutes from 'https://guix.example.org'... 100.0%
  10348. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  10349. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  10350. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  10351. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  10352. differing files:
  10353. /lib/libcrypto.so.1.1
  10354. /lib/libssl.so.1.1
  10355. /gnu/store/@dots{}-git-2.5.0 contents differ:
  10356. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  10357. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  10358. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  10359. differing file:
  10360. /libexec/git-core/git-fsck
  10361. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  10362. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  10363. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  10364. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  10365. differing file:
  10366. /share/man/man1/pius.1.gz
  10367. @dots{}
  10368. 6,406 store items were analyzed:
  10369. - 4,749 (74.1%) were identical
  10370. - 525 (8.2%) differed
  10371. - 1,132 (17.7%) were inconclusive
  10372. @end smallexample
  10373. @noindent
  10374. In this example, @command{guix challenge} first scans the store to
  10375. determine the set of locally-built derivations---as opposed to store
  10376. items that were downloaded from a substitute server---and then queries
  10377. all the substitute servers. It then reports those store items for which
  10378. the servers obtained a result different from the local build.
  10379. @cindex non-determinism, in package builds
  10380. As an example, @code{guix.example.org} always gets a different answer.
  10381. Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
  10382. case of Git. This might indicate that the build process of Git is
  10383. non-deterministic, meaning that its output varies as a function of
  10384. various things that Guix does not fully control, in spite of building
  10385. packages in isolated environments (@pxref{Features}). Most common
  10386. sources of non-determinism include the addition of timestamps in build
  10387. results, the inclusion of random numbers, and directory listings sorted
  10388. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  10389. more information.
  10390. To find out what is wrong with this Git binary, the easiest approach is
  10391. to run:
  10392. @example
  10393. guix challenge git \
  10394. --diff=diffoscope \
  10395. --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  10396. @end example
  10397. This automatically invokes @command{diffoscope}, which displays detailed
  10398. information about files that differ.
  10399. Alternatively, we can do something along these lines (@pxref{Invoking guix
  10400. archive}):
  10401. @example
  10402. $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/lzip/@dots{}-git-2.5.0 \
  10403. | lzip -d | guix archive -x /tmp/git
  10404. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  10405. @end example
  10406. This command shows the difference between the files resulting from the
  10407. local build, and the files resulting from the build on
  10408. @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
  10409. diffutils, Comparing and Merging Files}). The @command{diff} command
  10410. works great for text files. When binary files differ, a better option
  10411. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  10412. visualize differences for all kinds of files.
  10413. Once you have done that work, you can tell whether the differences are due
  10414. to a non-deterministic build process or to a malicious server. We try
  10415. hard to remove sources of non-determinism in packages to make it easier
  10416. to verify substitutes, but of course, this is a process that
  10417. involves not just Guix, but a large part of the free software community.
  10418. In the meantime, @command{guix challenge} is one tool to help address
  10419. the problem.
  10420. If you are writing packages for Guix, you are encouraged to check
  10421. whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
  10422. same build result as you did with:
  10423. @example
  10424. $ guix challenge @var{package}
  10425. @end example
  10426. @noindent
  10427. where @var{package} is a package specification such as
  10428. @code{guile@@2.0} or @code{glibc:debug}.
  10429. The general syntax is:
  10430. @example
  10431. guix challenge @var{options} [@var{packages}@dots{}]
  10432. @end example
  10433. When a difference is found between the hash of a locally-built item and
  10434. that of a server-provided substitute, or among substitutes provided by
  10435. different servers, the command displays it as in the example above and
  10436. its exit code is 2 (other non-zero exit codes denote other kinds of
  10437. errors).
  10438. The one option that matters is:
  10439. @table @code
  10440. @item --substitute-urls=@var{urls}
  10441. Consider @var{urls} the whitespace-separated list of substitute source
  10442. URLs to compare to.
  10443. @item --diff=@var{mode}
  10444. Upon mismatches, show differences according to @var{mode}, one of:
  10445. @table @asis
  10446. @item @code{simple} (the default)
  10447. Show the list of files that differ.
  10448. @item @code{diffoscope}
  10449. @itemx @var{command}
  10450. Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
  10451. two directories whose contents do not match.
  10452. When @var{command} is an absolute file name, run @var{command} instead
  10453. of Diffoscope.
  10454. @item @code{none}
  10455. Do not show further details about the differences.
  10456. @end table
  10457. Thus, unless @option{--diff=none} is passed, @command{guix challenge}
  10458. downloads the store items from the given substitute servers so that it
  10459. can compare them.
  10460. @item --verbose
  10461. @itemx -v
  10462. Show details about matches (identical contents) in addition to
  10463. information about mismatches.
  10464. @end table
  10465. @node Invoking guix copy
  10466. @section Invoking @command{guix copy}
  10467. @cindex copy, of store items, over SSH
  10468. @cindex SSH, copy of store items
  10469. @cindex sharing store items across machines
  10470. @cindex transferring store items across machines
  10471. The @command{guix copy} command copies items from the store of one
  10472. machine to that of another machine over a secure shell (SSH)
  10473. connection@footnote{This command is available only when Guile-SSH was
  10474. found. @xref{Requirements}, for details.}. For example, the following
  10475. command copies the @code{coreutils} package, the user's profile, and all
  10476. their dependencies over to @var{host}, logged in as @var{user}:
  10477. @example
  10478. guix copy --to=@var{user}@@@var{host} \
  10479. coreutils $(readlink -f ~/.guix-profile)
  10480. @end example
  10481. If some of the items to be copied are already present on @var{host},
  10482. they are not actually sent.
  10483. The command below retrieves @code{libreoffice} and @code{gimp} from
  10484. @var{host}, assuming they are available there:
  10485. @example
  10486. guix copy --from=@var{host} libreoffice gimp
  10487. @end example
  10488. The SSH connection is established using the Guile-SSH client, which is
  10489. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  10490. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  10491. The key used to sign items that are sent must be accepted by the remote
  10492. machine. Likewise, the key used by the remote machine to sign items you
  10493. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  10494. own daemon. @xref{Invoking guix archive}, for more information about
  10495. store item authentication.
  10496. The general syntax is:
  10497. @example
  10498. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  10499. @end example
  10500. You must always specify one of the following options:
  10501. @table @code
  10502. @item --to=@var{spec}
  10503. @itemx --from=@var{spec}
  10504. Specify the host to send to or receive from. @var{spec} must be an SSH
  10505. spec such as @code{example.org}, @code{charlie@@example.org}, or
  10506. @code{charlie@@example.org:2222}.
  10507. @end table
  10508. The @var{items} can be either package names, such as @code{gimp}, or
  10509. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  10510. When specifying the name of a package to send, it is first built if
  10511. needed, unless @option{--dry-run} was specified. Common build options
  10512. are supported (@pxref{Common Build Options}).
  10513. @node Invoking guix container
  10514. @section Invoking @command{guix container}
  10515. @cindex container
  10516. @cindex @command{guix container}
  10517. @quotation Note
  10518. As of version @value{VERSION}, this tool is experimental. The interface
  10519. is subject to radical change in the future.
  10520. @end quotation
  10521. The purpose of @command{guix container} is to manipulate processes
  10522. running within an isolated environment, commonly known as a
  10523. ``container'', typically created by the @command{guix environment}
  10524. (@pxref{Invoking guix environment}) and @command{guix system container}
  10525. (@pxref{Invoking guix system}) commands.
  10526. The general syntax is:
  10527. @example
  10528. guix container @var{action} @var{options}@dots{}
  10529. @end example
  10530. @var{action} specifies the operation to perform with a container, and
  10531. @var{options} specifies the context-specific arguments for the action.
  10532. The following actions are available:
  10533. @table @code
  10534. @item exec
  10535. Execute a command within the context of a running container.
  10536. The syntax is:
  10537. @example
  10538. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  10539. @end example
  10540. @var{pid} specifies the process ID of the running container.
  10541. @var{program} specifies an executable file name within the root file
  10542. system of the container. @var{arguments} are the additional options that
  10543. will be passed to @var{program}.
  10544. The following command launches an interactive login shell inside a
  10545. Guix system container, started by @command{guix system container}, and whose
  10546. process ID is 9001:
  10547. @example
  10548. guix container exec 9001 /run/current-system/profile/bin/bash --login
  10549. @end example
  10550. Note that the @var{pid} cannot be the parent process of a container. It
  10551. must be PID 1 of the container or one of its child processes.
  10552. @end table
  10553. @node Invoking guix weather
  10554. @section Invoking @command{guix weather}
  10555. Occasionally you're grumpy because substitutes are lacking and you end
  10556. up building packages by yourself (@pxref{Substitutes}). The
  10557. @command{guix weather} command reports on substitute availability on the
  10558. specified servers so you can have an idea of whether you'll be grumpy
  10559. today. It can sometimes be useful info as a user, but it is primarily
  10560. useful to people running @command{guix publish} (@pxref{Invoking guix
  10561. publish}).
  10562. @cindex statistics, for substitutes
  10563. @cindex availability of substitutes
  10564. @cindex substitute availability
  10565. @cindex weather, substitute availability
  10566. Here's a sample run:
  10567. @example
  10568. $ guix weather --substitute-urls=https://guix.example.org
  10569. computing 5,872 package derivations for x86_64-linux...
  10570. looking for 6,128 store items on https://guix.example.org..
  10571. updating list of substitutes from 'https://guix.example.org'... 100.0%
  10572. https://guix.example.org
  10573. 43.4% substitutes available (2,658 out of 6,128)
  10574. 7,032.5 MiB of nars (compressed)
  10575. 19,824.2 MiB on disk (uncompressed)
  10576. 0.030 seconds per request (182.9 seconds in total)
  10577. 33.5 requests per second
  10578. 9.8% (342 out of 3,470) of the missing items are queued
  10579. 867 queued builds
  10580. x86_64-linux: 518 (59.7%)
  10581. i686-linux: 221 (25.5%)
  10582. aarch64-linux: 128 (14.8%)
  10583. build rate: 23.41 builds per hour
  10584. x86_64-linux: 11.16 builds per hour
  10585. i686-linux: 6.03 builds per hour
  10586. aarch64-linux: 6.41 builds per hour
  10587. @end example
  10588. @cindex continuous integration, statistics
  10589. As you can see, it reports the fraction of all the packages for which
  10590. substitutes are available on the server---regardless of whether
  10591. substitutes are enabled, and regardless of whether this server's signing
  10592. key is authorized. It also reports the size of the compressed archives
  10593. (``nars'') provided by the server, the size the corresponding store
  10594. items occupy in the store (assuming deduplication is turned off), and
  10595. the server's throughput. The second part gives continuous integration
  10596. (CI) statistics, if the server supports it. In addition, using the
  10597. @option{--coverage} option, @command{guix weather} can list ``important''
  10598. package substitutes missing on the server (see below).
  10599. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  10600. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  10601. challenge}, it ignores signatures on those substitutes, which is
  10602. innocuous since the command only gathers statistics and cannot install
  10603. those substitutes.
  10604. The general syntax is:
  10605. @example
  10606. guix weather @var{options}@dots{} [@var{packages}@dots{}]
  10607. @end example
  10608. When @var{packages} is omitted, @command{guix weather} checks the availability
  10609. of substitutes for @emph{all} the packages, or for those specified with
  10610. @option{--manifest}; otherwise it only considers the specified packages. It
  10611. is also possible to query specific system types with @option{--system}.
  10612. @command{guix weather} exits with a non-zero code when the fraction of
  10613. available substitutes is below 100%.
  10614. The available options are listed below.
  10615. @table @code
  10616. @item --substitute-urls=@var{urls}
  10617. @var{urls} is the space-separated list of substitute server URLs to
  10618. query. When this option is omitted, the default set of substitute
  10619. servers is queried.
  10620. @item --system=@var{system}
  10621. @itemx -s @var{system}
  10622. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  10623. option can be repeated, in which case @command{guix weather} will query
  10624. substitutes for several system types.
  10625. @item --manifest=@var{file}
  10626. Instead of querying substitutes for all the packages, only ask for those
  10627. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  10628. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  10629. guix package}).
  10630. This option can be repeated several times, in which case the manifests
  10631. are concatenated.
  10632. @item --coverage[=@var{count}]
  10633. @itemx -c [@var{count}]
  10634. Report on substitute coverage for packages: list packages with at least
  10635. @var{count} dependents (zero by default) for which substitutes are
  10636. unavailable. Dependent packages themselves are not listed: if @var{b} depends
  10637. on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
  10638. @var{b} usually lacks substitutes as well. The result looks like this:
  10639. @example
  10640. $ guix weather --substitute-urls=@value{SUBSTITUTE-URL} -c 10
  10641. computing 8,983 package derivations for x86_64-linux...
  10642. looking for 9,343 store items on @value{SUBSTITUTE-URL}...
  10643. updating substitutes from '@value{SUBSTITUTE-URL}'... 100.0%
  10644. @value{SUBSTITUTE-URL}
  10645. 64.7% substitutes available (6,047 out of 9,343)
  10646. @dots{}
  10647. 2502 packages are missing from '@value{SUBSTITUTE-URL}' for 'x86_64-linux', among which:
  10648. 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
  10649. 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
  10650. 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
  10651. @dots{}
  10652. @end example
  10653. What this example shows is that @code{kcoreaddons} and presumably the 58
  10654. packages that depend on it have no substitutes at
  10655. @code{@value{SUBSTITUTE-SERVER}}; likewise for @code{qgpgme} and the 46
  10656. packages that depend on it.
  10657. If you are a Guix developer, or if you are taking care of this build farm,
  10658. you'll probably want to have a closer look at these packages: they may simply
  10659. fail to build.
  10660. @item --display-missing
  10661. Display the list of store items for which substitutes are missing.
  10662. @end table
  10663. @node Invoking guix processes
  10664. @section Invoking @command{guix processes}
  10665. The @command{guix processes} command can be useful to developers and system
  10666. administrators, especially on multi-user machines and on build farms: it lists
  10667. the current sessions (connections to the daemon), as well as information about
  10668. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  10669. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  10670. listed.}. Here's an example of the information it returns:
  10671. @example
  10672. $ sudo guix processes
  10673. SessionPID: 19002
  10674. ClientPID: 19090
  10675. ClientCommand: guix environment --ad-hoc python
  10676. SessionPID: 19402
  10677. ClientPID: 19367
  10678. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  10679. SessionPID: 19444
  10680. ClientPID: 19419
  10681. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  10682. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  10683. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  10684. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  10685. ChildPID: 20495
  10686. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10687. ChildPID: 27733
  10688. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10689. ChildPID: 27793
  10690. ChildCommand: guix offload x86_64-linux 7200 1 28800
  10691. @end example
  10692. In this example we see that @command{guix-daemon} has three clients:
  10693. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  10694. integration tool; their process identifier (PID) is given by the
  10695. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  10696. @command{guix-daemon} sub-process of this particular session.
  10697. The @code{LockHeld} fields show which store items are currently locked
  10698. by this session, which corresponds to store items being built or
  10699. substituted (the @code{LockHeld} field is not displayed when
  10700. @command{guix processes} is not running as root). Last, by looking at
  10701. the @code{ChildPID} and @code{ChildCommand} fields, we understand that
  10702. these three builds are being offloaded (@pxref{Daemon Offload Setup}).
  10703. The output is in Recutils format so we can use the handy @command{recsel}
  10704. command to select sessions of interest (@pxref{Selection Expressions,,,
  10705. recutils, GNU recutils manual}). As an example, the command shows the command
  10706. line and PID of the client that triggered the build of a Perl package:
  10707. @example
  10708. $ sudo guix processes | \
  10709. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  10710. ClientPID: 19419
  10711. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  10712. @end example
  10713. Additional options are listed below.
  10714. @table @code
  10715. @item --format=@var{format}
  10716. @itemx -f @var{format}
  10717. Produce output in the specified @var{format}, one of:
  10718. @table @code
  10719. @item recutils
  10720. The default option. It outputs a set of Session recutils records
  10721. that include each @code{ChildProcess} as a field.
  10722. @item normalized
  10723. Normalize the output records into record sets (@pxref{Record Sets,,,
  10724. recutils, GNU recutils manual}). Normalizing into record sets allows
  10725. joins across record types. The example below lists the PID of each
  10726. @code{ChildProcess} and the associated PID for @code{Session} that
  10727. spawned the @code{ChildProcess} where the @code{Session} was started
  10728. using @command{guix build}.
  10729. @example
  10730. $ guix processes --format=normalized | \
  10731. recsel \
  10732. -j Session \
  10733. -t ChildProcess \
  10734. -p Session.PID,PID \
  10735. -e 'Session.ClientCommand ~ "guix build"'
  10736. PID: 4435
  10737. Session_PID: 4278
  10738. PID: 4554
  10739. Session_PID: 4278
  10740. PID: 4646
  10741. Session_PID: 4278
  10742. @end example
  10743. @end table
  10744. @end table
  10745. @node System Configuration
  10746. @chapter System Configuration
  10747. @cindex system configuration
  10748. Guix System supports a consistent whole-system configuration
  10749. mechanism. By that we mean that all aspects of the global system
  10750. configuration---such as the available system services, timezone and
  10751. locale settings, user accounts---are declared in a single place. Such
  10752. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  10753. One of the advantages of putting all the system configuration under the
  10754. control of Guix is that it supports transactional system upgrades, and
  10755. makes it possible to roll back to a previous system instantiation,
  10756. should something go wrong with the new one (@pxref{Features}). Another
  10757. advantage is that it makes it easy to replicate the exact same configuration
  10758. across different machines, or at different points in time, without
  10759. having to resort to additional administration tools layered on top of
  10760. the own tools of the system.
  10761. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  10762. This section describes this mechanism. First we focus on the system
  10763. administrator's viewpoint---explaining how the system is configured and
  10764. instantiated. Then we show how this mechanism can be extended, for
  10765. instance to support new system services.
  10766. @menu
  10767. * Using the Configuration System:: Customizing your GNU system.
  10768. * operating-system Reference:: Detail of operating-system declarations.
  10769. * File Systems:: Configuring file system mounts.
  10770. * Mapped Devices:: Block device extra processing.
  10771. * User Accounts:: Specifying user accounts.
  10772. * Keyboard Layout:: How the system interprets key strokes.
  10773. * Locales:: Language and cultural convention settings.
  10774. * Services:: Specifying system services.
  10775. * Setuid Programs:: Programs running with root privileges.
  10776. * X.509 Certificates:: Authenticating HTTPS servers.
  10777. * Name Service Switch:: Configuring libc's name service switch.
  10778. * Initial RAM Disk:: Linux-Libre bootstrapping.
  10779. * Bootloader Configuration:: Configuring the boot loader.
  10780. * Invoking guix system:: Instantiating a system configuration.
  10781. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  10782. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  10783. * Defining Services:: Adding new service definitions.
  10784. @end menu
  10785. @node Using the Configuration System
  10786. @section Using the Configuration System
  10787. The operating system is configured by providing an
  10788. @code{operating-system} declaration in a file that can then be passed to
  10789. the @command{guix system} command (@pxref{Invoking guix system}). A
  10790. simple setup, with the default system services, the default Linux-Libre
  10791. kernel, initial RAM disk, and boot loader looks like this:
  10792. @findex operating-system
  10793. @lisp
  10794. @include os-config-bare-bones.texi
  10795. @end lisp
  10796. This example should be self-describing. Some of the fields defined
  10797. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  10798. Others, such as @code{packages} and @code{services}, can be omitted, in
  10799. which case they get a default value.
  10800. Below we discuss the effect of some of the most important fields
  10801. (@pxref{operating-system Reference}, for details about all the available
  10802. fields), and how to @dfn{instantiate} the operating system using
  10803. @command{guix system}.
  10804. @unnumberedsubsec Bootloader
  10805. @cindex legacy boot, on Intel machines
  10806. @cindex BIOS boot, on Intel machines
  10807. @cindex UEFI boot
  10808. @cindex EFI boot
  10809. The @code{bootloader} field describes the method that will be used to boot
  10810. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  10811. mode, as in the example above. However, more recent machines rely instead on
  10812. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  10813. the @code{bootloader} field should contain something along these lines:
  10814. @lisp
  10815. (bootloader-configuration
  10816. (bootloader grub-efi-bootloader)
  10817. (target "/boot/efi"))
  10818. @end lisp
  10819. @xref{Bootloader Configuration}, for more information on the available
  10820. configuration options.
  10821. @unnumberedsubsec Globally-Visible Packages
  10822. @vindex %base-packages
  10823. The @code{packages} field lists packages that will be globally visible
  10824. on the system, for all user accounts---i.e., in every user's @env{PATH}
  10825. environment variable---in addition to the per-user profiles
  10826. (@pxref{Invoking guix package}). The @code{%base-packages} variable
  10827. provides all the tools one would expect for basic user and administrator
  10828. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  10829. the GNU Zile lightweight text editor, @command{find}, @command{grep},
  10830. etc. The example above adds GNU@tie{}Screen to those,
  10831. taken from the @code{(gnu packages screen)}
  10832. module (@pxref{Package Modules}). The
  10833. @code{(list package output)} syntax can be used to add a specific output
  10834. of a package:
  10835. @lisp
  10836. (use-modules (gnu packages))
  10837. (use-modules (gnu packages dns))
  10838. (operating-system
  10839. ;; ...
  10840. (packages (cons (list bind "utils")
  10841. %base-packages)))
  10842. @end lisp
  10843. @findex specification->package
  10844. Referring to packages by variable name, like @code{bind} above, has
  10845. the advantage of being unambiguous; it also allows typos and such to be
  10846. diagnosed right away as ``unbound variables''. The downside is that one
  10847. needs to know which module defines which package, and to augment the
  10848. @code{use-package-modules} line accordingly. To avoid that, one can use
  10849. the @code{specification->package} procedure of the @code{(gnu packages)}
  10850. module, which returns the best package for a given name or name and
  10851. version:
  10852. @lisp
  10853. (use-modules (gnu packages))
  10854. (operating-system
  10855. ;; ...
  10856. (packages (append (map specification->package
  10857. '("tcpdump" "htop" "gnupg@@2.0"))
  10858. %base-packages)))
  10859. @end lisp
  10860. @unnumberedsubsec System Services
  10861. @cindex services
  10862. @vindex %base-services
  10863. The @code{services} field lists @dfn{system services} to be made
  10864. available when the system starts (@pxref{Services}).
  10865. The @code{operating-system} declaration above specifies that, in
  10866. addition to the basic services, we want the OpenSSH secure shell
  10867. daemon listening on port 2222 (@pxref{Networking Services,
  10868. @code{openssh-service-type}}). Under the hood,
  10869. @code{openssh-service-type} arranges so that @command{sshd} is started with the
  10870. right command-line options, possibly with supporting configuration files
  10871. generated as needed (@pxref{Defining Services}).
  10872. @cindex customization, of services
  10873. @findex modify-services
  10874. Occasionally, instead of using the base services as is, you will want to
  10875. customize them. To do this, use @code{modify-services} (@pxref{Service
  10876. Reference, @code{modify-services}}) to modify the list.
  10877. For example, suppose you want to modify @code{guix-daemon} and Mingetty
  10878. (the console log-in) in the @code{%base-services} list (@pxref{Base
  10879. Services, @code{%base-services}}). To do that, you can write the
  10880. following in your operating system declaration:
  10881. @lisp
  10882. (define %my-services
  10883. ;; My very own list of services.
  10884. (modify-services %base-services
  10885. (guix-service-type config =>
  10886. (guix-configuration
  10887. (inherit config)
  10888. ;; Fetch substitutes from example.org.
  10889. (substitute-urls
  10890. (list "https://example.org/guix"
  10891. "https://ci.guix.gnu.org"))))
  10892. (mingetty-service-type config =>
  10893. (mingetty-configuration
  10894. (inherit config)
  10895. ;; Automatially log in as "guest".
  10896. (auto-login "guest")))))
  10897. (operating-system
  10898. ;; @dots{}
  10899. (services %my-services))
  10900. @end lisp
  10901. This changes the configuration---i.e., the service parameters---of the
  10902. @code{guix-service-type} instance, and that of all the
  10903. @code{mingetty-service-type} instances in the @code{%base-services} list.
  10904. Observe how this is accomplished: first, we arrange for the original
  10905. configuration to be bound to the identifier @code{config} in the
  10906. @var{body}, and then we write the @var{body} so that it evaluates to the
  10907. desired configuration. In particular, notice how we use @code{inherit}
  10908. to create a new configuration which has the same values as the old
  10909. configuration, but with a few modifications.
  10910. @cindex encrypted disk
  10911. The configuration for a typical ``desktop'' usage, with an encrypted
  10912. root partition, the X11 display
  10913. server, GNOME and Xfce (users can choose which of these desktop
  10914. environments to use at the log-in screen by pressing @kbd{F1}), network
  10915. management, power management, and more, would look like this:
  10916. @lisp
  10917. @include os-config-desktop.texi
  10918. @end lisp
  10919. A graphical system with a choice of lightweight window managers
  10920. instead of full-blown desktop environments would look like this:
  10921. @lisp
  10922. @include os-config-lightweight-desktop.texi
  10923. @end lisp
  10924. This example refers to the @file{/boot/efi} file system by its UUID,
  10925. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  10926. as returned by the @command{blkid} command.
  10927. @xref{Desktop Services}, for the exact list of services provided by
  10928. @code{%desktop-services}. @xref{X.509 Certificates}, for background
  10929. information about the @code{nss-certs} package that is used here.
  10930. Again, @code{%desktop-services} is just a list of service objects. If
  10931. you want to remove services from there, you can do so using the
  10932. procedures for list filtering (@pxref{SRFI-1 Filtering and
  10933. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  10934. following expression returns a list that contains all the services in
  10935. @code{%desktop-services} minus the Avahi service:
  10936. @lisp
  10937. (remove (lambda (service)
  10938. (eq? (service-kind service) avahi-service-type))
  10939. %desktop-services)
  10940. @end lisp
  10941. @unnumberedsubsec Instantiating the System
  10942. Assuming the @code{operating-system} declaration
  10943. is stored in the @file{my-system-config.scm}
  10944. file, the @command{guix system reconfigure my-system-config.scm} command
  10945. instantiates that configuration, and makes it the default GRUB boot
  10946. entry (@pxref{Invoking guix system}).
  10947. The normal way to change the system configuration is by updating this
  10948. file and re-running @command{guix system reconfigure}. One should never
  10949. have to touch files in @file{/etc} or to run commands that modify the
  10950. system state such as @command{useradd} or @command{grub-install}. In
  10951. fact, you must avoid that since that would not only void your warranty
  10952. but also prevent you from rolling back to previous versions of your
  10953. system, should you ever need to.
  10954. @cindex roll-back, of the operating system
  10955. Speaking of roll-back, each time you run @command{guix system
  10956. reconfigure}, a new @dfn{generation} of the system is created---without
  10957. modifying or deleting previous generations. Old system generations get
  10958. an entry in the bootloader boot menu, allowing you to boot them in case
  10959. something went wrong with the latest generation. Reassuring, no? The
  10960. @command{guix system list-generations} command lists the system
  10961. generations available on disk. It is also possible to roll back the
  10962. system via the commands @command{guix system roll-back} and
  10963. @command{guix system switch-generation}.
  10964. Although the @command{guix system reconfigure} command will not modify
  10965. previous generations, you must take care when the current generation is not
  10966. the latest (e.g., after invoking @command{guix system roll-back}), since
  10967. the operation might overwrite a later generation (@pxref{Invoking guix
  10968. system}).
  10969. @unnumberedsubsec The Programming Interface
  10970. At the Scheme level, the bulk of an @code{operating-system} declaration
  10971. is instantiated with the following monadic procedure (@pxref{The Store
  10972. Monad}):
  10973. @deffn {Monadic Procedure} operating-system-derivation os
  10974. Return a derivation that builds @var{os}, an @code{operating-system}
  10975. object (@pxref{Derivations}).
  10976. The output of the derivation is a single directory that refers to all
  10977. the packages, configuration files, and other supporting files needed to
  10978. instantiate @var{os}.
  10979. @end deffn
  10980. This procedure is provided by the @code{(gnu system)} module. Along
  10981. with @code{(gnu services)} (@pxref{Services}), this module contains the
  10982. guts of Guix System. Make sure to visit it!
  10983. @node operating-system Reference
  10984. @section @code{operating-system} Reference
  10985. This section summarizes all the options available in
  10986. @code{operating-system} declarations (@pxref{Using the Configuration
  10987. System}).
  10988. @deftp {Data Type} operating-system
  10989. This is the data type representing an operating system configuration.
  10990. By that, we mean all the global system configuration, not per-user
  10991. configuration (@pxref{Using the Configuration System}).
  10992. @table @asis
  10993. @item @code{kernel} (default: @code{linux-libre})
  10994. The package object of the operating system kernel to
  10995. use@footnote{Currently only the Linux-libre kernel is fully supported.
  10996. Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
  10997. available when building a virtual machine disk image.}.
  10998. @cindex hurd
  10999. @item @code{hurd} (default: @code{#f})
  11000. The package object of the Hurd to be started by the kernel. When this
  11001. field is set, produce a GNU/Hurd operating system. In that case,
  11002. @code{kernel} must also be set to the @code{gnumach} package---the
  11003. microkernel the Hurd runs on.
  11004. @quotation Warning
  11005. This feature is experimental and only supported for disk images.
  11006. @end quotation
  11007. @item @code{kernel-loadable-modules} (default: '())
  11008. A list of objects (usually packages) to collect loadable kernel modules
  11009. from--e.g. @code{(list ddcci-driver-linux)}.
  11010. @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
  11011. List of strings or gexps representing additional arguments to pass on
  11012. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  11013. @item @code{bootloader}
  11014. The system bootloader configuration object. @xref{Bootloader Configuration}.
  11015. @item @code{label}
  11016. This is the label (a string) as it appears in the bootloader's menu entry.
  11017. The default label includes the kernel name and version.
  11018. @item @code{keyboard-layout} (default: @code{#f})
  11019. This field specifies the keyboard layout to use in the console. It can be
  11020. either @code{#f}, in which case the default keyboard layout is used (usually
  11021. US English), or a @code{<keyboard-layout>} record. @xref{Keyboard Layout},
  11022. for more information.
  11023. This keyboard layout is in effect as soon as the kernel has booted. For
  11024. instance, it is the keyboard layout in effect when you type a passphrase if
  11025. your root file system is on a @code{luks-device-mapping} mapped device
  11026. (@pxref{Mapped Devices}).
  11027. @quotation Note
  11028. This does @emph{not} specify the keyboard layout used by the bootloader, nor
  11029. that used by the graphical display server. @xref{Bootloader Configuration},
  11030. for information on how to specify the bootloader's keyboard layout. @xref{X
  11031. Window}, for information on how to specify the keyboard layout used by the X
  11032. Window System.
  11033. @end quotation
  11034. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  11035. @cindex initrd
  11036. @cindex initial RAM disk
  11037. The list of Linux kernel modules that need to be available in the
  11038. initial RAM disk. @xref{Initial RAM Disk}.
  11039. @item @code{initrd} (default: @code{base-initrd})
  11040. A procedure that returns an initial RAM disk for the Linux
  11041. kernel. This field is provided to support low-level customization and
  11042. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  11043. @item @code{firmware} (default: @code{%base-firmware})
  11044. @cindex firmware
  11045. List of firmware packages loadable by the operating system kernel.
  11046. The default includes firmware needed for Atheros- and Broadcom-based
  11047. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  11048. respectively). @xref{Hardware Considerations}, for more info on
  11049. supported hardware.
  11050. @item @code{host-name}
  11051. The host name.
  11052. @item @code{hosts-file}
  11053. @cindex hosts file
  11054. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  11055. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  11056. Reference Manual}). The default is a file with entries for
  11057. @code{localhost} and @var{host-name}.
  11058. @item @code{mapped-devices} (default: @code{'()})
  11059. A list of mapped devices. @xref{Mapped Devices}.
  11060. @item @code{file-systems}
  11061. A list of file systems. @xref{File Systems}.
  11062. @cindex swap devices
  11063. @cindex swap space
  11064. @item @code{swap-devices} (default: @code{'()})
  11065. A list of UUIDs, file system labels, or strings identifying devices or
  11066. files to be used for ``swap
  11067. space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
  11068. Manual}). Here are some examples:
  11069. @table @code
  11070. @item (list (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))
  11071. Use the swap partition with the given UUID@. You can learn the UUID of a
  11072. Linux swap partition by running @command{swaplabel @var{device}}, where
  11073. @var{device} is the @file{/dev} file name of that partition.
  11074. @item (list (file-system-label "swap"))
  11075. Use the partition with label @code{swap}. Again, the
  11076. @command{swaplabel} command allows you to view and change the label of a
  11077. Linux swap partition.
  11078. @item (list "/swapfile")
  11079. Use the file @file{/swapfile} as swap space.
  11080. @item (list "/dev/sda3" "/dev/sdb2")
  11081. Use the @file{/dev/sda3} and @file{/dev/sdb2} partitions as swap space.
  11082. We recommend referring to swap devices by UUIDs or labels as shown above
  11083. instead.
  11084. @end table
  11085. It is possible to specify a swap file in a file system on a mapped
  11086. device (under @file{/dev/mapper}), provided that the necessary device
  11087. mapping and file system are also specified. @xref{Mapped Devices} and
  11088. @ref{File Systems}.
  11089. @item @code{users} (default: @code{%base-user-accounts})
  11090. @itemx @code{groups} (default: @code{%base-groups})
  11091. List of user accounts and groups. @xref{User Accounts}.
  11092. If the @code{users} list lacks a user account with UID@tie{}0, a
  11093. ``root'' account with UID@tie{}0 is automatically added.
  11094. @item @code{skeletons} (default: @code{(default-skeletons)})
  11095. A list of target file name/file-like object tuples (@pxref{G-Expressions,
  11096. file-like objects}). These are the skeleton files that will be added to
  11097. the home directory of newly-created user accounts.
  11098. For instance, a valid value may look like this:
  11099. @lisp
  11100. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  11101. (".guile" ,(plain-file "guile"
  11102. "(use-modules (ice-9 readline))
  11103. (activate-readline)")))
  11104. @end lisp
  11105. @item @code{issue} (default: @code{%default-issue})
  11106. A string denoting the contents of the @file{/etc/issue} file, which is
  11107. displayed when users log in on a text console.
  11108. @item @code{packages} (default: @code{%base-packages})
  11109. A list of packages to be installed in the global profile, which is accessible
  11110. at @file{/run/current-system/profile}. Each element is either a package
  11111. variable or a package/output tuple. Here's a simple example of both:
  11112. @lisp
  11113. (cons* git ; the default "out" output
  11114. (list git "send-email") ; another output of git
  11115. %base-packages) ; the default set
  11116. @end lisp
  11117. The default set includes core utilities and it is good practice to
  11118. install non-core utilities in user profiles (@pxref{Invoking guix
  11119. package}).
  11120. @item @code{timezone}
  11121. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  11122. You can run the @command{tzselect} command to find out which timezone
  11123. string corresponds to your region. Choosing an invalid timezone name
  11124. causes @command{guix system} to fail.
  11125. @item @code{locale} (default: @code{"en_US.utf8"})
  11126. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  11127. Library Reference Manual}). @xref{Locales}, for more information.
  11128. @item @code{locale-definitions} (default: @code{%default-locale-definitions})
  11129. The list of locale definitions to be compiled and that may be used at
  11130. run time. @xref{Locales}.
  11131. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  11132. The list of GNU@tie{}libc packages whose locale data and tools are used
  11133. to build the locale definitions. @xref{Locales}, for compatibility
  11134. considerations that justify this option.
  11135. @item @code{name-service-switch} (default: @code{%default-nss})
  11136. Configuration of the libc name service switch (NSS)---a
  11137. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  11138. details.
  11139. @item @code{services} (default: @code{%base-services})
  11140. A list of service objects denoting system services. @xref{Services}.
  11141. @cindex essential services
  11142. @item @code{essential-services} (default: ...)
  11143. The list of ``essential services''---i.e., things like instances of
  11144. @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
  11145. Reference}), which are derived from the operating system definition itself.
  11146. As a user you should @emph{never} need to touch this field.
  11147. @item @code{pam-services} (default: @code{(base-pam-services)})
  11148. @cindex PAM
  11149. @cindex pluggable authentication modules
  11150. Linux @dfn{pluggable authentication module} (PAM) services.
  11151. @c FIXME: Add xref to PAM services section.
  11152. @item @code{setuid-programs} (default: @code{%setuid-programs})
  11153. List of string-valued G-expressions denoting setuid programs.
  11154. @xref{Setuid Programs}.
  11155. @item @code{sudoers-file} (default: @code{%sudoers-specification})
  11156. @cindex sudoers file
  11157. The contents of the @file{/etc/sudoers} file as a file-like object
  11158. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  11159. This file specifies which users can use the @command{sudo} command, what
  11160. they are allowed to do, and what privileges they may gain. The default
  11161. is that only @code{root} and members of the @code{wheel} group may use
  11162. @code{sudo}.
  11163. @end table
  11164. @deffn {Scheme Syntax} this-operating-system
  11165. When used in the @emph{lexical scope} of an operating system field definition,
  11166. this identifier resolves to the operating system being defined.
  11167. The example below shows how to refer to the operating system being defined in
  11168. the definition of the @code{label} field:
  11169. @lisp
  11170. (use-modules (gnu) (guix))
  11171. (operating-system
  11172. ;; ...
  11173. (label (package-full-name
  11174. (operating-system-kernel this-operating-system))))
  11175. @end lisp
  11176. It is an error to refer to @code{this-operating-system} outside an operating
  11177. system definition.
  11178. @end deffn
  11179. @end deftp
  11180. @node File Systems
  11181. @section File Systems
  11182. The list of file systems to be mounted is specified in the
  11183. @code{file-systems} field of the operating system declaration
  11184. (@pxref{Using the Configuration System}). Each file system is declared
  11185. using the @code{file-system} form, like this:
  11186. @lisp
  11187. (file-system
  11188. (mount-point "/home")
  11189. (device "/dev/sda3")
  11190. (type "ext4"))
  11191. @end lisp
  11192. As usual, some of the fields are mandatory---those shown in the example
  11193. above---while others can be omitted. These are described below.
  11194. @deftp {Data Type} file-system
  11195. Objects of this type represent file systems to be mounted. They
  11196. contain the following members:
  11197. @table @asis
  11198. @item @code{type}
  11199. This is a string specifying the type of the file system---e.g.,
  11200. @code{"ext4"}.
  11201. @item @code{mount-point}
  11202. This designates the place where the file system is to be mounted.
  11203. @item @code{device}
  11204. This names the ``source'' of the file system. It can be one of three
  11205. things: a file system label, a file system UUID, or the name of a
  11206. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  11207. systems without having to hard-code their actual device
  11208. name@footnote{Note that, while it is tempting to use
  11209. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  11210. result, this is not recommended: These special device nodes are created
  11211. by the udev daemon and may be unavailable at the time the device is
  11212. mounted.}.
  11213. @findex file-system-label
  11214. File system labels are created using the @code{file-system-label}
  11215. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  11216. plain strings. Here's an example of a file system referred to by its
  11217. label, as shown by the @command{e2label} command:
  11218. @lisp
  11219. (file-system
  11220. (mount-point "/home")
  11221. (type "ext4")
  11222. (device (file-system-label "my-home")))
  11223. @end lisp
  11224. @findex uuid
  11225. UUIDs are converted from their string representation (as shown by the
  11226. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  11227. @code{uuid} form expects 16-byte UUIDs as defined in
  11228. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  11229. form of UUID used by the ext2 family of file systems and others, but it
  11230. is different from ``UUIDs'' found in FAT file systems, for instance.},
  11231. like this:
  11232. @lisp
  11233. (file-system
  11234. (mount-point "/home")
  11235. (type "ext4")
  11236. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  11237. @end lisp
  11238. When the source of a file system is a mapped device (@pxref{Mapped
  11239. Devices}), its @code{device} field @emph{must} refer to the mapped
  11240. device name---e.g., @file{"/dev/mapper/root-partition"}.
  11241. This is required so that
  11242. the system knows that mounting the file system depends on having the
  11243. corresponding device mapping established.
  11244. @item @code{flags} (default: @code{'()})
  11245. This is a list of symbols denoting mount flags. Recognized flags
  11246. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  11247. access to special files), @code{no-suid} (ignore setuid and setgid
  11248. bits), @code{no-atime} (do not update file access times),
  11249. @code{strict-atime} (update file access time), @code{lazy-time} (only
  11250. update time on the in-memory version of the file inode), and
  11251. @code{no-exec} (disallow program execution).
  11252. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
  11253. Manual}, for more information on these flags.
  11254. @item @code{options} (default: @code{#f})
  11255. This is either @code{#f}, or a string denoting mount options passed to
  11256. the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
  11257. Library Reference Manual}, for details and run @command{man 8 mount} for
  11258. options for various file systems. Note that the
  11259. @code{file-system-options->alist} and @code{alist->file-system-options}
  11260. procedures from @code{(gnu system file-systems)} can be used to convert
  11261. file system options given as an association list to the string
  11262. representation, and vice-versa.
  11263. @item @code{mount?} (default: @code{#t})
  11264. This value indicates whether to automatically mount the file system when
  11265. the system is brought up. When set to @code{#f}, the file system gets
  11266. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  11267. is not automatically mounted.
  11268. @item @code{needed-for-boot?} (default: @code{#f})
  11269. This Boolean value indicates whether the file system is needed when
  11270. booting. If that is true, then the file system is mounted when the
  11271. initial RAM disk (initrd) is loaded. This is always the case, for
  11272. instance, for the root file system.
  11273. @item @code{check?} (default: @code{#t})
  11274. This Boolean indicates whether the file system needs to be checked for
  11275. errors before being mounted.
  11276. @item @code{create-mount-point?} (default: @code{#f})
  11277. When true, the mount point is created if it does not exist yet.
  11278. @item @code{mount-may-fail?} (default: @code{#f})
  11279. When true, this indicates that mounting this file system can fail but
  11280. that should not be considered an error. This is useful in unusual
  11281. cases; an example of this is @code{efivarfs}, a file system that can
  11282. only be mounted on EFI/UEFI systems.
  11283. @item @code{dependencies} (default: @code{'()})
  11284. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  11285. representing file systems that must be mounted or mapped devices that
  11286. must be opened before (and unmounted or closed after) this one.
  11287. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  11288. a dependency of @file{/sys/fs/cgroup/cpu} and
  11289. @file{/sys/fs/cgroup/memory}.
  11290. Another example is a file system that depends on a mapped device, for
  11291. example for an encrypted partition (@pxref{Mapped Devices}).
  11292. @end table
  11293. @end deftp
  11294. @deffn {Scheme Procedure} file-system-label @var{str}
  11295. This procedure returns an opaque file system label from @var{str}, a
  11296. string:
  11297. @lisp
  11298. (file-system-label "home")
  11299. @result{} #<file-system-label "home">
  11300. @end lisp
  11301. File system labels are used to refer to file systems by label rather
  11302. than by device name. See above for examples.
  11303. @end deffn
  11304. The @code{(gnu system file-systems)} exports the following useful
  11305. variables.
  11306. @defvr {Scheme Variable} %base-file-systems
  11307. These are essential file systems that are required on normal systems,
  11308. such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
  11309. below). Operating system declarations should always contain at least
  11310. these.
  11311. @end defvr
  11312. @defvr {Scheme Variable} %pseudo-terminal-file-system
  11313. This is the file system to be mounted as @file{/dev/pts}. It supports
  11314. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  11315. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  11316. Manual}). Pseudo-terminals are used by terminal emulators such as
  11317. @command{xterm}.
  11318. @end defvr
  11319. @defvr {Scheme Variable} %shared-memory-file-system
  11320. This file system is mounted as @file{/dev/shm} and is used to support
  11321. memory sharing across processes (@pxref{Memory-mapped I/O,
  11322. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  11323. @end defvr
  11324. @defvr {Scheme Variable} %immutable-store
  11325. This file system performs a read-only ``bind mount'' of
  11326. @file{/gnu/store}, making it read-only for all the users including
  11327. @code{root}. This prevents against accidental modification by software
  11328. running as @code{root} or by system administrators.
  11329. The daemon itself is still able to write to the store: it remounts it
  11330. read-write in its own ``name space.''
  11331. @end defvr
  11332. @defvr {Scheme Variable} %binary-format-file-system
  11333. The @code{binfmt_misc} file system, which allows handling of arbitrary
  11334. executable file types to be delegated to user space. This requires the
  11335. @code{binfmt.ko} kernel module to be loaded.
  11336. @end defvr
  11337. @defvr {Scheme Variable} %fuse-control-file-system
  11338. The @code{fusectl} file system, which allows unprivileged users to mount
  11339. and unmount user-space FUSE file systems. This requires the
  11340. @code{fuse.ko} kernel module to be loaded.
  11341. @end defvr
  11342. The @code{(gnu system uuid)} module provides tools to deal with file
  11343. system ``unique identifiers'' (UUIDs).
  11344. @deffn {Scheme Procedure} uuid @var{str} [@var{type}]
  11345. Return an opaque UUID (unique identifier) object of the given @var{type}
  11346. (a symbol) by parsing @var{str} (a string):
  11347. @lisp
  11348. (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
  11349. @result{} #<<uuid> type: dce bv: @dots{}>
  11350. (uuid "1234-ABCD" 'fat)
  11351. @result{} #<<uuid> type: fat bv: @dots{}>
  11352. @end lisp
  11353. @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
  11354. @code{ntfs}, or one of the commonly found synonyms for these.
  11355. UUIDs are another way to unambiguously refer to file systems in
  11356. operating system configuration. See the examples above.
  11357. @end deffn
  11358. @node Btrfs file system
  11359. @subsection Btrfs file system
  11360. The Btrfs has special features, such as subvolumes, that merit being
  11361. explained in more details. The following section attempts to cover
  11362. basic as well as complex uses of a Btrfs file system with the Guix
  11363. System.
  11364. In its simplest usage, a Btrfs file system can be described, for
  11365. example, by:
  11366. @lisp
  11367. (file-system
  11368. (mount-point "/home")
  11369. (type "btrfs")
  11370. (device (file-system-label "my-home")))
  11371. @end lisp
  11372. The example below is more complex, as it makes use of a Btrfs
  11373. subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
  11374. @code{my-btrfs-pool}, and is located on an encrypted device (hence the
  11375. dependency on @code{mapped-devices}):
  11376. @lisp
  11377. (file-system
  11378. (device (file-system-label "my-btrfs-pool"))
  11379. (mount-point "/")
  11380. (type "btrfs")
  11381. (options "subvol=rootfs")
  11382. (dependencies mapped-devices))
  11383. @end lisp
  11384. Some bootloaders, for example GRUB, only mount a Btrfs partition at its
  11385. top level during the early boot, and rely on their configuration to
  11386. refer to the correct subvolume path within that top level. The
  11387. bootloaders operating in this way typically produce their configuration
  11388. on a running system where the Btrfs partitions are already mounted and
  11389. where the subvolume information is readily available. As an example,
  11390. @command{grub-mkconfig}, the configuration generator command shipped
  11391. with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
  11392. path of a subvolume.
  11393. The Guix System produces a bootloader configuration using the operating
  11394. system configuration as its sole input; it is therefore necessary to
  11395. extract the subvolume name on which @file{/gnu/store} lives (if any)
  11396. from that operating system configuration. To better illustrate,
  11397. consider a subvolume named 'rootfs' which contains the root file system
  11398. data. In such situation, the GRUB bootloader would only see the top
  11399. level of the root Btrfs partition, e.g.:
  11400. @example
  11401. / (top level)
  11402. ├── rootfs (subvolume directory)
  11403. ├── gnu (normal directory)
  11404. ├── store (normal directory)
  11405. [...]
  11406. @end example
  11407. Thus, the subvolume name must be prepended to the @file{/gnu/store} path
  11408. of the kernel, initrd binaries and any other files referred to in the
  11409. GRUB configuration that must be found during the early boot.
  11410. The next example shows a nested hierarchy of subvolumes and
  11411. directories:
  11412. @example
  11413. / (top level)
  11414. ├── rootfs (subvolume)
  11415. ├── gnu (normal directory)
  11416. ├── store (subvolume)
  11417. [...]
  11418. @end example
  11419. This scenario would work without mounting the 'store' subvolume.
  11420. Mounting 'rootfs' is sufficient, since the subvolume name matches its
  11421. intended mount point in the file system hierarchy. Alternatively, the
  11422. 'store' subvolume could be referred to by setting the @code{subvol}
  11423. option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
  11424. Finally, a more contrived example of nested subvolumes:
  11425. @example
  11426. / (top level)
  11427. ├── root-snapshots (subvolume)
  11428. ├── root-current (subvolume)
  11429. ├── guix-store (subvolume)
  11430. [...]
  11431. @end example
  11432. Here, the 'guix-store' subvolume doesn't match its intended mount point,
  11433. so it is necessary to mount it. The subvolume must be fully specified,
  11434. by passing its file name to the @code{subvol} option. To illustrate,
  11435. the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
  11436. a file system declaration such as:
  11437. @lisp
  11438. (file-system
  11439. (device (file-system-label "btrfs-pool-1"))
  11440. (mount-point "/gnu/store")
  11441. (type "btrfs")
  11442. (options "subvol=root-snapshots/root-current/guix-store,\
  11443. compress-force=zstd,space_cache=v2"))
  11444. @end lisp
  11445. @node Mapped Devices
  11446. @section Mapped Devices
  11447. @cindex device mapping
  11448. @cindex mapped devices
  11449. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  11450. such as a hard disk partition, can be @dfn{mapped} into another device,
  11451. usually in @code{/dev/mapper/},
  11452. with additional processing over the data that flows through
  11453. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  11454. concept of a ``mapped device'' and that of a file system: both boil down
  11455. to @emph{translating} input/output operations made on a file to
  11456. operations on its backing store. Thus, the Hurd implements mapped
  11457. devices, like file systems, using the generic @dfn{translator} mechanism
  11458. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  11459. typical example is encryption device mapping: all writes to the mapped
  11460. device are encrypted, and all reads are deciphered, transparently.
  11461. Guix extends this notion by considering any device or set of devices that
  11462. are @dfn{transformed} in some way to create a new device; for instance,
  11463. RAID devices are obtained by @dfn{assembling} several other devices, such
  11464. as hard disks or partitions, into a new one that behaves as one partition.
  11465. Mapped devices are declared using the @code{mapped-device} form,
  11466. defined as follows; for examples, see below.
  11467. @deftp {Data Type} mapped-device
  11468. Objects of this type represent device mappings that will be made when
  11469. the system boots up.
  11470. @table @code
  11471. @item source
  11472. This is either a string specifying the name of the block device to be mapped,
  11473. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  11474. need to be assembled for creating a new one. In case of LVM this is a
  11475. string specifying name of the volume group to be mapped.
  11476. @item target
  11477. This string specifies the name of the resulting mapped device. For
  11478. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  11479. specifying @code{"my-partition"} leads to the creation of
  11480. the @code{"/dev/mapper/my-partition"} device.
  11481. For RAID devices of type @code{raid-device-mapping}, the full device name
  11482. such as @code{"/dev/md0"} needs to be given.
  11483. LVM logical volumes of type @code{lvm-device-mapping} need to
  11484. be specified as @code{"VGNAME-LVNAME"}.
  11485. @item targets
  11486. This list of strings specifies names of the resulting mapped devices in case
  11487. there are several. The format is identical to @var{target}.
  11488. @item type
  11489. This must be a @code{mapped-device-kind} object, which specifies how
  11490. @var{source} is mapped to @var{target}.
  11491. @end table
  11492. @end deftp
  11493. @defvr {Scheme Variable} luks-device-mapping
  11494. This defines LUKS block device encryption using the @command{cryptsetup}
  11495. command from the package with the same name. It relies on the
  11496. @code{dm-crypt} Linux kernel module.
  11497. @end defvr
  11498. @defvr {Scheme Variable} raid-device-mapping
  11499. This defines a RAID device, which is assembled using the @code{mdadm}
  11500. command from the package with the same name. It requires a Linux kernel
  11501. module for the appropriate RAID level to be loaded, such as @code{raid456}
  11502. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  11503. @end defvr
  11504. @cindex LVM, logical volume manager
  11505. @defvr {Scheme Variable} lvm-device-mapping
  11506. This defines one or more logical volumes for the Linux
  11507. @uref{https://www.sourceware.org/lvm2/, Logical Volume Manager (LVM)}.
  11508. The volume group is activated by the @command{vgchange} command from the
  11509. @code{lvm2} package.
  11510. @end defvr
  11511. @cindex disk encryption
  11512. @cindex LUKS
  11513. The following example specifies a mapping from @file{/dev/sda3} to
  11514. @file{/dev/mapper/home} using LUKS---the
  11515. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  11516. standard mechanism for disk encryption.
  11517. The @file{/dev/mapper/home}
  11518. device can then be used as the @code{device} of a @code{file-system}
  11519. declaration (@pxref{File Systems}).
  11520. @lisp
  11521. (mapped-device
  11522. (source "/dev/sda3")
  11523. (target "home")
  11524. (type luks-device-mapping))
  11525. @end lisp
  11526. Alternatively, to become independent of device numbering, one may obtain
  11527. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  11528. command like:
  11529. @example
  11530. cryptsetup luksUUID /dev/sda3
  11531. @end example
  11532. and use it as follows:
  11533. @lisp
  11534. (mapped-device
  11535. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  11536. (target "home")
  11537. (type luks-device-mapping))
  11538. @end lisp
  11539. @cindex swap encryption
  11540. It is also desirable to encrypt swap space, since swap space may contain
  11541. sensitive data. One way to accomplish that is to use a swap file in a
  11542. file system on a device mapped via LUKS encryption. In this way, the
  11543. swap file is encrypted because the entire device is encrypted.
  11544. @xref{Preparing for Installation,,Disk Partitioning}, for an example.
  11545. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  11546. may be declared as follows:
  11547. @lisp
  11548. (mapped-device
  11549. (source (list "/dev/sda1" "/dev/sdb1"))
  11550. (target "/dev/md0")
  11551. (type raid-device-mapping))
  11552. @end lisp
  11553. The @file{/dev/md0} device can then be used as the @code{device} of a
  11554. @code{file-system} declaration (@pxref{File Systems}).
  11555. Note that the RAID level need not be given; it is chosen during the
  11556. initial creation and formatting of the RAID device and is determined
  11557. automatically later.
  11558. LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
  11559. be declared as follows:
  11560. @lisp
  11561. (mapped-device
  11562. (source "vg0")
  11563. (targets (list "vg0-alpha" "vg0-beta"))
  11564. (type lvm-device-mapping))
  11565. @end lisp
  11566. Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
  11567. then be used as the @code{device} of a @code{file-system} declaration
  11568. (@pxref{File Systems}).
  11569. @node User Accounts
  11570. @section User Accounts
  11571. @cindex users
  11572. @cindex accounts
  11573. @cindex user accounts
  11574. User accounts and groups are entirely managed through the
  11575. @code{operating-system} declaration. They are specified with the
  11576. @code{user-account} and @code{user-group} forms:
  11577. @lisp
  11578. (user-account
  11579. (name "alice")
  11580. (group "users")
  11581. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  11582. "audio" ;sound card
  11583. "video" ;video devices such as webcams
  11584. "cdrom")) ;the good ol' CD-ROM
  11585. (comment "Bob's sister"))
  11586. @end lisp
  11587. Here's a user account that uses a different shell and a custom home
  11588. directory (the default would be @file{"/home/bob"}):
  11589. @lisp
  11590. (user-account
  11591. (name "bob")
  11592. (group "users")
  11593. (comment "Alice's bro")
  11594. (shell (file-append zsh "/bin/zsh"))
  11595. (home-directory "/home/robert"))
  11596. @end lisp
  11597. When booting or upon completion of @command{guix system reconfigure},
  11598. the system ensures that only the user accounts and groups specified in
  11599. the @code{operating-system} declaration exist, and with the specified
  11600. properties. Thus, account or group creations or modifications made by
  11601. directly invoking commands such as @command{useradd} are lost upon
  11602. reconfiguration or reboot. This ensures that the system remains exactly
  11603. as declared.
  11604. @deftp {Data Type} user-account
  11605. Objects of this type represent user accounts. The following members may
  11606. be specified:
  11607. @table @asis
  11608. @item @code{name}
  11609. The name of the user account.
  11610. @item @code{group}
  11611. @cindex groups
  11612. This is the name (a string) or identifier (a number) of the user group
  11613. this account belongs to.
  11614. @item @code{supplementary-groups} (default: @code{'()})
  11615. Optionally, this can be defined as a list of group names that this
  11616. account belongs to.
  11617. @item @code{uid} (default: @code{#f})
  11618. This is the user ID for this account (a number), or @code{#f}. In the
  11619. latter case, a number is automatically chosen by the system when the
  11620. account is created.
  11621. @item @code{comment} (default: @code{""})
  11622. A comment about the account, such as the account owner's full name.
  11623. @item @code{home-directory}
  11624. This is the name of the home directory for the account.
  11625. @item @code{create-home-directory?} (default: @code{#t})
  11626. Indicates whether the home directory of this account should be created
  11627. if it does not exist yet.
  11628. @item @code{shell} (default: Bash)
  11629. This is a G-expression denoting the file name of a program to be used as
  11630. the shell (@pxref{G-Expressions}). For example, you would refer to the
  11631. Bash executable like this:
  11632. @lisp
  11633. (file-append bash "/bin/bash")
  11634. @end lisp
  11635. @noindent
  11636. ... and to the Zsh executable like that:
  11637. @lisp
  11638. (file-append zsh "/bin/zsh")
  11639. @end lisp
  11640. @item @code{system?} (default: @code{#f})
  11641. This Boolean value indicates whether the account is a ``system''
  11642. account. System accounts are sometimes treated specially; for instance,
  11643. graphical login managers do not list them.
  11644. @anchor{user-account-password}
  11645. @cindex password, for user accounts
  11646. @item @code{password} (default: @code{#f})
  11647. You would normally leave this field to @code{#f}, initialize user
  11648. passwords as @code{root} with the @command{passwd} command, and then let
  11649. users change it with @command{passwd}. Passwords set with
  11650. @command{passwd} are of course preserved across reboot and
  11651. reconfiguration.
  11652. If you @emph{do} want to set an initial password for an account, then
  11653. this field must contain the encrypted password, as a string. You can use the
  11654. @code{crypt} procedure for this purpose:
  11655. @lisp
  11656. (user-account
  11657. (name "charlie")
  11658. (group "users")
  11659. ;; Specify a SHA-512-hashed initial password.
  11660. (password (crypt "InitialPassword!" "$6$abc")))
  11661. @end lisp
  11662. @quotation Note
  11663. The hash of this initial password will be available in a file in
  11664. @file{/gnu/store}, readable by all the users, so this method must be used with
  11665. care.
  11666. @end quotation
  11667. @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
  11668. more information on password encryption, and @ref{Encryption,,, guile, GNU
  11669. Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
  11670. @end table
  11671. @end deftp
  11672. @cindex groups
  11673. User group declarations are even simpler:
  11674. @lisp
  11675. (user-group (name "students"))
  11676. @end lisp
  11677. @deftp {Data Type} user-group
  11678. This type is for, well, user groups. There are just a few fields:
  11679. @table @asis
  11680. @item @code{name}
  11681. The name of the group.
  11682. @item @code{id} (default: @code{#f})
  11683. The group identifier (a number). If @code{#f}, a new number is
  11684. automatically allocated when the group is created.
  11685. @item @code{system?} (default: @code{#f})
  11686. This Boolean value indicates whether the group is a ``system'' group.
  11687. System groups have low numerical IDs.
  11688. @item @code{password} (default: @code{#f})
  11689. What, user groups can have a password? Well, apparently yes. Unless
  11690. @code{#f}, this field specifies the password of the group.
  11691. @end table
  11692. @end deftp
  11693. For convenience, a variable lists all the basic user groups one may
  11694. expect:
  11695. @defvr {Scheme Variable} %base-groups
  11696. This is the list of basic user groups that users and/or packages expect
  11697. to be present on the system. This includes groups such as ``root'',
  11698. ``wheel'', and ``users'', as well as groups used to control access to
  11699. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  11700. @end defvr
  11701. @defvr {Scheme Variable} %base-user-accounts
  11702. This is the list of basic system accounts that programs may expect to
  11703. find on a GNU/Linux system, such as the ``nobody'' account.
  11704. Note that the ``root'' account is not included here. It is a
  11705. special-case and is automatically added whether or not it is specified.
  11706. @end defvr
  11707. @node Keyboard Layout
  11708. @section Keyboard Layout
  11709. @cindex keyboard layout
  11710. @cindex keymap
  11711. To specify what each key of your keyboard does, you need to tell the operating
  11712. system what @dfn{keyboard layout} you want to use. The default, when nothing
  11713. is specified, is the US English QWERTY layout for 105-key PC keyboards.
  11714. However, German speakers will usually prefer the German QWERTZ layout, French
  11715. speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
  11716. or bépo, and they might even want to further customize the effect of some of
  11717. the keys. This section explains how to get that done.
  11718. @cindex keyboard layout, definition
  11719. There are three components that will want to know about your keyboard layout:
  11720. @itemize
  11721. @item
  11722. The @emph{bootloader} may want to know what keyboard layout you want to use
  11723. (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
  11724. you want, for instance, to make sure that you can type the passphrase of your
  11725. encrypted root partition using the right layout.
  11726. @item
  11727. The @emph{operating system kernel}, Linux, will need that so that the console
  11728. is properly configured (@pxref{operating-system Reference,
  11729. @code{keyboard-layout}}).
  11730. @item
  11731. The @emph{graphical display server}, usually Xorg, also has its own idea of
  11732. the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
  11733. @end itemize
  11734. Guix allows you to configure all three separately but, fortunately, it allows
  11735. you to share the same keyboard layout for all three components.
  11736. @cindex XKB, keyboard layouts
  11737. Keyboard layouts are represented by records created by the
  11738. @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
  11739. the X Keyboard extension (XKB), each layout has four attributes: a name (often
  11740. a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
  11741. optional variant name, an optional keyboard model name, and a possibly empty
  11742. list of additional options. In most cases the layout name is all you care
  11743. about.
  11744. @deffn {Scheme Procedure} keyboard-layout @var{name} [@var{variant}] @
  11745. [#:model] [#:options '()]
  11746. Return a new keyboard layout with the given @var{name} and @var{variant}.
  11747. @var{name} must be a string such as @code{"fr"}; @var{variant} must be a
  11748. string such as @code{"bepo"} or @code{"nodeadkeys"}. See the
  11749. @code{xkeyboard-config} package for valid options.
  11750. @end deffn
  11751. Here are a few examples:
  11752. @lisp
  11753. ;; The German QWERTZ layout. Here we assume a standard
  11754. ;; "pc105" keyboard model.
  11755. (keyboard-layout "de")
  11756. ;; The bépo variant of the French layout.
  11757. (keyboard-layout "fr" "bepo")
  11758. ;; The Catalan layout.
  11759. (keyboard-layout "es" "cat")
  11760. ;; Arabic layout with "Alt-Shift" to switch to US layout.
  11761. (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
  11762. ;; The Latin American Spanish layout. In addition, the
  11763. ;; "Caps Lock" key is used as an additional "Ctrl" key,
  11764. ;; and the "Menu" key is used as a "Compose" key to enter
  11765. ;; accented letters.
  11766. (keyboard-layout "latam"
  11767. #:options '("ctrl:nocaps" "compose:menu"))
  11768. ;; The Russian layout for a ThinkPad keyboard.
  11769. (keyboard-layout "ru" #:model "thinkpad")
  11770. ;; The "US international" layout, which is the US layout plus
  11771. ;; dead keys to enter accented characters. This is for an
  11772. ;; Apple MacBook keyboard.
  11773. (keyboard-layout "us" "intl" #:model "macbook78")
  11774. @end lisp
  11775. See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
  11776. for a complete list of supported layouts, variants, and models.
  11777. @cindex keyboard layout, configuration
  11778. Let's say you want your system to use the Turkish keyboard layout throughout
  11779. your system---bootloader, console, and Xorg. Here's what your system
  11780. configuration would look like:
  11781. @findex set-xorg-configuration
  11782. @lisp
  11783. ;; Using the Turkish layout for the bootloader, the console,
  11784. ;; and for Xorg.
  11785. (operating-system
  11786. ;; ...
  11787. (keyboard-layout (keyboard-layout "tr")) ;for the console
  11788. (bootloader (bootloader-configuration
  11789. (bootloader grub-efi-bootloader)
  11790. (target "/boot/efi")
  11791. (keyboard-layout keyboard-layout))) ;for GRUB
  11792. (services (cons (set-xorg-configuration
  11793. (xorg-configuration ;for Xorg
  11794. (keyboard-layout keyboard-layout)))
  11795. %desktop-services)))
  11796. @end lisp
  11797. In the example above, for GRUB and for Xorg, we just refer to the
  11798. @code{keyboard-layout} field defined above, but we could just as well refer to
  11799. a different layout. The @code{set-xorg-configuration} procedure communicates
  11800. the desired Xorg configuration to the graphical log-in manager, by default
  11801. GDM.
  11802. We've discussed how to specify the @emph{default} keyboard layout of your
  11803. system when it starts, but you can also adjust it at run time:
  11804. @itemize
  11805. @item
  11806. If you're using GNOME, its settings panel has a ``Region & Language'' entry
  11807. where you can select one or more keyboard layouts.
  11808. @item
  11809. Under Xorg, the @command{setxkbmap} command (from the same-named package)
  11810. allows you to change the current layout. For example, this is how you would
  11811. change the layout to US Dvorak:
  11812. @example
  11813. setxkbmap us dvorak
  11814. @end example
  11815. @item
  11816. The @code{loadkeys} command changes the keyboard layout in effect in the Linux
  11817. console. However, note that @code{loadkeys} does @emph{not} use the XKB
  11818. keyboard layout categorization described above. The command below loads the
  11819. French bépo layout:
  11820. @example
  11821. loadkeys fr-bepo
  11822. @end example
  11823. @end itemize
  11824. @node Locales
  11825. @section Locales
  11826. @cindex locale
  11827. A @dfn{locale} defines cultural conventions for a particular language
  11828. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  11829. Reference Manual}). Each locale has a name that typically has the form
  11830. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  11831. @code{fr_LU.utf8} designates the locale for the French language, with
  11832. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  11833. @cindex locale definition
  11834. Usually, you will want to specify the default locale for the machine
  11835. using the @code{locale} field of the @code{operating-system} declaration
  11836. (@pxref{operating-system Reference, @code{locale}}).
  11837. The selected locale is automatically added to the @dfn{locale
  11838. definitions} known to the system if needed, with its codeset inferred
  11839. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  11840. @code{UTF-8} codeset. Additional locale definitions can be specified in
  11841. the @code{locale-definitions} slot of @code{operating-system}---this is
  11842. useful, for instance, if the codeset could not be inferred from the
  11843. locale name. The default set of locale definitions includes some widely
  11844. used locales, but not all the available locales, in order to save space.
  11845. For instance, to add the North Frisian locale for Germany, the value of
  11846. that field may be:
  11847. @lisp
  11848. (cons (locale-definition
  11849. (name "fy_DE.utf8") (source "fy_DE"))
  11850. %default-locale-definitions)
  11851. @end lisp
  11852. Likewise, to save space, one might want @code{locale-definitions} to
  11853. list only the locales that are actually used, as in:
  11854. @lisp
  11855. (list (locale-definition
  11856. (name "ja_JP.eucjp") (source "ja_JP")
  11857. (charset "EUC-JP")))
  11858. @end lisp
  11859. @vindex LOCPATH
  11860. The compiled locale definitions are available at
  11861. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  11862. version, which is the default location where the GNU@tie{}libc provided
  11863. by Guix looks for locale data. This can be overridden using the
  11864. @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
  11865. @env{LOCPATH} and locale packages}).
  11866. The @code{locale-definition} form is provided by the @code{(gnu system
  11867. locale)} module. Details are given below.
  11868. @deftp {Data Type} locale-definition
  11869. This is the data type of a locale definition.
  11870. @table @asis
  11871. @item @code{name}
  11872. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  11873. Reference Manual}, for more information on locale names.
  11874. @item @code{source}
  11875. The name of the source for that locale. This is typically the
  11876. @code{@var{language}_@var{territory}} part of the locale name.
  11877. @item @code{charset} (default: @code{"UTF-8"})
  11878. The ``character set'' or ``code set'' for that locale,
  11879. @uref{https://www.iana.org/assignments/character-sets, as defined by
  11880. IANA}.
  11881. @end table
  11882. @end deftp
  11883. @defvr {Scheme Variable} %default-locale-definitions
  11884. A list of commonly used UTF-8 locales, used as the default
  11885. value of the @code{locale-definitions} field of @code{operating-system}
  11886. declarations.
  11887. @cindex locale name
  11888. @cindex normalized codeset in locale names
  11889. These locale definitions use the @dfn{normalized codeset} for the part
  11890. that follows the dot in the name (@pxref{Using gettextized software,
  11891. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  11892. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  11893. @code{uk_UA.UTF-8}.
  11894. @end defvr
  11895. @subsection Locale Data Compatibility Considerations
  11896. @cindex incompatibility, of locale data
  11897. @code{operating-system} declarations provide a @code{locale-libcs} field
  11898. to specify the GNU@tie{}libc packages that are used to compile locale
  11899. declarations (@pxref{operating-system Reference}). ``Why would I
  11900. care?'', you may ask. Well, it turns out that the binary format of
  11901. locale data is occasionally incompatible from one libc version to
  11902. another.
  11903. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  11904. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  11905. For instance, a program linked against libc version 2.21 is unable to
  11906. read locale data produced with libc 2.22; worse, that program
  11907. @emph{aborts} instead of simply ignoring the incompatible locale
  11908. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  11909. the incompatible locale data, which is already an improvement.}.
  11910. Similarly, a program linked against libc 2.22 can read most, but not
  11911. all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
  11912. data is incompatible); thus calls to @code{setlocale} may fail, but
  11913. programs will not abort.
  11914. The ``problem'' with Guix is that users have a lot of freedom: They can
  11915. choose whether and when to upgrade software in their profiles, and might
  11916. be using a libc version different from the one the system administrator
  11917. used to build the system-wide locale data.
  11918. Fortunately, unprivileged users can also install their own locale data
  11919. and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  11920. @env{GUIX_LOCPATH} and locale packages}).
  11921. Still, it is best if the system-wide locale data at
  11922. @file{/run/current-system/locale} is built for all the libc versions
  11923. actually in use on the system, so that all the programs can access
  11924. it---this is especially crucial on a multi-user system. To do that, the
  11925. administrator can specify several libc packages in the
  11926. @code{locale-libcs} field of @code{operating-system}:
  11927. @lisp
  11928. (use-package-modules base)
  11929. (operating-system
  11930. ;; @dots{}
  11931. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  11932. @end lisp
  11933. This example would lead to a system containing locale definitions for
  11934. both libc 2.21 and the current version of libc in
  11935. @file{/run/current-system/locale}.
  11936. @node Services
  11937. @section Services
  11938. @cindex system services
  11939. An important part of preparing an @code{operating-system} declaration is
  11940. listing @dfn{system services} and their configuration (@pxref{Using the
  11941. Configuration System}). System services are typically daemons launched
  11942. when the system boots, or other actions needed at that time---e.g.,
  11943. configuring network access.
  11944. Guix has a broad definition of ``service'' (@pxref{Service
  11945. Composition}), but many services are managed by the GNU@tie{}Shepherd
  11946. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  11947. command allows you to list the available services, show their status,
  11948. start and stop them, or do other specific operations (@pxref{Jump
  11949. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  11950. @example
  11951. # herd status
  11952. @end example
  11953. The above command, run as @code{root}, lists the currently defined
  11954. services. The @command{herd doc} command shows a synopsis of the given
  11955. service and its associated actions:
  11956. @example
  11957. # herd doc nscd
  11958. Run libc's name service cache daemon (nscd).
  11959. # herd doc nscd action invalidate
  11960. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  11961. @end example
  11962. The @command{start}, @command{stop}, and @command{restart} sub-commands
  11963. have the effect you would expect. For instance, the commands below stop
  11964. the nscd service and restart the Xorg display server:
  11965. @example
  11966. # herd stop nscd
  11967. Service nscd has been stopped.
  11968. # herd restart xorg-server
  11969. Service xorg-server has been stopped.
  11970. Service xorg-server has been started.
  11971. @end example
  11972. The following sections document the available services, starting with
  11973. the core services, that may be used in an @code{operating-system}
  11974. declaration.
  11975. @menu
  11976. * Base Services:: Essential system services.
  11977. * Scheduled Job Execution:: The mcron service.
  11978. * Log Rotation:: The rottlog service.
  11979. * Networking Services:: Network setup, SSH daemon, etc.
  11980. * Unattended Upgrades:: Automated system upgrades.
  11981. * X Window:: Graphical display.
  11982. * Printing Services:: Local and remote printer support.
  11983. * Desktop Services:: D-Bus and desktop services.
  11984. * Sound Services:: ALSA and Pulseaudio services.
  11985. * Database Services:: SQL databases, key-value stores, etc.
  11986. * Mail Services:: IMAP, POP3, SMTP, and all that.
  11987. * Messaging Services:: Messaging services.
  11988. * Telephony Services:: Telephony services.
  11989. * File-Sharing Services:: File-sharing services.
  11990. * Monitoring Services:: Monitoring services.
  11991. * Kerberos Services:: Kerberos services.
  11992. * LDAP Services:: LDAP services.
  11993. * Web Services:: Web servers.
  11994. * Certificate Services:: TLS certificates via Let's Encrypt.
  11995. * DNS Services:: DNS daemons.
  11996. * VPN Services:: VPN daemons.
  11997. * Network File System:: NFS related services.
  11998. * Continuous Integration:: The Cuirass service.
  11999. * Power Management Services:: Extending battery life.
  12000. * Audio Services:: The MPD.
  12001. * Virtualization Services:: Virtualization services.
  12002. * Version Control Services:: Providing remote access to Git repositories.
  12003. * Game Services:: Game servers.
  12004. * PAM Mount Service:: Service to mount volumes when logging in.
  12005. * Guix Services:: Services relating specifically to Guix.
  12006. * Linux Services:: Services tied to the Linux kernel.
  12007. * Hurd Services:: Services specific for a Hurd System.
  12008. * Miscellaneous Services:: Other services.
  12009. @end menu
  12010. @node Base Services
  12011. @subsection Base Services
  12012. The @code{(gnu services base)} module provides definitions for the basic
  12013. services that one expects from the system. The services exported by
  12014. this module are listed below.
  12015. @defvr {Scheme Variable} %base-services
  12016. This variable contains a list of basic services (@pxref{Service Types
  12017. and Services}, for more information on service objects) one would
  12018. expect from the system: a login service (mingetty) on each tty, syslogd,
  12019. the libc name service cache daemon (nscd), the udev device manager, and
  12020. more.
  12021. This is the default value of the @code{services} field of
  12022. @code{operating-system} declarations. Usually, when customizing a
  12023. system, you will want to append services to @code{%base-services}, like
  12024. this:
  12025. @lisp
  12026. (append (list (service avahi-service-type)
  12027. (service openssh-service-type))
  12028. %base-services)
  12029. @end lisp
  12030. @end defvr
  12031. @defvr {Scheme Variable} special-files-service-type
  12032. This is the service that sets up ``special files'' such as
  12033. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  12034. The value associated with @code{special-files-service-type} services
  12035. must be a list of tuples where the first element is the ``special file''
  12036. and the second element is its target. By default it is:
  12037. @cindex @file{/bin/sh}
  12038. @cindex @file{sh}, in @file{/bin}
  12039. @lisp
  12040. `(("/bin/sh" ,(file-append bash "/bin/sh")))
  12041. @end lisp
  12042. @cindex @file{/usr/bin/env}
  12043. @cindex @file{env}, in @file{/usr/bin}
  12044. If you want to add, say, @code{/usr/bin/env} to your system, you can
  12045. change it to:
  12046. @lisp
  12047. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  12048. ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
  12049. @end lisp
  12050. Since this is part of @code{%base-services}, you can use
  12051. @code{modify-services} to customize the set of special files
  12052. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  12053. to add a special file is @i{via} the @code{extra-special-file} procedure
  12054. (see below).
  12055. @end defvr
  12056. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  12057. Use @var{target} as the ``special file'' @var{file}.
  12058. For example, adding the following lines to the @code{services} field of
  12059. your operating system declaration leads to a @file{/usr/bin/env}
  12060. symlink:
  12061. @lisp
  12062. (extra-special-file "/usr/bin/env"
  12063. (file-append coreutils "/bin/env"))
  12064. @end lisp
  12065. @end deffn
  12066. @deffn {Scheme Procedure} host-name-service @var{name}
  12067. Return a service that sets the host name to @var{name}.
  12068. @end deffn
  12069. @defvr {Scheme Variable} console-font-service-type
  12070. Install the given fonts on the specified ttys (fonts are per
  12071. virtual console on the kernel Linux). The value of this service is a list of
  12072. tty/font pairs. The font can be the name of a font provided by the @code{kbd}
  12073. package or any valid argument to @command{setfont}, as in this example:
  12074. @lisp
  12075. `(("tty1" . "LatGrkCyr-8x16")
  12076. ("tty2" . ,(file-append
  12077. font-tamzen
  12078. "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  12079. ("tty3" . ,(file-append
  12080. font-terminus
  12081. "/share/consolefonts/ter-132n"))) ; for HDPI
  12082. @end lisp
  12083. @end defvr
  12084. @deffn {Scheme Procedure} login-service @var{config}
  12085. Return a service to run login according to @var{config}, a
  12086. @code{<login-configuration>} object, which specifies the message of the day,
  12087. among other things.
  12088. @end deffn
  12089. @deftp {Data Type} login-configuration
  12090. This is the data type representing the configuration of login.
  12091. @table @asis
  12092. @item @code{motd}
  12093. @cindex message of the day
  12094. A file-like object containing the ``message of the day''.
  12095. @item @code{allow-empty-passwords?} (default: @code{#t})
  12096. Allow empty passwords by default so that first-time users can log in when
  12097. the 'root' account has just been created.
  12098. @end table
  12099. @end deftp
  12100. @deffn {Scheme Procedure} mingetty-service @var{config}
  12101. Return a service to run mingetty according to @var{config}, a
  12102. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  12103. other things.
  12104. @end deffn
  12105. @deftp {Data Type} mingetty-configuration
  12106. This is the data type representing the configuration of Mingetty, which
  12107. provides the default implementation of virtual console log-in.
  12108. @table @asis
  12109. @item @code{tty}
  12110. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  12111. @item @code{auto-login} (default: @code{#f})
  12112. When true, this field must be a string denoting the user name under
  12113. which the system automatically logs in. When it is @code{#f}, a
  12114. user name and password must be entered to log in.
  12115. @item @code{login-program} (default: @code{#f})
  12116. This must be either @code{#f}, in which case the default log-in program
  12117. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  12118. the name of the log-in program.
  12119. @item @code{login-pause?} (default: @code{#f})
  12120. When set to @code{#t} in conjunction with @var{auto-login}, the user
  12121. will have to press a key before the log-in shell is launched.
  12122. @item @code{clear-on-logout?} (default: @code{#t})
  12123. When set to @code{#t}, the screen will be cleared after logout.
  12124. @item @code{mingetty} (default: @var{mingetty})
  12125. The Mingetty package to use.
  12126. @end table
  12127. @end deftp
  12128. @deffn {Scheme Procedure} agetty-service @var{config}
  12129. Return a service to run agetty according to @var{config}, an
  12130. @code{<agetty-configuration>} object, which specifies the tty to run,
  12131. among other things.
  12132. @end deffn
  12133. @deftp {Data Type} agetty-configuration
  12134. This is the data type representing the configuration of agetty, which
  12135. implements virtual and serial console log-in. See the @code{agetty(8)}
  12136. man page for more information.
  12137. @table @asis
  12138. @item @code{tty}
  12139. The name of the console this agetty runs on, as a string---e.g.,
  12140. @code{"ttyS0"}. This argument is optional, it will default to
  12141. a reasonable default serial port used by the kernel Linux.
  12142. For this, if there is a value for an option @code{agetty.tty} in the kernel
  12143. command line, agetty will extract the device name of the serial port
  12144. from it and use that.
  12145. If not and if there is a value for an option @code{console} with a tty in
  12146. the Linux command line, agetty will extract the device name of the
  12147. serial port from it and use that.
  12148. In both cases, agetty will leave the other serial device settings
  12149. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  12150. correct values.
  12151. @item @code{baud-rate} (default: @code{#f})
  12152. A string containing a comma-separated list of one or more baud rates, in
  12153. descending order.
  12154. @item @code{term} (default: @code{#f})
  12155. A string containing the value used for the @env{TERM} environment
  12156. variable.
  12157. @item @code{eight-bits?} (default: @code{#f})
  12158. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  12159. disabled.
  12160. @item @code{auto-login} (default: @code{#f})
  12161. When passed a login name, as a string, the specified user will be logged
  12162. in automatically without prompting for their login name or password.
  12163. @item @code{no-reset?} (default: @code{#f})
  12164. When @code{#t}, don't reset terminal cflags (control modes).
  12165. @item @code{host} (default: @code{#f})
  12166. This accepts a string containing the ``login_host'', which will be written
  12167. into the @file{/var/run/utmpx} file.
  12168. @item @code{remote?} (default: @code{#f})
  12169. When set to @code{#t} in conjunction with @var{host}, this will add an
  12170. @code{-r} fakehost option to the command line of the login program
  12171. specified in @var{login-program}.
  12172. @item @code{flow-control?} (default: @code{#f})
  12173. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  12174. @item @code{no-issue?} (default: @code{#f})
  12175. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  12176. not be displayed before presenting the login prompt.
  12177. @item @code{init-string} (default: @code{#f})
  12178. This accepts a string that will be sent to the tty or modem before
  12179. sending anything else. It can be used to initialize a modem.
  12180. @item @code{no-clear?} (default: @code{#f})
  12181. When set to @code{#t}, agetty will not clear the screen before showing
  12182. the login prompt.
  12183. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  12184. This must be either a gexp denoting the name of a log-in program, or
  12185. unset, in which case the default value is the @command{login} from the
  12186. Shadow tool suite.
  12187. @item @code{local-line} (default: @code{#f})
  12188. Control the CLOCAL line flag. This accepts one of three symbols as
  12189. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  12190. the default value chosen by agetty is @code{'auto}.
  12191. @item @code{extract-baud?} (default: @code{#f})
  12192. When set to @code{#t}, instruct agetty to try to extract the baud rate
  12193. from the status messages produced by certain types of modems.
  12194. @item @code{skip-login?} (default: @code{#f})
  12195. When set to @code{#t}, do not prompt the user for a login name. This
  12196. can be used with @var{login-program} field to use non-standard login
  12197. systems.
  12198. @item @code{no-newline?} (default: @code{#f})
  12199. When set to @code{#t}, do not print a newline before printing the
  12200. @file{/etc/issue} file.
  12201. @c Is this dangerous only when used with login-program, or always?
  12202. @item @code{login-options} (default: @code{#f})
  12203. This option accepts a string containing options that are passed to the
  12204. login program. When used with the @var{login-program}, be aware that a
  12205. malicious user could try to enter a login name containing embedded
  12206. options that could be parsed by the login program.
  12207. @item @code{login-pause} (default: @code{#f})
  12208. When set to @code{#t}, wait for any key before showing the login prompt.
  12209. This can be used in conjunction with @var{auto-login} to save memory by
  12210. lazily spawning shells.
  12211. @item @code{chroot} (default: @code{#f})
  12212. Change root to the specified directory. This option accepts a directory
  12213. path as a string.
  12214. @item @code{hangup?} (default: @code{#f})
  12215. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  12216. specified terminal.
  12217. @item @code{keep-baud?} (default: @code{#f})
  12218. When set to @code{#t}, try to keep the existing baud rate. The baud
  12219. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  12220. character.
  12221. @item @code{timeout} (default: @code{#f})
  12222. When set to an integer value, terminate if no user name could be read
  12223. within @var{timeout} seconds.
  12224. @item @code{detect-case?} (default: @code{#f})
  12225. When set to @code{#t}, turn on support for detecting an uppercase-only
  12226. terminal. This setting will detect a login name containing only
  12227. uppercase letters as indicating an uppercase-only terminal and turn on
  12228. some upper-to-lower case conversions. Note that this will not support
  12229. Unicode characters.
  12230. @item @code{wait-cr?} (default: @code{#f})
  12231. When set to @code{#t}, wait for the user or modem to send a
  12232. carriage-return or linefeed character before displaying
  12233. @file{/etc/issue} or login prompt. This is typically used with the
  12234. @var{init-string} option.
  12235. @item @code{no-hints?} (default: @code{#f})
  12236. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  12237. locks.
  12238. @item @code{no-hostname?} (default: @code{#f})
  12239. By default, the hostname is printed. When this option is set to
  12240. @code{#t}, no hostname will be shown at all.
  12241. @item @code{long-hostname?} (default: @code{#f})
  12242. By default, the hostname is only printed until the first dot. When this
  12243. option is set to @code{#t}, the fully qualified hostname by
  12244. @code{gethostname} or @code{getaddrinfo} is shown.
  12245. @item @code{erase-characters} (default: @code{#f})
  12246. This option accepts a string of additional characters that should be
  12247. interpreted as backspace when the user types their login name.
  12248. @item @code{kill-characters} (default: @code{#f})
  12249. This option accepts a string that should be interpreted to mean ``ignore
  12250. all previous characters'' (also called a ``kill'' character) when the user
  12251. types their login name.
  12252. @item @code{chdir} (default: @code{#f})
  12253. This option accepts, as a string, a directory path that will be changed
  12254. to before login.
  12255. @item @code{delay} (default: @code{#f})
  12256. This options accepts, as an integer, the number of seconds to sleep
  12257. before opening the tty and displaying the login prompt.
  12258. @item @code{nice} (default: @code{#f})
  12259. This option accepts, as an integer, the nice value with which to run the
  12260. @command{login} program.
  12261. @item @code{extra-options} (default: @code{'()})
  12262. This option provides an ``escape hatch'' for the user to provide arbitrary
  12263. command-line arguments to @command{agetty} as a list of strings.
  12264. @end table
  12265. @end deftp
  12266. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  12267. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  12268. according to @var{config}, a @code{<kmscon-configuration>} object, which
  12269. specifies the tty to run, among other things.
  12270. @end deffn
  12271. @deftp {Data Type} kmscon-configuration
  12272. This is the data type representing the configuration of Kmscon, which
  12273. implements virtual console log-in.
  12274. @table @asis
  12275. @item @code{virtual-terminal}
  12276. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  12277. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  12278. A gexp denoting the name of the log-in program. The default log-in program is
  12279. @command{login} from the Shadow tool suite.
  12280. @item @code{login-arguments} (default: @code{'("-p")})
  12281. A list of arguments to pass to @command{login}.
  12282. @item @code{auto-login} (default: @code{#f})
  12283. When passed a login name, as a string, the specified user will be logged
  12284. in automatically without prompting for their login name or password.
  12285. @item @code{hardware-acceleration?} (default: #f)
  12286. Whether to use hardware acceleration.
  12287. @item @code{font-engine} (default: @code{"pango"})
  12288. Font engine used in Kmscon.
  12289. @item @code{font-size} (default: @code{12})
  12290. Font size used in Kmscon.
  12291. @item @code{kmscon} (default: @var{kmscon})
  12292. The Kmscon package to use.
  12293. @end table
  12294. @end deftp
  12295. @cindex name service cache daemon
  12296. @cindex nscd
  12297. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  12298. [#:name-services '()]
  12299. Return a service that runs the libc name service cache daemon (nscd) with the
  12300. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  12301. Service Switch}, for an example.
  12302. For convenience, the Shepherd service for nscd provides the following actions:
  12303. @table @code
  12304. @item invalidate
  12305. @cindex cache invalidation, nscd
  12306. @cindex nscd, cache invalidation
  12307. This invalidate the given cache. For instance, running:
  12308. @example
  12309. herd invalidate nscd hosts
  12310. @end example
  12311. @noindent
  12312. invalidates the host name lookup cache of nscd.
  12313. @item statistics
  12314. Running @command{herd statistics nscd} displays information about nscd usage
  12315. and caches.
  12316. @end table
  12317. @end deffn
  12318. @defvr {Scheme Variable} %nscd-default-configuration
  12319. This is the default @code{<nscd-configuration>} value (see below) used
  12320. by @code{nscd-service}. It uses the caches defined by
  12321. @code{%nscd-default-caches}; see below.
  12322. @end defvr
  12323. @deftp {Data Type} nscd-configuration
  12324. This is the data type representing the name service cache daemon (nscd)
  12325. configuration.
  12326. @table @asis
  12327. @item @code{name-services} (default: @code{'()})
  12328. List of packages denoting @dfn{name services} that must be visible to
  12329. the nscd---e.g., @code{(list @var{nss-mdns})}.
  12330. @item @code{glibc} (default: @var{glibc})
  12331. Package object denoting the GNU C Library providing the @command{nscd}
  12332. command.
  12333. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  12334. Name of the nscd log file. This is where debugging output goes when
  12335. @code{debug-level} is strictly positive.
  12336. @item @code{debug-level} (default: @code{0})
  12337. Integer denoting the debugging levels. Higher numbers mean that more
  12338. debugging output is logged.
  12339. @item @code{caches} (default: @code{%nscd-default-caches})
  12340. List of @code{<nscd-cache>} objects denoting things to be cached; see
  12341. below.
  12342. @end table
  12343. @end deftp
  12344. @deftp {Data Type} nscd-cache
  12345. Data type representing a cache database of nscd and its parameters.
  12346. @table @asis
  12347. @item @code{database}
  12348. This is a symbol representing the name of the database to be cached.
  12349. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  12350. @code{services}, which designate the corresponding NSS database
  12351. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  12352. @item @code{positive-time-to-live}
  12353. @itemx @code{negative-time-to-live} (default: @code{20})
  12354. A number representing the number of seconds during which a positive or
  12355. negative lookup result remains in cache.
  12356. @item @code{check-files?} (default: @code{#t})
  12357. Whether to check for updates of the files corresponding to
  12358. @var{database}.
  12359. For instance, when @var{database} is @code{hosts}, setting this flag
  12360. instructs nscd to check for updates in @file{/etc/hosts} and to take
  12361. them into account.
  12362. @item @code{persistent?} (default: @code{#t})
  12363. Whether the cache should be stored persistently on disk.
  12364. @item @code{shared?} (default: @code{#t})
  12365. Whether the cache should be shared among users.
  12366. @item @code{max-database-size} (default: 32@tie{}MiB)
  12367. Maximum size in bytes of the database cache.
  12368. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  12369. @c settings, so leave them out.
  12370. @end table
  12371. @end deftp
  12372. @defvr {Scheme Variable} %nscd-default-caches
  12373. List of @code{<nscd-cache>} objects used by default by
  12374. @code{nscd-configuration} (see above).
  12375. It enables persistent and aggressive caching of service and host name
  12376. lookups. The latter provides better host name lookup performance,
  12377. resilience in the face of unreliable name servers, and also better
  12378. privacy---often the result of host name lookups is in local cache, so
  12379. external name servers do not even need to be queried.
  12380. @end defvr
  12381. @anchor{syslog-configuration-type}
  12382. @cindex syslog
  12383. @cindex logging
  12384. @deftp {Data Type} syslog-configuration
  12385. This data type represents the configuration of the syslog daemon.
  12386. @table @asis
  12387. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  12388. The syslog daemon to use.
  12389. @item @code{config-file} (default: @code{%default-syslog.conf})
  12390. The syslog configuration file to use.
  12391. @end table
  12392. @end deftp
  12393. @anchor{syslog-service}
  12394. @cindex syslog
  12395. @deffn {Scheme Procedure} syslog-service @var{config}
  12396. Return a service that runs a syslog daemon according to @var{config}.
  12397. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  12398. information on the configuration file syntax.
  12399. @end deffn
  12400. @defvr {Scheme Variable} guix-service-type
  12401. This is the type of the service that runs the build daemon,
  12402. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  12403. @code{guix-configuration} record as described below.
  12404. @end defvr
  12405. @anchor{guix-configuration-type}
  12406. @deftp {Data Type} guix-configuration
  12407. This data type represents the configuration of the Guix build daemon.
  12408. @xref{Invoking guix-daemon}, for more information.
  12409. @table @asis
  12410. @item @code{guix} (default: @var{guix})
  12411. The Guix package to use.
  12412. @item @code{build-group} (default: @code{"guixbuild"})
  12413. Name of the group for build user accounts.
  12414. @item @code{build-accounts} (default: @code{10})
  12415. Number of build user accounts to create.
  12416. @item @code{authorize-key?} (default: @code{#t})
  12417. @cindex substitutes, authorization thereof
  12418. Whether to authorize the substitute keys listed in
  12419. @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
  12420. (@pxref{Substitutes}).
  12421. When @code{authorize-key?} is true, @file{/etc/guix/acl} cannot be
  12422. changed by invoking @command{guix archive --authorize}. You must
  12423. instead adjust @code{guix-configuration} as you wish and reconfigure the
  12424. system. This ensures that your operating system configuration file is
  12425. self-contained.
  12426. @quotation Note
  12427. When booting or reconfiguring to a system where @code{authorize-key?}
  12428. is true, the existing @file{/etc/guix/acl} file is backed up as
  12429. @file{/etc/guix/acl.bak} if it was determined to be a manually modified
  12430. file. This is to facilitate migration from earlier versions, which
  12431. allowed for in-place modifications to @file{/etc/guix/acl}.
  12432. @end quotation
  12433. @vindex %default-authorized-guix-keys
  12434. @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
  12435. The list of authorized key files for archive imports, as a list of
  12436. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  12437. contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
  12438. See @code{substitute-urls} below for an example on how to change it.
  12439. @item @code{use-substitutes?} (default: @code{#t})
  12440. Whether to use substitutes.
  12441. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  12442. The list of URLs where to look for substitutes by default.
  12443. Suppose you would like to fetch substitutes from @code{guix.example.org}
  12444. in addition to @code{@value{SUBSTITUTE-SERVER}}. You will need to do
  12445. two things: (1) add @code{guix.example.org} to @code{substitute-urls},
  12446. and (2) authorize its signing key, having done appropriate checks
  12447. (@pxref{Substitute Server Authorization}). The configuration below does
  12448. exactly that:
  12449. @lisp
  12450. (guix-configuration
  12451. (substitute-urls
  12452. (append (list "https://guix.example.org")
  12453. %default-substitute-urls))
  12454. (authorized-keys
  12455. (append (list (local-file "./guix.example.org-key.pub"))
  12456. %default-authorized-guix-keys)))
  12457. @end lisp
  12458. This example assumes that the file @file{./guix.example.org-key.pub}
  12459. contains the public key that @code{guix.example.org} uses to sign
  12460. substitutes.
  12461. @item @code{max-silent-time} (default: @code{0})
  12462. @itemx @code{timeout} (default: @code{0})
  12463. The number of seconds of silence and the number of seconds of activity,
  12464. respectively, after which a build process times out. A value of zero
  12465. disables the timeout.
  12466. @item @code{log-compression} (default: @code{'bzip2})
  12467. The type of compression used for build logs---one of @code{gzip},
  12468. @code{bzip2}, or @code{none}.
  12469. @item @code{discover?} (default: @code{#f})
  12470. Whether to discover substitute servers on the local network using mDNS
  12471. and DNS-SD.
  12472. @item @code{extra-options} (default: @code{'()})
  12473. List of extra command-line options for @command{guix-daemon}.
  12474. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  12475. File where @command{guix-daemon}'s standard output and standard error
  12476. are written.
  12477. @cindex HTTP proxy, for @code{guix-daemon}
  12478. @cindex proxy, for @code{guix-daemon} HTTP access
  12479. @item @code{http-proxy} (default: @code{#f})
  12480. The URL of the HTTP and HTTPS proxy used for downloading fixed-output
  12481. derivations and substitutes.
  12482. It is also possible to change the daemon's proxy at run time through the
  12483. @code{set-http-proxy} action, which restarts it:
  12484. @example
  12485. herd set-http-proxy guix-daemon http://localhost:8118
  12486. @end example
  12487. To clear the proxy settings, run:
  12488. @example
  12489. herd set-http-proxy guix-daemon
  12490. @end example
  12491. @item @code{tmpdir} (default: @code{#f})
  12492. A directory path where the @command{guix-daemon} will perform builds.
  12493. @end table
  12494. @end deftp
  12495. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  12496. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  12497. udev rules can be provided as a list of files through the @var{rules}
  12498. variable. The procedures @code{udev-rule}, @code{udev-rules-service}
  12499. and @code{file->udev-rule} from @code{(gnu services base)} simplify the
  12500. creation of such rule files.
  12501. The @command{herd rules udev} command, as root, returns the name of the
  12502. directory containing all the active udev rules.
  12503. @end deffn
  12504. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  12505. Return a udev-rule file named @var{file-name} containing the rules
  12506. defined by the @var{contents} literal.
  12507. In the following example, a rule for a USB device is defined to be
  12508. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  12509. upon detecting a USB device with a given product identifier.
  12510. @lisp
  12511. (define %example-udev-rule
  12512. (udev-rule
  12513. "90-usb-thing.rules"
  12514. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  12515. "ATTR@{product@}==\"Example\", "
  12516. "RUN+=\"/path/to/script\"")))
  12517. @end lisp
  12518. @end deffn
  12519. @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
  12520. [#:groups @var{groups}]
  12521. Return a service that extends @code{udev-service-type } with @var{rules}
  12522. and @code{account-service-type} with @var{groups} as system groups.
  12523. This works by creating a singleton service type
  12524. @code{@var{name}-udev-rules}, of which the returned service is an
  12525. instance.
  12526. Here we show how it can be used to extend @code{udev-service-type} with the
  12527. previously defined rule @code{%example-udev-rule}.
  12528. @lisp
  12529. (operating-system
  12530. ;; @dots{}
  12531. (services
  12532. (cons (udev-rules-service 'usb-thing %example-udev-rule)
  12533. %desktop-services)))
  12534. @end lisp
  12535. @end deffn
  12536. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  12537. Return a udev file named @var{file-name} containing the rules defined
  12538. within @var{file}, a file-like object.
  12539. The following example showcases how we can use an existing rule file.
  12540. @lisp
  12541. (use-modules (guix download) ;for url-fetch
  12542. (guix packages) ;for origin
  12543. @dots{})
  12544. (define %android-udev-rules
  12545. (file->udev-rule
  12546. "51-android-udev.rules"
  12547. (let ((version "20170910"))
  12548. (origin
  12549. (method url-fetch)
  12550. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  12551. "android-udev-rules/" version "/51-android.rules"))
  12552. (sha256
  12553. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  12554. @end lisp
  12555. @end deffn
  12556. Additionally, Guix package definitions can be included in @var{rules} in
  12557. order to extend the udev rules with the definitions found under their
  12558. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  12559. @var{file->udev-rule} example, we could have used the
  12560. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  12561. packages android)} module.
  12562. The following example shows how to use the @var{android-udev-rules}
  12563. package so that the Android tool @command{adb} can detect devices
  12564. without root privileges. It also details how to create the
  12565. @code{adbusers} group, which is required for the proper functioning of
  12566. the rules defined within the @code{android-udev-rules} package. To
  12567. create such a group, we must define it both as part of the
  12568. @code{supplementary-groups} of our @code{user-account} declaration, as
  12569. well as in the @var{groups} of the @code{udev-rules-service} procedure.
  12570. @lisp
  12571. (use-modules (gnu packages android) ;for android-udev-rules
  12572. (gnu system shadow) ;for user-group
  12573. @dots{})
  12574. (operating-system
  12575. ;; @dots{}
  12576. (users (cons (user-account
  12577. ;; @dots{}
  12578. (supplementary-groups
  12579. '("adbusers" ;for adb
  12580. "wheel" "netdev" "audio" "video")))))
  12581. ;; @dots{}
  12582. (services
  12583. (cons (udev-rules-service 'android android-udev-rules
  12584. #:groups '("adbusers"))
  12585. %desktop-services)))
  12586. @end lisp
  12587. @defvr {Scheme Variable} urandom-seed-service-type
  12588. Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
  12589. when rebooting. It also tries to seed @file{/dev/urandom} from
  12590. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  12591. readable.
  12592. @end defvr
  12593. @defvr {Scheme Variable} %random-seed-file
  12594. This is the name of the file where some random bytes are saved by
  12595. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  12596. It defaults to @file{/var/lib/random-seed}.
  12597. @end defvr
  12598. @cindex mouse
  12599. @cindex gpm
  12600. @defvr {Scheme Variable} gpm-service-type
  12601. This is the type of the service that runs GPM, the @dfn{general-purpose
  12602. mouse daemon}, which provides mouse support to the Linux console. GPM
  12603. allows users to use the mouse in the console, notably to select, copy,
  12604. and paste text.
  12605. The value for services of this type must be a @code{gpm-configuration}
  12606. (see below). This service is not part of @code{%base-services}.
  12607. @end defvr
  12608. @deftp {Data Type} gpm-configuration
  12609. Data type representing the configuration of GPM.
  12610. @table @asis
  12611. @item @code{options} (default: @code{%default-gpm-options})
  12612. Command-line options passed to @command{gpm}. The default set of
  12613. options instruct @command{gpm} to listen to mouse events on
  12614. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  12615. more information.
  12616. @item @code{gpm} (default: @code{gpm})
  12617. The GPM package to use.
  12618. @end table
  12619. @end deftp
  12620. @anchor{guix-publish-service-type}
  12621. @deffn {Scheme Variable} guix-publish-service-type
  12622. This is the service type for @command{guix publish} (@pxref{Invoking
  12623. guix publish}). Its value must be a @code{guix-publish-configuration}
  12624. object, as described below.
  12625. This assumes that @file{/etc/guix} already contains a signing key pair as
  12626. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  12627. archive}). If that is not the case, the service will fail to start.
  12628. @end deffn
  12629. @deftp {Data Type} guix-publish-configuration
  12630. Data type representing the configuration of the @code{guix publish}
  12631. service.
  12632. @table @asis
  12633. @item @code{guix} (default: @code{guix})
  12634. The Guix package to use.
  12635. @item @code{port} (default: @code{80})
  12636. The TCP port to listen for connections.
  12637. @item @code{host} (default: @code{"localhost"})
  12638. The host (and thus, network interface) to listen to. Use
  12639. @code{"0.0.0.0"} to listen on all the network interfaces.
  12640. @item @code{advertise?} (default: @code{#f})
  12641. When true, advertise the service on the local network @i{via} the DNS-SD
  12642. protocol, using Avahi.
  12643. This allows neighboring Guix devices with discovery on (see
  12644. @code{guix-configuration} above) to discover this @command{guix publish}
  12645. instance and to automatically download substitutes from it.
  12646. @item @code{compression} (default: @code{'(("gzip" 3) ("zstd" 3))})
  12647. This is a list of compression method/level tuple used when compressing
  12648. substitutes. For example, to compress all substitutes with @emph{both} lzip
  12649. at level 7 and gzip at level 9, write:
  12650. @lisp
  12651. '(("lzip" 7) ("gzip" 9))
  12652. @end lisp
  12653. Level 9 achieves the best compression ratio at the expense of increased CPU
  12654. usage, whereas level 1 achieves fast compression. @xref{Invoking guix
  12655. publish}, for more information on the available compression methods and
  12656. the tradeoffs involved.
  12657. An empty list disables compression altogether.
  12658. @item @code{nar-path} (default: @code{"nar"})
  12659. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  12660. publish, @option{--nar-path}}, for details.
  12661. @item @code{cache} (default: @code{#f})
  12662. When it is @code{#f}, disable caching and instead generate archives on
  12663. demand. Otherwise, this should be the name of a directory---e.g.,
  12664. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  12665. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  12666. @option{--cache}}, for more information on the tradeoffs involved.
  12667. @item @code{workers} (default: @code{#f})
  12668. When it is an integer, this is the number of worker threads used for
  12669. caching; when @code{#f}, the number of processors is used.
  12670. @xref{Invoking guix publish, @option{--workers}}, for more information.
  12671. @item @code{cache-bypass-threshold} (default: 10 MiB)
  12672. When @code{cache} is true, this is the maximum size in bytes of a store
  12673. item for which @command{guix publish} may bypass its cache in case of a
  12674. cache miss. @xref{Invoking guix publish,
  12675. @option{--cache-bypass-threshold}}, for more information.
  12676. @item @code{ttl} (default: @code{#f})
  12677. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  12678. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  12679. for more information.
  12680. @end table
  12681. @end deftp
  12682. @anchor{rngd-service}
  12683. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  12684. [#:device "/dev/hwrng"]
  12685. Return a service that runs the @command{rngd} program from @var{rng-tools}
  12686. to add @var{device} to the kernel's entropy pool. The service will fail if
  12687. @var{device} does not exist.
  12688. @end deffn
  12689. @anchor{pam-limits-service}
  12690. @cindex session limits
  12691. @cindex ulimit
  12692. @cindex priority
  12693. @cindex realtime
  12694. @cindex jackd
  12695. @cindex nofile
  12696. @cindex open file descriptors
  12697. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  12698. Return a service that installs a configuration file for the
  12699. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  12700. @code{pam_limits} module}. The procedure optionally takes a list of
  12701. @code{pam-limits-entry} values, which can be used to specify
  12702. @code{ulimit} limits and @code{nice} priority limits to user sessions.
  12703. The following limits definition sets two hard and soft limits for all
  12704. login sessions of users in the @code{realtime} group:
  12705. @lisp
  12706. (pam-limits-service
  12707. (list
  12708. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  12709. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  12710. @end lisp
  12711. The first entry increases the maximum realtime priority for
  12712. non-privileged processes; the second entry lifts any restriction of the
  12713. maximum address space that can be locked in memory. These settings are
  12714. commonly used for real-time audio systems.
  12715. Another useful example is raising the maximum number of open file
  12716. descriptors that can be used:
  12717. @lisp
  12718. (pam-limits-service
  12719. (list
  12720. (pam-limits-entry "*" 'both 'nofile 100000)))
  12721. @end lisp
  12722. In the above example, the asterisk means the limit should apply to any
  12723. user. It is important to ensure the chosen value doesn't exceed the
  12724. maximum system value visible in the @file{/proc/sys/fs/file-max} file,
  12725. else the users would be prevented from login in. For more information
  12726. about the Pluggable Authentication Module (PAM) limits, refer to the
  12727. @samp{pam_limits} man page from the @code{linux-pam} package.
  12728. @end deffn
  12729. @node Scheduled Job Execution
  12730. @subsection Scheduled Job Execution
  12731. @cindex cron
  12732. @cindex mcron
  12733. @cindex scheduling jobs
  12734. The @code{(gnu services mcron)} module provides an interface to
  12735. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  12736. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  12737. Unix @command{cron} daemon; the main difference is that it is
  12738. implemented in Guile Scheme, which provides a lot of flexibility when
  12739. specifying the scheduling of jobs and their actions.
  12740. The example below defines an operating system that runs the
  12741. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  12742. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  12743. well as the @command{mkid} command on behalf of an unprivileged user
  12744. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  12745. gexps to introduce job definitions that are passed to mcron
  12746. (@pxref{G-Expressions}).
  12747. @lisp
  12748. (use-modules (guix) (gnu) (gnu services mcron))
  12749. (use-package-modules base idutils)
  12750. (define updatedb-job
  12751. ;; Run 'updatedb' at 3AM every day. Here we write the
  12752. ;; job's action as a Scheme procedure.
  12753. #~(job '(next-hour '(3))
  12754. (lambda ()
  12755. (execl (string-append #$findutils "/bin/updatedb")
  12756. "updatedb"
  12757. "--prunepaths=/tmp /var/tmp /gnu/store"))))
  12758. (define garbage-collector-job
  12759. ;; Collect garbage 5 minutes after midnight every day.
  12760. ;; The job's action is a shell command.
  12761. #~(job "5 0 * * *" ;Vixie cron syntax
  12762. "guix gc -F 1G"))
  12763. (define idutils-job
  12764. ;; Update the index database as user "charlie" at 12:15PM
  12765. ;; and 19:15PM. This runs from the user's home directory.
  12766. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  12767. (string-append #$idutils "/bin/mkid src")
  12768. #:user "charlie"))
  12769. (operating-system
  12770. ;; @dots{}
  12771. ;; %BASE-SERVICES already includes an instance of
  12772. ;; 'mcron-service-type', which we extend with additional
  12773. ;; jobs using 'simple-service'.
  12774. (services (cons (simple-service 'my-cron-jobs
  12775. mcron-service-type
  12776. (list garbage-collector-job
  12777. updatedb-job
  12778. idutils-job))
  12779. %base-services)))
  12780. @end lisp
  12781. For more complex jobs defined in Scheme where you need control over the top
  12782. level, for instance to introduce a @code{use-modules} form, you can move your
  12783. code to a separate program using the @code{program-file} procedure of the
  12784. @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
  12785. illustrates that.
  12786. @lisp
  12787. (define %battery-alert-job
  12788. ;; Beep when the battery percentage falls below %MIN-LEVEL.
  12789. #~(job
  12790. '(next-minute (range 0 60 1))
  12791. #$(program-file
  12792. "battery-alert.scm"
  12793. (with-imported-modules (source-module-closure
  12794. '((guix build utils)))
  12795. #~(begin
  12796. (use-modules (guix build utils)
  12797. (ice-9 popen)
  12798. (ice-9 regex)
  12799. (ice-9 textual-ports)
  12800. (srfi srfi-2))
  12801. (define %min-level 20)
  12802. (setenv "LC_ALL" "C") ;ensure English output
  12803. (and-let* ((input-pipe (open-pipe*
  12804. OPEN_READ
  12805. #$(file-append acpi "/bin/acpi")))
  12806. (output (get-string-all input-pipe))
  12807. (m (string-match "Discharging, ([0-9]+)%" output))
  12808. (level (string->number (match:substring m 1)))
  12809. ((< level %min-level)))
  12810. (format #t "warning: Battery level is low (~a%)~%" level)
  12811. (invoke #$(file-append beep "/bin/beep") "-r5")))))))
  12812. @end lisp
  12813. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  12814. for more information on mcron job specifications. Below is the
  12815. reference of the mcron service.
  12816. On a running system, you can use the @code{schedule} action of the service to
  12817. visualize the mcron jobs that will be executed next:
  12818. @example
  12819. # herd schedule mcron
  12820. @end example
  12821. @noindent
  12822. The example above lists the next five tasks that will be executed, but you can
  12823. also specify the number of tasks to display:
  12824. @example
  12825. # herd schedule mcron 10
  12826. @end example
  12827. @defvr {Scheme Variable} mcron-service-type
  12828. This is the type of the @code{mcron} service, whose value is an
  12829. @code{mcron-configuration} object.
  12830. This service type can be the target of a service extension that provides
  12831. it additional job specifications (@pxref{Service Composition}). In
  12832. other words, it is possible to define services that provide additional
  12833. mcron jobs to run.
  12834. @end defvr
  12835. @deftp {Data Type} mcron-configuration
  12836. Data type representing the configuration of mcron.
  12837. @table @asis
  12838. @item @code{mcron} (default: @var{mcron})
  12839. The mcron package to use.
  12840. @item @code{jobs}
  12841. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  12842. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  12843. specifications,, mcron, GNU@tie{}mcron}).
  12844. @end table
  12845. @end deftp
  12846. @node Log Rotation
  12847. @subsection Log Rotation
  12848. @cindex rottlog
  12849. @cindex log rotation
  12850. @cindex logging
  12851. Log files such as those found in @file{/var/log} tend to grow endlessly,
  12852. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  12853. their contents in separate files, possibly compressed. The @code{(gnu
  12854. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  12855. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  12856. This service is part of @code{%base-services}, and thus enabled by
  12857. default, with the default settings, for commonly encountered log files.
  12858. The example below shows how to extend it with an additional
  12859. @dfn{rotation}, should you need to do that (usually, services that
  12860. produce log files already take care of that):
  12861. @lisp
  12862. (use-modules (guix) (gnu))
  12863. (use-service-modules admin)
  12864. (define my-log-files
  12865. ;; Log files that I want to rotate.
  12866. '("/var/log/something.log" "/var/log/another.log"))
  12867. (operating-system
  12868. ;; @dots{}
  12869. (services (cons (simple-service 'rotate-my-stuff
  12870. rottlog-service-type
  12871. (list (log-rotation
  12872. (frequency 'daily)
  12873. (files my-log-files))))
  12874. %base-services)))
  12875. @end lisp
  12876. @defvr {Scheme Variable} rottlog-service-type
  12877. This is the type of the Rottlog service, whose value is a
  12878. @code{rottlog-configuration} object.
  12879. Other services can extend this one with new @code{log-rotation} objects
  12880. (see below), thereby augmenting the set of files to be rotated.
  12881. This service type can define mcron jobs (@pxref{Scheduled Job
  12882. Execution}) to run the rottlog service.
  12883. @end defvr
  12884. @deftp {Data Type} rottlog-configuration
  12885. Data type representing the configuration of rottlog.
  12886. @table @asis
  12887. @item @code{rottlog} (default: @code{rottlog})
  12888. The Rottlog package to use.
  12889. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  12890. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  12891. rottlog, GNU Rot[t]log Manual}).
  12892. @item @code{rotations} (default: @code{%default-rotations})
  12893. A list of @code{log-rotation} objects as defined below.
  12894. @item @code{jobs}
  12895. This is a list of gexps where each gexp corresponds to an mcron job
  12896. specification (@pxref{Scheduled Job Execution}).
  12897. @end table
  12898. @end deftp
  12899. @deftp {Data Type} log-rotation
  12900. Data type representing the rotation of a group of log files.
  12901. Taking an example from the Rottlog manual (@pxref{Period Related File
  12902. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  12903. defined like this:
  12904. @lisp
  12905. (log-rotation
  12906. (frequency 'daily)
  12907. (files '("/var/log/apache/*"))
  12908. (options '("storedir apache-archives"
  12909. "rotate 6"
  12910. "notifempty"
  12911. "nocompress")))
  12912. @end lisp
  12913. The list of fields is as follows:
  12914. @table @asis
  12915. @item @code{frequency} (default: @code{'weekly})
  12916. The log rotation frequency, a symbol.
  12917. @item @code{files}
  12918. The list of files or file glob patterns to rotate.
  12919. @item @code{options} (default: @code{'()})
  12920. The list of rottlog options for this rotation (@pxref{Configuration
  12921. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  12922. @item @code{post-rotate} (default: @code{#f})
  12923. Either @code{#f} or a gexp to execute once the rotation has completed.
  12924. @end table
  12925. @end deftp
  12926. @defvr {Scheme Variable} %default-rotations
  12927. Specifies weekly rotation of @code{%rotated-files} and of
  12928. @file{/var/log/guix-daemon.log}.
  12929. @end defvr
  12930. @defvr {Scheme Variable} %rotated-files
  12931. The list of syslog-controlled files to be rotated. By default it is:
  12932. @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
  12933. "/var/log/maillog")}.
  12934. @end defvr
  12935. @node Networking Services
  12936. @subsection Networking Services
  12937. The @code{(gnu services networking)} module provides services to configure
  12938. the network interface.
  12939. @cindex DHCP, networking service
  12940. @defvr {Scheme Variable} dhcp-client-service-type
  12941. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  12942. Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
  12943. is the DHCP client package to use, @code{isc-dhcp} by default.
  12944. @end defvr
  12945. @deffn {Scheme Procedure} dhcpd-service-type
  12946. This type defines a service that runs a DHCP daemon. To create a
  12947. service of this type, you must supply a @code{<dhcpd-configuration>}.
  12948. For example:
  12949. @lisp
  12950. (service dhcpd-service-type
  12951. (dhcpd-configuration
  12952. (config-file (local-file "my-dhcpd.conf"))
  12953. (interfaces '("enp0s25"))))
  12954. @end lisp
  12955. @end deffn
  12956. @deftp {Data Type} dhcpd-configuration
  12957. @table @asis
  12958. @item @code{package} (default: @code{isc-dhcp})
  12959. The package that provides the DHCP daemon. This package is expected to
  12960. provide the daemon at @file{sbin/dhcpd} relative to its output
  12961. directory. The default package is the
  12962. @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
  12963. @item @code{config-file} (default: @code{#f})
  12964. The configuration file to use. This is required. It will be passed to
  12965. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  12966. object (@pxref{G-Expressions, file-like objects}). See @code{man
  12967. dhcpd.conf} for details on the configuration file syntax.
  12968. @item @code{version} (default: @code{"4"})
  12969. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  12970. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  12971. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  12972. details.
  12973. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  12974. The run directory to use. At service activation time, this directory
  12975. will be created if it does not exist.
  12976. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  12977. The PID file to use. This corresponds to the @code{-pf} option of
  12978. @code{dhcpd}. See @code{man dhcpd} for details.
  12979. @item @code{interfaces} (default: @code{'()})
  12980. The names of the network interfaces on which dhcpd should listen for
  12981. broadcasts. If this list is not empty, then its elements (which must be
  12982. strings) will be appended to the @code{dhcpd} invocation when starting
  12983. the daemon. It may not be necessary to explicitly specify any
  12984. interfaces here; see @code{man dhcpd} for details.
  12985. @end table
  12986. @end deftp
  12987. @defvr {Scheme Variable} static-networking-service-type
  12988. This is the type for statically-configured network interfaces.
  12989. @c TODO Document <static-networking> data structures.
  12990. @end defvr
  12991. @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
  12992. [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
  12993. [#:requirement @code{'(udev)}]
  12994. Return a service that starts @var{interface} with address @var{ip}. If
  12995. @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
  12996. it must be a string specifying the default network gateway. @var{requirement}
  12997. can be used to declare a dependency on another service before configuring the
  12998. interface.
  12999. This procedure can be called several times, one for each network
  13000. interface of interest. Behind the scenes what it does is extend
  13001. @code{static-networking-service-type} with additional network interfaces
  13002. to handle.
  13003. For example:
  13004. @lisp
  13005. (static-networking-service "eno1" "192.168.1.82"
  13006. #:gateway "192.168.1.2"
  13007. #:name-servers '("192.168.1.2"))
  13008. @end lisp
  13009. @end deffn
  13010. @cindex wicd
  13011. @cindex wireless
  13012. @cindex WiFi
  13013. @cindex network management
  13014. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  13015. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  13016. management daemon that aims to simplify wired and wireless networking.
  13017. This service adds the @var{wicd} package to the global profile, providing
  13018. several commands to interact with the daemon and configure networking:
  13019. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  13020. and @command{wicd-curses} user interfaces.
  13021. @end deffn
  13022. @cindex ModemManager
  13023. @defvr {Scheme Variable} modem-manager-service-type
  13024. This is the service type for the
  13025. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  13026. service. The value for this service type is a
  13027. @code{modem-manager-configuration} record.
  13028. This service is part of @code{%desktop-services} (@pxref{Desktop
  13029. Services}).
  13030. @end defvr
  13031. @deftp {Data Type} modem-manager-configuration
  13032. Data type representing the configuration of ModemManager.
  13033. @table @asis
  13034. @item @code{modem-manager} (default: @code{modem-manager})
  13035. The ModemManager package to use.
  13036. @end table
  13037. @end deftp
  13038. @cindex USB_ModeSwitch
  13039. @cindex Modeswitching
  13040. @defvr {Scheme Variable} usb-modeswitch-service-type
  13041. This is the service type for the
  13042. @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch}
  13043. service. The value for this service type is
  13044. a @code{usb-modeswitch-configuration} record.
  13045. When plugged in, some USB modems (and other USB devices) initially present
  13046. themselves as a read-only storage medium and not as a modem. They need to be
  13047. @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
  13048. installs udev rules to automatically modeswitch these devices when they are
  13049. plugged in.
  13050. This service is part of @code{%desktop-services} (@pxref{Desktop
  13051. Services}).
  13052. @end defvr
  13053. @deftp {Data Type} usb-modeswitch-configuration
  13054. Data type representing the configuration of USB_ModeSwitch.
  13055. @table @asis
  13056. @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
  13057. The USB_ModeSwitch package providing the binaries for modeswitching.
  13058. @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
  13059. The package providing the device data and udev rules file used by
  13060. USB_ModeSwitch.
  13061. @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
  13062. Which config file to use for the USB_ModeSwitch dispatcher. By default the
  13063. config file shipped with USB_ModeSwitch is used which disables logging to
  13064. @file{/var/log} among other default settings. If set to @code{#f}, no config
  13065. file is used.
  13066. @end table
  13067. @end deftp
  13068. @cindex NetworkManager
  13069. @defvr {Scheme Variable} network-manager-service-type
  13070. This is the service type for the
  13071. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  13072. service. The value for this service type is a
  13073. @code{network-manager-configuration} record.
  13074. This service is part of @code{%desktop-services} (@pxref{Desktop
  13075. Services}).
  13076. @end defvr
  13077. @deftp {Data Type} network-manager-configuration
  13078. Data type representing the configuration of NetworkManager.
  13079. @table @asis
  13080. @item @code{network-manager} (default: @code{network-manager})
  13081. The NetworkManager package to use.
  13082. @item @code{dns} (default: @code{"default"})
  13083. Processing mode for DNS, which affects how NetworkManager uses the
  13084. @code{resolv.conf} configuration file.
  13085. @table @samp
  13086. @item default
  13087. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  13088. provided by currently active connections.
  13089. @item dnsmasq
  13090. NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
  13091. @dfn{conditional forwarding} configuration if you are connected to a VPN, and
  13092. then update @code{resolv.conf} to point to the local nameserver.
  13093. With this setting, you can share your network connection. For example when
  13094. you want to share your network connection to another laptop @i{via} an
  13095. Ethernet cable, you can open @command{nm-connection-editor} and configure the
  13096. Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
  13097. and reestablish the connection (or reboot).
  13098. You can also set up a @dfn{host-to-guest connection} to QEMU VMs
  13099. (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
  13100. e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
  13101. browser on your host system, or connect to the VM @i{via} SSH
  13102. (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
  13103. host-to-guest connection, run this command once:
  13104. @example
  13105. nmcli connection add type tun \
  13106. connection.interface-name tap0 \
  13107. tun.mode tap tun.owner $(id -u) \
  13108. ipv4.method shared \
  13109. ipv4.addresses 172.28.112.1/24
  13110. @end example
  13111. Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
  13112. @option{-nic tap,ifname=tap0,script=no,downscript=no} to
  13113. @command{qemu-system-...}.
  13114. @item none
  13115. NetworkManager will not modify @code{resolv.conf}.
  13116. @end table
  13117. @item @code{vpn-plugins} (default: @code{'()})
  13118. This is the list of available plugins for virtual private networks
  13119. (VPNs). An example of this is the @code{network-manager-openvpn}
  13120. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  13121. @end table
  13122. @end deftp
  13123. @cindex Connman
  13124. @deffn {Scheme Variable} connman-service-type
  13125. This is the service type to run @url{https://01.org/connman,Connman},
  13126. a network connection manager.
  13127. Its value must be an
  13128. @code{connman-configuration} record as in this example:
  13129. @lisp
  13130. (service connman-service-type
  13131. (connman-configuration
  13132. (disable-vpn? #t)))
  13133. @end lisp
  13134. See below for details about @code{connman-configuration}.
  13135. @end deffn
  13136. @deftp {Data Type} connman-configuration
  13137. Data Type representing the configuration of connman.
  13138. @table @asis
  13139. @item @code{connman} (default: @var{connman})
  13140. The connman package to use.
  13141. @item @code{disable-vpn?} (default: @code{#f})
  13142. When true, disable connman's vpn plugin.
  13143. @end table
  13144. @end deftp
  13145. @cindex WPA Supplicant
  13146. @defvr {Scheme Variable} wpa-supplicant-service-type
  13147. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  13148. supplicant}, an authentication daemon required to authenticate against
  13149. encrypted WiFi or ethernet networks.
  13150. @end defvr
  13151. @deftp {Data Type} wpa-supplicant-configuration
  13152. Data type representing the configuration of WPA Supplicant.
  13153. It takes the following parameters:
  13154. @table @asis
  13155. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  13156. The WPA Supplicant package to use.
  13157. @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
  13158. List of services that should be started before WPA Supplicant starts.
  13159. @item @code{dbus?} (default: @code{#t})
  13160. Whether to listen for requests on D-Bus.
  13161. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  13162. Where to store the PID file.
  13163. @item @code{interface} (default: @code{#f})
  13164. If this is set, it must specify the name of a network interface that
  13165. WPA supplicant will control.
  13166. @item @code{config-file} (default: @code{#f})
  13167. Optional configuration file to use.
  13168. @item @code{extra-options} (default: @code{'()})
  13169. List of additional command-line arguments to pass to the daemon.
  13170. @end table
  13171. @end deftp
  13172. @cindex hostapd service, for Wi-Fi access points
  13173. @cindex Wi-Fi access points, hostapd service
  13174. @defvr {Scheme Variable} hostapd-service-type
  13175. This is the service type to run the @uref{https://w1.fi/hostapd/,
  13176. hostapd} daemon to set up WiFi (IEEE 802.11) access points and
  13177. authentication servers. Its associated value must be a
  13178. @code{hostapd-configuration} as shown below:
  13179. @lisp
  13180. ;; Use wlan1 to run the access point for "My Network".
  13181. (service hostapd-service-type
  13182. (hostapd-configuration
  13183. (interface "wlan1")
  13184. (ssid "My Network")
  13185. (channel 12)))
  13186. @end lisp
  13187. @end defvr
  13188. @deftp {Data Type} hostapd-configuration
  13189. This data type represents the configuration of the hostapd service, with
  13190. the following fields:
  13191. @table @asis
  13192. @item @code{package} (default: @code{hostapd})
  13193. The hostapd package to use.
  13194. @item @code{interface} (default: @code{"wlan0"})
  13195. The network interface to run the WiFi access point.
  13196. @item @code{ssid}
  13197. The SSID (@dfn{service set identifier}), a string that identifies this
  13198. network.
  13199. @item @code{broadcast-ssid?} (default: @code{#t})
  13200. Whether to broadcast this SSID.
  13201. @item @code{channel} (default: @code{1})
  13202. The WiFi channel to use.
  13203. @item @code{driver} (default: @code{"nl80211"})
  13204. The driver interface type. @code{"nl80211"} is used with all Linux
  13205. mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
  13206. RADIUS server that does # not control any wireless/wired driver.
  13207. @item @code{extra-settings} (default: @code{""})
  13208. Extra settings to append as-is to the hostapd configuration file. See
  13209. @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
  13210. configuration file reference.
  13211. @end table
  13212. @end deftp
  13213. @defvr {Scheme Variable} simulated-wifi-service-type
  13214. This is the type of a service to simulate WiFi networking, which can be
  13215. useful in virtual machines for testing purposes. The service loads the
  13216. Linux kernel
  13217. @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
  13218. @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
  13219. network that can be seen on @code{wlan0}, by default.
  13220. The service's value is a @code{hostapd-configuration} record.
  13221. @end defvr
  13222. @cindex iptables
  13223. @defvr {Scheme Variable} iptables-service-type
  13224. This is the service type to set up an iptables configuration. iptables is a
  13225. packet filtering framework supported by the Linux kernel. This service
  13226. supports configuring iptables for both IPv4 and IPv6. A simple example
  13227. configuration rejecting all incoming connections except those to the ssh port
  13228. 22 is shown below.
  13229. @lisp
  13230. (service iptables-service-type
  13231. (iptables-configuration
  13232. (ipv4-rules (plain-file "iptables.rules" "*filter
  13233. :INPUT ACCEPT
  13234. :FORWARD ACCEPT
  13235. :OUTPUT ACCEPT
  13236. -A INPUT -p tcp --dport 22 -j ACCEPT
  13237. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  13238. COMMIT
  13239. "))
  13240. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  13241. :INPUT ACCEPT
  13242. :FORWARD ACCEPT
  13243. :OUTPUT ACCEPT
  13244. -A INPUT -p tcp --dport 22 -j ACCEPT
  13245. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  13246. COMMIT
  13247. "))))
  13248. @end lisp
  13249. @end defvr
  13250. @deftp {Data Type} iptables-configuration
  13251. The data type representing the configuration of iptables.
  13252. @table @asis
  13253. @item @code{iptables} (default: @code{iptables})
  13254. The iptables package that provides @code{iptables-restore} and
  13255. @code{ip6tables-restore}.
  13256. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  13257. The iptables rules to use. It will be passed to @code{iptables-restore}.
  13258. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  13259. objects}).
  13260. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  13261. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  13262. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  13263. objects}).
  13264. @end table
  13265. @end deftp
  13266. @cindex nftables
  13267. @defvr {Scheme Variable} nftables-service-type
  13268. This is the service type to set up a nftables configuration. nftables is a
  13269. netfilter project that aims to replace the existing iptables, ip6tables,
  13270. arptables and ebtables framework. It provides a new packet filtering
  13271. framework, a new user-space utility @command{nft}, and a compatibility layer
  13272. for iptables. This service comes with a default ruleset
  13273. @code{%default-nftables-ruleset} that rejecting all incomming connections
  13274. except those to the ssh port 22. To use it, simply write:
  13275. @lisp
  13276. (service nftables-service-type)
  13277. @end lisp
  13278. @end defvr
  13279. @deftp {Data Type} nftables-configuration
  13280. The data type representing the configuration of nftables.
  13281. @table @asis
  13282. @item @code{package} (default: @code{nftables})
  13283. The nftables package that provides @command{nft}.
  13284. @item @code{ruleset} (default: @code{%default-nftables-ruleset})
  13285. The nftables ruleset to use. This may be any ``file-like'' object
  13286. (@pxref{G-Expressions, file-like objects}).
  13287. @end table
  13288. @end deftp
  13289. @cindex NTP (Network Time Protocol), service
  13290. @cindex ntpd, service for the Network Time Protocol daemon
  13291. @cindex real time clock
  13292. @defvr {Scheme Variable} ntp-service-type
  13293. This is the type of the service running the @uref{https://www.ntp.org,
  13294. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  13295. system clock synchronized with that of the specified NTP servers.
  13296. The value of this service is an @code{ntpd-configuration} object, as described
  13297. below.
  13298. @end defvr
  13299. @deftp {Data Type} ntp-configuration
  13300. This is the data type for the NTP service configuration.
  13301. @table @asis
  13302. @item @code{servers} (default: @code{%ntp-servers})
  13303. This is the list of servers (@code{<ntp-server>} records) with which
  13304. @command{ntpd} will be synchronized. See the @code{ntp-server} data type
  13305. definition below.
  13306. @item @code{allow-large-adjustment?} (default: @code{#t})
  13307. This determines whether @command{ntpd} is allowed to make an initial
  13308. adjustment of more than 1,000 seconds.
  13309. @item @code{ntp} (default: @code{ntp})
  13310. The NTP package to use.
  13311. @end table
  13312. @end deftp
  13313. @defvr {Scheme Variable} %ntp-servers
  13314. List of host names used as the default NTP servers. These are servers of the
  13315. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  13316. @end defvr
  13317. @deftp {Data Type} ntp-server
  13318. The data type representing the configuration of a NTP server.
  13319. @table @asis
  13320. @item @code{type} (default: @code{'server})
  13321. The type of the NTP server, given as a symbol. One of @code{'pool},
  13322. @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
  13323. @item @code{address}
  13324. The address of the server, as a string.
  13325. @item @code{options}
  13326. NTPD options to use with that specific server, given as a list of option names
  13327. and/or of option names and values tuples. The following example define a server
  13328. to use with the options @option{iburst} and @option{prefer}, as well as
  13329. @option{version} 3 and a @option{maxpoll} time of 16 seconds.
  13330. @example
  13331. (ntp-server
  13332. (type 'server)
  13333. (address "some.ntp.server.org")
  13334. (options `(iburst (version 3) (maxpoll 16) prefer))))
  13335. @end example
  13336. @end table
  13337. @end deftp
  13338. @cindex OpenNTPD
  13339. @deffn {Scheme Procedure} openntpd-service-type
  13340. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  13341. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  13342. clock synchronized with that of the given servers.
  13343. @lisp
  13344. (service
  13345. openntpd-service-type
  13346. (openntpd-configuration
  13347. (listen-on '("127.0.0.1" "::1"))
  13348. (sensor '("udcf0 correction 70000"))
  13349. (constraint-from '("www.gnu.org"))
  13350. (constraints-from '("https://www.google.com/"))))
  13351. @end lisp
  13352. @end deffn
  13353. @defvr {Scheme Variable} %openntpd-servers
  13354. This variable is a list of the server addresses defined in
  13355. @code{%ntp-servers}.
  13356. @end defvr
  13357. @deftp {Data Type} openntpd-configuration
  13358. @table @asis
  13359. @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
  13360. The openntpd executable to use.
  13361. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  13362. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  13363. @item @code{query-from} (default: @code{'()})
  13364. A list of local IP address the ntpd daemon should use for outgoing queries.
  13365. @item @code{sensor} (default: @code{'()})
  13366. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  13367. will listen to each sensor that actually exists and ignore non-existent ones.
  13368. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  13369. information.
  13370. @item @code{server} (default: @code{'()})
  13371. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  13372. @item @code{servers} (default: @code{%openntp-servers})
  13373. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  13374. @item @code{constraint-from} (default: @code{'()})
  13375. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  13376. This time information is not used for precision but acts as an authenticated
  13377. constraint, thereby reducing the impact of unauthenticated NTP
  13378. man-in-the-middle attacks.
  13379. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  13380. a constraint.
  13381. @item @code{constraints-from} (default: @code{'()})
  13382. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  13383. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  13384. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  13385. @end table
  13386. @end deftp
  13387. @cindex inetd
  13388. @deffn {Scheme variable} inetd-service-type
  13389. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  13390. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  13391. connections on internet sockets, and lazily starts the specified server
  13392. program when a connection is made on one of these sockets.
  13393. The value of this service is an @code{inetd-configuration} object. The
  13394. following example configures the @command{inetd} daemon to provide the
  13395. built-in @command{echo} service, as well as an smtp service which
  13396. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  13397. gateway @code{hostname}:
  13398. @lisp
  13399. (service
  13400. inetd-service-type
  13401. (inetd-configuration
  13402. (entries (list
  13403. (inetd-entry
  13404. (name "echo")
  13405. (socket-type 'stream)
  13406. (protocol "tcp")
  13407. (wait? #f)
  13408. (user "root"))
  13409. (inetd-entry
  13410. (node "127.0.0.1")
  13411. (name "smtp")
  13412. (socket-type 'stream)
  13413. (protocol "tcp")
  13414. (wait? #f)
  13415. (user "root")
  13416. (program (file-append openssh "/bin/ssh"))
  13417. (arguments
  13418. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  13419. "-W" "smtp-server:25" "user@@hostname")))))))
  13420. @end lisp
  13421. See below for more details about @code{inetd-configuration}.
  13422. @end deffn
  13423. @deftp {Data Type} inetd-configuration
  13424. Data type representing the configuration of @command{inetd}.
  13425. @table @asis
  13426. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  13427. The @command{inetd} executable to use.
  13428. @item @code{entries} (default: @code{'()})
  13429. A list of @command{inetd} service entries. Each entry should be created
  13430. by the @code{inetd-entry} constructor.
  13431. @end table
  13432. @end deftp
  13433. @deftp {Data Type} inetd-entry
  13434. Data type representing an entry in the @command{inetd} configuration.
  13435. Each entry corresponds to a socket where @command{inetd} will listen for
  13436. requests.
  13437. @table @asis
  13438. @item @code{node} (default: @code{#f})
  13439. Optional string, a comma-separated list of local addresses
  13440. @command{inetd} should use when listening for this service.
  13441. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  13442. description of all options.
  13443. @item @code{name}
  13444. A string, the name must correspond to an entry in @code{/etc/services}.
  13445. @item @code{socket-type}
  13446. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  13447. @code{'seqpacket}.
  13448. @item @code{protocol}
  13449. A string, must correspond to an entry in @code{/etc/protocols}.
  13450. @item @code{wait?} (default: @code{#t})
  13451. Whether @command{inetd} should wait for the server to exit before
  13452. listening to new service requests.
  13453. @item @code{user}
  13454. A string containing the user (and, optionally, group) name of the user
  13455. as whom the server should run. The group name can be specified in a
  13456. suffix, separated by a colon or period, i.e.@: @code{"user"},
  13457. @code{"user:group"} or @code{"user.group"}.
  13458. @item @code{program} (default: @code{"internal"})
  13459. The server program which will serve the requests, or @code{"internal"}
  13460. if @command{inetd} should use a built-in service.
  13461. @item @code{arguments} (default: @code{'()})
  13462. A list strings or file-like objects, which are the server program's
  13463. arguments, starting with the zeroth argument, i.e.@: the name of the
  13464. program itself. For @command{inetd}'s internal services, this entry
  13465. must be @code{'()} or @code{'("internal")}.
  13466. @end table
  13467. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  13468. detailed discussion of each configuration field.
  13469. @end deftp
  13470. @cindex Tor
  13471. @defvr {Scheme Variable} tor-service-type
  13472. This is the type for a service that runs the @uref{https://torproject.org,
  13473. Tor} anonymous networking daemon. The service is configured using a
  13474. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  13475. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  13476. @end defvr
  13477. @deftp {Data Type} tor-configuration
  13478. @table @asis
  13479. @item @code{tor} (default: @code{tor})
  13480. The package that provides the Tor daemon. This package is expected to provide
  13481. the daemon at @file{bin/tor} relative to its output directory. The default
  13482. package is the @uref{https://www.torproject.org, Tor Project's}
  13483. implementation.
  13484. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  13485. The configuration file to use. It will be appended to a default configuration
  13486. file, and the final configuration file will be passed to @code{tor} via its
  13487. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  13488. file-like objects}). See @code{man tor} for details on the configuration file
  13489. syntax.
  13490. @item @code{hidden-services} (default: @code{'()})
  13491. The list of @code{<hidden-service>} records to use. For any hidden service
  13492. you include in this list, appropriate configuration to enable the hidden
  13493. service will be automatically added to the default configuration file. You
  13494. may conveniently create @code{<hidden-service>} records using the
  13495. @code{tor-hidden-service} procedure described below.
  13496. @item @code{socks-socket-type} (default: @code{'tcp})
  13497. The default socket type that Tor should use for its SOCKS socket. This must
  13498. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  13499. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  13500. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  13501. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  13502. @code{tor} group.
  13503. If you want to customize the SOCKS socket in more detail, leave
  13504. @code{socks-socket-type} at its default value of @code{'tcp} and use
  13505. @code{config-file} to override the default by providing your own
  13506. @code{SocksPort} option.
  13507. @item @code{control-socket?} (default: @code{#f})
  13508. Whether or not to provide a ``control socket'' by which Tor can be
  13509. controlled to, for instance, dynamically instantiate tor onion services.
  13510. If @code{#t}, Tor will listen for control commands on the UNIX domain socket
  13511. @file{/var/run/tor/control-sock}, which will be made writable by members of the
  13512. @code{tor} group.
  13513. @end table
  13514. @end deftp
  13515. @cindex hidden service
  13516. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  13517. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  13518. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  13519. @example
  13520. '((22 "127.0.0.1:22")
  13521. (80 "127.0.0.1:8080"))
  13522. @end example
  13523. In this example, port 22 of the hidden service is mapped to local port 22, and
  13524. port 80 is mapped to local port 8080.
  13525. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  13526. the @file{hostname} file contains the @code{.onion} host name for the hidden
  13527. service.
  13528. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  13529. project's documentation} for more information.
  13530. @end deffn
  13531. The @code{(gnu services rsync)} module provides the following services:
  13532. You might want an rsync daemon if you have files that you want available
  13533. so anyone (or just yourself) can download existing files or upload new
  13534. files.
  13535. @deffn {Scheme Variable} rsync-service-type
  13536. This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
  13537. The value for this service type is a
  13538. @command{rsync-configuration} record as in this example:
  13539. @lisp
  13540. (service rsync-service-type)
  13541. @end lisp
  13542. See below for details about @code{rsync-configuration}.
  13543. @end deffn
  13544. @deftp {Data Type} rsync-configuration
  13545. Data type representing the configuration for @code{rsync-service}.
  13546. @table @asis
  13547. @item @code{package} (default: @var{rsync})
  13548. @code{rsync} package to use.
  13549. @item @code{port-number} (default: @code{873})
  13550. TCP port on which @command{rsync} listens for incoming connections. If port
  13551. is less than @code{1024} @command{rsync} needs to be started as the
  13552. @code{root} user and group.
  13553. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  13554. Name of the file where @command{rsync} writes its PID.
  13555. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  13556. Name of the file where @command{rsync} writes its lock file.
  13557. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  13558. Name of the file where @command{rsync} writes its log file.
  13559. @item @code{use-chroot?} (default: @var{#t})
  13560. Whether to use chroot for @command{rsync} shared directory.
  13561. @item @code{share-path} (default: @file{/srv/rsync})
  13562. Location of the @command{rsync} shared directory.
  13563. @item @code{share-comment} (default: @code{"Rsync share"})
  13564. Comment of the @command{rsync} shared directory.
  13565. @item @code{read-only?} (default: @var{#f})
  13566. Read-write permissions to shared directory.
  13567. @item @code{timeout} (default: @code{300})
  13568. I/O timeout in seconds.
  13569. @item @code{user} (default: @var{"root"})
  13570. Owner of the @code{rsync} process.
  13571. @item @code{group} (default: @var{"root"})
  13572. Group of the @code{rsync} process.
  13573. @item @code{uid} (default: @var{"rsyncd"})
  13574. User name or user ID that file transfers to and from that module should take
  13575. place as when the daemon was run as @code{root}.
  13576. @item @code{gid} (default: @var{"rsyncd"})
  13577. Group name or group ID that will be used when accessing the module.
  13578. @end table
  13579. @end deftp
  13580. The @code{(gnu services syncthing)} module provides the following services:
  13581. @cindex syncthing
  13582. You might want a syncthing daemon if you have files between two or more
  13583. computers and want to sync them in real time, safely protected from
  13584. prying eyes.
  13585. @deffn {Scheme Variable} syncthing-service-type
  13586. This is the service type for the @uref{https://syncthing.net/,
  13587. syncthing} daemon, The value for this service type is a
  13588. @command{syncthing-configuration} record as in this example:
  13589. @lisp
  13590. (service syncthing-service-type
  13591. (syncthing-configuration (user "alice")))
  13592. @end lisp
  13593. See below for details about @code{syncthing-configuration}.
  13594. @deftp {Data Type} syncthing-configuration
  13595. Data type representing the configuration for @code{syncthing-service-type}.
  13596. @table @asis
  13597. @item @code{syncthing} (default: @var{syncthing})
  13598. @code{syncthing} package to use.
  13599. @item @code{arguments} (default: @var{'()})
  13600. List of command-line arguments passing to @code{syncthing} binary.
  13601. @item @code{logflags} (default: @var{0})
  13602. Sum of loging flags, see
  13603. @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}.
  13604. @item @code{user} (default: @var{#f})
  13605. The user as which the Syncthing service is to be run.
  13606. This assumes that the specified user exists.
  13607. @item @code{group} (default: @var{"users"})
  13608. The group as which the Syncthing service is to be run.
  13609. This assumes that the specified group exists.
  13610. @item @code{home} (default: @var{#f})
  13611. Common configuration and data directory. The default configuration
  13612. directory is @file{$HOME} of the specified Syncthing @code{user}.
  13613. @end table
  13614. @end deftp
  13615. @end deffn
  13616. Furthermore, @code{(gnu services ssh)} provides the following services.
  13617. @cindex SSH
  13618. @cindex SSH server
  13619. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  13620. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  13621. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  13622. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  13623. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  13624. [#:public-key-authentication? #t] [#:initialize? #t]
  13625. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  13626. @var{host-key} must designate a file containing the host key, and readable
  13627. only by root.
  13628. When @var{daemonic?} is true, @command{lshd} will detach from the
  13629. controlling terminal and log its output to syslogd, unless one sets
  13630. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  13631. depend on existence of syslogd service. When @var{pid-file?} is true,
  13632. @command{lshd} writes its PID to the file called @var{pid-file}.
  13633. When @var{initialize?} is true, automatically create the seed and host key
  13634. upon service activation if they do not exist yet. This may take long and
  13635. require interaction.
  13636. When @var{initialize?} is false, it is up to the user to initialize the
  13637. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  13638. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  13639. basics,,, lsh, LSH Manual}).
  13640. When @var{interfaces} is empty, lshd listens for connections on all the
  13641. network interfaces; otherwise, @var{interfaces} must be a list of host names
  13642. or addresses.
  13643. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  13644. passwords, and @var{root-login?} specifies whether to accept log-ins as
  13645. root.
  13646. The other options should be self-descriptive.
  13647. @end deffn
  13648. @cindex SSH
  13649. @cindex SSH server
  13650. @deffn {Scheme Variable} openssh-service-type
  13651. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  13652. shell daemon, @command{sshd}. Its value must be an
  13653. @code{openssh-configuration} record as in this example:
  13654. @lisp
  13655. (service openssh-service-type
  13656. (openssh-configuration
  13657. (x11-forwarding? #t)
  13658. (permit-root-login 'without-password)
  13659. (authorized-keys
  13660. `(("alice" ,(local-file "alice.pub"))
  13661. ("bob" ,(local-file "bob.pub"))))))
  13662. @end lisp
  13663. See below for details about @code{openssh-configuration}.
  13664. This service can be extended with extra authorized keys, as in this
  13665. example:
  13666. @lisp
  13667. (service-extension openssh-service-type
  13668. (const `(("charlie"
  13669. ,(local-file "charlie.pub")))))
  13670. @end lisp
  13671. @end deffn
  13672. @deftp {Data Type} openssh-configuration
  13673. This is the configuration record for OpenSSH's @command{sshd}.
  13674. @table @asis
  13675. @item @code{openssh} (default @var{openssh})
  13676. The Openssh package to use.
  13677. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  13678. Name of the file where @command{sshd} writes its PID.
  13679. @item @code{port-number} (default: @code{22})
  13680. TCP port on which @command{sshd} listens for incoming connections.
  13681. @item @code{permit-root-login} (default: @code{#f})
  13682. This field determines whether and when to allow logins as root. If
  13683. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  13684. If it's the symbol @code{'without-password}, then root logins are
  13685. permitted but not with password-based authentication.
  13686. @item @code{allow-empty-passwords?} (default: @code{#f})
  13687. When true, users with empty passwords may log in. When false, they may
  13688. not.
  13689. @item @code{password-authentication?} (default: @code{#t})
  13690. When true, users may log in with their password. When false, they have
  13691. other authentication methods.
  13692. @item @code{public-key-authentication?} (default: @code{#t})
  13693. When true, users may log in using public key authentication. When
  13694. false, users have to use other authentication method.
  13695. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  13696. This is used only by protocol version 2.
  13697. @item @code{x11-forwarding?} (default: @code{#f})
  13698. When true, forwarding of X11 graphical client connections is
  13699. enabled---in other words, @command{ssh} options @option{-X} and
  13700. @option{-Y} will work.
  13701. @item @code{allow-agent-forwarding?} (default: @code{#t})
  13702. Whether to allow agent forwarding.
  13703. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  13704. Whether to allow TCP forwarding.
  13705. @item @code{gateway-ports?} (default: @code{#f})
  13706. Whether to allow gateway ports.
  13707. @item @code{challenge-response-authentication?} (default: @code{#f})
  13708. Specifies whether challenge response authentication is allowed (e.g.@: via
  13709. PAM).
  13710. @item @code{use-pam?} (default: @code{#t})
  13711. Enables the Pluggable Authentication Module interface. If set to
  13712. @code{#t}, this will enable PAM authentication using
  13713. @code{challenge-response-authentication?} and
  13714. @code{password-authentication?}, in addition to PAM account and session
  13715. module processing for all authentication types.
  13716. Because PAM challenge response authentication usually serves an
  13717. equivalent role to password authentication, you should disable either
  13718. @code{challenge-response-authentication?} or
  13719. @code{password-authentication?}.
  13720. @item @code{print-last-log?} (default: @code{#t})
  13721. Specifies whether @command{sshd} should print the date and time of the
  13722. last user login when a user logs in interactively.
  13723. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  13724. Configures external subsystems (e.g.@: file transfer daemon).
  13725. This is a list of two-element lists, each of which containing the
  13726. subsystem name and a command (with optional arguments) to execute upon
  13727. subsystem request.
  13728. The command @command{internal-sftp} implements an in-process SFTP
  13729. server. Alternatively, one can specify the @command{sftp-server} command:
  13730. @lisp
  13731. (service openssh-service-type
  13732. (openssh-configuration
  13733. (subsystems
  13734. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  13735. @end lisp
  13736. @item @code{accepted-environment} (default: @code{'()})
  13737. List of strings describing which environment variables may be exported.
  13738. Each string gets on its own line. See the @code{AcceptEnv} option in
  13739. @code{man sshd_config}.
  13740. This example allows ssh-clients to export the @env{COLORTERM} variable.
  13741. It is set by terminal emulators, which support colors. You can use it in
  13742. your shell's resource file to enable colors for the prompt and commands
  13743. if this variable is set.
  13744. @lisp
  13745. (service openssh-service-type
  13746. (openssh-configuration
  13747. (accepted-environment '("COLORTERM"))))
  13748. @end lisp
  13749. @item @code{authorized-keys} (default: @code{'()})
  13750. @cindex authorized keys, SSH
  13751. @cindex SSH authorized keys
  13752. This is the list of authorized keys. Each element of the list is a user
  13753. name followed by one or more file-like objects that represent SSH public
  13754. keys. For example:
  13755. @lisp
  13756. (openssh-configuration
  13757. (authorized-keys
  13758. `(("rekado" ,(local-file "rekado.pub"))
  13759. ("chris" ,(local-file "chris.pub"))
  13760. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  13761. @end lisp
  13762. @noindent
  13763. registers the specified public keys for user accounts @code{rekado},
  13764. @code{chris}, and @code{root}.
  13765. Additional authorized keys can be specified @i{via}
  13766. @code{service-extension}.
  13767. Note that this does @emph{not} interfere with the use of
  13768. @file{~/.ssh/authorized_keys}.
  13769. @item @code{log-level} (default: @code{'info})
  13770. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  13771. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  13772. page for @file{sshd_config} for the full list of level names.
  13773. @item @code{extra-content} (default: @code{""})
  13774. This field can be used to append arbitrary text to the configuration file. It
  13775. is especially useful for elaborate configurations that cannot be expressed
  13776. otherwise. This configuration, for example, would generally disable root
  13777. logins, but permit them from one specific IP address:
  13778. @lisp
  13779. (openssh-configuration
  13780. (extra-content "\
  13781. Match Address 192.168.0.1
  13782. PermitRootLogin yes"))
  13783. @end lisp
  13784. @end table
  13785. @end deftp
  13786. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  13787. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  13788. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  13789. object.
  13790. For example, to specify a Dropbear service listening on port 1234, add
  13791. this call to the operating system's @code{services} field:
  13792. @lisp
  13793. (dropbear-service (dropbear-configuration
  13794. (port-number 1234)))
  13795. @end lisp
  13796. @end deffn
  13797. @deftp {Data Type} dropbear-configuration
  13798. This data type represents the configuration of a Dropbear SSH daemon.
  13799. @table @asis
  13800. @item @code{dropbear} (default: @var{dropbear})
  13801. The Dropbear package to use.
  13802. @item @code{port-number} (default: 22)
  13803. The TCP port where the daemon waits for incoming connections.
  13804. @item @code{syslog-output?} (default: @code{#t})
  13805. Whether to enable syslog output.
  13806. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  13807. File name of the daemon's PID file.
  13808. @item @code{root-login?} (default: @code{#f})
  13809. Whether to allow @code{root} logins.
  13810. @item @code{allow-empty-passwords?} (default: @code{#f})
  13811. Whether to allow empty passwords.
  13812. @item @code{password-authentication?} (default: @code{#t})
  13813. Whether to enable password-based authentication.
  13814. @end table
  13815. @end deftp
  13816. @cindex AutoSSH
  13817. @deffn {Scheme Variable} autossh-service-type
  13818. This is the type for the @uref{https://www.harding.motd.ca/autossh,
  13819. AutoSSH} program that runs a copy of @command{ssh} and monitors it,
  13820. restarting it as necessary should it die or stop passing traffic.
  13821. AutoSSH can be run manually from the command-line by passing arguments
  13822. to the binary @command{autossh} from the package @code{autossh}, but it
  13823. can also be run as a Guix service. This latter use case is documented
  13824. here.
  13825. AutoSSH can be used to forward local traffic to a remote machine using
  13826. an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
  13827. is run as.
  13828. For example, to specify a service running autossh as the user
  13829. @code{pino} and forwarding all local connections to port @code{8081} to
  13830. @code{remote:8081} using an SSH tunnel, add this call to the operating
  13831. system's @code{services} field:
  13832. @lisp
  13833. (service autossh-service-type
  13834. (autossh-configuration
  13835. (user "pino")
  13836. (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
  13837. @end lisp
  13838. @end deffn
  13839. @deftp {Data Type} autossh-configuration
  13840. This data type represents the configuration of an AutoSSH service.
  13841. @table @asis
  13842. @item @code{user} (default @code{"autossh"})
  13843. The user as which the AutoSSH service is to be run.
  13844. This assumes that the specified user exists.
  13845. @item @code{poll} (default @code{600})
  13846. Specifies the connection poll time in seconds.
  13847. @item @code{first-poll} (default @code{#f})
  13848. Specifies how many seconds AutoSSH waits before the first connection
  13849. test. After this first test, polling is resumed at the pace defined in
  13850. @code{poll}. When set to @code{#f}, the first poll is not treated
  13851. specially and will also use the connection poll specified in
  13852. @code{poll}.
  13853. @item @code{gate-time} (default @code{30})
  13854. Specifies how many seconds an SSH connection must be active before it is
  13855. considered successful.
  13856. @item @code{log-level} (default @code{1})
  13857. The log level, corresponding to the levels used by syslog---so @code{0}
  13858. is the most silent while @code{7} is the chattiest.
  13859. @item @code{max-start} (default @code{#f})
  13860. The maximum number of times SSH may be (re)started before AutoSSH exits.
  13861. When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
  13862. @item @code{message} (default @code{""})
  13863. The message to append to the echo message sent when testing connections.
  13864. @item @code{port} (default @code{"0"})
  13865. The ports used for monitoring the connection. When set to @code{"0"},
  13866. monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
  13867. a positive integer, ports @var{n} and @var{n}+1 are used for
  13868. monitoring the connection, such that port @var{n} is the base
  13869. monitoring port and @code{n+1} is the echo port. When set to
  13870. @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
  13871. integers, the ports @var{n} and @var{m} are used for monitoring the
  13872. connection, such that port @var{n} is the base monitoring port and
  13873. @var{m} is the echo port.
  13874. @item @code{ssh-options} (default @code{'()})
  13875. The list of command-line arguments to pass to @command{ssh} when it is
  13876. run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
  13877. may cause undefined behaviour.
  13878. @end table
  13879. @end deftp
  13880. @cindex WebSSH
  13881. @deffn {Scheme Variable} webssh-service-type
  13882. This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
  13883. program that runs a web SSH client. WebSSH can be run manually from the
  13884. command-line by passing arguments to the binary @command{wssh} from the
  13885. package @code{webssh}, but it can also be run as a Guix service. This
  13886. latter use case is documented here.
  13887. For example, to specify a service running WebSSH on loopback interface
  13888. on port @code{8888} with reject policy with a list of allowed to
  13889. connection hosts, and NGINX as a reverse-proxy to this service listening
  13890. for HTTPS connection, add this call to the operating system's
  13891. @code{services} field:
  13892. @lisp
  13893. (service webssh-service-type
  13894. (webssh-configuration (address "127.0.0.1")
  13895. (port 8888)
  13896. (policy 'reject)
  13897. (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
  13898. "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
  13899. (service nginx-service-type
  13900. (nginx-configuration
  13901. (server-blocks
  13902. (list
  13903. (nginx-server-configuration
  13904. (inherit %webssh-configuration-nginx)
  13905. (server-name '("webssh.example.com"))
  13906. (listen '("443 ssl"))
  13907. (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
  13908. (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
  13909. (locations
  13910. (cons (nginx-location-configuration
  13911. (uri "/.well-known")
  13912. (body '("root /var/www;")))
  13913. (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
  13914. @end lisp
  13915. @end deffn
  13916. @deftp {Data Type} webssh-configuration
  13917. Data type representing the configuration for @code{webssh-service}.
  13918. @table @asis
  13919. @item @code{package} (default: @var{webssh})
  13920. @code{webssh} package to use.
  13921. @item @code{user-name} (default: @var{"webssh"})
  13922. User name or user ID that file transfers to and from that module should take
  13923. place.
  13924. @item @code{group-name} (default: @var{"webssh"})
  13925. Group name or group ID that will be used when accessing the module.
  13926. @item @code{address} (default: @var{#f})
  13927. IP address on which @command{webssh} listens for incoming connections.
  13928. @item @code{port} (default: @var{8888})
  13929. TCP port on which @command{webssh} listens for incoming connections.
  13930. @item @code{policy} (default: @var{#f})
  13931. Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
  13932. @item @code{known-hosts} (default: @var{'()})
  13933. List of hosts which allowed for SSH connection from @command{webssh}.
  13934. @item @code{log-file} (default: @file{"/var/log/webssh.log"})
  13935. Name of the file where @command{webssh} writes its log file.
  13936. @item @code{log-level} (default: @var{#f})
  13937. Logging level.
  13938. @end table
  13939. @end deftp
  13940. @defvr {Scheme Variable} %facebook-host-aliases
  13941. This variable contains a string for use in @file{/etc/hosts}
  13942. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  13943. line contains a entry that maps a known server name of the Facebook
  13944. on-line service---e.g., @code{www.facebook.com}---to the local
  13945. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  13946. This variable is typically used in the @code{hosts-file} field of an
  13947. @code{operating-system} declaration (@pxref{operating-system Reference,
  13948. @file{/etc/hosts}}):
  13949. @lisp
  13950. (use-modules (gnu) (guix))
  13951. (operating-system
  13952. (host-name "mymachine")
  13953. ;; ...
  13954. (hosts-file
  13955. ;; Create a /etc/hosts file with aliases for "localhost"
  13956. ;; and "mymachine", as well as for Facebook servers.
  13957. (plain-file "hosts"
  13958. (string-append (local-host-aliases host-name)
  13959. %facebook-host-aliases))))
  13960. @end lisp
  13961. This mechanism can prevent programs running locally, such as Web
  13962. browsers, from accessing Facebook.
  13963. @end defvr
  13964. The @code{(gnu services avahi)} provides the following definition.
  13965. @defvr {Scheme Variable} avahi-service-type
  13966. This is the service that runs @command{avahi-daemon}, a system-wide
  13967. mDNS/DNS-SD responder that allows for service discovery and
  13968. ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
  13969. Its value must be an @code{avahi-configuration} record---see below.
  13970. This service extends the name service cache daemon (nscd) so that it can
  13971. resolve @code{.local} host names using
  13972. @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
  13973. Service Switch}, for information on host name resolution.
  13974. Additionally, add the @var{avahi} package to the system profile so that
  13975. commands such as @command{avahi-browse} are directly usable.
  13976. @end defvr
  13977. @deftp {Data Type} avahi-configuration
  13978. Data type representation the configuration for Avahi.
  13979. @table @asis
  13980. @item @code{host-name} (default: @code{#f})
  13981. If different from @code{#f}, use that as the host name to
  13982. publish for this machine; otherwise, use the machine's actual host name.
  13983. @item @code{publish?} (default: @code{#t})
  13984. When true, allow host names and services to be published (broadcast) over the
  13985. network.
  13986. @item @code{publish-workstation?} (default: @code{#t})
  13987. When true, @command{avahi-daemon} publishes the machine's host name and IP
  13988. address via mDNS on the local network. To view the host names published on
  13989. your local network, you can run:
  13990. @example
  13991. avahi-browse _workstation._tcp
  13992. @end example
  13993. @item @code{wide-area?} (default: @code{#f})
  13994. When true, DNS-SD over unicast DNS is enabled.
  13995. @item @code{ipv4?} (default: @code{#t})
  13996. @itemx @code{ipv6?} (default: @code{#t})
  13997. These fields determine whether to use IPv4/IPv6 sockets.
  13998. @item @code{domains-to-browse} (default: @code{'()})
  13999. This is a list of domains to browse.
  14000. @end table
  14001. @end deftp
  14002. @deffn {Scheme Variable} openvswitch-service-type
  14003. This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
  14004. service, whose value should be an @code{openvswitch-configuration}
  14005. object.
  14006. @end deffn
  14007. @deftp {Data Type} openvswitch-configuration
  14008. Data type representing the configuration of Open vSwitch, a multilayer
  14009. virtual switch which is designed to enable massive network automation
  14010. through programmatic extension.
  14011. @table @asis
  14012. @item @code{package} (default: @var{openvswitch})
  14013. Package object of the Open vSwitch.
  14014. @end table
  14015. @end deftp
  14016. @defvr {Scheme Variable} pagekite-service-type
  14017. This is the service type for the @uref{https://pagekite.net, PageKite} service,
  14018. a tunneling solution for making localhost servers publicly visible, even from
  14019. behind restrictive firewalls or NAT without forwarded ports. The value for
  14020. this service type is a @code{pagekite-configuration} record.
  14021. Here's an example exposing the local HTTP and SSH daemons:
  14022. @lisp
  14023. (service pagekite-service-type
  14024. (pagekite-configuration
  14025. (kites '("http:@@kitename:localhost:80:@@kitesecret"
  14026. "raw/22:@@kitename:localhost:22:@@kitesecret"))
  14027. (extra-file "/etc/pagekite.rc")))
  14028. @end lisp
  14029. @end defvr
  14030. @deftp {Data Type} pagekite-configuration
  14031. Data type representing the configuration of PageKite.
  14032. @table @asis
  14033. @item @code{package} (default: @var{pagekite})
  14034. Package object of PageKite.
  14035. @item @code{kitename} (default: @code{#f})
  14036. PageKite name for authenticating to the frontend server.
  14037. @item @code{kitesecret} (default: @code{#f})
  14038. Shared secret for authenticating to the frontend server. You should probably
  14039. put this inside @code{extra-file} instead.
  14040. @item @code{frontend} (default: @code{#f})
  14041. Connect to the named PageKite frontend server instead of the
  14042. @uref{https://pagekite.net,,pagekite.net} service.
  14043. @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
  14044. List of service kites to use. Exposes HTTP on port 80 by default. The format
  14045. is @code{proto:kitename:host:port:secret}.
  14046. @item @code{extra-file} (default: @code{#f})
  14047. Extra configuration file to read, which you are expected to create manually.
  14048. Use this to add additional options and manage shared secrets out-of-band.
  14049. @end table
  14050. @end deftp
  14051. @defvr {Scheme Variable} yggdrasil-service-type
  14052. The service type for connecting to the @uref{https://yggdrasil-network.github.io/,
  14053. Yggdrasil network}, an early-stage implementation of a fully end-to-end
  14054. encrypted IPv6 network.
  14055. @quotation
  14056. Yggdrasil provides name-independent routing with cryptographically generated
  14057. addresses. Static addressing means you can keep the same address as long as
  14058. you want, even if you move to a new location, or generate a new address (by
  14059. generating new keys) whenever you want.
  14060. @uref{https://yggdrasil-network.github.io/2018/07/28/addressing.html}
  14061. @end quotation
  14062. Pass it a value of @code{yggdrasil-configuration} to connect it to public
  14063. peers and/or local peers.
  14064. Here is an example using public peers and a static address. The static
  14065. signing and encryption keys are defined in @file{/etc/yggdrasil-private.conf}
  14066. (the default value for @code{config-file}).
  14067. @lisp
  14068. ;; part of the operating-system declaration
  14069. (service yggdrasil-service-type
  14070. (yggdrasil-configuration
  14071. (autoconf? #f) ;; use only the public peers
  14072. (json-config
  14073. ;; choose one from
  14074. ;; https://github.com/yggdrasil-network/public-peers
  14075. '((peers . #("tcp://1.2.3.4:1337"))))
  14076. ;; /etc/yggdrasil-private.conf is the default value for config-file
  14077. ))
  14078. @end lisp
  14079. @example
  14080. # sample content for /etc/yggdrasil-private.conf
  14081. @{
  14082. # Your public encryption key. Your peers may ask you for this to put
  14083. # into their AllowedEncryptionPublicKeys configuration.
  14084. EncryptionPublicKey: 378dc5...
  14085. # Your private encryption key. DO NOT share this with anyone!
  14086. EncryptionPrivateKey: 0777...
  14087. # Your public signing key. You should not ordinarily need to share
  14088. # this with anyone.
  14089. SigningPublicKey: e1664...
  14090. # Your private signing key. DO NOT share this with anyone!
  14091. SigningPrivateKey: 0589d...
  14092. @}
  14093. @end example
  14094. @end defvr
  14095. @deftp {Data Type} yggdrasil-configuration
  14096. Data type representing the configuration of Yggdrasil.
  14097. @table @asis
  14098. @item @code{package} (default: @code{yggdrasil})
  14099. Package object of Yggdrasil.
  14100. @item @code{json-config} (default: @code{'()})
  14101. Contents of @file{/etc/yggdrasil.conf}. Will be merged with
  14102. @file{/etc/yggdrasil-private.conf}. Note that these settings are stored in
  14103. the Guix store, which is readable to all users. @strong{Do not store your
  14104. private keys in it}. See the output of @code{yggdrasil -genconf} for a
  14105. quick overview of valid keys and their default values.
  14106. @item @code{autoconf?} (default: @code{#f})
  14107. Whether to use automatic mode. Enabling it makes Yggdrasil use adynamic IP
  14108. and peer with IPv6 neighbors.
  14109. @item @code{log-level} (default: @code{'info})
  14110. How much detail to include in logs. Use @code{'debug} for more detail.
  14111. @item @code{log-to} (default: @code{'stdout})
  14112. Where to send logs. By default, the service logs standard output to
  14113. @file{/var/log/yggdrasil.log}. The alternative is @code{'syslog}, which
  14114. sends output to the running syslog service.
  14115. @item @code{config-file} (default: @code{"/etc/yggdrasil-private.conf"})
  14116. What HJSON file to load sensitive data from. This is where private keys
  14117. should be stored, which are necessary to specify if you don't want a
  14118. randomized address after each restart. Use @code{#f} to disable. Options
  14119. defined in this file take precedence over @code{json-config}. Use the output
  14120. of @code{yggdrasil -genconf} as a starting point. To configure a static
  14121. address, delete everything except these options:
  14122. @itemize
  14123. @item @code{EncryptionPublicKey}
  14124. @item @code{EncryptionPrivateKey}
  14125. @item @code{SigningPublicKey}
  14126. @item @code{SigningPrivateKey}
  14127. @end itemize
  14128. @end table
  14129. @end deftp
  14130. @cindex keepalived
  14131. @deffn {Scheme Variable} keepalived-service-type
  14132. This is the type for the @uref{https://www.keepalived.org/, Keepalived}
  14133. routing software, @command{keepalived}. Its value must be an
  14134. @code{keepalived-configuration} record as in this example for master
  14135. machine:
  14136. @lisp
  14137. (service keepalived-service-type
  14138. (keepalived-configuration
  14139. (config-file (local-file "keepalived-master.conf"))))
  14140. @end lisp
  14141. where @file{keepalived-master.conf}:
  14142. @example
  14143. vrrp_instance my-group @{
  14144. state MASTER
  14145. interface enp9s0
  14146. virtual_router_id 100
  14147. priority 100
  14148. unicast_peer @{ 10.0.0.2 @}
  14149. virtual_ipaddress @{
  14150. 10.0.0.4/24
  14151. @}
  14152. @}
  14153. @end example
  14154. and for backup machine:
  14155. @lisp
  14156. (service keepalived-service-type
  14157. (keepalived-configuration
  14158. (config-file (local-file "keepalived-backup.conf"))))
  14159. @end lisp
  14160. where @file{keepalived-backup.conf}:
  14161. @example
  14162. vrrp_instance my-group @{
  14163. state BACKUP
  14164. interface enp9s0
  14165. virtual_router_id 100
  14166. priority 99
  14167. unicast_peer @{ 10.0.0.3 @}
  14168. virtual_ipaddress @{
  14169. 10.0.0.4/24
  14170. @}
  14171. @}
  14172. @end example
  14173. @end deffn
  14174. @node Unattended Upgrades
  14175. @subsection Unattended Upgrades
  14176. @cindex unattended upgrades
  14177. @cindex upgrades, unattended
  14178. Guix provides a service to perform @emph{unattended upgrades}:
  14179. periodically, the system automatically reconfigures itself from the
  14180. latest Guix. Guix System has several properties that make unattended
  14181. upgrades safe:
  14182. @itemize
  14183. @item
  14184. upgrades are transactional (either the upgrade succeeds or it fails, but
  14185. you cannot end up with an ``in-between'' system state);
  14186. @item
  14187. the upgrade log is kept---you can view it with @command{guix system
  14188. list-generations}---and you can roll back to any previous generation,
  14189. should the upgraded system fail to behave as intended;
  14190. @item
  14191. channel code is authenticated so you know you can only run genuine code
  14192. (@pxref{Channels});
  14193. @item
  14194. @command{guix system reconfigure} prevents downgrades, which makes it
  14195. immune to @dfn{downgrade attacks}.
  14196. @end itemize
  14197. To set up unattended upgrades, add an instance of
  14198. @code{unattended-upgrade-service-type} like the one below to the list of
  14199. your operating system services:
  14200. @lisp
  14201. (service unattended-upgrade-service-type)
  14202. @end lisp
  14203. The defaults above set up weekly upgrades: every Sunday at midnight.
  14204. You do not need to provide the operating system configuration file: it
  14205. uses @file{/run/current-system/configuration.scm}, which ensures it
  14206. always uses your latest configuration---@pxref{provenance-service-type},
  14207. for more information about this file.
  14208. There are several things that can be configured, in particular the
  14209. periodicity and services (daemons) to be restarted upon completion.
  14210. When the upgrade is successful, the service takes care of deleting
  14211. system generations older that some threshold, as per @command{guix
  14212. system delete-generations}. See the reference below for details.
  14213. To ensure that upgrades are actually happening, you can run
  14214. @command{guix system describe}. To investigate upgrade failures, visit
  14215. the unattended upgrade log file (see below).
  14216. @defvr {Scheme Variable} unattended-upgrade-service-type
  14217. This is the service type for unattended upgrades. It sets up an mcron
  14218. job (@pxref{Scheduled Job Execution}) that runs @command{guix system
  14219. reconfigure} from the latest version of the specified channels.
  14220. Its value must be a @code{unattended-upgrade-configuration} record (see
  14221. below).
  14222. @end defvr
  14223. @deftp {Data Type} unattended-upgrade-configuration
  14224. This data type represents the configuration of the unattended upgrade
  14225. service. The following fields are available:
  14226. @table @asis
  14227. @item @code{schedule} (default: @code{"30 01 * * 0"})
  14228. This is the schedule of upgrades, expressed as a gexp containing an
  14229. mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
  14230. mcron, GNU@tie{}mcron}).
  14231. @item @code{channels} (default: @code{#~%default-channels})
  14232. This gexp specifies the channels to use for the upgrade
  14233. (@pxref{Channels}). By default, the tip of the official @code{guix}
  14234. channel is used.
  14235. @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
  14236. This field specifies the operating system configuration file to use.
  14237. The default is to reuse the config file of the current configuration.
  14238. There are cases, though, where referring to
  14239. @file{/run/current-system/configuration.scm} is not enough, for instance
  14240. because that file refers to extra files (SSH public keys, extra
  14241. configuration files, etc.) @i{via} @code{local-file} and similar
  14242. constructs. For those cases, we recommend something along these lines:
  14243. @lisp
  14244. (unattended-upgrade-configuration
  14245. (operating-system-file
  14246. (file-append (local-file "." "config-dir" #:recursive? #t)
  14247. "/config.scm")))
  14248. @end lisp
  14249. The effect here is to import all of the current directory into the
  14250. store, and to refer to @file{config.scm} within that directory.
  14251. Therefore, uses of @code{local-file} within @file{config.scm} will work
  14252. as expected. @xref{G-Expressions}, for information about
  14253. @code{local-file} and @code{file-append}.
  14254. @item @code{services-to-restart} (default: @code{'(mcron)})
  14255. This field specifies the Shepherd services to restart when the upgrade
  14256. completes.
  14257. Those services are restarted right away upon completion, as with
  14258. @command{herd restart}, which ensures that the latest version is
  14259. running---remember that by default @command{guix system reconfigure}
  14260. only restarts services that are not currently running, which is
  14261. conservative: it minimizes disruption but leaves outdated services
  14262. running.
  14263. Use @command{herd status} to find out candidates for restarting.
  14264. @xref{Services}, for general information about services. Common
  14265. services to restart would include @code{ntpd} and @code{ssh-daemon}.
  14266. By default, the @code{mcron} service is restarted. This ensures that
  14267. the latest version of the unattended upgrade job will be used next time.
  14268. @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
  14269. This is the expiration time in seconds for system generations. System
  14270. generations older that this amount of time are deleted with
  14271. @command{guix system delete-generations} when an upgrade completes.
  14272. @quotation Note
  14273. The unattended upgrade service does not run the garbage collector. You
  14274. will probably want to set up your own mcron job to run @command{guix gc}
  14275. periodically.
  14276. @end quotation
  14277. @item @code{maximum-duration} (default: @code{3600})
  14278. Maximum duration in seconds for the upgrade; past that time, the upgrade
  14279. aborts.
  14280. This is primarily useful to ensure the upgrade does not end up
  14281. rebuilding or re-downloading ``the world''.
  14282. @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
  14283. File where unattended upgrades are logged.
  14284. @end table
  14285. @end deftp
  14286. @node X Window
  14287. @subsection X Window
  14288. @cindex X11
  14289. @cindex X Window System
  14290. @cindex login manager
  14291. Support for the X Window graphical display system---specifically
  14292. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  14293. there is no @code{xorg-service} procedure. Instead, the X server is
  14294. started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
  14295. @cindex GDM
  14296. @cindex GNOME, login manager
  14297. GDM of course allows users to log in into window managers and desktop
  14298. environments other than GNOME; for those using GNOME, GDM is required for
  14299. features such as automatic screen locking.
  14300. @cindex window manager
  14301. To use X11, you must install at least one @dfn{window manager}---for
  14302. example the @code{windowmaker} or @code{openbox} packages---preferably
  14303. by adding it to the @code{packages} field of your operating system
  14304. definition (@pxref{operating-system Reference, system-wide packages}).
  14305. @defvr {Scheme Variable} gdm-service-type
  14306. This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
  14307. Desktop Manager} (GDM), a program that manages graphical display servers and
  14308. handles graphical user logins. Its value must be a @code{gdm-configuration}
  14309. (see below).
  14310. @cindex session types (X11)
  14311. @cindex X11 session types
  14312. GDM looks for @dfn{session types} described by the @file{.desktop} files in
  14313. @file{/run/current-system/profile/share/xsessions} and allows users to choose
  14314. a session from the log-in screen. Packages such as @code{gnome}, @code{xfce},
  14315. and @code{i3} provide @file{.desktop} files; adding them to the system-wide
  14316. set of packages automatically makes them available at the log-in screen.
  14317. In addition, @file{~/.xsession} files are honored. When available,
  14318. @file{~/.xsession} must be an executable that starts a window manager
  14319. and/or other X clients.
  14320. @end defvr
  14321. @deftp {Data Type} gdm-configuration
  14322. @table @asis
  14323. @item @code{auto-login?} (default: @code{#f})
  14324. @itemx @code{default-user} (default: @code{#f})
  14325. When @code{auto-login?} is false, GDM presents a log-in screen.
  14326. When @code{auto-login?} is true, GDM logs in directly as
  14327. @code{default-user}.
  14328. @item @code{debug?} (default: @code{#f})
  14329. When true, GDM writes debug messages to its log.
  14330. @item @code{gnome-shell-assets} (default: ...)
  14331. List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
  14332. @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
  14333. Configuration of the Xorg graphical server.
  14334. @item @code{xsession} (default: @code{(xinitrc)})
  14335. Script to run before starting a X session.
  14336. @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
  14337. File name of the @code{dbus-daemon} executable.
  14338. @item @code{gdm} (default: @code{gdm})
  14339. The GDM package to use.
  14340. @end table
  14341. @end deftp
  14342. @defvr {Scheme Variable} slim-service-type
  14343. This is the type for the SLiM graphical login manager for X11.
  14344. Like GDM, SLiM looks for session types described by @file{.desktop} files and
  14345. allows users to choose a session from the log-in screen using @kbd{F1}. It
  14346. also honors @file{~/.xsession} files.
  14347. Unlike GDM, SLiM does not spawn the user session on a different VT after
  14348. logging in, which means that you can only start one graphical session. If you
  14349. want to be able to run multiple graphical sessions at the same time you have
  14350. to add multiple SLiM services to your system services. The following example
  14351. shows how to replace the default GDM service with two SLiM services on tty7
  14352. and tty8.
  14353. @lisp
  14354. (use-modules (gnu services)
  14355. (gnu services desktop)
  14356. (gnu services xorg)
  14357. (srfi srfi-1)) ;for 'remove'
  14358. (operating-system
  14359. ;; ...
  14360. (services (cons* (service slim-service-type (slim-configuration
  14361. (display ":0")
  14362. (vt "vt7")))
  14363. (service slim-service-type (slim-configuration
  14364. (display ":1")
  14365. (vt "vt8")))
  14366. (remove (lambda (service)
  14367. (eq? (service-kind service) gdm-service-type))
  14368. %desktop-services))))
  14369. @end lisp
  14370. @end defvr
  14371. @deftp {Data Type} slim-configuration
  14372. Data type representing the configuration of @code{slim-service-type}.
  14373. @table @asis
  14374. @item @code{allow-empty-passwords?} (default: @code{#t})
  14375. Whether to allow logins with empty passwords.
  14376. @item @code{auto-login?} (default: @code{#f})
  14377. @itemx @code{default-user} (default: @code{""})
  14378. When @code{auto-login?} is false, SLiM presents a log-in screen.
  14379. When @code{auto-login?} is true, SLiM logs in directly as
  14380. @code{default-user}.
  14381. @item @code{theme} (default: @code{%default-slim-theme})
  14382. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  14383. The graphical theme to use and its name.
  14384. @item @code{auto-login-session} (default: @code{#f})
  14385. If true, this must be the name of the executable to start as the default
  14386. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  14387. If false, a session described by one of the available @file{.desktop}
  14388. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  14389. will be used.
  14390. @quotation Note
  14391. You must install at least one window manager in the system profile or in
  14392. your user profile. Failing to do that, if @code{auto-login-session} is
  14393. false, you will be unable to log in.
  14394. @end quotation
  14395. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  14396. Configuration of the Xorg graphical server.
  14397. @item @code{display} (default @code{":0"})
  14398. The display on which to start the Xorg graphical server.
  14399. @item @code{vt} (default @code{"vt7"})
  14400. The VT on which to start the Xorg graphical server.
  14401. @item @code{xauth} (default: @code{xauth})
  14402. The XAuth package to use.
  14403. @item @code{shepherd} (default: @code{shepherd})
  14404. The Shepherd package used when invoking @command{halt} and
  14405. @command{reboot}.
  14406. @item @code{sessreg} (default: @code{sessreg})
  14407. The sessreg package used in order to register the session.
  14408. @item @code{slim} (default: @code{slim})
  14409. The SLiM package to use.
  14410. @end table
  14411. @end deftp
  14412. @defvr {Scheme Variable} %default-theme
  14413. @defvrx {Scheme Variable} %default-theme-name
  14414. The default SLiM theme and its name.
  14415. @end defvr
  14416. @deftp {Data Type} sddm-configuration
  14417. This is the data type representing the SDDM service configuration.
  14418. @table @asis
  14419. @item @code{display-server} (default: "x11")
  14420. Select display server to use for the greeter. Valid values are
  14421. @samp{"x11"} or @samp{"wayland"}.
  14422. @item @code{numlock} (default: "on")
  14423. Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
  14424. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  14425. Command to run when halting.
  14426. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  14427. Command to run when rebooting.
  14428. @item @code{theme} (default "maldives")
  14429. Theme to use. Default themes provided by SDDM are @samp{"elarun"},
  14430. @samp{"maldives"} or @samp{"maya"}.
  14431. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  14432. Directory to look for themes.
  14433. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  14434. Directory to look for faces.
  14435. @item @code{default-path} (default "/run/current-system/profile/bin")
  14436. Default PATH to use.
  14437. @item @code{minimum-uid} (default: 1000)
  14438. Minimum UID displayed in SDDM and allowed for log-in.
  14439. @item @code{maximum-uid} (default: 2000)
  14440. Maximum UID to display in SDDM.
  14441. @item @code{remember-last-user?} (default #t)
  14442. Remember last user.
  14443. @item @code{remember-last-session?} (default #t)
  14444. Remember last session.
  14445. @item @code{hide-users} (default "")
  14446. Usernames to hide from SDDM greeter.
  14447. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  14448. Users with shells listed will be hidden from the SDDM greeter.
  14449. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  14450. Script to run before starting a wayland session.
  14451. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  14452. Directory to look for desktop files starting wayland sessions.
  14453. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  14454. Configuration of the Xorg graphical server.
  14455. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  14456. Path to xauth.
  14457. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  14458. Path to Xephyr.
  14459. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  14460. Script to run after starting xorg-server.
  14461. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  14462. Script to run before stopping xorg-server.
  14463. @item @code{xsession-command} (default: @code{xinitrc})
  14464. Script to run before starting a X session.
  14465. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  14466. Directory to look for desktop files starting X sessions.
  14467. @item @code{minimum-vt} (default: 7)
  14468. Minimum VT to use.
  14469. @item @code{auto-login-user} (default "")
  14470. User to use for auto-login.
  14471. @item @code{auto-login-session} (default "")
  14472. Desktop file to use for auto-login.
  14473. @item @code{relogin?} (default #f)
  14474. Relogin after logout.
  14475. @end table
  14476. @end deftp
  14477. @cindex login manager
  14478. @cindex X11 login
  14479. @defvr {Scheme Variable} sddm-service-type
  14480. This is the type of the service to run the
  14481. @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
  14482. must be a @code{sddm-configuration} record (see below).
  14483. Here's an example use:
  14484. @lisp
  14485. (service sddm-service-type
  14486. (sddm-configuration
  14487. (auto-login-user "alice")
  14488. (auto-login-session "xfce.desktop")))
  14489. @end lisp
  14490. @end defvr
  14491. @deftp {Data Type} sddm-configuration
  14492. This data type represents the configuration of the SDDM login manager.
  14493. The available fields are:
  14494. @table @asis
  14495. @item @code{sddm} (default: @code{sddm})
  14496. The SDDM package to use.
  14497. @item @code{display-server} (default: @code{"x11"})
  14498. This must be either @code{"x11"} or @code{"wayland"}.
  14499. @c FIXME: Add more fields.
  14500. @item @code{auto-login-user} (default: @code{""})
  14501. If non-empty, this is the user account under which to log in
  14502. automatically.
  14503. @item @code{auto-login-session} (default: @code{""})
  14504. If non-empty, this is the @file{.desktop} file name to use as the
  14505. auto-login session.
  14506. @end table
  14507. @end deftp
  14508. @cindex Xorg, configuration
  14509. @deftp {Data Type} xorg-configuration
  14510. This data type represents the configuration of the Xorg graphical display
  14511. server. Note that there is no Xorg service; instead, the X server is started
  14512. by a ``display manager'' such as GDM, SDDM, and SLiM@. Thus, the configuration
  14513. of these display managers aggregates an @code{xorg-configuration} record.
  14514. @table @asis
  14515. @item @code{modules} (default: @code{%default-xorg-modules})
  14516. This is a list of @dfn{module packages} loaded by the Xorg
  14517. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  14518. @item @code{fonts} (default: @code{%default-xorg-fonts})
  14519. This is a list of font directories to add to the server's @dfn{font path}.
  14520. @item @code{drivers} (default: @code{'()})
  14521. This must be either the empty list, in which case Xorg chooses a graphics
  14522. driver automatically, or a list of driver names that will be tried in this
  14523. order---e.g., @code{("modesetting" "vesa")}.
  14524. @item @code{resolutions} (default: @code{'()})
  14525. When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
  14526. resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
  14527. 768) (640 480))}.
  14528. @cindex keyboard layout, for Xorg
  14529. @cindex keymap, for Xorg
  14530. @item @code{keyboard-layout} (default: @code{#f})
  14531. If this is @code{#f}, Xorg uses the default keyboard layout---usually US
  14532. English (``qwerty'') for a 105-key PC keyboard.
  14533. Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
  14534. layout in use when Xorg is running. @xref{Keyboard Layout}, for more
  14535. information on how to specify the keyboard layout.
  14536. @item @code{extra-config} (default: @code{'()})
  14537. This is a list of strings or objects appended to the configuration file. It
  14538. is used to pass extra text to be added verbatim to the configuration file.
  14539. @item @code{server} (default: @code{xorg-server})
  14540. This is the package providing the Xorg server.
  14541. @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
  14542. This is the list of command-line arguments to pass to the X server. The
  14543. default is @code{-nolisten tcp}.
  14544. @end table
  14545. @end deftp
  14546. @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
  14547. [@var{login-manager-service-type}]
  14548. Tell the log-in manager (of type @var{login-manager-service-type}) to use
  14549. @var{config}, an @code{<xorg-configuration>} record.
  14550. Since the Xorg configuration is embedded in the log-in manager's
  14551. configuration---e.g., @code{gdm-configuration}---this procedure provides a
  14552. shorthand to set the Xorg configuration.
  14553. @end deffn
  14554. @deffn {Scheme Procedure} xorg-start-command [@var{config}]
  14555. Return a @code{startx} script in which the modules, fonts, etc. specified
  14556. in @var{config}, are available. The result should be used in place of
  14557. @code{startx}.
  14558. Usually the X server is started by a login manager.
  14559. @end deffn
  14560. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
  14561. Add @var{package}, a package for a screen locker or screen saver whose
  14562. command is @var{program}, to the set of setuid programs and add a PAM entry
  14563. for it. For example:
  14564. @lisp
  14565. (screen-locker-service xlockmore "xlock")
  14566. @end lisp
  14567. makes the good ol' XlockMore usable.
  14568. @end deffn
  14569. @node Printing Services
  14570. @subsection Printing Services
  14571. @cindex printer support with CUPS
  14572. The @code{(gnu services cups)} module provides a Guix service definition
  14573. for the CUPS printing service. To add printer support to a Guix
  14574. system, add a @code{cups-service} to the operating system definition:
  14575. @deffn {Scheme Variable} cups-service-type
  14576. The service type for the CUPS print server. Its value should be a valid
  14577. CUPS configuration (see below). To use the default settings, simply
  14578. write:
  14579. @lisp
  14580. (service cups-service-type)
  14581. @end lisp
  14582. @end deffn
  14583. The CUPS configuration controls the basic things about your CUPS
  14584. installation: what interfaces it listens on, what to do if a print job
  14585. fails, how much logging to do, and so on. To actually add a printer,
  14586. you have to visit the @url{http://localhost:631} URL, or use a tool such
  14587. as GNOME's printer configuration services. By default, configuring a
  14588. CUPS service will generate a self-signed certificate if needed, for
  14589. secure connections to the print server.
  14590. Suppose you want to enable the Web interface of CUPS and also add
  14591. support for Epson printers @i{via} the @code{epson-inkjet-printer-escpr}
  14592. package and for HP printers @i{via} the @code{hplip-minimal} package.
  14593. You can do that directly, like this (you need to use the
  14594. @code{(gnu packages cups)} module):
  14595. @lisp
  14596. (service cups-service-type
  14597. (cups-configuration
  14598. (web-interface? #t)
  14599. (extensions
  14600. (list cups-filters epson-inkjet-printer-escpr hplip-minimal))))
  14601. @end lisp
  14602. Note: If you wish to use the Qt5 based GUI which comes with the hplip
  14603. package then it is suggested that you install the @code{hplip} package,
  14604. either in your OS configuration file or as your user.
  14605. The available configuration parameters follow. Each parameter
  14606. definition is preceded by its type; for example, @samp{string-list foo}
  14607. indicates that the @code{foo} parameter should be specified as a list of
  14608. strings. There is also a way to specify the configuration as a string,
  14609. if you have an old @code{cupsd.conf} file that you want to port over
  14610. from some other system; see the end for more details.
  14611. @c The following documentation was initially generated by
  14612. @c (generate-documentation) in (gnu services cups). Manually maintained
  14613. @c documentation is better, so we shouldn't hesitate to edit below as
  14614. @c needed. However if the change you want to make to this documentation
  14615. @c can be done in an automated way, it's probably easier to change
  14616. @c (generate-documentation) than to make it below and have to deal with
  14617. @c the churn as CUPS updates.
  14618. Available @code{cups-configuration} fields are:
  14619. @deftypevr {@code{cups-configuration} parameter} package cups
  14620. The CUPS package.
  14621. @end deftypevr
  14622. @deftypevr {@code{cups-configuration} parameter} package-list extensions (default: @code{(list brlaser cups-filters epson-inkjet-printer-escpr foomatic-filters hplip-minimal splix)})
  14623. Drivers and other extensions to the CUPS package.
  14624. @end deftypevr
  14625. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  14626. Configuration of where to write logs, what directories to use for print
  14627. spools, and related privileged configuration parameters.
  14628. Available @code{files-configuration} fields are:
  14629. @deftypevr {@code{files-configuration} parameter} log-location access-log
  14630. Defines the access log filename. Specifying a blank filename disables
  14631. access log generation. The value @code{stderr} causes log entries to be
  14632. sent to the standard error file when the scheduler is running in the
  14633. foreground, or to the system log daemon when run in the background. The
  14634. value @code{syslog} causes log entries to be sent to the system log
  14635. daemon. The server name may be included in filenames using the string
  14636. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  14637. Defaults to @samp{"/var/log/cups/access_log"}.
  14638. @end deftypevr
  14639. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  14640. Where CUPS should cache data.
  14641. Defaults to @samp{"/var/cache/cups"}.
  14642. @end deftypevr
  14643. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  14644. Specifies the permissions for all configuration files that the scheduler
  14645. writes.
  14646. Note that the permissions for the printers.conf file are currently
  14647. masked to only allow access from the scheduler user (typically root).
  14648. This is done because printer device URIs sometimes contain sensitive
  14649. authentication information that should not be generally known on the
  14650. system. There is no way to disable this security feature.
  14651. Defaults to @samp{"0640"}.
  14652. @end deftypevr
  14653. @deftypevr {@code{files-configuration} parameter} log-location error-log
  14654. Defines the error log filename. Specifying a blank filename disables
  14655. error log generation. The value @code{stderr} causes log entries to be
  14656. sent to the standard error file when the scheduler is running in the
  14657. foreground, or to the system log daemon when run in the background. The
  14658. value @code{syslog} causes log entries to be sent to the system log
  14659. daemon. The server name may be included in filenames using the string
  14660. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  14661. Defaults to @samp{"/var/log/cups/error_log"}.
  14662. @end deftypevr
  14663. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  14664. Specifies which errors are fatal, causing the scheduler to exit. The
  14665. kind strings are:
  14666. @table @code
  14667. @item none
  14668. No errors are fatal.
  14669. @item all
  14670. All of the errors below are fatal.
  14671. @item browse
  14672. Browsing initialization errors are fatal, for example failed connections
  14673. to the DNS-SD daemon.
  14674. @item config
  14675. Configuration file syntax errors are fatal.
  14676. @item listen
  14677. Listen or Port errors are fatal, except for IPv6 failures on the
  14678. loopback or @code{any} addresses.
  14679. @item log
  14680. Log file creation or write errors are fatal.
  14681. @item permissions
  14682. Bad startup file permissions are fatal, for example shared TLS
  14683. certificate and key files with world-read permissions.
  14684. @end table
  14685. Defaults to @samp{"all -browse"}.
  14686. @end deftypevr
  14687. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  14688. Specifies whether the file pseudo-device can be used for new printer
  14689. queues. The URI @uref{file:///dev/null} is always allowed.
  14690. Defaults to @samp{#f}.
  14691. @end deftypevr
  14692. @deftypevr {@code{files-configuration} parameter} string group
  14693. Specifies the group name or ID that will be used when executing external
  14694. programs.
  14695. Defaults to @samp{"lp"}.
  14696. @end deftypevr
  14697. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  14698. Specifies the permissions for all log files that the scheduler writes.
  14699. Defaults to @samp{"0644"}.
  14700. @end deftypevr
  14701. @deftypevr {@code{files-configuration} parameter} log-location page-log
  14702. Defines the page log filename. Specifying a blank filename disables
  14703. page log generation. The value @code{stderr} causes log entries to be
  14704. sent to the standard error file when the scheduler is running in the
  14705. foreground, or to the system log daemon when run in the background. The
  14706. value @code{syslog} causes log entries to be sent to the system log
  14707. daemon. The server name may be included in filenames using the string
  14708. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  14709. Defaults to @samp{"/var/log/cups/page_log"}.
  14710. @end deftypevr
  14711. @deftypevr {@code{files-configuration} parameter} string remote-root
  14712. Specifies the username that is associated with unauthenticated accesses
  14713. by clients claiming to be the root user. The default is @code{remroot}.
  14714. Defaults to @samp{"remroot"}.
  14715. @end deftypevr
  14716. @deftypevr {@code{files-configuration} parameter} file-name request-root
  14717. Specifies the directory that contains print jobs and other HTTP request
  14718. data.
  14719. Defaults to @samp{"/var/spool/cups"}.
  14720. @end deftypevr
  14721. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  14722. Specifies the level of security sandboxing that is applied to print
  14723. filters, backends, and other child processes of the scheduler; either
  14724. @code{relaxed} or @code{strict}. This directive is currently only
  14725. used/supported on macOS.
  14726. Defaults to @samp{strict}.
  14727. @end deftypevr
  14728. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  14729. Specifies the location of TLS certificates and private keys. CUPS will
  14730. look for public and private keys in this directory: @file{.crt} files
  14731. for PEM-encoded certificates and corresponding @file{.key} files for
  14732. PEM-encoded private keys.
  14733. Defaults to @samp{"/etc/cups/ssl"}.
  14734. @end deftypevr
  14735. @deftypevr {@code{files-configuration} parameter} file-name server-root
  14736. Specifies the directory containing the server configuration files.
  14737. Defaults to @samp{"/etc/cups"}.
  14738. @end deftypevr
  14739. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  14740. Specifies whether the scheduler calls fsync(2) after writing
  14741. configuration or state files.
  14742. Defaults to @samp{#f}.
  14743. @end deftypevr
  14744. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  14745. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  14746. @end deftypevr
  14747. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  14748. Specifies the directory where temporary files are stored.
  14749. Defaults to @samp{"/var/spool/cups/tmp"}.
  14750. @end deftypevr
  14751. @deftypevr {@code{files-configuration} parameter} string user
  14752. Specifies the user name or ID that is used when running external
  14753. programs.
  14754. Defaults to @samp{"lp"}.
  14755. @end deftypevr
  14756. @deftypevr {@code{files-configuration} parameter} string set-env
  14757. Set the specified environment variable to be passed to child processes.
  14758. Defaults to @samp{"variable value"}.
  14759. @end deftypevr
  14760. @end deftypevr
  14761. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  14762. Specifies the logging level for the AccessLog file. The @code{config}
  14763. level logs when printers and classes are added, deleted, or modified and
  14764. when configuration files are accessed or updated. The @code{actions}
  14765. level logs when print jobs are submitted, held, released, modified, or
  14766. canceled, and any of the conditions for @code{config}. The @code{all}
  14767. level logs all requests.
  14768. Defaults to @samp{actions}.
  14769. @end deftypevr
  14770. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  14771. Specifies whether to purge job history data automatically when it is no
  14772. longer required for quotas.
  14773. Defaults to @samp{#f}.
  14774. @end deftypevr
  14775. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
  14776. Specifies a list of DNS-SD sub-types to advertise for each shared printer.
  14777. For example, @samp{"_cups" "_print"} will tell network clients that both
  14778. CUPS sharing and IPP Everywhere are supported.
  14779. Defaults to @samp{"_cups"}.
  14780. @end deftypevr
  14781. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  14782. Specifies which protocols to use for local printer sharing.
  14783. Defaults to @samp{dnssd}.
  14784. @end deftypevr
  14785. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  14786. Specifies whether the CUPS web interface is advertised.
  14787. Defaults to @samp{#f}.
  14788. @end deftypevr
  14789. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  14790. Specifies whether shared printers are advertised.
  14791. Defaults to @samp{#f}.
  14792. @end deftypevr
  14793. @deftypevr {@code{cups-configuration} parameter} string classification
  14794. Specifies the security classification of the server. Any valid banner
  14795. name can be used, including @samp{"classified"}, @samp{"confidential"},
  14796. @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
  14797. banner can be omitted to disable secure printing functions.
  14798. Defaults to @samp{""}.
  14799. @end deftypevr
  14800. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  14801. Specifies whether users may override the classification (cover page) of
  14802. individual print jobs using the @code{job-sheets} option.
  14803. Defaults to @samp{#f}.
  14804. @end deftypevr
  14805. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  14806. Specifies the default type of authentication to use.
  14807. Defaults to @samp{Basic}.
  14808. @end deftypevr
  14809. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  14810. Specifies whether encryption will be used for authenticated requests.
  14811. Defaults to @samp{Required}.
  14812. @end deftypevr
  14813. @deftypevr {@code{cups-configuration} parameter} string default-language
  14814. Specifies the default language to use for text and web content.
  14815. Defaults to @samp{"en"}.
  14816. @end deftypevr
  14817. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  14818. Specifies the default paper size for new print queues. @samp{"Auto"}
  14819. uses a locale-specific default, while @samp{"None"} specifies there is
  14820. no default paper size. Specific size names are typically
  14821. @samp{"Letter"} or @samp{"A4"}.
  14822. Defaults to @samp{"Auto"}.
  14823. @end deftypevr
  14824. @deftypevr {@code{cups-configuration} parameter} string default-policy
  14825. Specifies the default access policy to use.
  14826. Defaults to @samp{"default"}.
  14827. @end deftypevr
  14828. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  14829. Specifies whether local printers are shared by default.
  14830. Defaults to @samp{#t}.
  14831. @end deftypevr
  14832. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  14833. Specifies the delay for updating of configuration and state files, in
  14834. seconds. A value of 0 causes the update to happen as soon as possible,
  14835. typically within a few milliseconds.
  14836. Defaults to @samp{30}.
  14837. @end deftypevr
  14838. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  14839. Specifies what to do when an error occurs. Possible values are
  14840. @code{abort-job}, which will discard the failed print job;
  14841. @code{retry-job}, which will retry the job at a later time;
  14842. @code{retry-current-job}, which retries the failed job immediately; and
  14843. @code{stop-printer}, which stops the printer.
  14844. Defaults to @samp{stop-printer}.
  14845. @end deftypevr
  14846. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  14847. Specifies the maximum cost of filters that are run concurrently, which
  14848. can be used to minimize disk, memory, and CPU resource problems. A
  14849. limit of 0 disables filter limiting. An average print to a
  14850. non-PostScript printer needs a filter limit of about 200. A PostScript
  14851. printer needs about half that (100). Setting the limit below these
  14852. thresholds will effectively limit the scheduler to printing a single job
  14853. at any time.
  14854. Defaults to @samp{0}.
  14855. @end deftypevr
  14856. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  14857. Specifies the scheduling priority of filters that are run to print a
  14858. job. The nice value ranges from 0, the highest priority, to 19, the
  14859. lowest priority.
  14860. Defaults to @samp{0}.
  14861. @end deftypevr
  14862. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  14863. Specifies whether to do reverse lookups on connecting clients. The
  14864. @code{double} setting causes @code{cupsd} to verify that the hostname
  14865. resolved from the address matches one of the addresses returned for that
  14866. hostname. Double lookups also prevent clients with unregistered
  14867. addresses from connecting to your server. Only set this option to
  14868. @code{#t} or @code{double} if absolutely required.
  14869. Defaults to @samp{#f}.
  14870. @end deftypevr
  14871. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  14872. Specifies the number of seconds to wait before killing the filters and
  14873. backend associated with a canceled or held job.
  14874. Defaults to @samp{30}.
  14875. @end deftypevr
  14876. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  14877. Specifies the interval between retries of jobs in seconds. This is
  14878. typically used for fax queues but can also be used with normal print
  14879. queues whose error policy is @code{retry-job} or
  14880. @code{retry-current-job}.
  14881. Defaults to @samp{30}.
  14882. @end deftypevr
  14883. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  14884. Specifies the number of retries that are done for jobs. This is
  14885. typically used for fax queues but can also be used with normal print
  14886. queues whose error policy is @code{retry-job} or
  14887. @code{retry-current-job}.
  14888. Defaults to @samp{5}.
  14889. @end deftypevr
  14890. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  14891. Specifies whether to support HTTP keep-alive connections.
  14892. Defaults to @samp{#t}.
  14893. @end deftypevr
  14894. @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
  14895. Specifies how long an idle client connection remains open, in seconds.
  14896. Defaults to @samp{30}.
  14897. @end deftypevr
  14898. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  14899. Specifies the maximum size of print files, IPP requests, and HTML form
  14900. data. A limit of 0 disables the limit check.
  14901. Defaults to @samp{0}.
  14902. @end deftypevr
  14903. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  14904. Listens on the specified interfaces for connections. Valid values are
  14905. of the form @var{address}:@var{port}, where @var{address} is either an
  14906. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  14907. indicate all addresses. Values can also be file names of local UNIX
  14908. domain sockets. The Listen directive is similar to the Port directive
  14909. but allows you to restrict access to specific interfaces or networks.
  14910. @end deftypevr
  14911. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  14912. Specifies the number of pending connections that will be allowed. This
  14913. normally only affects very busy servers that have reached the MaxClients
  14914. limit, but can also be triggered by large numbers of simultaneous
  14915. connections. When the limit is reached, the operating system will
  14916. refuse additional connections until the scheduler can accept the pending
  14917. ones.
  14918. Defaults to @samp{128}.
  14919. @end deftypevr
  14920. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  14921. Specifies a set of additional access controls.
  14922. Available @code{location-access-controls} fields are:
  14923. @deftypevr {@code{location-access-controls} parameter} file-name path
  14924. Specifies the URI path to which the access control applies.
  14925. @end deftypevr
  14926. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  14927. Access controls for all access to this path, in the same format as the
  14928. @code{access-controls} of @code{operation-access-control}.
  14929. Defaults to @samp{()}.
  14930. @end deftypevr
  14931. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  14932. Access controls for method-specific access to this path.
  14933. Defaults to @samp{()}.
  14934. Available @code{method-access-controls} fields are:
  14935. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  14936. If @code{#t}, apply access controls to all methods except the listed
  14937. methods. Otherwise apply to only the listed methods.
  14938. Defaults to @samp{#f}.
  14939. @end deftypevr
  14940. @deftypevr {@code{method-access-controls} parameter} method-list methods
  14941. Methods to which this access control applies.
  14942. Defaults to @samp{()}.
  14943. @end deftypevr
  14944. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  14945. Access control directives, as a list of strings. Each string should be
  14946. one directive, such as @samp{"Order allow,deny"}.
  14947. Defaults to @samp{()}.
  14948. @end deftypevr
  14949. @end deftypevr
  14950. @end deftypevr
  14951. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  14952. Specifies the number of debugging messages that are retained for logging
  14953. if an error occurs in a print job. Debug messages are logged regardless
  14954. of the LogLevel setting.
  14955. Defaults to @samp{100}.
  14956. @end deftypevr
  14957. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  14958. Specifies the level of logging for the ErrorLog file. The value
  14959. @code{none} stops all logging while @code{debug2} logs everything.
  14960. Defaults to @samp{info}.
  14961. @end deftypevr
  14962. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  14963. Specifies the format of the date and time in the log files. The value
  14964. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  14965. Defaults to @samp{standard}.
  14966. @end deftypevr
  14967. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  14968. Specifies the maximum number of simultaneous clients that are allowed by
  14969. the scheduler.
  14970. Defaults to @samp{100}.
  14971. @end deftypevr
  14972. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  14973. Specifies the maximum number of simultaneous clients that are allowed
  14974. from a single address.
  14975. Defaults to @samp{100}.
  14976. @end deftypevr
  14977. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  14978. Specifies the maximum number of copies that a user can print of each
  14979. job.
  14980. Defaults to @samp{9999}.
  14981. @end deftypevr
  14982. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  14983. Specifies the maximum time a job may remain in the @code{indefinite}
  14984. hold state before it is canceled. A value of 0 disables cancellation of
  14985. held jobs.
  14986. Defaults to @samp{0}.
  14987. @end deftypevr
  14988. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  14989. Specifies the maximum number of simultaneous jobs that are allowed. Set
  14990. to 0 to allow an unlimited number of jobs.
  14991. Defaults to @samp{500}.
  14992. @end deftypevr
  14993. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  14994. Specifies the maximum number of simultaneous jobs that are allowed per
  14995. printer. A value of 0 allows up to MaxJobs jobs per printer.
  14996. Defaults to @samp{0}.
  14997. @end deftypevr
  14998. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  14999. Specifies the maximum number of simultaneous jobs that are allowed per
  15000. user. A value of 0 allows up to MaxJobs jobs per user.
  15001. Defaults to @samp{0}.
  15002. @end deftypevr
  15003. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  15004. Specifies the maximum time a job may take to print before it is
  15005. canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
  15006. Defaults to @samp{10800}.
  15007. @end deftypevr
  15008. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  15009. Specifies the maximum size of the log files before they are rotated, in
  15010. bytes. The value 0 disables log rotation.
  15011. Defaults to @samp{1048576}.
  15012. @end deftypevr
  15013. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  15014. Specifies the maximum amount of time to allow between files in a
  15015. multiple file print job, in seconds.
  15016. Defaults to @samp{300}.
  15017. @end deftypevr
  15018. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  15019. Specifies the format of PageLog lines. Sequences beginning with percent
  15020. (@samp{%}) characters are replaced with the corresponding information,
  15021. while all other characters are copied literally. The following percent
  15022. sequences are recognized:
  15023. @table @samp
  15024. @item %%
  15025. insert a single percent character
  15026. @item %@{name@}
  15027. insert the value of the specified IPP attribute
  15028. @item %C
  15029. insert the number of copies for the current page
  15030. @item %P
  15031. insert the current page number
  15032. @item %T
  15033. insert the current date and time in common log format
  15034. @item %j
  15035. insert the job ID
  15036. @item %p
  15037. insert the printer name
  15038. @item %u
  15039. insert the username
  15040. @end table
  15041. A value of the empty string disables page logging. The string @code{%p
  15042. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  15043. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  15044. standard items.
  15045. Defaults to @samp{""}.
  15046. @end deftypevr
  15047. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  15048. Passes the specified environment variable(s) to child processes; a list
  15049. of strings.
  15050. Defaults to @samp{()}.
  15051. @end deftypevr
  15052. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  15053. Specifies named access control policies.
  15054. Available @code{policy-configuration} fields are:
  15055. @deftypevr {@code{policy-configuration} parameter} string name
  15056. Name of the policy.
  15057. @end deftypevr
  15058. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  15059. Specifies an access list for a job's private values. @code{@@ACL} maps
  15060. to the printer's requesting-user-name-allowed or
  15061. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  15062. owner. @code{@@SYSTEM} maps to the groups listed for the
  15063. @code{system-group} field of the @code{files-config} configuration,
  15064. which is reified into the @code{cups-files.conf(5)} file. Other
  15065. possible elements of the access list include specific user names, and
  15066. @code{@@@var{group}} to indicate members of a specific group. The
  15067. access list may also be simply @code{all} or @code{default}.
  15068. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  15069. @end deftypevr
  15070. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  15071. Specifies the list of job values to make private, or @code{all},
  15072. @code{default}, or @code{none}.
  15073. Defaults to @samp{"job-name job-originating-host-name
  15074. job-originating-user-name phone"}.
  15075. @end deftypevr
  15076. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  15077. Specifies an access list for a subscription's private values.
  15078. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  15079. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  15080. owner. @code{@@SYSTEM} maps to the groups listed for the
  15081. @code{system-group} field of the @code{files-config} configuration,
  15082. which is reified into the @code{cups-files.conf(5)} file. Other
  15083. possible elements of the access list include specific user names, and
  15084. @code{@@@var{group}} to indicate members of a specific group. The
  15085. access list may also be simply @code{all} or @code{default}.
  15086. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  15087. @end deftypevr
  15088. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  15089. Specifies the list of job values to make private, or @code{all},
  15090. @code{default}, or @code{none}.
  15091. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  15092. notify-subscriber-user-name notify-user-data"}.
  15093. @end deftypevr
  15094. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  15095. Access control by IPP operation.
  15096. Defaults to @samp{()}.
  15097. @end deftypevr
  15098. @end deftypevr
  15099. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  15100. Specifies whether job files (documents) are preserved after a job is
  15101. printed. If a numeric value is specified, job files are preserved for
  15102. the indicated number of seconds after printing. Otherwise a boolean
  15103. value applies indefinitely.
  15104. Defaults to @samp{86400}.
  15105. @end deftypevr
  15106. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  15107. Specifies whether the job history is preserved after a job is printed.
  15108. If a numeric value is specified, the job history is preserved for the
  15109. indicated number of seconds after printing. If @code{#t}, the job
  15110. history is preserved until the MaxJobs limit is reached.
  15111. Defaults to @samp{#t}.
  15112. @end deftypevr
  15113. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  15114. Specifies the amount of time to wait for job completion before
  15115. restarting the scheduler.
  15116. Defaults to @samp{30}.
  15117. @end deftypevr
  15118. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  15119. Specifies the maximum amount of memory to use when converting documents
  15120. into bitmaps for a printer.
  15121. Defaults to @samp{"128m"}.
  15122. @end deftypevr
  15123. @deftypevr {@code{cups-configuration} parameter} string server-admin
  15124. Specifies the email address of the server administrator.
  15125. Defaults to @samp{"root@@localhost.localdomain"}.
  15126. @end deftypevr
  15127. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  15128. The ServerAlias directive is used for HTTP Host header validation when
  15129. clients connect to the scheduler from external interfaces. Using the
  15130. special name @code{*} can expose your system to known browser-based DNS
  15131. rebinding attacks, even when accessing sites through a firewall. If the
  15132. auto-discovery of alternate names does not work, we recommend listing
  15133. each alternate name with a ServerAlias directive instead of using
  15134. @code{*}.
  15135. Defaults to @samp{*}.
  15136. @end deftypevr
  15137. @deftypevr {@code{cups-configuration} parameter} string server-name
  15138. Specifies the fully-qualified host name of the server.
  15139. Defaults to @samp{"localhost"}.
  15140. @end deftypevr
  15141. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  15142. Specifies what information is included in the Server header of HTTP
  15143. responses. @code{None} disables the Server header. @code{ProductOnly}
  15144. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  15145. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  15146. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  15147. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  15148. 2.0.0 (@var{uname}) IPP/2.0}.
  15149. Defaults to @samp{Minimal}.
  15150. @end deftypevr
  15151. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  15152. Listens on the specified interfaces for encrypted connections. Valid
  15153. values are of the form @var{address}:@var{port}, where @var{address} is
  15154. either an IPv6 address enclosed in brackets, an IPv4 address, or
  15155. @code{*} to indicate all addresses.
  15156. Defaults to @samp{()}.
  15157. @end deftypevr
  15158. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  15159. Sets encryption options. By default, CUPS only supports encryption
  15160. using TLS v1.0 or higher using known secure cipher suites. Security is
  15161. reduced when @code{Allow} options are used, and enhanced when @code{Deny}
  15162. options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
  15163. suites, which are required for some older clients. The @code{AllowSSL3} option
  15164. enables SSL v3.0, which is required for some older clients that do not support
  15165. TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
  15166. @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
  15167. protocol version to TLS v1.1.
  15168. Defaults to @samp{()}.
  15169. @end deftypevr
  15170. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  15171. Specifies whether the scheduler requires clients to strictly adhere to
  15172. the IPP specifications.
  15173. Defaults to @samp{#f}.
  15174. @end deftypevr
  15175. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  15176. Specifies the HTTP request timeout, in seconds.
  15177. Defaults to @samp{300}.
  15178. @end deftypevr
  15179. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  15180. Specifies whether the web interface is enabled.
  15181. Defaults to @samp{#f}.
  15182. @end deftypevr
  15183. At this point you're probably thinking ``oh dear, Guix manual, I like
  15184. you but you can stop already with the configuration options''. Indeed.
  15185. However, one more point: it could be that you have an existing
  15186. @code{cupsd.conf} that you want to use. In that case, you can pass an
  15187. @code{opaque-cups-configuration} as the configuration of a
  15188. @code{cups-service-type}.
  15189. Available @code{opaque-cups-configuration} fields are:
  15190. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  15191. The CUPS package.
  15192. @end deftypevr
  15193. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  15194. The contents of the @code{cupsd.conf}, as a string.
  15195. @end deftypevr
  15196. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  15197. The contents of the @code{cups-files.conf} file, as a string.
  15198. @end deftypevr
  15199. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  15200. strings of the same name, you could instantiate a CUPS service like
  15201. this:
  15202. @lisp
  15203. (service cups-service-type
  15204. (opaque-cups-configuration
  15205. (cupsd.conf cupsd.conf)
  15206. (cups-files.conf cups-files.conf)))
  15207. @end lisp
  15208. @node Desktop Services
  15209. @subsection Desktop Services
  15210. The @code{(gnu services desktop)} module provides services that are
  15211. usually useful in the context of a ``desktop'' setup---that is, on a
  15212. machine running a graphical display server, possibly with graphical user
  15213. interfaces, etc. It also defines services that provide specific desktop
  15214. environments like GNOME, Xfce or MATE.
  15215. To simplify things, the module defines a variable containing the set of
  15216. services that users typically expect on a machine with a graphical
  15217. environment and networking:
  15218. @defvr {Scheme Variable} %desktop-services
  15219. This is a list of services that builds upon @code{%base-services} and
  15220. adds or adjusts services for a typical ``desktop'' setup.
  15221. In particular, it adds a graphical login manager (@pxref{X Window,
  15222. @code{gdm-service-type}}), screen lockers, a network management tool
  15223. (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
  15224. support (@pxref{Networking Services, @code{modem-manager-service-type}}),
  15225. energy and color management services, the @code{elogind} login and seat
  15226. manager, the Polkit privilege service, the GeoClue location service, the
  15227. AccountsService daemon that allows authorized users change system passwords,
  15228. an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
  15229. name service switch service configured to be able to use @code{nss-mdns}
  15230. (@pxref{Name Service Switch, mDNS}).
  15231. @end defvr
  15232. The @code{%desktop-services} variable can be used as the @code{services}
  15233. field of an @code{operating-system} declaration (@pxref{operating-system
  15234. Reference, @code{services}}).
  15235. Additionally, the @code{gnome-desktop-service-type},
  15236. @code{xfce-desktop-service}, @code{mate-desktop-service-type},
  15237. @code{lxqt-desktop-service-type} and @code{enlightenment-desktop-service-type}
  15238. procedures can add GNOME, Xfce, MATE and/or Enlightenment to a system. To
  15239. ``add GNOME'' means that system-level services like the backlight adjustment
  15240. helpers and the power management utilities are added to the system, extending
  15241. @code{polkit} and @code{dbus} appropriately, allowing GNOME to operate with
  15242. elevated privileges on a limited number of special-purpose system interfaces.
  15243. Additionally, adding a service made by @code{gnome-desktop-service-type} adds
  15244. the GNOME metapackage to the system profile. Likewise, adding the Xfce
  15245. service not only adds the @code{xfce} metapackage to the system profile, but
  15246. it also gives the Thunar file manager the ability to open a ``root-mode'' file
  15247. management window, if the user authenticates using the administrator's
  15248. password via the standard polkit graphical interface. To ``add MATE'' means
  15249. that @code{polkit} and @code{dbus} are extended appropriately, allowing MATE
  15250. to operate with elevated privileges on a limited number of special-purpose
  15251. system interfaces. Additionally, adding a service of type
  15252. @code{mate-desktop-service-type} adds the MATE metapackage to the system
  15253. profile. ``Adding Enlightenment'' means that @code{dbus} is extended
  15254. appropriately, and several of Enlightenment's binaries are set as setuid,
  15255. allowing Enlightenment's screen locker and other functionality to work as
  15256. expected.
  15257. The desktop environments in Guix use the Xorg display server by
  15258. default. If you'd like to use the newer display server protocol
  15259. called Wayland, you need to use the @code{sddm-service} instead of
  15260. GDM as the graphical login manager. You should then
  15261. select the ``GNOME (Wayland)'' session in SDDM@. Alternatively you can
  15262. also try starting GNOME on Wayland manually from a TTY with the
  15263. command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  15264. gnome-session``. Currently only GNOME has support for Wayland.
  15265. @defvr {Scheme Variable} gnome-desktop-service-type
  15266. This is the type of the service that adds the @uref{https://www.gnome.org,
  15267. GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
  15268. object (see below).
  15269. This service adds the @code{gnome} package to the system profile, and extends
  15270. polkit with the actions from @code{gnome-settings-daemon}.
  15271. @end defvr
  15272. @deftp {Data Type} gnome-desktop-configuration
  15273. Configuration record for the GNOME desktop environment.
  15274. @table @asis
  15275. @item @code{gnome} (default: @code{gnome})
  15276. The GNOME package to use.
  15277. @end table
  15278. @end deftp
  15279. @defvr {Scheme Variable} xfce-desktop-service-type
  15280. This is the type of a service to run the @uref{Xfce, https://xfce.org/}
  15281. desktop environment. Its value is an @code{xfce-desktop-configuration} object
  15282. (see below).
  15283. This service adds the @code{xfce} package to the system profile, and
  15284. extends polkit with the ability for @code{thunar} to manipulate the file
  15285. system as root from within a user session, after the user has authenticated
  15286. with the administrator's password.
  15287. Note that @code{xfce4-panel} and its plugin packages should be installed in
  15288. the same profile to ensure compatibility. When using this service, you should
  15289. add extra plugins (@code{xfce4-whiskermenu-plugin},
  15290. @code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your
  15291. @code{operating-system}.
  15292. @end defvr
  15293. @deftp {Data Type} xfce-desktop-configuration
  15294. Configuration record for the Xfce desktop environment.
  15295. @table @asis
  15296. @item @code{xfce} (default: @code{xfce})
  15297. The Xfce package to use.
  15298. @end table
  15299. @end deftp
  15300. @deffn {Scheme Variable} mate-desktop-service-type
  15301. This is the type of the service that runs the @uref{https://mate-desktop.org/,
  15302. MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
  15303. object (see below).
  15304. This service adds the @code{mate} package to the system
  15305. profile, and extends polkit with the actions from
  15306. @code{mate-settings-daemon}.
  15307. @end deffn
  15308. @deftp {Data Type} mate-desktop-configuration
  15309. Configuration record for the MATE desktop environment.
  15310. @table @asis
  15311. @item @code{mate} (default: @code{mate})
  15312. The MATE package to use.
  15313. @end table
  15314. @end deftp
  15315. @deffn {Scheme Variable} lxqt-desktop-service-type
  15316. This is the type of the service that runs the @uref{https://lxqt.github.io,
  15317. LXQt desktop environment}. Its value is a @code{lxqt-desktop-configuration}
  15318. object (see below).
  15319. This service adds the @code{lxqt} package to the system
  15320. profile.
  15321. @end deffn
  15322. @deftp {Data Type} lxqt-desktop-configuration
  15323. Configuration record for the LXQt desktop environment.
  15324. @table @asis
  15325. @item @code{lxqt} (default: @code{lxqt})
  15326. The LXQT package to use.
  15327. @end table
  15328. @end deftp
  15329. @deffn {Scheme Variable} enlightenment-desktop-service-type
  15330. Return a service that adds the @code{enlightenment} package to the system
  15331. profile, and extends dbus with actions from @code{efl}.
  15332. @end deffn
  15333. @deftp {Data Type} enlightenment-desktop-service-configuration
  15334. @table @asis
  15335. @item @code{enlightenment} (default: @code{enlightenment})
  15336. The enlightenment package to use.
  15337. @end table
  15338. @end deftp
  15339. Because the GNOME, Xfce and MATE desktop services pull in so many packages,
  15340. the default @code{%desktop-services} variable doesn't include any of
  15341. them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
  15342. @code{%desktop-services} in the @code{services} field of your
  15343. @code{operating-system}:
  15344. @lisp
  15345. (use-modules (gnu))
  15346. (use-service-modules desktop)
  15347. (operating-system
  15348. ...
  15349. ;; cons* adds items to the list given as its last argument.
  15350. (services (cons* (service gnome-desktop-service-type)
  15351. (service xfce-desktop-service)
  15352. %desktop-services))
  15353. ...)
  15354. @end lisp
  15355. These desktop environments will then be available as options in the
  15356. graphical login window.
  15357. The actual service definitions included in @code{%desktop-services} and
  15358. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  15359. are described below.
  15360. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  15361. Return a service that runs the ``system bus'', using @var{dbus}, with
  15362. support for @var{services}.
  15363. @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  15364. facility. Its system bus is used to allow system services to communicate
  15365. and to be notified of system-wide events.
  15366. @var{services} must be a list of packages that provide an
  15367. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  15368. and policy files. For example, to allow avahi-daemon to use the system bus,
  15369. @var{services} must be equal to @code{(list avahi)}.
  15370. @end deffn
  15371. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  15372. Return a service that runs the @code{elogind} login and
  15373. seat management daemon. @uref{https://github.com/elogind/elogind,
  15374. Elogind} exposes a D-Bus interface that can be used to know which users
  15375. are logged in, know what kind of sessions they have open, suspend the
  15376. system, inhibit system suspend, reboot the system, and other tasks.
  15377. Elogind handles most system-level power events for a computer, for
  15378. example suspending the system when a lid is closed, or shutting it down
  15379. when the power button is pressed.
  15380. The @var{config} keyword argument specifies the configuration for
  15381. elogind, and should be the result of an @code{(elogind-configuration
  15382. (@var{parameter} @var{value})...)} invocation. Available parameters and
  15383. their default values are:
  15384. @table @code
  15385. @item kill-user-processes?
  15386. @code{#f}
  15387. @item kill-only-users
  15388. @code{()}
  15389. @item kill-exclude-users
  15390. @code{("root")}
  15391. @item inhibit-delay-max-seconds
  15392. @code{5}
  15393. @item handle-power-key
  15394. @code{poweroff}
  15395. @item handle-suspend-key
  15396. @code{suspend}
  15397. @item handle-hibernate-key
  15398. @code{hibernate}
  15399. @item handle-lid-switch
  15400. @code{suspend}
  15401. @item handle-lid-switch-docked
  15402. @code{ignore}
  15403. @item handle-lid-switch-external-power
  15404. @code{ignore}
  15405. @item power-key-ignore-inhibited?
  15406. @code{#f}
  15407. @item suspend-key-ignore-inhibited?
  15408. @code{#f}
  15409. @item hibernate-key-ignore-inhibited?
  15410. @code{#f}
  15411. @item lid-switch-ignore-inhibited?
  15412. @code{#t}
  15413. @item holdoff-timeout-seconds
  15414. @code{30}
  15415. @item idle-action
  15416. @code{ignore}
  15417. @item idle-action-seconds
  15418. @code{(* 30 60)}
  15419. @item runtime-directory-size-percent
  15420. @code{10}
  15421. @item runtime-directory-size
  15422. @code{#f}
  15423. @item remove-ipc?
  15424. @code{#t}
  15425. @item suspend-state
  15426. @code{("mem" "standby" "freeze")}
  15427. @item suspend-mode
  15428. @code{()}
  15429. @item hibernate-state
  15430. @code{("disk")}
  15431. @item hibernate-mode
  15432. @code{("platform" "shutdown")}
  15433. @item hybrid-sleep-state
  15434. @code{("disk")}
  15435. @item hybrid-sleep-mode
  15436. @code{("suspend" "platform" "shutdown")}
  15437. @end table
  15438. @end deffn
  15439. @deffn {Scheme Procedure} accountsservice-service @
  15440. [#:accountsservice @var{accountsservice}]
  15441. Return a service that runs AccountsService, a system service that can
  15442. list available accounts, change their passwords, and so on.
  15443. AccountsService integrates with PolicyKit to enable unprivileged users
  15444. to acquire the capability to modify their system configuration.
  15445. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  15446. accountsservice web site} for more information.
  15447. The @var{accountsservice} keyword argument is the @code{accountsservice}
  15448. package to expose as a service.
  15449. @end deffn
  15450. @deffn {Scheme Procedure} polkit-service @
  15451. [#:polkit @var{polkit}]
  15452. Return a service that runs the
  15453. @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  15454. management service}, which allows system administrators to grant access to
  15455. privileged operations in a structured way. By querying the Polkit service, a
  15456. privileged system component can know when it should grant additional
  15457. capabilities to ordinary users. For example, an ordinary user can be granted
  15458. the capability to suspend the system if the user is logged in locally.
  15459. @end deffn
  15460. @defvr {Scheme Variable} polkit-wheel-service
  15461. Service that adds the @code{wheel} group as admins to the Polkit
  15462. service. This makes it so that users in the @code{wheel} group are queried
  15463. for their own passwords when performing administrative actions instead of
  15464. @code{root}'s, similar to the behaviour used by @code{sudo}.
  15465. @end defvr
  15466. @defvr {Scheme Variable} upower-service-type
  15467. Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
  15468. system-wide monitor for power consumption and battery levels, with the given
  15469. configuration settings.
  15470. It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
  15471. notably used by GNOME.
  15472. @end defvr
  15473. @deftp {Data Type} upower-configuration
  15474. Data type representation the configuration for UPower.
  15475. @table @asis
  15476. @item @code{upower} (default: @var{upower})
  15477. Package to use for @code{upower}.
  15478. @item @code{watts-up-pro?} (default: @code{#f})
  15479. Enable the Watts Up Pro device.
  15480. @item @code{poll-batteries?} (default: @code{#t})
  15481. Enable polling the kernel for battery level changes.
  15482. @item @code{ignore-lid?} (default: @code{#f})
  15483. Ignore the lid state, this can be useful if it's incorrect on a device.
  15484. @item @code{use-percentage-for-policy?} (default: @code{#f})
  15485. Whether battery percentage based policy should be used. The default is to use
  15486. the time left, change to @code{#t} to use the percentage.
  15487. @item @code{percentage-low} (default: @code{10})
  15488. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15489. at which the battery is considered low.
  15490. @item @code{percentage-critical} (default: @code{3})
  15491. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15492. at which the battery is considered critical.
  15493. @item @code{percentage-action} (default: @code{2})
  15494. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  15495. at which action will be taken.
  15496. @item @code{time-low} (default: @code{1200})
  15497. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15498. seconds at which the battery is considered low.
  15499. @item @code{time-critical} (default: @code{300})
  15500. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15501. seconds at which the battery is considered critical.
  15502. @item @code{time-action} (default: @code{120})
  15503. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  15504. seconds at which action will be taken.
  15505. @item @code{critical-power-action} (default: @code{'hybrid-sleep})
  15506. The action taken when @code{percentage-action} or @code{time-action} is
  15507. reached (depending on the configuration of @code{use-percentage-for-policy?}).
  15508. Possible values are:
  15509. @itemize @bullet
  15510. @item
  15511. @code{'power-off}
  15512. @item
  15513. @code{'hibernate}
  15514. @item
  15515. @code{'hybrid-sleep}.
  15516. @end itemize
  15517. @end table
  15518. @end deftp
  15519. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  15520. Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
  15521. UDisks}, a @dfn{disk management} daemon that provides user interfaces
  15522. with notifications and ways to mount/unmount disks. Programs that talk
  15523. to UDisks include the @command{udisksctl} command, part of UDisks, and
  15524. GNOME Disks. Note that Udisks relies on the @command{mount} command, so
  15525. it will only be able to use the file-system utilities installed in the
  15526. system profile. For example if you want to be able to mount NTFS
  15527. file-systems in read and write fashion, you'll need to have
  15528. @code{ntfs-3g} installed system-wide.
  15529. @end deffn
  15530. @deffn {Scheme Variable} colord-service-type
  15531. This is the type of the service that runs @command{colord}, a system
  15532. service with a D-Bus
  15533. interface to manage the color profiles of input and output devices such as
  15534. screens and scanners. It is notably used by the GNOME Color Manager graphical
  15535. tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
  15536. site} for more information.
  15537. @end deffn
  15538. @cindex scanner access
  15539. @defvr {Scheme Variable} sane-service-type
  15540. This service provides access to scanners @i{via}
  15541. @uref{http://www.sane-project.org, SANE} by installing the necessary
  15542. udev rules. It is included in @code{%desktop-services} (@pxref{Desktop
  15543. Services}) and relies by default on @code{sane-backends-minimal} package
  15544. (see below) for hardware support.
  15545. @end defvr
  15546. @defvr {Scheme Variable} sane-backends-minimal
  15547. The default package which the @code{sane-service-type} installs. It
  15548. supports many recent scanners.
  15549. @end defvr
  15550. @defvr {Scheme Variable} sane-backends
  15551. This package includes support for all scanners that
  15552. @code{sane-backends-minimal} supports, plus older Hewlett-Packard
  15553. scanners supported by @code{hplip} package. In order to use this on
  15554. a system which relies on @code{%desktop-services}, you may use
  15555. @code{modify-services} (@pxref{Service Reference,
  15556. @code{modify-services}}) as illustrated below:
  15557. @lisp
  15558. (use-modules (gnu))
  15559. (use-service-modules
  15560. @dots{}
  15561. desktop)
  15562. (use-package-modules
  15563. @dots{}
  15564. scanner)
  15565. (define %my-desktop-services
  15566. ;; List of desktop services that supports a broader range of scanners.
  15567. (modify-services %desktop-services
  15568. (sane-service-type _ => sane-backends)))
  15569. (operating-system
  15570. @dots{}
  15571. (services %my-desktop-services)
  15572. @end lisp
  15573. @end defvr
  15574. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  15575. Return a configuration allowing an application to access GeoClue
  15576. location data. @var{name} is the Desktop ID of the application, without
  15577. the @code{.desktop} part. If @var{allowed?} is true, the application
  15578. will have access to location information by default. The boolean
  15579. @var{system?} value indicates whether an application is a system component
  15580. or not. Finally @var{users} is a list of UIDs of all users for which
  15581. this application is allowed location info access. An empty users list
  15582. means that all users are allowed.
  15583. @end deffn
  15584. @defvr {Scheme Variable} %standard-geoclue-applications
  15585. The standard list of well-known GeoClue application configurations,
  15586. granting authority to the GNOME date-and-time utility to ask for the
  15587. current location in order to set the time zone, and allowing the
  15588. IceCat and Epiphany web browsers to request location information.
  15589. IceCat and Epiphany both query the user before allowing a web page to
  15590. know the user's location.
  15591. @end defvr
  15592. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  15593. [#:whitelist '()] @
  15594. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  15595. [#:submit-data? #f]
  15596. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  15597. [#:submission-nick "geoclue"] @
  15598. [#:applications %standard-geoclue-applications]
  15599. Return a service that runs the GeoClue location service. This service
  15600. provides a D-Bus interface to allow applications to request access to a
  15601. user's physical location, and optionally to add information to online
  15602. location databases. See
  15603. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  15604. web site} for more information.
  15605. @end deffn
  15606. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  15607. [@w{#:auto-enable? #f}]
  15608. Return a service that runs the @command{bluetoothd} daemon, which
  15609. manages all the Bluetooth devices and provides a number of D-Bus
  15610. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  15611. powered automatically at boot, which can be useful when using a
  15612. bluetooth keyboard or mouse.
  15613. Users need to be in the @code{lp} group to access the D-Bus service.
  15614. @end deffn
  15615. @defvr {Scheme Variable} gnome-keyring-service-type
  15616. This is the type of the service that adds the
  15617. @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
  15618. value is a @code{gnome-keyring-configuration} object (see below).
  15619. This service adds the @code{gnome-keyring} package to the system profile
  15620. and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
  15621. a user's login keyring when they log in or setting its password with passwd.
  15622. @end defvr
  15623. @deftp {Data Type} gnome-keyring-configuration
  15624. Configuration record for the GNOME Keyring service.
  15625. @table @asis
  15626. @item @code{keyring} (default: @code{gnome-keyring})
  15627. The GNOME keyring package to use.
  15628. @item @code{pam-services}
  15629. A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
  15630. services to extend, where @var{service} is the name of an existing
  15631. service to extend and @var{kind} is one of @code{login} or
  15632. @code{passwd}.
  15633. If @code{login} is given, it adds an optional
  15634. @code{pam_gnome_keyring.so} to the auth block without arguments and to
  15635. the session block with @code{auto_start}. If @code{passwd} is given, it
  15636. adds an optional @code{pam_gnome_keyring.so} to the password block
  15637. without arguments.
  15638. By default, this field contains ``gdm-password'' with the value @code{login}
  15639. and ``passwd'' is with the value @code{passwd}.
  15640. @end table
  15641. @end deftp
  15642. @node Sound Services
  15643. @subsection Sound Services
  15644. @cindex sound support
  15645. @cindex ALSA
  15646. @cindex PulseAudio, sound support
  15647. The @code{(gnu services sound)} module provides a service to configure the
  15648. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  15649. preferred ALSA output driver.
  15650. @deffn {Scheme Variable} alsa-service-type
  15651. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  15652. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  15653. configuration file. The value for this type is a @command{alsa-configuration}
  15654. record as in this example:
  15655. @lisp
  15656. (service alsa-service-type)
  15657. @end lisp
  15658. See below for details about @code{alsa-configuration}.
  15659. @end deffn
  15660. @deftp {Data Type} alsa-configuration
  15661. Data type representing the configuration for @code{alsa-service}.
  15662. @table @asis
  15663. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  15664. @code{alsa-plugins} package to use.
  15665. @item @code{pulseaudio?} (default: @var{#t})
  15666. Whether ALSA applications should transparently be made to use the
  15667. @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
  15668. Using PulseAudio allows you to run several sound-producing applications
  15669. at the same time and to individual control them @i{via}
  15670. @command{pavucontrol}, among other things.
  15671. @item @code{extra-options} (default: @var{""})
  15672. String to append to the @file{/etc/asound.conf} file.
  15673. @end table
  15674. @end deftp
  15675. Individual users who want to override the system configuration of ALSA can do
  15676. it with the @file{~/.asoundrc} file:
  15677. @example
  15678. # In guix, we have to specify the absolute path for plugins.
  15679. pcm_type.jack @{
  15680. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  15681. @}
  15682. # Routing ALSA to jack:
  15683. # <http://jackaudio.org/faq/routing_alsa.html>.
  15684. pcm.rawjack @{
  15685. type jack
  15686. playback_ports @{
  15687. 0 system:playback_1
  15688. 1 system:playback_2
  15689. @}
  15690. capture_ports @{
  15691. 0 system:capture_1
  15692. 1 system:capture_2
  15693. @}
  15694. @}
  15695. pcm.!default @{
  15696. type plug
  15697. slave @{
  15698. pcm "rawjack"
  15699. @}
  15700. @}
  15701. @end example
  15702. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  15703. details.
  15704. @deffn {Scheme Variable} pulseaudio-service-type
  15705. This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
  15706. sound server. It exists to allow system overrides of the default settings
  15707. via @code{pulseaudio-configuration}, see below.
  15708. @quotation Warning
  15709. This service overrides per-user configuration files. If you want
  15710. PulseAudio to honor configuration files in @file{~/.config/pulse} you
  15711. have to unset the environment variables @env{PULSE_CONFIG} and
  15712. @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
  15713. @end quotation
  15714. @quotation Warning
  15715. This service on its own does not ensure, that the @code{pulseaudio} package
  15716. exists on your machine. It merely adds configuration files for it, as
  15717. detailed below. In the (admittedly unlikely) case, that you find yourself
  15718. without a @code{pulseaudio} package, consider enabling it through the
  15719. @code{alsa-service-type} above.
  15720. @end quotation
  15721. @end deffn
  15722. @deftp {Data Type} pulseaudio-configuration
  15723. Data type representing the configuration for @code{pulseaudio-service}.
  15724. @table @asis
  15725. @item @code{client-conf} (default: @code{'()})
  15726. List of settings to set in @file{client.conf}.
  15727. Accepts a list of strings or a symbol-value pairs. A string will be
  15728. inserted as-is with a newline added. A pair will be formatted as
  15729. ``key = value'', again with a newline added.
  15730. @item @code{daemon-conf} (default: @code{'((flat-volumes . no))})
  15731. List of settings to set in @file{daemon.conf}, formatted just like
  15732. @var{client-conf}.
  15733. @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
  15734. Script file to use as @file{default.pa}.
  15735. @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
  15736. Script file to use as @file{system.pa}.
  15737. @end table
  15738. @end deftp
  15739. @deffn {Scheme Variable} ladspa-service-type
  15740. This service sets the @var{LADSPA_PATH} variable, so that programs, which
  15741. respect it, e.g. PulseAudio, can load LADSPA plugins.
  15742. The following example will setup the service to enable modules from the
  15743. @code{swh-plugins} package:
  15744. @lisp
  15745. (service ladspa-service-type
  15746. (ladspa-configuration (plugins (list swh-plugins))))
  15747. @end lisp
  15748. See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
  15749. details.
  15750. @end deffn
  15751. @node Database Services
  15752. @subsection Database Services
  15753. @cindex database
  15754. @cindex SQL
  15755. The @code{(gnu services databases)} module provides the following services.
  15756. @subsubheading PostgreSQL
  15757. The following example describes a PostgreSQL service with the default
  15758. configuration.
  15759. @lisp
  15760. (service postgresql-service-type
  15761. (postgresql-configuration
  15762. (postgresql postgresql-10)))
  15763. @end lisp
  15764. If the services fails to start, it may be due to an incompatible
  15765. cluster already present in @var{data-directory}. Adjust it (or, if you
  15766. don't need the cluster anymore, delete @var{data-directory}), then
  15767. restart the service.
  15768. Peer authentication is used by default and the @code{postgres} user
  15769. account has no shell, which prevents the direct execution of @code{psql}
  15770. commands as this user. To use @code{psql}, you can temporarily log in
  15771. as @code{postgres} using a shell, create a PostgreSQL superuser with the
  15772. same name as one of the system users and then create the associated
  15773. database.
  15774. @example
  15775. sudo -u postgres -s /bin/sh
  15776. createuser --interactive
  15777. createdb $MY_USER_LOGIN # Replace appropriately.
  15778. @end example
  15779. @deftp {Data Type} postgresql-configuration
  15780. Data type representing the configuration for the
  15781. @code{postgresql-service-type}.
  15782. @table @asis
  15783. @item @code{postgresql}
  15784. PostgreSQL package to use for the service.
  15785. @item @code{port} (default: @code{5432})
  15786. Port on which PostgreSQL should listen.
  15787. @item @code{locale} (default: @code{"en_US.utf8"})
  15788. Locale to use as the default when creating the database cluster.
  15789. @item @code{config-file} (default: @code{(postgresql-config-file)})
  15790. The configuration file to use when running PostgreSQL@. The default
  15791. behaviour uses the postgresql-config-file record with the default values
  15792. for the fields.
  15793. @item @code{log-directory} (default: @code{"/var/log/postgresql"})
  15794. The directory where @command{pg_ctl} output will be written in a file
  15795. named @code{"pg_ctl.log"}. This file can be useful to debug PostgreSQL
  15796. configuration errors for instance.
  15797. @item @code{data-directory} (default: @code{"/var/lib/postgresql/data"})
  15798. Directory in which to store the data.
  15799. @item @code{extension-packages} (default: @code{'()})
  15800. @cindex postgresql extension-packages
  15801. Additional extensions are loaded from packages listed in
  15802. @var{extension-packages}. Extensions are available at runtime. For instance,
  15803. to create a geographic database using the @code{postgis} extension, a user can
  15804. configure the postgresql-service as in this example:
  15805. @cindex postgis
  15806. @lisp
  15807. (use-package-modules databases geo)
  15808. (operating-system
  15809. ...
  15810. ;; postgresql is required to run `psql' but postgis is not required for
  15811. ;; proper operation.
  15812. (packages (cons* postgresql %base-packages))
  15813. (services
  15814. (cons*
  15815. (service postgresql-service-type
  15816. (postgresql-configuration
  15817. (postgresql postgresql-10)
  15818. (extension-packages (list postgis))))
  15819. %base-services)))
  15820. @end lisp
  15821. Then the extension becomes visible and you can initialise an empty geographic
  15822. database in this way:
  15823. @example
  15824. psql -U postgres
  15825. > create database postgistest;
  15826. > \connect postgistest;
  15827. > create extension postgis;
  15828. > create extension postgis_topology;
  15829. @end example
  15830. There is no need to add this field for contrib extensions such as hstore or
  15831. dblink as they are already loadable by postgresql. This field is only
  15832. required to add extensions provided by other packages.
  15833. @end table
  15834. @end deftp
  15835. @deftp {Data Type} postgresql-config-file
  15836. Data type representing the PostgreSQL configuration file. As shown in
  15837. the following example, this can be used to customize the configuration
  15838. of PostgreSQL@. Note that you can use any G-expression or filename in
  15839. place of this record, if you already have a configuration file you'd
  15840. like to use for example.
  15841. @lisp
  15842. (service postgresql-service-type
  15843. (postgresql-configuration
  15844. (config-file
  15845. (postgresql-config-file
  15846. (log-destination "stderr")
  15847. (hba-file
  15848. (plain-file "pg_hba.conf"
  15849. "
  15850. local all all trust
  15851. host all all 127.0.0.1/32 md5
  15852. host all all ::1/128 md5"))
  15853. (extra-config
  15854. '(("session_preload_libraries" "auto_explain")
  15855. ("random_page_cost" 2)
  15856. ("auto_explain.log_min_duration" "100 ms")
  15857. ("work_mem" "500 MB")
  15858. ("logging_collector" #t)
  15859. ("log_directory" "/var/log/postgresql")))))))
  15860. @end lisp
  15861. @table @asis
  15862. @item @code{log-destination} (default: @code{"syslog"})
  15863. The logging method to use for PostgreSQL@. Multiple values are accepted,
  15864. separated by commas.
  15865. @item @code{hba-file} (default: @code{%default-postgres-hba})
  15866. Filename or G-expression for the host-based authentication
  15867. configuration.
  15868. @item @code{ident-file} (default: @code{%default-postgres-ident})
  15869. Filename or G-expression for the user name mapping configuration.
  15870. @item @code{socket-directory} (default: @code{"/var/run/postgresql"})
  15871. Specifies the directory of the Unix-domain socket(s) on which PostgreSQL
  15872. is to listen for connections from client applications. If set to
  15873. @code{#false} PostgreSQL does not listen on any Unix-domain sockets, in
  15874. which case only TCP/IP sockets can be used to connect to the server.
  15875. @item @code{extra-config} (default: @code{'()})
  15876. List of additional keys and values to include in the PostgreSQL config
  15877. file. Each entry in the list should be a list where the first element
  15878. is the key, and the remaining elements are the values.
  15879. The values can be numbers, booleans or strings and will be mapped to
  15880. PostgreSQL parameters types @code{Boolean}, @code{String},
  15881. @code{Numeric}, @code{Numeric with Unit} and @code{Enumerated} described
  15882. @uref{https://www.postgresql.org/docs/current/config-setting.html,
  15883. here}.
  15884. @end table
  15885. @end deftp
  15886. @deffn {Scheme Variable} postgresql-role-service-type
  15887. This service allows to create PostgreSQL roles and databases after
  15888. PostgreSQL service start. Here is an example of its use.
  15889. @lisp
  15890. (service postgresql-role-service-type
  15891. (postgresql-role-configuration
  15892. (roles
  15893. (list (postgresql-role
  15894. (name "test")
  15895. (create-database? #t))))))
  15896. @end lisp
  15897. This service can be extended with extra roles, as in this
  15898. example:
  15899. @lisp
  15900. (service-extension postgresql-role-service-type
  15901. (const (postgresql-role
  15902. (name "alice")
  15903. (create-database? #t))))
  15904. @end lisp
  15905. @end deffn
  15906. @deftp {Data Type} postgresql-role
  15907. PostgreSQL manages database access permissions using the concept of
  15908. roles. A role can be thought of as either a database user, or a group
  15909. of database users, depending on how the role is set up. Roles can own
  15910. database objects (for example, tables) and can assign privileges on
  15911. those objects to other roles to control who has access to which objects.
  15912. @table @asis
  15913. @item @code{name}
  15914. The role name.
  15915. @item @code{permissions} (default: @code{'(createdb login)})
  15916. The role permissions list. Supported permissions are @code{bypassrls},
  15917. @code{createdb}, @code{createrole}, @code{login}, @code{replication} and
  15918. @code{superuser}.
  15919. @item @code{create-database?} (default: @code{#f})
  15920. Whether to create a database with the same name as the role.
  15921. @end table
  15922. @end deftp
  15923. @deftp {Data Type} postgresql-role-configuration
  15924. Data type representing the configuration of
  15925. @var{postgresql-role-service-type}.
  15926. @table @asis
  15927. @item @code{host} (default: @code{"/var/run/postgresql"})
  15928. The PostgreSQL host to connect to.
  15929. @item @code{log} (default: @code{"/var/log/postgresql_roles.log"})
  15930. File name of the log file.
  15931. @item @code{roles} (default: @code{'()})
  15932. The initial PostgreSQL roles to create.
  15933. @end table
  15934. @end deftp
  15935. @subsubheading MariaDB/MySQL
  15936. @defvr {Scheme Variable} mysql-service-type
  15937. This is the service type for a MySQL or MariaDB database server. Its value
  15938. is a @code{mysql-configuration} object that specifies which package to use,
  15939. as well as various settings for the @command{mysqld} daemon.
  15940. @end defvr
  15941. @deftp {Data Type} mysql-configuration
  15942. Data type representing the configuration of @var{mysql-service-type}.
  15943. @table @asis
  15944. @item @code{mysql} (default: @var{mariadb})
  15945. Package object of the MySQL database server, can be either @var{mariadb}
  15946. or @var{mysql}.
  15947. For MySQL, a temporary root password will be displayed at activation time.
  15948. For MariaDB, the root password is empty.
  15949. @item @code{bind-address} (default: @code{"127.0.0.1"})
  15950. The IP on which to listen for network connections. Use @code{"0.0.0.0"}
  15951. to bind to all available network interfaces.
  15952. @item @code{port} (default: @code{3306})
  15953. TCP port on which the database server listens for incoming connections.
  15954. @item @code{socket} (default: @code{"/run/mysqld/mysqld.sock"})
  15955. Socket file to use for local (non-network) connections.
  15956. @item @code{extra-content} (default: @code{""})
  15957. Additional settings for the @file{my.cnf} configuration file.
  15958. @item @code{auto-upgrade?} (default: @code{#t})
  15959. Whether to automatically run @command{mysql_upgrade} after starting the
  15960. service. This is necessary to upgrade the @dfn{system schema} after
  15961. ``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can
  15962. be disabled if you would rather do that manually.
  15963. @end table
  15964. @end deftp
  15965. @subsubheading Memcached
  15966. @defvr {Scheme Variable} memcached-service-type
  15967. This is the service type for the @uref{https://memcached.org/,
  15968. Memcached} service, which provides a distributed in memory cache. The
  15969. value for the service type is a @code{memcached-configuration} object.
  15970. @end defvr
  15971. @lisp
  15972. (service memcached-service-type)
  15973. @end lisp
  15974. @deftp {Data Type} memcached-configuration
  15975. Data type representing the configuration of memcached.
  15976. @table @asis
  15977. @item @code{memcached} (default: @code{memcached})
  15978. The Memcached package to use.
  15979. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  15980. Network interfaces on which to listen.
  15981. @item @code{tcp-port} (default: @code{11211})
  15982. Port on which to accept connections.
  15983. @item @code{udp-port} (default: @code{11211})
  15984. Port on which to accept UDP connections on, a value of 0 will disable
  15985. listening on a UDP socket.
  15986. @item @code{additional-options} (default: @code{'()})
  15987. Additional command line options to pass to @code{memcached}.
  15988. @end table
  15989. @end deftp
  15990. @subsubheading Redis
  15991. @defvr {Scheme Variable} redis-service-type
  15992. This is the service type for the @uref{https://redis.io/, Redis}
  15993. key/value store, whose value is a @code{redis-configuration} object.
  15994. @end defvr
  15995. @deftp {Data Type} redis-configuration
  15996. Data type representing the configuration of redis.
  15997. @table @asis
  15998. @item @code{redis} (default: @code{redis})
  15999. The Redis package to use.
  16000. @item @code{bind} (default: @code{"127.0.0.1"})
  16001. Network interface on which to listen.
  16002. @item @code{port} (default: @code{6379})
  16003. Port on which to accept connections on, a value of 0 will disable
  16004. listening on a TCP socket.
  16005. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  16006. Directory in which to store the database and related files.
  16007. @end table
  16008. @end deftp
  16009. @node Mail Services
  16010. @subsection Mail Services
  16011. @cindex mail
  16012. @cindex email
  16013. The @code{(gnu services mail)} module provides Guix service definitions
  16014. for email services: IMAP, POP3, and LMTP servers, as well as mail
  16015. transport agents (MTAs). Lots of acronyms! These services are detailed
  16016. in the subsections below.
  16017. @subsubheading Dovecot Service
  16018. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  16019. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  16020. @end deffn
  16021. By default, Dovecot does not need much configuration; the default
  16022. configuration object created by @code{(dovecot-configuration)} will
  16023. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  16024. certificate will be generated for TLS-protected connections, though
  16025. Dovecot will also listen on cleartext ports by default. There are a
  16026. number of options, though, which mail administrators might need to change,
  16027. and as is the case with other services, Guix allows the system
  16028. administrator to specify these parameters via a uniform Scheme interface.
  16029. For example, to specify that mail is located at @code{maildir~/.mail},
  16030. one would instantiate the Dovecot service like this:
  16031. @lisp
  16032. (dovecot-service #:config
  16033. (dovecot-configuration
  16034. (mail-location "maildir:~/.mail")))
  16035. @end lisp
  16036. The available configuration parameters follow. Each parameter
  16037. definition is preceded by its type; for example, @samp{string-list foo}
  16038. indicates that the @code{foo} parameter should be specified as a list of
  16039. strings. There is also a way to specify the configuration as a string,
  16040. if you have an old @code{dovecot.conf} file that you want to port over
  16041. from some other system; see the end for more details.
  16042. @c The following documentation was initially generated by
  16043. @c (generate-documentation) in (gnu services mail). Manually maintained
  16044. @c documentation is better, so we shouldn't hesitate to edit below as
  16045. @c needed. However if the change you want to make to this documentation
  16046. @c can be done in an automated way, it's probably easier to change
  16047. @c (generate-documentation) than to make it below and have to deal with
  16048. @c the churn as dovecot updates.
  16049. Available @code{dovecot-configuration} fields are:
  16050. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  16051. The dovecot package.
  16052. @end deftypevr
  16053. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  16054. A list of IPs or hosts where to listen for connections. @samp{*}
  16055. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  16056. interfaces. If you want to specify non-default ports or anything more
  16057. complex, customize the address and port fields of the
  16058. @samp{inet-listener} of the specific services you are interested in.
  16059. @end deftypevr
  16060. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  16061. List of protocols we want to serve. Available protocols include
  16062. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  16063. Available @code{protocol-configuration} fields are:
  16064. @deftypevr {@code{protocol-configuration} parameter} string name
  16065. The name of the protocol.
  16066. @end deftypevr
  16067. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  16068. UNIX socket path to the master authentication server to find users.
  16069. This is used by imap (for shared users) and lda.
  16070. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  16071. @end deftypevr
  16072. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  16073. Space separated list of plugins to load.
  16074. @end deftypevr
  16075. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  16076. Maximum number of IMAP connections allowed for a user from each IP
  16077. address. NOTE: The username is compared case-sensitively.
  16078. Defaults to @samp{10}.
  16079. @end deftypevr
  16080. @end deftypevr
  16081. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  16082. List of services to enable. Available services include @samp{imap},
  16083. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  16084. @samp{lmtp}.
  16085. Available @code{service-configuration} fields are:
  16086. @deftypevr {@code{service-configuration} parameter} string kind
  16087. The service kind. Valid values include @code{director},
  16088. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  16089. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  16090. @code{tcpwrap}, @code{quota-warning}, or anything else.
  16091. @end deftypevr
  16092. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  16093. Listeners for the service. A listener is either a
  16094. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  16095. an @code{inet-listener-configuration}.
  16096. Defaults to @samp{()}.
  16097. Available @code{unix-listener-configuration} fields are:
  16098. @deftypevr {@code{unix-listener-configuration} parameter} string path
  16099. Path to the file, relative to @code{base-dir} field. This is also used as
  16100. the section name.
  16101. @end deftypevr
  16102. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  16103. The access mode for the socket.
  16104. Defaults to @samp{"0600"}.
  16105. @end deftypevr
  16106. @deftypevr {@code{unix-listener-configuration} parameter} string user
  16107. The user to own the socket.
  16108. Defaults to @samp{""}.
  16109. @end deftypevr
  16110. @deftypevr {@code{unix-listener-configuration} parameter} string group
  16111. The group to own the socket.
  16112. Defaults to @samp{""}.
  16113. @end deftypevr
  16114. Available @code{fifo-listener-configuration} fields are:
  16115. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  16116. Path to the file, relative to @code{base-dir} field. This is also used as
  16117. the section name.
  16118. @end deftypevr
  16119. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  16120. The access mode for the socket.
  16121. Defaults to @samp{"0600"}.
  16122. @end deftypevr
  16123. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  16124. The user to own the socket.
  16125. Defaults to @samp{""}.
  16126. @end deftypevr
  16127. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  16128. The group to own the socket.
  16129. Defaults to @samp{""}.
  16130. @end deftypevr
  16131. Available @code{inet-listener-configuration} fields are:
  16132. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  16133. The protocol to listen for.
  16134. @end deftypevr
  16135. @deftypevr {@code{inet-listener-configuration} parameter} string address
  16136. The address on which to listen, or empty for all addresses.
  16137. Defaults to @samp{""}.
  16138. @end deftypevr
  16139. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  16140. The port on which to listen.
  16141. @end deftypevr
  16142. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  16143. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  16144. @samp{required}.
  16145. Defaults to @samp{#t}.
  16146. @end deftypevr
  16147. @end deftypevr
  16148. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  16149. Maximum number of simultaneous client connections per process. Once
  16150. this number of connections is received, the next incoming connection
  16151. will prompt Dovecot to spawn another process. If set to 0,
  16152. @code{default-client-limit} is used instead.
  16153. Defaults to @samp{0}.
  16154. @end deftypevr
  16155. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  16156. Number of connections to handle before starting a new process.
  16157. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  16158. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  16159. Defaults to @samp{1}.
  16160. @end deftypevr
  16161. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  16162. Maximum number of processes that can exist for this service. If set to
  16163. 0, @code{default-process-limit} is used instead.
  16164. Defaults to @samp{0}.
  16165. @end deftypevr
  16166. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  16167. Number of processes to always keep waiting for more connections.
  16168. Defaults to @samp{0}.
  16169. @end deftypevr
  16170. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  16171. If you set @samp{service-count 0}, you probably need to grow
  16172. this.
  16173. Defaults to @samp{256000000}.
  16174. @end deftypevr
  16175. @end deftypevr
  16176. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  16177. Dict configuration, as created by the @code{dict-configuration}
  16178. constructor.
  16179. Available @code{dict-configuration} fields are:
  16180. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  16181. A list of key-value pairs that this dict should hold.
  16182. Defaults to @samp{()}.
  16183. @end deftypevr
  16184. @end deftypevr
  16185. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  16186. A list of passdb configurations, each one created by the
  16187. @code{passdb-configuration} constructor.
  16188. Available @code{passdb-configuration} fields are:
  16189. @deftypevr {@code{passdb-configuration} parameter} string driver
  16190. The driver that the passdb should use. Valid values include
  16191. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  16192. @samp{static}.
  16193. Defaults to @samp{"pam"}.
  16194. @end deftypevr
  16195. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  16196. Space separated list of arguments to the passdb driver.
  16197. Defaults to @samp{""}.
  16198. @end deftypevr
  16199. @end deftypevr
  16200. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  16201. List of userdb configurations, each one created by the
  16202. @code{userdb-configuration} constructor.
  16203. Available @code{userdb-configuration} fields are:
  16204. @deftypevr {@code{userdb-configuration} parameter} string driver
  16205. The driver that the userdb should use. Valid values include
  16206. @samp{passwd} and @samp{static}.
  16207. Defaults to @samp{"passwd"}.
  16208. @end deftypevr
  16209. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  16210. Space separated list of arguments to the userdb driver.
  16211. Defaults to @samp{""}.
  16212. @end deftypevr
  16213. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  16214. Override fields from passwd.
  16215. Defaults to @samp{()}.
  16216. @end deftypevr
  16217. @end deftypevr
  16218. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  16219. Plug-in configuration, created by the @code{plugin-configuration}
  16220. constructor.
  16221. @end deftypevr
  16222. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  16223. List of namespaces. Each item in the list is created by the
  16224. @code{namespace-configuration} constructor.
  16225. Available @code{namespace-configuration} fields are:
  16226. @deftypevr {@code{namespace-configuration} parameter} string name
  16227. Name for this namespace.
  16228. @end deftypevr
  16229. @deftypevr {@code{namespace-configuration} parameter} string type
  16230. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  16231. Defaults to @samp{"private"}.
  16232. @end deftypevr
  16233. @deftypevr {@code{namespace-configuration} parameter} string separator
  16234. Hierarchy separator to use. You should use the same separator for
  16235. all namespaces or some clients get confused. @samp{/} is usually a good
  16236. one. The default however depends on the underlying mail storage
  16237. format.
  16238. Defaults to @samp{""}.
  16239. @end deftypevr
  16240. @deftypevr {@code{namespace-configuration} parameter} string prefix
  16241. Prefix required to access this namespace. This needs to be
  16242. different for all namespaces. For example @samp{Public/}.
  16243. Defaults to @samp{""}.
  16244. @end deftypevr
  16245. @deftypevr {@code{namespace-configuration} parameter} string location
  16246. Physical location of the mailbox. This is in the same format as
  16247. mail_location, which is also the default for it.
  16248. Defaults to @samp{""}.
  16249. @end deftypevr
  16250. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  16251. There can be only one INBOX, and this setting defines which
  16252. namespace has it.
  16253. Defaults to @samp{#f}.
  16254. @end deftypevr
  16255. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  16256. If namespace is hidden, it's not advertised to clients via NAMESPACE
  16257. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  16258. useful when converting from another server with different namespaces
  16259. which you want to deprecate but still keep working. For example you can
  16260. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  16261. and @samp{mail/}.
  16262. Defaults to @samp{#f}.
  16263. @end deftypevr
  16264. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  16265. Show the mailboxes under this namespace with the LIST command. This
  16266. makes the namespace visible for clients that do not support the NAMESPACE
  16267. extension. The special @code{children} value lists child mailboxes, but
  16268. hides the namespace prefix.
  16269. Defaults to @samp{#t}.
  16270. @end deftypevr
  16271. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  16272. Namespace handles its own subscriptions. If set to @code{#f}, the
  16273. parent namespace handles them. The empty prefix should always have this
  16274. as @code{#t}).
  16275. Defaults to @samp{#t}.
  16276. @end deftypevr
  16277. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  16278. List of predefined mailboxes in this namespace.
  16279. Defaults to @samp{()}.
  16280. Available @code{mailbox-configuration} fields are:
  16281. @deftypevr {@code{mailbox-configuration} parameter} string name
  16282. Name for this mailbox.
  16283. @end deftypevr
  16284. @deftypevr {@code{mailbox-configuration} parameter} string auto
  16285. @samp{create} will automatically create this mailbox.
  16286. @samp{subscribe} will both create and subscribe to the mailbox.
  16287. Defaults to @samp{"no"}.
  16288. @end deftypevr
  16289. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  16290. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  16291. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  16292. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  16293. Defaults to @samp{()}.
  16294. @end deftypevr
  16295. @end deftypevr
  16296. @end deftypevr
  16297. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  16298. Base directory where to store runtime data.
  16299. Defaults to @samp{"/var/run/dovecot/"}.
  16300. @end deftypevr
  16301. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  16302. Greeting message for clients.
  16303. Defaults to @samp{"Dovecot ready."}.
  16304. @end deftypevr
  16305. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  16306. List of trusted network ranges. Connections from these IPs are
  16307. allowed to override their IP addresses and ports (for logging and for
  16308. authentication checks). @samp{disable-plaintext-auth} is also ignored
  16309. for these networks. Typically you would specify your IMAP proxy servers
  16310. here.
  16311. Defaults to @samp{()}.
  16312. @end deftypevr
  16313. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  16314. List of login access check sockets (e.g.@: tcpwrap).
  16315. Defaults to @samp{()}.
  16316. @end deftypevr
  16317. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  16318. Show more verbose process titles (in ps). Currently shows user name
  16319. and IP address. Useful for seeing who is actually using the IMAP
  16320. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  16321. accounts).
  16322. Defaults to @samp{#f}.
  16323. @end deftypevr
  16324. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  16325. Should all processes be killed when Dovecot master process shuts down.
  16326. Setting this to @code{#f} means that Dovecot can be upgraded without
  16327. forcing existing client connections to close (although that could also
  16328. be a problem if the upgrade is e.g.@: due to a security fix).
  16329. Defaults to @samp{#t}.
  16330. @end deftypevr
  16331. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  16332. If non-zero, run mail commands via this many connections to doveadm
  16333. server, instead of running them directly in the same process.
  16334. Defaults to @samp{0}.
  16335. @end deftypevr
  16336. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  16337. UNIX socket or host:port used for connecting to doveadm server.
  16338. Defaults to @samp{"doveadm-server"}.
  16339. @end deftypevr
  16340. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  16341. List of environment variables that are preserved on Dovecot startup
  16342. and passed down to all of its child processes. You can also give
  16343. key=value pairs to always set specific settings.
  16344. @end deftypevr
  16345. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  16346. Disable LOGIN command and all other plaintext authentications unless
  16347. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  16348. matches the local IP (i.e.@: you're connecting from the same computer),
  16349. the connection is considered secure and plaintext authentication is
  16350. allowed. See also ssl=required setting.
  16351. Defaults to @samp{#t}.
  16352. @end deftypevr
  16353. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  16354. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  16355. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  16356. for caching to be used.
  16357. Defaults to @samp{0}.
  16358. @end deftypevr
  16359. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  16360. Time to live for cached data. After TTL expires the cached record
  16361. is no longer used, *except* if the main database lookup returns internal
  16362. failure. We also try to handle password changes automatically: If
  16363. user's previous authentication was successful, but this one wasn't, the
  16364. cache isn't used. For now this works only with plaintext
  16365. authentication.
  16366. Defaults to @samp{"1 hour"}.
  16367. @end deftypevr
  16368. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  16369. TTL for negative hits (user not found, password mismatch).
  16370. 0 disables caching them completely.
  16371. Defaults to @samp{"1 hour"}.
  16372. @end deftypevr
  16373. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  16374. List of realms for SASL authentication mechanisms that need them.
  16375. You can leave it empty if you don't want to support multiple realms.
  16376. Many clients simply use the first one listed here, so keep the default
  16377. realm first.
  16378. Defaults to @samp{()}.
  16379. @end deftypevr
  16380. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  16381. Default realm/domain to use if none was specified. This is used for
  16382. both SASL realms and appending @@domain to username in plaintext
  16383. logins.
  16384. Defaults to @samp{""}.
  16385. @end deftypevr
  16386. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  16387. List of allowed characters in username. If the user-given username
  16388. contains a character not listed in here, the login automatically fails.
  16389. This is just an extra check to make sure user can't exploit any
  16390. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  16391. you want to allow all characters, set this value to empty.
  16392. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  16393. @end deftypevr
  16394. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  16395. Username character translations before it's looked up from
  16396. databases. The value contains series of from -> to characters. For
  16397. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  16398. translated to @samp{@@}.
  16399. Defaults to @samp{""}.
  16400. @end deftypevr
  16401. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  16402. Username formatting before it's looked up from databases. You can
  16403. use the standard variables here, e.g.@: %Lu would lowercase the username,
  16404. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  16405. change the @samp{@@} into @samp{-AT-}. This translation is done after
  16406. @samp{auth-username-translation} changes.
  16407. Defaults to @samp{"%Lu"}.
  16408. @end deftypevr
  16409. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  16410. If you want to allow master users to log in by specifying the master
  16411. username within the normal username string (i.e.@: not using SASL
  16412. mechanism's support for it), you can specify the separator character
  16413. here. The format is then <username><separator><master username>.
  16414. UW-IMAP uses @samp{*} as the separator, so that could be a good
  16415. choice.
  16416. Defaults to @samp{""}.
  16417. @end deftypevr
  16418. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  16419. Username to use for users logging in with ANONYMOUS SASL
  16420. mechanism.
  16421. Defaults to @samp{"anonymous"}.
  16422. @end deftypevr
  16423. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  16424. Maximum number of dovecot-auth worker processes. They're used to
  16425. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  16426. They're automatically created and destroyed as needed.
  16427. Defaults to @samp{30}.
  16428. @end deftypevr
  16429. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  16430. Host name to use in GSSAPI principal names. The default is to use
  16431. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  16432. allow all keytab entries.
  16433. Defaults to @samp{""}.
  16434. @end deftypevr
  16435. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  16436. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  16437. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  16438. need to change the auth service to run as root to be able to read this
  16439. file.
  16440. Defaults to @samp{""}.
  16441. @end deftypevr
  16442. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  16443. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  16444. and @samp{ntlm-auth} helper.
  16445. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  16446. Defaults to @samp{#f}.
  16447. @end deftypevr
  16448. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  16449. Path for Samba's @samp{ntlm-auth} helper binary.
  16450. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  16451. @end deftypevr
  16452. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  16453. Time to delay before replying to failed authentications.
  16454. Defaults to @samp{"2 secs"}.
  16455. @end deftypevr
  16456. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  16457. Require a valid SSL client certificate or the authentication
  16458. fails.
  16459. Defaults to @samp{#f}.
  16460. @end deftypevr
  16461. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  16462. Take the username from client's SSL certificate, using
  16463. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  16464. CommonName.
  16465. Defaults to @samp{#f}.
  16466. @end deftypevr
  16467. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  16468. List of wanted authentication mechanisms. Supported mechanisms are:
  16469. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  16470. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  16471. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  16472. @samp{disable-plaintext-auth} setting.
  16473. @end deftypevr
  16474. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  16475. List of IPs or hostnames to all director servers, including ourself.
  16476. Ports can be specified as ip:port. The default port is the same as what
  16477. director service's @samp{inet-listener} is using.
  16478. Defaults to @samp{()}.
  16479. @end deftypevr
  16480. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  16481. List of IPs or hostnames to all backend mail servers. Ranges are
  16482. allowed too, like 10.0.0.10-10.0.0.30.
  16483. Defaults to @samp{()}.
  16484. @end deftypevr
  16485. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  16486. How long to redirect users to a specific server after it no longer
  16487. has any connections.
  16488. Defaults to @samp{"15 min"}.
  16489. @end deftypevr
  16490. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  16491. How the username is translated before being hashed. Useful values
  16492. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  16493. are shared within domain.
  16494. Defaults to @samp{"%Lu"}.
  16495. @end deftypevr
  16496. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  16497. Log file to use for error messages. @samp{syslog} logs to syslog,
  16498. @samp{/dev/stderr} logs to stderr.
  16499. Defaults to @samp{"syslog"}.
  16500. @end deftypevr
  16501. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  16502. Log file to use for informational messages. Defaults to
  16503. @samp{log-path}.
  16504. Defaults to @samp{""}.
  16505. @end deftypevr
  16506. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  16507. Log file to use for debug messages. Defaults to
  16508. @samp{info-log-path}.
  16509. Defaults to @samp{""}.
  16510. @end deftypevr
  16511. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  16512. Syslog facility to use if you're logging to syslog. Usually if you
  16513. don't want to use @samp{mail}, you'll use local0..local7. Also other
  16514. standard facilities are supported.
  16515. Defaults to @samp{"mail"}.
  16516. @end deftypevr
  16517. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  16518. Log unsuccessful authentication attempts and the reasons why they
  16519. failed.
  16520. Defaults to @samp{#f}.
  16521. @end deftypevr
  16522. @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
  16523. In case of password mismatches, log the attempted password. Valid
  16524. values are no, plain and sha1. sha1 can be useful for detecting brute
  16525. force password attempts vs. user simply trying the same password over
  16526. and over again. You can also truncate the value to n chars by appending
  16527. ":n" (e.g.@: sha1:6).
  16528. Defaults to @samp{"no"}.
  16529. @end deftypevr
  16530. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  16531. Even more verbose logging for debugging purposes. Shows for example
  16532. SQL queries.
  16533. Defaults to @samp{#f}.
  16534. @end deftypevr
  16535. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  16536. In case of password mismatches, log the passwords and used scheme so
  16537. the problem can be debugged. Enabling this also enables
  16538. @samp{auth-debug}.
  16539. Defaults to @samp{#f}.
  16540. @end deftypevr
  16541. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  16542. Enable mail process debugging. This can help you figure out why
  16543. Dovecot isn't finding your mails.
  16544. Defaults to @samp{#f}.
  16545. @end deftypevr
  16546. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  16547. Show protocol level SSL errors.
  16548. Defaults to @samp{#f}.
  16549. @end deftypevr
  16550. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  16551. Prefix for each line written to log file. % codes are in
  16552. strftime(3) format.
  16553. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  16554. @end deftypevr
  16555. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  16556. List of elements we want to log. The elements which have a
  16557. non-empty variable value are joined together to form a comma-separated
  16558. string.
  16559. @end deftypevr
  16560. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  16561. Login log format. %s contains @samp{login-log-format-elements}
  16562. string, %$ contains the data we want to log.
  16563. Defaults to @samp{"%$: %s"}.
  16564. @end deftypevr
  16565. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  16566. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  16567. of possible variables you can use.
  16568. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  16569. @end deftypevr
  16570. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  16571. Format to use for logging mail deliveries. You can use variables:
  16572. @table @code
  16573. @item %$
  16574. Delivery status message (e.g.@: @samp{saved to INBOX})
  16575. @item %m
  16576. Message-ID
  16577. @item %s
  16578. Subject
  16579. @item %f
  16580. From address
  16581. @item %p
  16582. Physical size
  16583. @item %w
  16584. Virtual size.
  16585. @end table
  16586. Defaults to @samp{"msgid=%m: %$"}.
  16587. @end deftypevr
  16588. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  16589. Location for users' mailboxes. The default is empty, which means
  16590. that Dovecot tries to find the mailboxes automatically. This won't work
  16591. if the user doesn't yet have any mail, so you should explicitly tell
  16592. Dovecot the full location.
  16593. If you're using mbox, giving a path to the INBOX
  16594. file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
  16595. where the other mailboxes are kept. This is called the @emph{root mail
  16596. directory}, and it must be the first path given in the
  16597. @samp{mail-location} setting.
  16598. There are a few special variables you can use, e.g.:
  16599. @table @samp
  16600. @item %u
  16601. username
  16602. @item %n
  16603. user part in user@@domain, same as %u if there's no domain
  16604. @item %d
  16605. domain part in user@@domain, empty if there's no domain
  16606. @item %h
  16607. home director
  16608. @end table
  16609. See doc/wiki/Variables.txt for full list. Some examples:
  16610. @table @samp
  16611. @item maildir:~/Maildir
  16612. @item mbox:~/mail:INBOX=/var/mail/%u
  16613. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  16614. @end table
  16615. Defaults to @samp{""}.
  16616. @end deftypevr
  16617. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  16618. System user and group used to access mails. If you use multiple,
  16619. userdb can override these by returning uid or gid fields. You can use
  16620. either numbers or names. <doc/wiki/UserIds.txt>.
  16621. Defaults to @samp{""}.
  16622. @end deftypevr
  16623. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  16624. Defaults to @samp{""}.
  16625. @end deftypevr
  16626. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  16627. Group to enable temporarily for privileged operations. Currently
  16628. this is used only with INBOX when either its initial creation or
  16629. dotlocking fails. Typically this is set to @samp{"mail"} to give access to
  16630. @file{/var/mail}.
  16631. Defaults to @samp{""}.
  16632. @end deftypevr
  16633. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  16634. Grant access to these supplementary groups for mail processes.
  16635. Typically these are used to set up access to shared mailboxes. Note
  16636. that it may be dangerous to set these if users can create symlinks
  16637. (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
  16638. could allow a user to delete others' mailboxes, or @code{ln -s
  16639. /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
  16640. @samp{""}.
  16641. @end deftypevr
  16642. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  16643. Allow full file system access to clients. There's no access checks
  16644. other than what the operating system does for the active UID/GID@. It
  16645. works with both maildir and mboxes, allowing you to prefix mailboxes
  16646. names with e.g.@: @file{/path/} or @file{~user/}.
  16647. Defaults to @samp{#f}.
  16648. @end deftypevr
  16649. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  16650. Don't use @code{mmap()} at all. This is required if you store indexes to
  16651. shared file systems (NFS or clustered file system).
  16652. Defaults to @samp{#f}.
  16653. @end deftypevr
  16654. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  16655. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  16656. supports @samp{O_EXCL} since version 3, so this should be safe to use
  16657. nowadays by default.
  16658. Defaults to @samp{#t}.
  16659. @end deftypevr
  16660. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  16661. When to use fsync() or fdatasync() calls:
  16662. @table @code
  16663. @item optimized
  16664. Whenever necessary to avoid losing important data
  16665. @item always
  16666. Useful with e.g.@: NFS when @code{write()}s are delayed
  16667. @item never
  16668. Never use it (best performance, but crashes can lose data).
  16669. @end table
  16670. Defaults to @samp{"optimized"}.
  16671. @end deftypevr
  16672. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  16673. Mail storage exists in NFS@. Set this to yes to make Dovecot flush
  16674. NFS caches whenever needed. If you're using only a single mail server
  16675. this isn't needed.
  16676. Defaults to @samp{#f}.
  16677. @end deftypevr
  16678. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  16679. Mail index files also exist in NFS@. Setting this to yes requires
  16680. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  16681. Defaults to @samp{#f}.
  16682. @end deftypevr
  16683. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  16684. Locking method for index files. Alternatives are fcntl, flock and
  16685. dotlock. Dotlocking uses some tricks which may create more disk I/O
  16686. than other locking methods. NFS users: flock doesn't work, remember to
  16687. change @samp{mmap-disable}.
  16688. Defaults to @samp{"fcntl"}.
  16689. @end deftypevr
  16690. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  16691. Directory in which LDA/LMTP temporarily stores incoming mails >128
  16692. kB.
  16693. Defaults to @samp{"/tmp"}.
  16694. @end deftypevr
  16695. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  16696. Valid UID range for users. This is mostly to make sure that users can't
  16697. log in as daemons or other system users. Note that denying root logins is
  16698. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  16699. is set to 0.
  16700. Defaults to @samp{500}.
  16701. @end deftypevr
  16702. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  16703. Defaults to @samp{0}.
  16704. @end deftypevr
  16705. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  16706. Valid GID range for users. Users having non-valid GID as primary group ID
  16707. aren't allowed to log in. If user belongs to supplementary groups with
  16708. non-valid GIDs, those groups are not set.
  16709. Defaults to @samp{1}.
  16710. @end deftypevr
  16711. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  16712. Defaults to @samp{0}.
  16713. @end deftypevr
  16714. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  16715. Maximum allowed length for mail keyword name. It's only forced when
  16716. trying to create new keywords.
  16717. Defaults to @samp{50}.
  16718. @end deftypevr
  16719. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  16720. List of directories under which chrooting is allowed for mail
  16721. processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
  16722. too). This setting doesn't affect @samp{login-chroot}
  16723. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  16724. @samp{/./} in home dirs are ignored. WARNING: Never add directories here
  16725. which local users can modify, that may lead to root exploit. Usually
  16726. this should be done only if you don't allow shell access for users.
  16727. <doc/wiki/Chrooting.txt>.
  16728. Defaults to @samp{()}.
  16729. @end deftypevr
  16730. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  16731. Default chroot directory for mail processes. This can be overridden
  16732. for specific users in user database by giving @samp{/./} in user's home
  16733. directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
  16734. there is no real need to do chrooting, Dovecot doesn't allow users to
  16735. access files outside their mail directory anyway. If your home
  16736. directories are prefixed with the chroot directory, append @samp{/.} to
  16737. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  16738. Defaults to @samp{""}.
  16739. @end deftypevr
  16740. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  16741. UNIX socket path to master authentication server to find users.
  16742. This is used by imap (for shared users) and lda.
  16743. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  16744. @end deftypevr
  16745. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  16746. Directory where to look up mail plugins.
  16747. Defaults to @samp{"/usr/lib/dovecot"}.
  16748. @end deftypevr
  16749. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  16750. List of plugins to load for all services. Plugins specific to IMAP,
  16751. LDA, etc.@: are added to this list in their own .conf files.
  16752. Defaults to @samp{()}.
  16753. @end deftypevr
  16754. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  16755. The minimum number of mails in a mailbox before updates are done to
  16756. cache file. This allows optimizing Dovecot's behavior to do less disk
  16757. writes at the cost of more disk reads.
  16758. Defaults to @samp{0}.
  16759. @end deftypevr
  16760. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  16761. When IDLE command is running, mailbox is checked once in a while to
  16762. see if there are any new mails or other changes. This setting defines
  16763. the minimum time to wait between those checks. Dovecot can also use
  16764. dnotify, inotify and kqueue to find out immediately when changes
  16765. occur.
  16766. Defaults to @samp{"30 secs"}.
  16767. @end deftypevr
  16768. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  16769. Save mails with CR+LF instead of plain LF@. This makes sending those
  16770. mails take less CPU, especially with sendfile() syscall with Linux and
  16771. FreeBSD@. But it also creates a bit more disk I/O which may just make it
  16772. slower. Also note that if other software reads the mboxes/maildirs,
  16773. they may handle the extra CRs wrong and cause problems.
  16774. Defaults to @samp{#f}.
  16775. @end deftypevr
  16776. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  16777. By default LIST command returns all entries in maildir beginning
  16778. with a dot. Enabling this option makes Dovecot return only entries
  16779. which are directories. This is done by stat()ing each entry, so it
  16780. causes more disk I/O.
  16781. (For systems setting struct @samp{dirent->d_type} this check is free
  16782. and it's done always regardless of this setting).
  16783. Defaults to @samp{#f}.
  16784. @end deftypevr
  16785. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  16786. When copying a message, do it with hard links whenever possible.
  16787. This makes the performance much better, and it's unlikely to have any
  16788. side effects.
  16789. Defaults to @samp{#t}.
  16790. @end deftypevr
  16791. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  16792. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  16793. directory only when its mtime changes unexpectedly or when we can't find
  16794. the mail otherwise.
  16795. Defaults to @samp{#f}.
  16796. @end deftypevr
  16797. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  16798. Which locking methods to use for locking mbox. There are four
  16799. available:
  16800. @table @code
  16801. @item dotlock
  16802. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  16803. solution. If you want to use /var/mail/ like directory, the users will
  16804. need write access to that directory.
  16805. @item dotlock-try
  16806. Same as dotlock, but if it fails because of permissions or because there
  16807. isn't enough disk space, just skip it.
  16808. @item fcntl
  16809. Use this if possible. Works with NFS too if lockd is used.
  16810. @item flock
  16811. May not exist in all systems. Doesn't work with NFS.
  16812. @item lockf
  16813. May not exist in all systems. Doesn't work with NFS.
  16814. @end table
  16815. You can use multiple locking methods; if you do the order they're declared
  16816. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  16817. locking methods as well. Some operating systems don't allow using some of
  16818. them simultaneously.
  16819. @end deftypevr
  16820. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  16821. @end deftypevr
  16822. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  16823. Maximum time to wait for lock (all of them) before aborting.
  16824. Defaults to @samp{"5 mins"}.
  16825. @end deftypevr
  16826. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  16827. If dotlock exists but the mailbox isn't modified in any way,
  16828. override the lock file after this much time.
  16829. Defaults to @samp{"2 mins"}.
  16830. @end deftypevr
  16831. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  16832. When mbox changes unexpectedly we have to fully read it to find out
  16833. what changed. If the mbox is large this can take a long time. Since
  16834. the change is usually just a newly appended mail, it'd be faster to
  16835. simply read the new mails. If this setting is enabled, Dovecot does
  16836. this but still safely fallbacks to re-reading the whole mbox file
  16837. whenever something in mbox isn't how it's expected to be. The only real
  16838. downside to this setting is that if some other MUA changes message
  16839. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  16840. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  16841. Defaults to @samp{#t}.
  16842. @end deftypevr
  16843. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  16844. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  16845. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  16846. @samp{mbox-dirty-syncs} is ignored.
  16847. Defaults to @samp{#f}.
  16848. @end deftypevr
  16849. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  16850. Delay writing mbox headers until doing a full write sync (EXPUNGE
  16851. and CHECK commands and when closing the mailbox). This is especially
  16852. useful for POP3 where clients often delete all mails. The downside is
  16853. that our changes aren't immediately visible to other MUAs.
  16854. Defaults to @samp{#t}.
  16855. @end deftypevr
  16856. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  16857. If mbox size is smaller than this (e.g.@: 100k), don't write index
  16858. files. If an index file already exists it's still read, just not
  16859. updated.
  16860. Defaults to @samp{0}.
  16861. @end deftypevr
  16862. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  16863. Maximum dbox file size until it's rotated.
  16864. Defaults to @samp{10000000}.
  16865. @end deftypevr
  16866. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  16867. Maximum dbox file age until it's rotated. Typically in days. Day
  16868. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  16869. disabled.
  16870. Defaults to @samp{"1d"}.
  16871. @end deftypevr
  16872. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  16873. When creating new mdbox files, immediately preallocate their size to
  16874. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  16875. with some file systems (ext4, xfs).
  16876. Defaults to @samp{#f}.
  16877. @end deftypevr
  16878. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  16879. sdbox and mdbox support saving mail attachments to external files,
  16880. which also allows single instance storage for them. Other backends
  16881. don't support this for now.
  16882. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  16883. Directory root where to store mail attachments. Disabled, if empty.
  16884. Defaults to @samp{""}.
  16885. @end deftypevr
  16886. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  16887. Attachments smaller than this aren't saved externally. It's also
  16888. possible to write a plugin to disable saving specific attachments
  16889. externally.
  16890. Defaults to @samp{128000}.
  16891. @end deftypevr
  16892. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  16893. File system backend to use for saving attachments:
  16894. @table @code
  16895. @item posix
  16896. No SiS done by Dovecot (but this might help FS's own deduplication)
  16897. @item sis posix
  16898. SiS with immediate byte-by-byte comparison during saving
  16899. @item sis-queue posix
  16900. SiS with delayed comparison and deduplication.
  16901. @end table
  16902. Defaults to @samp{"sis posix"}.
  16903. @end deftypevr
  16904. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  16905. Hash format to use in attachment filenames. You can add any text and
  16906. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  16907. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  16908. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  16909. Defaults to @samp{"%@{sha1@}"}.
  16910. @end deftypevr
  16911. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  16912. Defaults to @samp{100}.
  16913. @end deftypevr
  16914. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  16915. Defaults to @samp{1000}.
  16916. @end deftypevr
  16917. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  16918. Default VSZ (virtual memory size) limit for service processes.
  16919. This is mainly intended to catch and kill processes that leak memory
  16920. before they eat up everything.
  16921. Defaults to @samp{256000000}.
  16922. @end deftypevr
  16923. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  16924. Login user is internally used by login processes. This is the most
  16925. untrusted user in Dovecot system. It shouldn't have access to anything
  16926. at all.
  16927. Defaults to @samp{"dovenull"}.
  16928. @end deftypevr
  16929. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  16930. Internal user is used by unprivileged processes. It should be
  16931. separate from login user, so that login processes can't disturb other
  16932. processes.
  16933. Defaults to @samp{"dovecot"}.
  16934. @end deftypevr
  16935. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  16936. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  16937. Defaults to @samp{"required"}.
  16938. @end deftypevr
  16939. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  16940. PEM encoded X.509 SSL/TLS certificate (public key).
  16941. Defaults to @samp{"</etc/dovecot/default.pem"}.
  16942. @end deftypevr
  16943. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  16944. PEM encoded SSL/TLS private key. The key is opened before
  16945. dropping root privileges, so keep the key file unreadable by anyone but
  16946. root.
  16947. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  16948. @end deftypevr
  16949. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  16950. If key file is password protected, give the password here.
  16951. Alternatively give it when starting dovecot with -p parameter. Since
  16952. this file is often world-readable, you may want to place this setting
  16953. instead to a different.
  16954. Defaults to @samp{""}.
  16955. @end deftypevr
  16956. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  16957. PEM encoded trusted certificate authority. Set this only if you
  16958. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  16959. contain the CA certificate(s) followed by the matching
  16960. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  16961. Defaults to @samp{""}.
  16962. @end deftypevr
  16963. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  16964. Require that CRL check succeeds for client certificates.
  16965. Defaults to @samp{#t}.
  16966. @end deftypevr
  16967. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  16968. Request client to send a certificate. If you also want to require
  16969. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  16970. Defaults to @samp{#f}.
  16971. @end deftypevr
  16972. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  16973. Which field from certificate to use for username. commonName and
  16974. x500UniqueIdentifier are the usual choices. You'll also need to set
  16975. @samp{auth-ssl-username-from-cert? #t}.
  16976. Defaults to @samp{"commonName"}.
  16977. @end deftypevr
  16978. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  16979. Minimum SSL protocol version to accept.
  16980. Defaults to @samp{"TLSv1"}.
  16981. @end deftypevr
  16982. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  16983. SSL ciphers to use.
  16984. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  16985. @end deftypevr
  16986. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  16987. SSL crypto device to use, for valid values run "openssl engine".
  16988. Defaults to @samp{""}.
  16989. @end deftypevr
  16990. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  16991. Address to use when sending rejection mails.
  16992. %d expands to recipient domain.
  16993. Defaults to @samp{"postmaster@@%d"}.
  16994. @end deftypevr
  16995. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  16996. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  16997. and in LMTP replies. Default is the system's real hostname@@domain.
  16998. Defaults to @samp{""}.
  16999. @end deftypevr
  17000. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  17001. If user is over quota, return with temporary failure instead of
  17002. bouncing the mail.
  17003. Defaults to @samp{#f}.
  17004. @end deftypevr
  17005. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  17006. Binary to use for sending mails.
  17007. Defaults to @samp{"/usr/sbin/sendmail"}.
  17008. @end deftypevr
  17009. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  17010. If non-empty, send mails via this SMTP host[:port] instead of
  17011. sendmail.
  17012. Defaults to @samp{""}.
  17013. @end deftypevr
  17014. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  17015. Subject: header to use for rejection mails. You can use the same
  17016. variables as for @samp{rejection-reason} below.
  17017. Defaults to @samp{"Rejected: %s"}.
  17018. @end deftypevr
  17019. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  17020. Human readable error message for rejection mails. You can use
  17021. variables:
  17022. @table @code
  17023. @item %n
  17024. CRLF
  17025. @item %r
  17026. reason
  17027. @item %s
  17028. original subject
  17029. @item %t
  17030. recipient
  17031. @end table
  17032. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  17033. @end deftypevr
  17034. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  17035. Delimiter character between local-part and detail in email
  17036. address.
  17037. Defaults to @samp{"+"}.
  17038. @end deftypevr
  17039. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  17040. Header where the original recipient address (SMTP's RCPT TO:
  17041. address) is taken from if not available elsewhere. With dovecot-lda -a
  17042. parameter overrides this. A commonly used header for this is
  17043. X-Original-To.
  17044. Defaults to @samp{""}.
  17045. @end deftypevr
  17046. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  17047. Should saving a mail to a nonexistent mailbox automatically create
  17048. it?.
  17049. Defaults to @samp{#f}.
  17050. @end deftypevr
  17051. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  17052. Should automatically created mailboxes be also automatically
  17053. subscribed?.
  17054. Defaults to @samp{#f}.
  17055. @end deftypevr
  17056. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  17057. Maximum IMAP command line length. Some clients generate very long
  17058. command lines with huge mailboxes, so you may need to raise this if you
  17059. get "Too long argument" or "IMAP command line too large" errors
  17060. often.
  17061. Defaults to @samp{64000}.
  17062. @end deftypevr
  17063. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  17064. IMAP logout format string:
  17065. @table @code
  17066. @item %i
  17067. total number of bytes read from client
  17068. @item %o
  17069. total number of bytes sent to client.
  17070. @end table
  17071. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  17072. 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@}"}.
  17073. @end deftypevr
  17074. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  17075. Override the IMAP CAPABILITY response. If the value begins with '+',
  17076. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  17077. Defaults to @samp{""}.
  17078. @end deftypevr
  17079. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  17080. How long to wait between "OK Still here" notifications when client
  17081. is IDLEing.
  17082. Defaults to @samp{"2 mins"}.
  17083. @end deftypevr
  17084. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  17085. ID field names and values to send to clients. Using * as the value
  17086. makes Dovecot use the default value. The following fields have default
  17087. values currently: name, version, os, os-version, support-url,
  17088. support-email.
  17089. Defaults to @samp{""}.
  17090. @end deftypevr
  17091. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  17092. ID fields sent by client to log. * means everything.
  17093. Defaults to @samp{""}.
  17094. @end deftypevr
  17095. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  17096. Workarounds for various client bugs:
  17097. @table @code
  17098. @item delay-newmail
  17099. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  17100. CHECK commands. Some clients ignore them otherwise, for example OSX
  17101. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  17102. may show user "Message no longer in server" errors. Note that OE6
  17103. still breaks even with this workaround if synchronization is set to
  17104. "Headers Only".
  17105. @item tb-extra-mailbox-sep
  17106. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  17107. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  17108. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  17109. @item tb-lsub-flags
  17110. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  17111. This makes Thunderbird realize they aren't selectable and show them
  17112. greyed out, instead of only later giving "not selectable" popup error.
  17113. @end table
  17114. Defaults to @samp{()}.
  17115. @end deftypevr
  17116. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  17117. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  17118. Defaults to @samp{""}.
  17119. @end deftypevr
  17120. Whew! Lots of configuration options. The nice thing about it though is
  17121. that Guix has a complete interface to Dovecot's configuration
  17122. language. This allows not only a nice way to declare configurations,
  17123. but also offers reflective capabilities as well: users can write code to
  17124. inspect and transform configurations from within Scheme.
  17125. However, it could be that you just want to get a @code{dovecot.conf} up
  17126. and running. In that case, you can pass an
  17127. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  17128. @code{dovecot-service}. As its name indicates, an opaque configuration
  17129. does not have easy reflective capabilities.
  17130. Available @code{opaque-dovecot-configuration} fields are:
  17131. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  17132. The dovecot package.
  17133. @end deftypevr
  17134. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  17135. The contents of the @code{dovecot.conf}, as a string.
  17136. @end deftypevr
  17137. For example, if your @code{dovecot.conf} is just the empty string, you
  17138. could instantiate a dovecot service like this:
  17139. @lisp
  17140. (dovecot-service #:config
  17141. (opaque-dovecot-configuration
  17142. (string "")))
  17143. @end lisp
  17144. @subsubheading OpenSMTPD Service
  17145. @deffn {Scheme Variable} opensmtpd-service-type
  17146. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  17147. service, whose value should be an @code{opensmtpd-configuration} object
  17148. as in this example:
  17149. @lisp
  17150. (service opensmtpd-service-type
  17151. (opensmtpd-configuration
  17152. (config-file (local-file "./my-smtpd.conf"))))
  17153. @end lisp
  17154. @end deffn
  17155. @deftp {Data Type} opensmtpd-configuration
  17156. Data type representing the configuration of opensmtpd.
  17157. @table @asis
  17158. @item @code{package} (default: @var{opensmtpd})
  17159. Package object of the OpenSMTPD SMTP server.
  17160. @item @code{config-file} (default: @code{%default-opensmtpd-file})
  17161. File-like object of the OpenSMTPD configuration file to use. By default
  17162. it listens on the loopback network interface, and allows for mail from
  17163. users and daemons on the local machine, as well as permitting email to
  17164. remote servers. Run @command{man smtpd.conf} for more information.
  17165. @end table
  17166. @end deftp
  17167. @subsubheading Exim Service
  17168. @cindex mail transfer agent (MTA)
  17169. @cindex MTA (mail transfer agent)
  17170. @cindex SMTP
  17171. @deffn {Scheme Variable} exim-service-type
  17172. This is the type of the @uref{https://exim.org, Exim} mail transfer
  17173. agent (MTA), whose value should be an @code{exim-configuration} object
  17174. as in this example:
  17175. @lisp
  17176. (service exim-service-type
  17177. (exim-configuration
  17178. (config-file (local-file "./my-exim.conf"))))
  17179. @end lisp
  17180. @end deffn
  17181. In order to use an @code{exim-service-type} service you must also have a
  17182. @code{mail-aliases-service-type} service present in your
  17183. @code{operating-system} (even if it has no aliases).
  17184. @deftp {Data Type} exim-configuration
  17185. Data type representing the configuration of exim.
  17186. @table @asis
  17187. @item @code{package} (default: @var{exim})
  17188. Package object of the Exim server.
  17189. @item @code{config-file} (default: @code{#f})
  17190. File-like object of the Exim configuration file to use. If its value is
  17191. @code{#f} then use the default configuration file from the package
  17192. provided in @code{package}. The resulting configuration file is loaded
  17193. after setting the @code{exim_user} and @code{exim_group} configuration
  17194. variables.
  17195. @end table
  17196. @end deftp
  17197. @subsubheading Getmail service
  17198. @cindex IMAP
  17199. @cindex POP
  17200. @deffn {Scheme Variable} getmail-service-type
  17201. This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
  17202. mail retriever, whose value should be an @code{getmail-configuration}.
  17203. @end deffn
  17204. Available @code{getmail-configuration} fields are:
  17205. @deftypevr {@code{getmail-configuration} parameter} symbol name
  17206. A symbol to identify the getmail service.
  17207. Defaults to @samp{"unset"}.
  17208. @end deftypevr
  17209. @deftypevr {@code{getmail-configuration} parameter} package package
  17210. The getmail package to use.
  17211. @end deftypevr
  17212. @deftypevr {@code{getmail-configuration} parameter} string user
  17213. The user to run getmail as.
  17214. Defaults to @samp{"getmail"}.
  17215. @end deftypevr
  17216. @deftypevr {@code{getmail-configuration} parameter} string group
  17217. The group to run getmail as.
  17218. Defaults to @samp{"getmail"}.
  17219. @end deftypevr
  17220. @deftypevr {@code{getmail-configuration} parameter} string directory
  17221. The getmail directory to use.
  17222. Defaults to @samp{"/var/lib/getmail/default"}.
  17223. @end deftypevr
  17224. @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
  17225. The getmail configuration file to use.
  17226. Available @code{getmail-configuration-file} fields are:
  17227. @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
  17228. What mail account to retrieve mail from, and how to access that account.
  17229. Available @code{getmail-retriever-configuration} fields are:
  17230. @deftypevr {@code{getmail-retriever-configuration} parameter} string type
  17231. The type of mail retriever to use. Valid values include @samp{passwd}
  17232. and @samp{static}.
  17233. Defaults to @samp{"SimpleIMAPSSLRetriever"}.
  17234. @end deftypevr
  17235. @deftypevr {@code{getmail-retriever-configuration} parameter} string server
  17236. Username to login to the mail server with.
  17237. Defaults to @samp{unset}.
  17238. @end deftypevr
  17239. @deftypevr {@code{getmail-retriever-configuration} parameter} string username
  17240. Username to login to the mail server with.
  17241. Defaults to @samp{unset}.
  17242. @end deftypevr
  17243. @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
  17244. Port number to connect to.
  17245. Defaults to @samp{#f}.
  17246. @end deftypevr
  17247. @deftypevr {@code{getmail-retriever-configuration} parameter} string password
  17248. Override fields from passwd.
  17249. Defaults to @samp{""}.
  17250. @end deftypevr
  17251. @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
  17252. Override fields from passwd.
  17253. Defaults to @samp{()}.
  17254. @end deftypevr
  17255. @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
  17256. PEM-formatted key file to use for the TLS negotiation.
  17257. Defaults to @samp{""}.
  17258. @end deftypevr
  17259. @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
  17260. PEM-formatted certificate file to use for the TLS negotiation.
  17261. Defaults to @samp{""}.
  17262. @end deftypevr
  17263. @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
  17264. CA certificates to use.
  17265. Defaults to @samp{""}.
  17266. @end deftypevr
  17267. @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
  17268. Extra retriever parameters.
  17269. Defaults to @samp{()}.
  17270. @end deftypevr
  17271. @end deftypevr
  17272. @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
  17273. What to do with retrieved messages.
  17274. Available @code{getmail-destination-configuration} fields are:
  17275. @deftypevr {@code{getmail-destination-configuration} parameter} string type
  17276. The type of mail destination. Valid values include @samp{Maildir},
  17277. @samp{Mboxrd} and @samp{MDA_external}.
  17278. Defaults to @samp{unset}.
  17279. @end deftypevr
  17280. @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
  17281. The path option for the mail destination. The behaviour depends on the
  17282. chosen type.
  17283. Defaults to @samp{""}.
  17284. @end deftypevr
  17285. @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
  17286. Extra destination parameters
  17287. Defaults to @samp{()}.
  17288. @end deftypevr
  17289. @end deftypevr
  17290. @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
  17291. Configure getmail.
  17292. Available @code{getmail-options-configuration} fields are:
  17293. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
  17294. If set to @samp{0}, getmail will only print warnings and errors. A
  17295. value of @samp{1} means that messages will be printed about retrieving
  17296. and deleting messages. If set to @samp{2}, getmail will print messages
  17297. about each of it's actions.
  17298. Defaults to @samp{1}.
  17299. @end deftypevr
  17300. @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
  17301. If true, getmail will retrieve all available messages. Otherwise it
  17302. will only retrieve messages it hasn't seen previously.
  17303. Defaults to @samp{#t}.
  17304. @end deftypevr
  17305. @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
  17306. If set to true, messages will be deleted from the server after
  17307. retrieving and successfully delivering them. Otherwise, messages will
  17308. be left on the server.
  17309. Defaults to @samp{#f}.
  17310. @end deftypevr
  17311. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
  17312. Getmail will delete messages this number of days after seeing them, if
  17313. they have been delivered. This means messages will be left on the
  17314. server this number of days after delivering them. A value of @samp{0}
  17315. disabled this feature.
  17316. Defaults to @samp{0}.
  17317. @end deftypevr
  17318. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
  17319. Delete messages larger than this of bytes after retrieving them, even if
  17320. the delete and delete-after options are disabled. A value of @samp{0}
  17321. disables this feature.
  17322. Defaults to @samp{0}.
  17323. @end deftypevr
  17324. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
  17325. Retrieve messages totalling up to this number of bytes before closing
  17326. the session with the server. A value of @samp{0} disables this feature.
  17327. Defaults to @samp{0}.
  17328. @end deftypevr
  17329. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
  17330. Don't retrieve messages larger than this number of bytes. A value of
  17331. @samp{0} disables this feature.
  17332. Defaults to @samp{0}.
  17333. @end deftypevr
  17334. @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
  17335. If true, getmail will add a Delivered-To header to messages.
  17336. Defaults to @samp{#t}.
  17337. @end deftypevr
  17338. @deftypevr {@code{getmail-options-configuration} parameter} boolean received
  17339. If set, getmail adds a Received header to the messages.
  17340. Defaults to @samp{#t}.
  17341. @end deftypevr
  17342. @deftypevr {@code{getmail-options-configuration} parameter} string message-log
  17343. Getmail will record a log of its actions to the named file. A value of
  17344. @samp{""} disables this feature.
  17345. Defaults to @samp{""}.
  17346. @end deftypevr
  17347. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
  17348. If true, getmail will record a log of its actions using the system
  17349. logger.
  17350. Defaults to @samp{#f}.
  17351. @end deftypevr
  17352. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
  17353. If true, getmail will log information about messages not retrieved and
  17354. the reason for not retrieving them, as well as starting and ending
  17355. information lines.
  17356. Defaults to @samp{#f}.
  17357. @end deftypevr
  17358. @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
  17359. Extra options to include.
  17360. Defaults to @samp{()}.
  17361. @end deftypevr
  17362. @end deftypevr
  17363. @end deftypevr
  17364. @deftypevr {@code{getmail-configuration} parameter} list idle
  17365. A list of mailboxes that getmail should wait on the server for new mail
  17366. notifications. This depends on the server supporting the IDLE
  17367. extension.
  17368. Defaults to @samp{()}.
  17369. @end deftypevr
  17370. @deftypevr {@code{getmail-configuration} parameter} list environment-variables
  17371. Environment variables to set for getmail.
  17372. Defaults to @samp{()}.
  17373. @end deftypevr
  17374. @subsubheading Mail Aliases Service
  17375. @cindex email aliases
  17376. @cindex aliases, for email addresses
  17377. @deffn {Scheme Variable} mail-aliases-service-type
  17378. This is the type of the service which provides @code{/etc/aliases},
  17379. specifying how to deliver mail to users on this system.
  17380. @lisp
  17381. (service mail-aliases-service-type
  17382. '(("postmaster" "bob")
  17383. ("bob" "bob@@example.com" "bob@@example2.com")))
  17384. @end lisp
  17385. @end deffn
  17386. The configuration for a @code{mail-aliases-service-type} service is an
  17387. association list denoting how to deliver mail that comes to this
  17388. system. Each entry is of the form @code{(alias addresses ...)}, with
  17389. @code{alias} specifying the local alias and @code{addresses} specifying
  17390. where to deliver this user's mail.
  17391. The aliases aren't required to exist as users on the local system. In
  17392. the above example, there doesn't need to be a @code{postmaster} entry in
  17393. the @code{operating-system}'s @code{user-accounts} in order to deliver
  17394. the @code{postmaster} mail to @code{bob} (which subsequently would
  17395. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  17396. @subsubheading GNU Mailutils IMAP4 Daemon
  17397. @cindex GNU Mailutils IMAP4 Daemon
  17398. @deffn {Scheme Variable} imap4d-service-type
  17399. This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
  17400. mailutils, GNU Mailutils Manual}), whose value should be an
  17401. @code{imap4d-configuration} object as in this example:
  17402. @lisp
  17403. (service imap4d-service-type
  17404. (imap4d-configuration
  17405. (config-file (local-file "imap4d.conf"))))
  17406. @end lisp
  17407. @end deffn
  17408. @deftp {Data Type} imap4d-configuration
  17409. Data type representing the configuration of @command{imap4d}.
  17410. @table @asis
  17411. @item @code{package} (default: @code{mailutils})
  17412. The package that provides @command{imap4d}.
  17413. @item @code{config-file} (default: @code{%default-imap4d-config-file})
  17414. File-like object of the configuration file to use, by default it will listen
  17415. on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
  17416. Mailutils Manual}, for details.
  17417. @end table
  17418. @end deftp
  17419. @subsubheading Radicale Service
  17420. @cindex CalDAV
  17421. @cindex CardDAV
  17422. @deffn {Scheme Variable} radicale-service-type
  17423. This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV
  17424. server whose value should be a @code{radicale-configuration}.
  17425. @end deffn
  17426. @deftp {Data Type} radicale-configuration
  17427. Data type representing the configuration of @command{radicale}.
  17428. @table @asis
  17429. @item @code{package} (default: @code{radicale})
  17430. The package that provides @command{radicale}.
  17431. @item @code{config-file} (default: @code{%default-radicale-config-file})
  17432. File-like object of the configuration file to use, by default it will listen
  17433. on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at
  17434. @file{/var/lib/radicale/users} with no (@code{plain}) encryption.
  17435. @end table
  17436. @end deftp
  17437. @node Messaging Services
  17438. @subsection Messaging Services
  17439. @cindex messaging
  17440. @cindex jabber
  17441. @cindex XMPP
  17442. The @code{(gnu services messaging)} module provides Guix service
  17443. definitions for messaging services. Currently it provides the following
  17444. services:
  17445. @subsubheading Prosody Service
  17446. @deffn {Scheme Variable} prosody-service-type
  17447. This is the type for the @uref{https://prosody.im, Prosody XMPP
  17448. communication server}. Its value must be a @code{prosody-configuration}
  17449. record as in this example:
  17450. @lisp
  17451. (service prosody-service-type
  17452. (prosody-configuration
  17453. (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
  17454. (int-components
  17455. (list
  17456. (int-component-configuration
  17457. (hostname "conference.example.net")
  17458. (plugin "muc")
  17459. (mod-muc (mod-muc-configuration)))))
  17460. (virtualhosts
  17461. (list
  17462. (virtualhost-configuration
  17463. (domain "example.net"))))))
  17464. @end lisp
  17465. See below for details about @code{prosody-configuration}.
  17466. @end deffn
  17467. By default, Prosody does not need much configuration. Only one
  17468. @code{virtualhosts} field is needed: it specifies the domain you wish
  17469. Prosody to serve.
  17470. You can perform various sanity checks on the generated configuration
  17471. with the @code{prosodyctl check} command.
  17472. Prosodyctl will also help you to import certificates from the
  17473. @code{letsencrypt} directory so that the @code{prosody} user can access
  17474. them. See @url{https://prosody.im/doc/letsencrypt}.
  17475. @example
  17476. prosodyctl --root cert import /etc/letsencrypt/live
  17477. @end example
  17478. The available configuration parameters follow. Each parameter
  17479. definition is preceded by its type; for example, @samp{string-list foo}
  17480. indicates that the @code{foo} parameter should be specified as a list of
  17481. strings. Types starting with @code{maybe-} denote parameters that won't
  17482. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  17483. There is also a way to specify the configuration as a string, if you
  17484. have an old @code{prosody.cfg.lua} file that you want to port over from
  17485. some other system; see the end for more details.
  17486. The @code{file-object} type designates either a file-like object
  17487. (@pxref{G-Expressions, file-like objects}) or a file name.
  17488. @c The following documentation was initially generated by
  17489. @c (generate-documentation) in (gnu services messaging). Manually maintained
  17490. @c documentation is better, so we shouldn't hesitate to edit below as
  17491. @c needed. However if the change you want to make to this documentation
  17492. @c can be done in an automated way, it's probably easier to change
  17493. @c (generate-documentation) than to make it below and have to deal with
  17494. @c the churn as Prosody updates.
  17495. Available @code{prosody-configuration} fields are:
  17496. @deftypevr {@code{prosody-configuration} parameter} package prosody
  17497. The Prosody package.
  17498. @end deftypevr
  17499. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  17500. Location of the Prosody data storage directory. See
  17501. @url{https://prosody.im/doc/configure}.
  17502. Defaults to @samp{"/var/lib/prosody"}.
  17503. @end deftypevr
  17504. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  17505. Additional plugin directories. They are searched in all the specified
  17506. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  17507. Defaults to @samp{()}.
  17508. @end deftypevr
  17509. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  17510. Every virtual host and component needs a certificate so that clients and
  17511. servers can securely verify its identity. Prosody will automatically load
  17512. certificates/keys from the directory specified here.
  17513. Defaults to @samp{"/etc/prosody/certs"}.
  17514. @end deftypevr
  17515. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  17516. This is a list of accounts that are admins for the server. Note that you
  17517. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  17518. @url{https://prosody.im/doc/creating_accounts}.
  17519. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  17520. Defaults to @samp{()}.
  17521. @end deftypevr
  17522. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  17523. Enable use of libevent for better performance under high load. See
  17524. @url{https://prosody.im/doc/libevent}.
  17525. Defaults to @samp{#f}.
  17526. @end deftypevr
  17527. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  17528. This is the list of modules Prosody will load on startup. It looks for
  17529. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  17530. Documentation on modules can be found at:
  17531. @url{https://prosody.im/doc/modules}.
  17532. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  17533. @end deftypevr
  17534. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  17535. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  17536. should you want to disable them then add them to this list.
  17537. Defaults to @samp{()}.
  17538. @end deftypevr
  17539. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  17540. Path to a text file where the shared groups are defined. If this path is
  17541. empty then @samp{mod_groups} does nothing. See
  17542. @url{https://prosody.im/doc/modules/mod_groups}.
  17543. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  17544. @end deftypevr
  17545. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  17546. Disable account creation by default, for security. See
  17547. @url{https://prosody.im/doc/creating_accounts}.
  17548. Defaults to @samp{#f}.
  17549. @end deftypevr
  17550. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  17551. These are the SSL/TLS-related settings. Most of them are disabled so to
  17552. use Prosody's defaults. If you do not completely understand these options, do
  17553. not add them to your config, it is easy to lower the security of your server
  17554. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  17555. Available @code{ssl-configuration} fields are:
  17556. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  17557. This determines what handshake to use.
  17558. @end deftypevr
  17559. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  17560. Path to your private key file.
  17561. @end deftypevr
  17562. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  17563. Path to your certificate file.
  17564. @end deftypevr
  17565. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  17566. Path to directory containing root certificates that you wish Prosody to
  17567. trust when verifying the certificates of remote servers.
  17568. Defaults to @samp{"/etc/ssl/certs"}.
  17569. @end deftypevr
  17570. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  17571. Path to a file containing root certificates that you wish Prosody to trust.
  17572. Similar to @code{capath} but with all certificates concatenated together.
  17573. @end deftypevr
  17574. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  17575. A list of verification options (these mostly map to OpenSSL's
  17576. @code{set_verify()} flags).
  17577. @end deftypevr
  17578. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  17579. A list of general options relating to SSL/TLS@. These map to OpenSSL's
  17580. @code{set_options()}. For a full list of options available in LuaSec, see the
  17581. LuaSec source.
  17582. @end deftypevr
  17583. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  17584. How long a chain of certificate authorities to check when looking for a
  17585. trusted root certificate.
  17586. @end deftypevr
  17587. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  17588. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  17589. clients, and in what order.
  17590. @end deftypevr
  17591. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  17592. A path to a file containing parameters for Diffie-Hellman key exchange. You
  17593. can create such a file with:
  17594. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  17595. @end deftypevr
  17596. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  17597. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  17598. @samp{"secp384r1"}.
  17599. @end deftypevr
  17600. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  17601. A list of ``extra'' verification options.
  17602. @end deftypevr
  17603. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  17604. Password for encrypted private keys.
  17605. @end deftypevr
  17606. @end deftypevr
  17607. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  17608. Whether to force all client-to-server connections to be encrypted or not.
  17609. See @url{https://prosody.im/doc/modules/mod_tls}.
  17610. Defaults to @samp{#f}.
  17611. @end deftypevr
  17612. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  17613. Set of mechanisms that will never be offered. See
  17614. @url{https://prosody.im/doc/modules/mod_saslauth}.
  17615. Defaults to @samp{("DIGEST-MD5")}.
  17616. @end deftypevr
  17617. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  17618. Whether to force all server-to-server connections to be encrypted or not.
  17619. See @url{https://prosody.im/doc/modules/mod_tls}.
  17620. Defaults to @samp{#f}.
  17621. @end deftypevr
  17622. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  17623. Whether to require encryption and certificate authentication. This
  17624. provides ideal security, but requires servers you communicate with to support
  17625. encryption AND present valid, trusted certificates. See
  17626. @url{https://prosody.im/doc/s2s#security}.
  17627. Defaults to @samp{#f}.
  17628. @end deftypevr
  17629. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  17630. Many servers don't support encryption or have invalid or self-signed
  17631. certificates. You can list domains here that will not be required to
  17632. authenticate using certificates. They will be authenticated using DNS@. See
  17633. @url{https://prosody.im/doc/s2s#security}.
  17634. Defaults to @samp{()}.
  17635. @end deftypevr
  17636. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  17637. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  17638. valid certificates for some domains by specifying a list here. See
  17639. @url{https://prosody.im/doc/s2s#security}.
  17640. Defaults to @samp{()}.
  17641. @end deftypevr
  17642. @deftypevr {@code{prosody-configuration} parameter} string authentication
  17643. Select the authentication backend to use. The default provider stores
  17644. passwords in plaintext and uses Prosody's configured data storage to store the
  17645. authentication data. If you do not trust your server please see
  17646. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  17647. about using the hashed backend. See also
  17648. @url{https://prosody.im/doc/authentication}
  17649. Defaults to @samp{"internal_plain"}.
  17650. @end deftypevr
  17651. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  17652. Set logging options. Advanced logging configuration is not yet supported
  17653. by the Prosody service. See @url{https://prosody.im/doc/logging}.
  17654. Defaults to @samp{"*syslog"}.
  17655. @end deftypevr
  17656. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  17657. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  17658. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  17659. @end deftypevr
  17660. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  17661. Maximum allowed size of the HTTP body (in bytes).
  17662. @end deftypevr
  17663. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  17664. Some modules expose their own URL in various ways. This URL is built
  17665. from the protocol, host and port used. If Prosody sits behind a proxy, the
  17666. public URL will be @code{http-external-url} instead. See
  17667. @url{https://prosody.im/doc/http#external_url}.
  17668. @end deftypevr
  17669. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  17670. A host in Prosody is a domain on which user accounts can be created. For
  17671. example if you want your users to have addresses like
  17672. @samp{"john.smith@@example.com"} then you need to add a host
  17673. @samp{"example.com"}. All options in this list will apply only to this host.
  17674. Note: the name @emph{virtual} host is used in configuration to avoid confusion with
  17675. the actual physical host that Prosody is installed on. A single Prosody
  17676. instance can serve many domains, each one defined as a VirtualHost entry in
  17677. Prosody's configuration. Conversely a server that hosts a single domain would
  17678. have just one VirtualHost entry.
  17679. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  17680. Available @code{virtualhost-configuration} fields are:
  17681. 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:
  17682. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  17683. Domain you wish Prosody to serve.
  17684. @end deftypevr
  17685. @end deftypevr
  17686. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  17687. Components are extra services on a server which are available to clients,
  17688. usually on a subdomain of the main server (such as
  17689. @samp{"mycomponent.example.com"}). Example components might be chatroom
  17690. servers, user directories, or gateways to other protocols.
  17691. Internal components are implemented with Prosody-specific plugins. To add an
  17692. internal component, you simply fill the hostname field, and the plugin you wish
  17693. to use for the component.
  17694. See @url{https://prosody.im/doc/components}.
  17695. Defaults to @samp{()}.
  17696. Available @code{int-component-configuration} fields are:
  17697. 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:
  17698. @deftypevr {@code{int-component-configuration} parameter} string hostname
  17699. Hostname of the component.
  17700. @end deftypevr
  17701. @deftypevr {@code{int-component-configuration} parameter} string plugin
  17702. Plugin you wish to use for the component.
  17703. @end deftypevr
  17704. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  17705. Multi-user chat (MUC) is Prosody's module for allowing you to create
  17706. hosted chatrooms/conferences for XMPP users.
  17707. General information on setting up and using multi-user chatrooms can be found
  17708. in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
  17709. which you should read if you are new to XMPP chatrooms.
  17710. See also @url{https://prosody.im/doc/modules/mod_muc}.
  17711. Available @code{mod-muc-configuration} fields are:
  17712. @deftypevr {@code{mod-muc-configuration} parameter} string name
  17713. The name to return in service discovery responses.
  17714. Defaults to @samp{"Prosody Chatrooms"}.
  17715. @end deftypevr
  17716. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  17717. If @samp{#t}, this will only allow admins to create new chatrooms.
  17718. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  17719. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  17720. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  17721. restricts to service administrators only.
  17722. Defaults to @samp{#f}.
  17723. @end deftypevr
  17724. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  17725. Maximum number of history messages that will be sent to the member that has
  17726. just joined the room.
  17727. Defaults to @samp{20}.
  17728. @end deftypevr
  17729. @end deftypevr
  17730. @end deftypevr
  17731. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  17732. External components use XEP-0114, which most standalone components
  17733. support. To add an external component, you simply fill the hostname field. See
  17734. @url{https://prosody.im/doc/components}.
  17735. Defaults to @samp{()}.
  17736. Available @code{ext-component-configuration} fields are:
  17737. 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:
  17738. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  17739. Password which the component will use to log in.
  17740. @end deftypevr
  17741. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  17742. Hostname of the component.
  17743. @end deftypevr
  17744. @end deftypevr
  17745. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  17746. Port(s) Prosody listens on for component connections.
  17747. Defaults to @samp{(5347)}.
  17748. @end deftypevr
  17749. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  17750. Interface Prosody listens on for component connections.
  17751. Defaults to @samp{"127.0.0.1"}.
  17752. @end deftypevr
  17753. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  17754. Raw content that will be added to the configuration file.
  17755. @end deftypevr
  17756. It could be that you just want to get a @code{prosody.cfg.lua}
  17757. up and running. In that case, you can pass an
  17758. @code{opaque-prosody-configuration} record as the value of
  17759. @code{prosody-service-type}. As its name indicates, an opaque configuration
  17760. does not have easy reflective capabilities.
  17761. Available @code{opaque-prosody-configuration} fields are:
  17762. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  17763. The prosody package.
  17764. @end deftypevr
  17765. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  17766. The contents of the @code{prosody.cfg.lua} to use.
  17767. @end deftypevr
  17768. For example, if your @code{prosody.cfg.lua} is just the empty
  17769. string, you could instantiate a prosody service like this:
  17770. @lisp
  17771. (service prosody-service-type
  17772. (opaque-prosody-configuration
  17773. (prosody.cfg.lua "")))
  17774. @end lisp
  17775. @c end of Prosody auto-generated documentation
  17776. @subsubheading BitlBee Service
  17777. @cindex IRC (Internet Relay Chat)
  17778. @cindex IRC gateway
  17779. @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
  17780. interface to a variety of messaging protocols such as XMPP.
  17781. @defvr {Scheme Variable} bitlbee-service-type
  17782. This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
  17783. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  17784. below).
  17785. To have BitlBee listen on port 6667 on localhost, add this line to your
  17786. services:
  17787. @lisp
  17788. (service bitlbee-service-type)
  17789. @end lisp
  17790. @end defvr
  17791. @deftp {Data Type} bitlbee-configuration
  17792. This is the configuration for BitlBee, with the following fields:
  17793. @table @asis
  17794. @item @code{interface} (default: @code{"127.0.0.1"})
  17795. @itemx @code{port} (default: @code{6667})
  17796. Listen on the network interface corresponding to the IP address
  17797. specified in @var{interface}, on @var{port}.
  17798. When @var{interface} is @code{127.0.0.1}, only local clients can
  17799. connect; when it is @code{0.0.0.0}, connections can come from any
  17800. networking interface.
  17801. @item @code{bitlbee} (default: @code{bitlbee})
  17802. The BitlBee package to use.
  17803. @item @code{plugins} (default: @code{'()})
  17804. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  17805. @item @code{extra-settings} (default: @code{""})
  17806. Configuration snippet added as-is to the BitlBee configuration file.
  17807. @end table
  17808. @end deftp
  17809. @subsubheading Quassel Service
  17810. @cindex IRC (Internet Relay Chat)
  17811. @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
  17812. meaning that one or more clients can attach to and detach from the
  17813. central core.
  17814. @defvr {Scheme Variable} quassel-service-type
  17815. This is the service type for the @url{https://quassel-irc.org/,Quassel}
  17816. IRC backend daemon. Its value is a @code{quassel-configuration}
  17817. (see below).
  17818. @end defvr
  17819. @deftp {Data Type} quassel-configuration
  17820. This is the configuration for Quassel, with the following fields:
  17821. @table @asis
  17822. @item @code{quassel} (default: @code{quassel})
  17823. The Quassel package to use.
  17824. @item @code{interface} (default: @code{"::,0.0.0.0"})
  17825. @item @code{port} (default: @code{4242})
  17826. Listen on the network interface(s) corresponding to the IPv4 or IPv6
  17827. interfaces specified in the comma delimited @var{interface}, on
  17828. @var{port}.
  17829. @item @code{loglevel} (default: @code{"Info"})
  17830. The level of logging desired. Accepted values are Debug, Info, Warning
  17831. and Error.
  17832. @end table
  17833. @end deftp
  17834. @node Telephony Services
  17835. @subsection Telephony Services
  17836. @cindex Murmur (VoIP server)
  17837. @cindex VoIP server
  17838. This section describes how to set up and run a Murmur server. Murmur is
  17839. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  17840. (VoIP) suite.
  17841. @deftp {Data Type} murmur-configuration
  17842. The service type for the Murmur server. An example configuration can
  17843. look like this:
  17844. @lisp
  17845. (service murmur-service-type
  17846. (murmur-configuration
  17847. (welcome-text
  17848. "Welcome to this Mumble server running on Guix!")
  17849. (cert-required? #t) ;disallow text password logins
  17850. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  17851. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  17852. @end lisp
  17853. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  17854. password with the command that is printed during the activation phase.
  17855. It is recommended to register a normal Mumble user account
  17856. and grant it admin or moderator rights.
  17857. You can use the @code{mumble} client to
  17858. login as new normal user, register yourself, and log out.
  17859. For the next step login with the name @code{SuperUser} use
  17860. the @code{SuperUser} password that you set previously,
  17861. and grant your newly registered mumble user administrator or moderator
  17862. rights and create some channels.
  17863. Available @code{murmur-configuration} fields are:
  17864. @table @asis
  17865. @item @code{package} (default: @code{mumble})
  17866. Package that contains @code{bin/murmurd}.
  17867. @item @code{user} (default: @code{"murmur"})
  17868. User who will run the Murmur server.
  17869. @item @code{group} (default: @code{"murmur"})
  17870. Group of the user who will run the murmur server.
  17871. @item @code{port} (default: @code{64738})
  17872. Port on which the server will listen.
  17873. @item @code{welcome-text} (default: @code{""})
  17874. Welcome text sent to clients when they connect.
  17875. @item @code{server-password} (default: @code{""})
  17876. Password the clients have to enter in order to connect.
  17877. @item @code{max-users} (default: @code{100})
  17878. Maximum of users that can be connected to the server at once.
  17879. @item @code{max-user-bandwidth} (default: @code{#f})
  17880. Maximum voice traffic a user can send per second.
  17881. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  17882. File name of the sqlite database.
  17883. The service's user will become the owner of the directory.
  17884. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  17885. File name of the log file.
  17886. The service's user will become the owner of the directory.
  17887. @item @code{autoban-attempts} (default: @code{10})
  17888. Maximum number of logins a user can make in @code{autoban-timeframe}
  17889. without getting auto banned for @code{autoban-time}.
  17890. @item @code{autoban-timeframe} (default: @code{120})
  17891. Timeframe for autoban in seconds.
  17892. @item @code{autoban-time} (default: @code{300})
  17893. Amount of time in seconds for which a client gets banned
  17894. when violating the autoban limits.
  17895. @item @code{opus-threshold} (default: @code{100})
  17896. Percentage of clients that need to support opus
  17897. before switching over to opus audio codec.
  17898. @item @code{channel-nesting-limit} (default: @code{10})
  17899. How deep channels can be nested at maximum.
  17900. @item @code{channelname-regex} (default: @code{#f})
  17901. A string in form of a Qt regular expression that channel names must conform to.
  17902. @item @code{username-regex} (default: @code{#f})
  17903. A string in form of a Qt regular expression that user names must conform to.
  17904. @item @code{text-message-length} (default: @code{5000})
  17905. Maximum size in bytes that a user can send in one text chat message.
  17906. @item @code{image-message-length} (default: @code{(* 128 1024)})
  17907. Maximum size in bytes that a user can send in one image message.
  17908. @item @code{cert-required?} (default: @code{#f})
  17909. If it is set to @code{#t} clients that use weak password authentication
  17910. will not be accepted. Users must have completed the certificate wizard to join.
  17911. @item @code{remember-channel?} (default: @code{#f})
  17912. Should murmur remember the last channel each user was in when they disconnected
  17913. and put them into the remembered channel when they rejoin.
  17914. @item @code{allow-html?} (default: @code{#f})
  17915. Should html be allowed in text messages, user comments, and channel descriptions.
  17916. @item @code{allow-ping?} (default: @code{#f})
  17917. Setting to true exposes the current user count, the maximum user count, and
  17918. the server's maximum bandwidth per client to unauthenticated users. In the
  17919. Mumble client, this information is shown in the Connect dialog.
  17920. Disabling this setting will prevent public listing of the server.
  17921. @item @code{bonjour?} (default: @code{#f})
  17922. Should the server advertise itself in the local network through the bonjour protocol.
  17923. @item @code{send-version?} (default: @code{#f})
  17924. Should the murmur server version be exposed in ping requests.
  17925. @item @code{log-days} (default: @code{31})
  17926. Murmur also stores logs in the database, which are accessible via RPC.
  17927. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  17928. or -1 to disable logging to the database.
  17929. @item @code{obfuscate-ips?} (default: @code{#t})
  17930. Should logged ips be obfuscated to protect the privacy of users.
  17931. @item @code{ssl-cert} (default: @code{#f})
  17932. File name of the SSL/TLS certificate used for encrypted connections.
  17933. @lisp
  17934. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  17935. @end lisp
  17936. @item @code{ssl-key} (default: @code{#f})
  17937. Filepath to the ssl private key used for encrypted connections.
  17938. @lisp
  17939. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  17940. @end lisp
  17941. @item @code{ssl-dh-params} (default: @code{#f})
  17942. File name of a PEM-encoded file with Diffie-Hellman parameters
  17943. for the SSL/TLS encryption. Alternatively you set it to
  17944. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  17945. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  17946. @item @code{ssl-ciphers} (default: @code{#f})
  17947. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  17948. in SSL/TLS.
  17949. This option is specified using
  17950. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  17951. OpenSSL cipher list notation}.
  17952. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  17953. before setting it here, to get a feel for which cipher suites you will get.
  17954. After setting this option, it is recommend that you inspect your Murmur log
  17955. to ensure that Murmur is using the cipher suites that you expected it to.
  17956. Note: Changing this option may impact the backwards compatibility of your
  17957. Murmur server, and can remove the ability for older Mumble clients to be able
  17958. to connect to it.
  17959. @item @code{public-registration} (default: @code{#f})
  17960. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  17961. You can optionally register your server in the public server list that the
  17962. @code{mumble} client shows on startup.
  17963. You cannot register your server if you have set a @code{server-password},
  17964. or set @code{allow-ping} to @code{#f}.
  17965. It might take a few hours until it shows up in the public list.
  17966. @item @code{file} (default: @code{#f})
  17967. Optional alternative override for this configuration.
  17968. @end table
  17969. @end deftp
  17970. @deftp {Data Type} murmur-public-registration-configuration
  17971. Configuration for public registration of a murmur service.
  17972. @table @asis
  17973. @item @code{name}
  17974. This is a display name for your server. Not to be confused with the hostname.
  17975. @item @code{password}
  17976. A password to identify your registration.
  17977. Subsequent updates will need the same password. Don't lose your password.
  17978. @item @code{url}
  17979. This should be a @code{http://} or @code{https://} link to your web
  17980. site.
  17981. @item @code{hostname} (default: @code{#f})
  17982. By default your server will be listed by its IP address.
  17983. If it is set your server will be linked by this host name instead.
  17984. @end table
  17985. @end deftp
  17986. @node File-Sharing Services
  17987. @subsection File-Sharing Services
  17988. The @code{(gnu services file-sharing)} module provides services that
  17989. assist with transferring files over peer-to-peer file-sharing networks.
  17990. @subsubheading Transmission Daemon Service
  17991. @uref{https://transmissionbt.com/, Transmission} is a flexible
  17992. BitTorrent client that offers a variety of graphical and command-line
  17993. interfaces. A @code{transmission-daemon-service-type} service provides
  17994. Transmission's headless variant, @command{transmission-daemon}, as a
  17995. system service, allowing users to share files via BitTorrent even when
  17996. they are not logged in.
  17997. @deffn {Scheme Variable} transmission-daemon-service-type
  17998. The service type for the Transmission Daemon BitTorrent client. Its
  17999. value must be a @code{transmission-daemon-configuration} object as in
  18000. this example:
  18001. @lisp
  18002. (service transmission-daemon-service-type
  18003. (transmission-daemon-configuration
  18004. ;; Restrict access to the RPC ("control") interface
  18005. (rpc-authentication-required? #t)
  18006. (rpc-username "transmission")
  18007. (rpc-password
  18008. (transmission-password-hash
  18009. "transmission" ; desired password
  18010. "uKd1uMs9")) ; arbitrary salt value
  18011. ;; Accept requests from this and other hosts on the
  18012. ;; local network
  18013. (rpc-whitelist-enabled? #t)
  18014. (rpc-whitelist '("::1" "127.0.0.1" "192.168.0.*"))
  18015. ;; Limit bandwidth use during work hours
  18016. (alt-speed-down (* 1024 2)) ; 2 MB/s
  18017. (alt-speed-up 512) ; 512 kB/s
  18018. (alt-speed-time-enabled? #t)
  18019. (alt-speed-time-day 'weekdays)
  18020. (alt-speed-time-begin
  18021. (+ (* 60 8) 30)) ; 8:30 am
  18022. (alt-speed-time-end
  18023. (+ (* 60 (+ 12 5)) 30)))) ; 5:30 pm
  18024. @end lisp
  18025. @end deffn
  18026. Once the service is started, users can interact with the daemon through
  18027. its Web interface (at @code{http://localhost:9091/}) or by using the
  18028. @command{transmission-remote} command-line tool, available in the
  18029. @code{transmission} package. (Emacs users may want to also consider the
  18030. @code{emacs-transmission} package.) Both communicate with the daemon
  18031. through its remote procedure call (RPC) interface, which by default is
  18032. available to all users on the system; you may wish to change this by
  18033. assigning values to the @code{rpc-authentication-required?},
  18034. @code{rpc-username} and @code{rpc-password} settings, as shown in the
  18035. example above and documented further below.
  18036. The value for @code{rpc-password} must be a password hash of the type
  18037. generated and used by Transmission clients. This can be copied verbatim
  18038. from an existing @file{settings.json} file, if another Transmission
  18039. client is already being used. Otherwise, the
  18040. @code{transmission-password-hash} and @code{transmission-random-salt}
  18041. procedures provided by this module can be used to obtain a suitable hash
  18042. value.
  18043. @deffn {Scheme Procedure} transmission-password-hash @var{password} @var{salt}
  18044. Returns a string containing the result of hashing @var{password}
  18045. together with @var{salt}, in the format recognized by Transmission
  18046. clients for their @code{rpc-password} configuration setting.
  18047. @var{salt} must be an eight-character string. The
  18048. @code{transmission-random-salt} procedure can be used to generate a
  18049. suitable salt value at random.
  18050. @end deffn
  18051. @deffn {Scheme Procedure} transmission-random-salt
  18052. Returns a string containing a random, eight-character salt value of the
  18053. type generated and used by Transmission clients, suitable for passing to
  18054. the @code{transmission-password-hash} procedure.
  18055. @end deffn
  18056. These procedures are accessible from within a Guile REPL started with
  18057. the @command{guix repl} command (@pxref{Invoking guix repl}). This is
  18058. useful for obtaining a random salt value to provide as the second
  18059. parameter to `transmission-password-hash`, as in this example session:
  18060. @example
  18061. $ guix repl
  18062. scheme@@(guix-user)> ,use (gnu services file-sharing)
  18063. scheme@@(guix-user)> (transmission-random-salt)
  18064. $1 = "uKd1uMs9"
  18065. @end example
  18066. Alternatively, a complete password hash can generated in a single step:
  18067. @example
  18068. scheme@@(guix-user)> (transmission-password-hash "transmission"
  18069. (transmission-random-salt))
  18070. $2 = "@{c8bbc6d1740cd8dc819a6e25563b67812c1c19c9VtFPfdsX"
  18071. @end example
  18072. The resulting string can be used as-is for the value of
  18073. @code{rpc-password}, allowing the password to be kept hidden even in the
  18074. operating-system configuration.
  18075. Torrent files downloaded by the daemon are directly accessible only to
  18076. users in the ``transmission'' user group, who receive read-only access
  18077. to the directory specified by the @code{download-dir} configuration
  18078. setting (and also the directory specified by @code{incomplete-dir}, if
  18079. @code{incomplete-dir-enabled?} is @code{#t}). Downloaded files can be
  18080. moved to another directory or deleted altogether using
  18081. @command{transmission-remote} with its @code{--move} and
  18082. @code{--remove-and-delete} options.
  18083. If the @code{watch-dir-enabled?} setting is set to @code{#t}, users in
  18084. the ``transmission'' group are able also to place @file{.torrent} files
  18085. in the directory specified by @code{watch-dir} to have the corresponding
  18086. torrents added by the daemon. (The @code{trash-original-torrent-files?}
  18087. setting controls whether the daemon deletes these files after processing
  18088. them.)
  18089. Some of the daemon's configuration settings can be changed temporarily
  18090. by @command{transmission-remote} and similar tools. To undo these
  18091. changes, use the service's @code{reload} action to have the daemon
  18092. reload its settings from disk:
  18093. @example
  18094. # herd reload transmission-daemon
  18095. @end example
  18096. The full set of available configuration settings is defined by the
  18097. @code{transmission-daemon-configuration} data type.
  18098. @deftp {Data Type} transmission-daemon-configuration
  18099. The data type representing configuration settings for Transmission
  18100. Daemon. These correspond directly to the settings recognized by
  18101. Transmission clients in their @file{settings.json} file.
  18102. @end deftp
  18103. @c The following documentation was initially generated by
  18104. @c (generate-transmission-daemon-documentation) in (gnu services
  18105. @c file-sharing). Manually maintained documentation is better, so we
  18106. @c shouldn't hesitate to edit below as needed. However if the change
  18107. @c you want to make to this documentation can be done in an automated
  18108. @c way, it's probably easier to change (generate-documentation) than to
  18109. @c make it below and have to deal with the churn as Transmission Daemon
  18110. @c updates.
  18111. @c %start of fragment
  18112. Available @code{transmission-daemon-configuration} fields are:
  18113. @deftypevr {@code{transmission-daemon-configuration} parameter} package transmission
  18114. The Transmission package to use.
  18115. @end deftypevr
  18116. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer stop-wait-period
  18117. The period, in seconds, to wait when stopping the service for
  18118. @command{transmission-daemon} to exit before killing its process. This
  18119. allows the daemon time to complete its housekeeping and send a final
  18120. update to trackers as it shuts down. On slow hosts, or hosts with a
  18121. slow network connection, this value may need to be increased.
  18122. Defaults to @samp{10}.
  18123. @end deftypevr
  18124. @deftypevr {@code{transmission-daemon-configuration} parameter} string download-dir
  18125. The directory to which torrent files are downloaded.
  18126. Defaults to @samp{"/var/lib/transmission-daemon/downloads"}.
  18127. @end deftypevr
  18128. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean incomplete-dir-enabled?
  18129. If @code{#t}, files will be held in @code{incomplete-dir} while their
  18130. torrent is being downloaded, then moved to @code{download-dir} once the
  18131. torrent is complete. Otherwise, files for all torrents (including those
  18132. still being downloaded) will be placed in @code{download-dir}.
  18133. Defaults to @samp{#f}.
  18134. @end deftypevr
  18135. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string incomplete-dir
  18136. The directory in which files from incompletely downloaded torrents will
  18137. be held when @code{incomplete-dir-enabled?} is @code{#t}.
  18138. Defaults to @samp{disabled}.
  18139. @end deftypevr
  18140. @deftypevr {@code{transmission-daemon-configuration} parameter} umask umask
  18141. The file mode creation mask used for downloaded files. (See the
  18142. @command{umask} man page for more information.)
  18143. Defaults to @samp{18}.
  18144. @end deftypevr
  18145. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rename-partial-files?
  18146. When @code{#t}, ``.part'' is appended to the name of partially
  18147. downloaded files.
  18148. Defaults to @samp{#t}.
  18149. @end deftypevr
  18150. @deftypevr {@code{transmission-daemon-configuration} parameter} preallocation-mode preallocation
  18151. The mode by which space should be preallocated for downloaded files, one
  18152. of @code{none}, @code{fast} (or @code{sparse}) and @code{full}.
  18153. Specifying @code{full} will minimize disk fragmentation at a cost to
  18154. file-creation speed.
  18155. Defaults to @samp{fast}.
  18156. @end deftypevr
  18157. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean watch-dir-enabled?
  18158. If @code{#t}, the directory specified by @code{watch-dir} will be
  18159. watched for new @file{.torrent} files and the torrents they describe
  18160. added automatically (and the original files removed, if
  18161. @code{trash-original-torrent-files?} is @code{#t}).
  18162. Defaults to @samp{#f}.
  18163. @end deftypevr
  18164. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string watch-dir
  18165. The directory to be watched for @file{.torrent} files indicating new
  18166. torrents to be added, when @code{watch-dir-enabled} is @code{#t}.
  18167. Defaults to @samp{disabled}.
  18168. @end deftypevr
  18169. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean trash-original-torrent-files?
  18170. When @code{#t}, @file{.torrent} files will be deleted from the watch
  18171. directory once their torrent has been added (see
  18172. @code{watch-directory-enabled?}).
  18173. Defaults to @samp{#f}.
  18174. @end deftypevr
  18175. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-down-enabled?
  18176. When @code{#t}, the daemon's download speed will be limited to the rate
  18177. specified by @code{speed-limit-down}.
  18178. Defaults to @samp{#f}.
  18179. @end deftypevr
  18180. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-down
  18181. The default global-maximum download speed, in kilobytes per second.
  18182. Defaults to @samp{100}.
  18183. @end deftypevr
  18184. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-up-enabled?
  18185. When @code{#t}, the daemon's upload speed will be limited to the rate
  18186. specified by @code{speed-limit-up}.
  18187. Defaults to @samp{#f}.
  18188. @end deftypevr
  18189. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-up
  18190. The default global-maximum upload speed, in kilobytes per second.
  18191. Defaults to @samp{100}.
  18192. @end deftypevr
  18193. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-enabled?
  18194. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  18195. @code{alt-speed-up} are used (in place of @code{speed-limit-down} and
  18196. @code{speed-limit-up}, if they are enabled) to constrain the daemon's
  18197. bandwidth usage. This can be scheduled to occur automatically at
  18198. certain times during the week; see @code{alt-speed-time-enabled?}.
  18199. Defaults to @samp{#f}.
  18200. @end deftypevr
  18201. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-down
  18202. The alternate global-maximum download speed, in kilobytes per second.
  18203. Defaults to @samp{50}.
  18204. @end deftypevr
  18205. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-up
  18206. The alternate global-maximum upload speed, in kilobytes per second.
  18207. Defaults to @samp{50}.
  18208. @end deftypevr
  18209. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-time-enabled?
  18210. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  18211. @code{alt-speed-up} will be enabled automatically during the periods
  18212. specified by @code{alt-speed-time-day}, @code{alt-speed-time-begin} and
  18213. @code{alt-time-speed-end}.
  18214. Defaults to @samp{#f}.
  18215. @end deftypevr
  18216. @deftypevr {@code{transmission-daemon-configuration} parameter} day-list alt-speed-time-day
  18217. The days of the week on which the alternate-speed schedule should be
  18218. used, specified either as a list of days (@code{sunday}, @code{monday},
  18219. and so on) or using one of the symbols @code{weekdays}, @code{weekends}
  18220. or @code{all}.
  18221. Defaults to @samp{all}.
  18222. @end deftypevr
  18223. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-begin
  18224. The time of day at which to enable the alternate speed limits, expressed
  18225. as a number of minutes since midnight.
  18226. Defaults to @samp{540}.
  18227. @end deftypevr
  18228. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-end
  18229. The time of day at which to disable the alternate speed limits,
  18230. expressed as a number of minutes since midnight.
  18231. Defaults to @samp{1020}.
  18232. @end deftypevr
  18233. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv4
  18234. The IP address at which to listen for peer connections, or ``0.0.0.0''
  18235. to listen at all available IP addresses.
  18236. Defaults to @samp{"0.0.0.0"}.
  18237. @end deftypevr
  18238. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv6
  18239. The IPv6 address at which to listen for peer connections, or ``::'' to
  18240. listen at all available IPv6 addresses.
  18241. Defaults to @samp{"::"}.
  18242. @end deftypevr
  18243. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean peer-port-random-on-start?
  18244. If @code{#t}, when the daemon starts it will select a port at random on
  18245. which to listen for peer connections, from the range specified
  18246. (inclusively) by @code{peer-port-random-low} and
  18247. @code{peer-port-random-high}. Otherwise, it listens on the port
  18248. specified by @code{peer-port}.
  18249. Defaults to @samp{#f}.
  18250. @end deftypevr
  18251. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-low
  18252. The lowest selectable port number when @code{peer-port-random-on-start?}
  18253. is @code{#t}.
  18254. Defaults to @samp{49152}.
  18255. @end deftypevr
  18256. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-high
  18257. The highest selectable port number when @code{peer-port-random-on-start}
  18258. is @code{#t}.
  18259. Defaults to @samp{65535}.
  18260. @end deftypevr
  18261. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port
  18262. The port on which to listen for peer connections when
  18263. @code{peer-port-random-on-start?} is @code{#f}.
  18264. Defaults to @samp{51413}.
  18265. @end deftypevr
  18266. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean port-forwarding-enabled?
  18267. If @code{#t}, the daemon will attempt to configure port-forwarding on an
  18268. upstream gateway automatically using @acronym{UPnP} and
  18269. @acronym{NAT-PMP}.
  18270. Defaults to @samp{#t}.
  18271. @end deftypevr
  18272. @deftypevr {@code{transmission-daemon-configuration} parameter} encryption-mode encryption
  18273. The encryption preference for peer connections, one of
  18274. @code{prefer-unencrypted-connections},
  18275. @code{prefer-encrypted-connections} or
  18276. @code{require-encrypted-connections}.
  18277. Defaults to @samp{prefer-encrypted-connections}.
  18278. @end deftypevr
  18279. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
  18280. The TCP congestion-control algorithm to use for peer connections,
  18281. specified using a string recognized by the operating system in calls to
  18282. @code{setsockopt} (or set to @code{disabled}, in which case the
  18283. operating-system default is used).
  18284. Note that on GNU/Linux systems, the kernel must be configured to allow
  18285. processes to use a congestion-control algorithm not in the default set;
  18286. otherwise, it will deny these requests with ``Operation not permitted''.
  18287. To see which algorithms are available on your system and which are
  18288. currently permitted for use, look at the contents of the files
  18289. @file{tcp_available_congestion_control} and
  18290. @file{tcp_allowed_congestion_control} in the @file{/proc/sys/net/ipv4}
  18291. directory.
  18292. As an example, to have Transmission Daemon use
  18293. @uref{http://www-ece.rice.edu/networks/TCP-LP/,the TCP Low Priority
  18294. congestion-control algorithm}, you'll need to modify your kernel
  18295. configuration to build in support for the algorithm, then update your
  18296. operating-system configuration to allow its use by adding a
  18297. @code{sysctl-service-type} service (or updating the existing one's
  18298. configuration) with lines like the following:
  18299. @lisp
  18300. (service sysctl-service-type
  18301. (sysctl-configuration
  18302. (settings
  18303. ("net.ipv4.tcp_allowed_congestion_control" .
  18304. "reno cubic lp"))))
  18305. @end lisp
  18306. The Transmission Daemon configuration can then be updated with
  18307. @lisp
  18308. (peer-congestion-algorithm "lp")
  18309. @end lisp
  18310. and the system reconfigured to have the changes take effect.
  18311. Defaults to @samp{disabled}.
  18312. @end deftypevr
  18313. @deftypevr {@code{transmission-daemon-configuration} parameter} tcp-type-of-service peer-socket-tos
  18314. The type of service to request in outgoing @acronym{TCP} packets, one of
  18315. @code{default}, @code{low-cost}, @code{throughput}, @code{low-delay} and
  18316. @code{reliability}.
  18317. Defaults to @samp{default}.
  18318. @end deftypevr
  18319. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-global
  18320. The global limit on the number of connected peers.
  18321. Defaults to @samp{200}.
  18322. @end deftypevr
  18323. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-per-torrent
  18324. The per-torrent limit on the number of connected peers.
  18325. Defaults to @samp{50}.
  18326. @end deftypevr
  18327. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer upload-slots-per-torrent
  18328. The maximum number of peers to which the daemon will upload data
  18329. simultaneously for each torrent.
  18330. Defaults to @samp{14}.
  18331. @end deftypevr
  18332. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-id-ttl-hours
  18333. The maximum lifespan, in hours, of the peer ID associated with each
  18334. public torrent before it is regenerated.
  18335. Defaults to @samp{6}.
  18336. @end deftypevr
  18337. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean blocklist-enabled?
  18338. When @code{#t}, the daemon will ignore peers mentioned in the blocklist
  18339. it has most recently downloaded from @code{blocklist-url}.
  18340. Defaults to @samp{#f}.
  18341. @end deftypevr
  18342. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string blocklist-url
  18343. The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
  18344. @file{.dat} format) to be periodically downloaded and applied when
  18345. @code{blocklist-enabled?} is @code{#t}.
  18346. Defaults to @samp{disabled}.
  18347. @end deftypevr
  18348. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean download-queue-enabled?
  18349. If @code{#t}, the daemon will be limited to downloading at most
  18350. @code{download-queue-size} non-stalled torrents simultaneously.
  18351. Defaults to @samp{#t}.
  18352. @end deftypevr
  18353. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer download-queue-size
  18354. The size of the daemon's download queue, which limits the number of
  18355. non-stalled torrents it will download at any one time when
  18356. @code{download-queue-enabled?} is @code{#t}.
  18357. Defaults to @samp{5}.
  18358. @end deftypevr
  18359. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean seed-queue-enabled?
  18360. If @code{#t}, the daemon will be limited to seeding at most
  18361. @code{seed-queue-size} non-stalled torrents simultaneously.
  18362. Defaults to @samp{#f}.
  18363. @end deftypevr
  18364. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer seed-queue-size
  18365. The size of the daemon's seed queue, which limits the number of
  18366. non-stalled torrents it will seed at any one time when
  18367. @code{seed-queue-enabled?} is @code{#t}.
  18368. Defaults to @samp{10}.
  18369. @end deftypevr
  18370. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean queue-stalled-enabled?
  18371. When @code{#t}, the daemon will consider torrents for which it has not
  18372. shared data in the past @code{queue-stalled-minutes} minutes to be
  18373. stalled and not count them against its @code{download-queue-size} and
  18374. @code{seed-queue-size} limits.
  18375. Defaults to @samp{#t}.
  18376. @end deftypevr
  18377. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer queue-stalled-minutes
  18378. The maximum period, in minutes, a torrent may be idle before it is
  18379. considered to be stalled, when @code{queue-stalled-enabled?} is
  18380. @code{#t}.
  18381. Defaults to @samp{30}.
  18382. @end deftypevr
  18383. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean ratio-limit-enabled?
  18384. When @code{#t}, a torrent being seeded will automatically be paused once
  18385. it reaches the ratio specified by @code{ratio-limit}.
  18386. Defaults to @samp{#f}.
  18387. @end deftypevr
  18388. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-rational ratio-limit
  18389. The ratio at which a torrent being seeded will be paused, when
  18390. @code{ratio-limit-enabled?} is @code{#t}.
  18391. Defaults to @samp{2.0}.
  18392. @end deftypevr
  18393. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean idle-seeding-limit-enabled?
  18394. When @code{#t}, a torrent being seeded will automatically be paused once
  18395. it has been idle for @code{idle-seeding-limit} minutes.
  18396. Defaults to @samp{#f}.
  18397. @end deftypevr
  18398. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer idle-seeding-limit
  18399. The maximum period, in minutes, a torrent being seeded may be idle
  18400. before it is paused, when @code{idle-seeding-limit-enabled?} is
  18401. @code{#t}.
  18402. Defaults to @samp{30}.
  18403. @end deftypevr
  18404. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean dht-enabled?
  18405. Enable @uref{http://bittorrent.org/beps/bep_0005.html,the distributed
  18406. hash table (@acronym{DHT}) protocol}, which supports the use of
  18407. trackerless torrents.
  18408. Defaults to @samp{#t}.
  18409. @end deftypevr
  18410. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean lpd-enabled?
  18411. Enable @uref{https://en.wikipedia.org/wiki/Local_Peer_Discovery,local
  18412. peer discovery} (@acronym{LPD}), which allows the discovery of peers on
  18413. the local network and may reduce the amount of data sent over the public
  18414. Internet.
  18415. Defaults to @samp{#f}.
  18416. @end deftypevr
  18417. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean pex-enabled?
  18418. Enable @uref{https://en.wikipedia.org/wiki/Peer_exchange,peer exchange}
  18419. (@acronym{PEX}), which reduces the daemon's reliance on external
  18420. trackers and may improve its performance.
  18421. Defaults to @samp{#t}.
  18422. @end deftypevr
  18423. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean utp-enabled?
  18424. Enable @uref{http://bittorrent.org/beps/bep_0029.html,the micro
  18425. transport protocol} (@acronym{uTP}), which aims to reduce the impact of
  18426. BitTorrent traffic on other users of the local network while maintaining
  18427. full utilization of the available bandwidth.
  18428. Defaults to @samp{#t}.
  18429. @end deftypevr
  18430. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-enabled?
  18431. If @code{#t}, enable the remote procedure call (@acronym{RPC})
  18432. interface, which allows remote control of the daemon via its Web
  18433. interface, the @command{transmission-remote} command-line client, and
  18434. similar tools.
  18435. Defaults to @samp{#t}.
  18436. @end deftypevr
  18437. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-bind-address
  18438. The IP address at which to listen for @acronym{RPC} connections, or
  18439. ``0.0.0.0'' to listen at all available IP addresses.
  18440. Defaults to @samp{"0.0.0.0"}.
  18441. @end deftypevr
  18442. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number rpc-port
  18443. The port on which to listen for @acronym{RPC} connections.
  18444. Defaults to @samp{9091}.
  18445. @end deftypevr
  18446. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-url
  18447. The path prefix to use in the @acronym{RPC}-endpoint @acronym{URL}.
  18448. Defaults to @samp{"/transmission/"}.
  18449. @end deftypevr
  18450. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-authentication-required?
  18451. When @code{#t}, clients must authenticate (see @code{rpc-username} and
  18452. @code{rpc-password}) when using the @acronym{RPC} interface. Note this
  18453. has the side effect of disabling host-name whitelisting (see
  18454. @code{rpc-host-whitelist-enabled?}.
  18455. Defaults to @samp{#f}.
  18456. @end deftypevr
  18457. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string rpc-username
  18458. The username required by clients to access the @acronym{RPC} interface
  18459. when @code{rpc-authentication-required?} is @code{#t}.
  18460. Defaults to @samp{disabled}.
  18461. @end deftypevr
  18462. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-transmission-password-hash rpc-password
  18463. The password required by clients to access the @acronym{RPC} interface
  18464. when @code{rpc-authentication-required?} is @code{#t}. This must be
  18465. specified using a password hash in the format recognized by Transmission
  18466. clients, either copied from an existing @file{settings.json} file or
  18467. generated using the @code{transmission-password-hash} procedure.
  18468. Defaults to @samp{disabled}.
  18469. @end deftypevr
  18470. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-whitelist-enabled?
  18471. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  18472. originate from an address specified in @code{rpc-whitelist}.
  18473. Defaults to @samp{#t}.
  18474. @end deftypevr
  18475. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-whitelist
  18476. The list of IP and IPv6 addresses from which @acronym{RPC} requests will
  18477. be accepted when @code{rpc-whitelist-enabled?} is @code{#t}. Wildcards
  18478. may be specified using @samp{*}.
  18479. Defaults to @samp{("127.0.0.1" "::1")}.
  18480. @end deftypevr
  18481. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-host-whitelist-enabled?
  18482. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  18483. are addressed to a host named in @code{rpc-host-whitelist}. Note that
  18484. requests to ``localhost'' or ``localhost.'', or to a numeric address,
  18485. are always accepted regardless of these settings.
  18486. Note also this functionality is disabled when
  18487. @code{rpc-authentication-required?} is @code{#t}.
  18488. Defaults to @samp{#t}.
  18489. @end deftypevr
  18490. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-host-whitelist
  18491. The list of host names recognized by the @acronym{RPC} server when
  18492. @code{rpc-host-whitelist-enabled?} is @code{#t}.
  18493. Defaults to @samp{()}.
  18494. @end deftypevr
  18495. @deftypevr {@code{transmission-daemon-configuration} parameter} message-level message-level
  18496. The minimum severity level of messages to be logged (to
  18497. @file{/var/log/transmission.log}) by the daemon, one of @code{none} (no
  18498. logging), @code{error}, @code{info} and @code{debug}.
  18499. Defaults to @samp{info}.
  18500. @end deftypevr
  18501. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean start-added-torrents?
  18502. When @code{#t}, torrents are started as soon as they are added;
  18503. otherwise, they are added in ``paused'' state.
  18504. Defaults to @samp{#t}.
  18505. @end deftypevr
  18506. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean script-torrent-done-enabled?
  18507. When @code{#t}, the script specified by
  18508. @code{script-torrent-done-filename} will be invoked each time a torrent
  18509. completes.
  18510. Defaults to @samp{#f}.
  18511. @end deftypevr
  18512. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-file-object script-torrent-done-filename
  18513. A file name or file-like object specifying a script to run each time a
  18514. torrent completes, when @code{script-torrent-done-enabled?} is
  18515. @code{#t}.
  18516. Defaults to @samp{disabled}.
  18517. @end deftypevr
  18518. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean scrape-paused-torrents-enabled?
  18519. When @code{#t}, the daemon will scrape trackers for a torrent even when
  18520. the torrent is paused.
  18521. Defaults to @samp{#t}.
  18522. @end deftypevr
  18523. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer cache-size-mb
  18524. The amount of memory, in megabytes, to allocate for the daemon's
  18525. in-memory cache. A larger value may increase performance by reducing
  18526. the frequency of disk I/O.
  18527. Defaults to @samp{4}.
  18528. @end deftypevr
  18529. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean prefetch-enabled?
  18530. When @code{#t}, the daemon will try to improve I/O performance by
  18531. hinting to the operating system which data is likely to be read next
  18532. from disk to satisfy requests from peers.
  18533. Defaults to @samp{#t}.
  18534. @end deftypevr
  18535. @c %end of fragment
  18536. @node Monitoring Services
  18537. @subsection Monitoring Services
  18538. @subsubheading Tailon Service
  18539. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  18540. viewing and searching log files.
  18541. The following example will configure the service with default values.
  18542. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  18543. @lisp
  18544. (service tailon-service-type)
  18545. @end lisp
  18546. The following example customises more of the Tailon configuration,
  18547. adding @command{sed} to the list of allowed commands.
  18548. @lisp
  18549. (service tailon-service-type
  18550. (tailon-configuration
  18551. (config-file
  18552. (tailon-configuration-file
  18553. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  18554. @end lisp
  18555. @deftp {Data Type} tailon-configuration
  18556. Data type representing the configuration of Tailon.
  18557. This type has the following parameters:
  18558. @table @asis
  18559. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  18560. The configuration file to use for Tailon. This can be set to a
  18561. @dfn{tailon-configuration-file} record value, or any gexp
  18562. (@pxref{G-Expressions}).
  18563. For example, to instead use a local file, the @code{local-file} function
  18564. can be used:
  18565. @lisp
  18566. (service tailon-service-type
  18567. (tailon-configuration
  18568. (config-file (local-file "./my-tailon.conf"))))
  18569. @end lisp
  18570. @item @code{package} (default: @code{tailon})
  18571. The tailon package to use.
  18572. @end table
  18573. @end deftp
  18574. @deftp {Data Type} tailon-configuration-file
  18575. Data type representing the configuration options for Tailon.
  18576. This type has the following parameters:
  18577. @table @asis
  18578. @item @code{files} (default: @code{(list "/var/log")})
  18579. List of files to display. The list can include strings for a single file
  18580. or directory, or a list, where the first item is the name of a
  18581. subsection, and the remaining items are the files or directories in that
  18582. subsection.
  18583. @item @code{bind} (default: @code{"localhost:8080"})
  18584. Address and port to which Tailon should bind on.
  18585. @item @code{relative-root} (default: @code{#f})
  18586. URL path to use for Tailon, set to @code{#f} to not use a path.
  18587. @item @code{allow-transfers?} (default: @code{#t})
  18588. Allow downloading the log files in the web interface.
  18589. @item @code{follow-names?} (default: @code{#t})
  18590. Allow tailing of not-yet existent files.
  18591. @item @code{tail-lines} (default: @code{200})
  18592. Number of lines to read initially from each file.
  18593. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  18594. Commands to allow running. By default, @code{sed} is disabled.
  18595. @item @code{debug?} (default: @code{#f})
  18596. Set @code{debug?} to @code{#t} to show debug messages.
  18597. @item @code{wrap-lines} (default: @code{#t})
  18598. Initial line wrapping state in the web interface. Set to @code{#t} to
  18599. initially wrap lines (the default), or to @code{#f} to initially not
  18600. wrap lines.
  18601. @item @code{http-auth} (default: @code{#f})
  18602. HTTP authentication type to use. Set to @code{#f} to disable
  18603. authentication (the default). Supported values are @code{"digest"} or
  18604. @code{"basic"}.
  18605. @item @code{users} (default: @code{#f})
  18606. If HTTP authentication is enabled (see @code{http-auth}), access will be
  18607. restricted to the credentials provided here. To configure users, use a
  18608. list of pairs, where the first element of the pair is the username, and
  18609. the 2nd element of the pair is the password.
  18610. @lisp
  18611. (tailon-configuration-file
  18612. (http-auth "basic")
  18613. (users '(("user1" . "password1")
  18614. ("user2" . "password2"))))
  18615. @end lisp
  18616. @end table
  18617. @end deftp
  18618. @subsubheading Darkstat Service
  18619. @cindex darkstat
  18620. Darkstat is a packet sniffer that captures network traffic, calculates
  18621. statistics about usage, and serves reports over HTTP.
  18622. @defvar {Scheme Variable} darkstat-service-type
  18623. This is the service type for the
  18624. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  18625. service, its value must be a @code{darkstat-configuration} record as in
  18626. this example:
  18627. @lisp
  18628. (service darkstat-service-type
  18629. (darkstat-configuration
  18630. (interface "eno1")))
  18631. @end lisp
  18632. @end defvar
  18633. @deftp {Data Type} darkstat-configuration
  18634. Data type representing the configuration of @command{darkstat}.
  18635. @table @asis
  18636. @item @code{package} (default: @code{darkstat})
  18637. The darkstat package to use.
  18638. @item @code{interface}
  18639. Capture traffic on the specified network interface.
  18640. @item @code{port} (default: @code{"667"})
  18641. Bind the web interface to the specified port.
  18642. @item @code{bind-address} (default: @code{"127.0.0.1"})
  18643. Bind the web interface to the specified address.
  18644. @item @code{base} (default: @code{"/"})
  18645. Specify the path of the base URL@. This can be useful if
  18646. @command{darkstat} is accessed via a reverse proxy.
  18647. @end table
  18648. @end deftp
  18649. @subsubheading Prometheus Node Exporter Service
  18650. @cindex prometheus-node-exporter
  18651. The Prometheus ``node exporter'' makes hardware and operating system statistics
  18652. provided by the Linux kernel available for the Prometheus monitoring system.
  18653. This service should be deployed on all physical nodes and virtual machines,
  18654. where monitoring these statistics is desirable.
  18655. @defvar {Scheme variable} prometheus-node-exporter-service-type
  18656. This is the service type for the
  18657. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  18658. service, its value must be a @code{prometheus-node-exporter-configuration}.
  18659. @lisp
  18660. (service prometheus-node-exporter-service-type)
  18661. @end lisp
  18662. @end defvar
  18663. @deftp {Data Type} prometheus-node-exporter-configuration
  18664. Data type representing the configuration of @command{node_exporter}.
  18665. @table @asis
  18666. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  18667. The prometheus-node-exporter package to use.
  18668. @item @code{web-listen-address} (default: @code{":9100"})
  18669. Bind the web interface to the specified address.
  18670. @item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"})
  18671. This directory can be used to export metrics specific to this machine.
  18672. Files containing metrics in the text format, with the filename ending in
  18673. @code{.prom} should be placed in this directory.
  18674. @item @code{extra-options} (default: @code{'()})
  18675. Extra options to pass to the Prometheus node exporter.
  18676. @end table
  18677. @end deftp
  18678. @subsubheading Zabbix server
  18679. @cindex zabbix zabbix-server
  18680. Zabbix provides monitoring metrics, among others network utilization, CPU load
  18681. and disk space consumption:
  18682. @itemize
  18683. @item High performance, high capacity (able to monitor hundreds of thousands of devices).
  18684. @item Auto-discovery of servers and network devices and interfaces.
  18685. @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
  18686. @item Distributed monitoring with centralized web administration.
  18687. @item Native high performance agents.
  18688. @item SLA, and ITIL KPI metrics on reporting.
  18689. @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
  18690. @item Remote command execution through Zabbix proxies.
  18691. @end itemize
  18692. @c %start of fragment
  18693. Available @code{zabbix-server-configuration} fields are:
  18694. @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
  18695. The zabbix-server package.
  18696. @end deftypevr
  18697. @deftypevr {@code{zabbix-server-configuration} parameter} string user
  18698. User who will run the Zabbix server.
  18699. Defaults to @samp{"zabbix"}.
  18700. @end deftypevr
  18701. @deftypevr {@code{zabbix-server-configuration} parameter} group group
  18702. Group who will run the Zabbix server.
  18703. Defaults to @samp{"zabbix"}.
  18704. @end deftypevr
  18705. @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
  18706. Database host name.
  18707. Defaults to @samp{"127.0.0.1"}.
  18708. @end deftypevr
  18709. @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
  18710. Database name.
  18711. Defaults to @samp{"zabbix"}.
  18712. @end deftypevr
  18713. @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
  18714. Database user.
  18715. Defaults to @samp{"zabbix"}.
  18716. @end deftypevr
  18717. @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
  18718. Database password. Please, use @code{include-files} with
  18719. @code{DBPassword=SECRET} inside a specified file instead.
  18720. Defaults to @samp{""}.
  18721. @end deftypevr
  18722. @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
  18723. Database port.
  18724. Defaults to @samp{5432}.
  18725. @end deftypevr
  18726. @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
  18727. Specifies where log messages are written to:
  18728. @itemize @bullet
  18729. @item
  18730. @code{system} - syslog.
  18731. @item
  18732. @code{file} - file specified with @code{log-file} parameter.
  18733. @item
  18734. @code{console} - standard output.
  18735. @end itemize
  18736. Defaults to @samp{""}.
  18737. @end deftypevr
  18738. @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
  18739. Log file name for @code{log-type} @code{file} parameter.
  18740. Defaults to @samp{"/var/log/zabbix/server.log"}.
  18741. @end deftypevr
  18742. @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
  18743. Name of PID file.
  18744. Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
  18745. @end deftypevr
  18746. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
  18747. The location of certificate authority (CA) files for SSL server
  18748. certificate verification.
  18749. Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
  18750. @end deftypevr
  18751. @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
  18752. Location of SSL client certificates.
  18753. Defaults to @samp{"/etc/ssl/certs"}.
  18754. @end deftypevr
  18755. @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
  18756. Extra options will be appended to Zabbix server configuration file.
  18757. Defaults to @samp{""}.
  18758. @end deftypevr
  18759. @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
  18760. You may include individual files or all files in a directory in the
  18761. configuration file.
  18762. Defaults to @samp{()}.
  18763. @end deftypevr
  18764. @c %end of fragment
  18765. @subsubheading Zabbix agent
  18766. @cindex zabbix zabbix-agent
  18767. Zabbix agent gathers information for Zabbix server.
  18768. @c %start of fragment
  18769. Available @code{zabbix-agent-configuration} fields are:
  18770. @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
  18771. The zabbix-agent package.
  18772. @end deftypevr
  18773. @deftypevr {@code{zabbix-agent-configuration} parameter} string user
  18774. User who will run the Zabbix agent.
  18775. Defaults to @samp{"zabbix"}.
  18776. @end deftypevr
  18777. @deftypevr {@code{zabbix-agent-configuration} parameter} group group
  18778. Group who will run the Zabbix agent.
  18779. Defaults to @samp{"zabbix"}.
  18780. @end deftypevr
  18781. @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
  18782. Unique, case sensitive hostname which is required for active checks and
  18783. must match hostname as configured on the server.
  18784. Defaults to @samp{""}.
  18785. @end deftypevr
  18786. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
  18787. Specifies where log messages are written to:
  18788. @itemize @bullet
  18789. @item
  18790. @code{system} - syslog.
  18791. @item
  18792. @code{file} - file specified with @code{log-file} parameter.
  18793. @item
  18794. @code{console} - standard output.
  18795. @end itemize
  18796. Defaults to @samp{""}.
  18797. @end deftypevr
  18798. @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
  18799. Log file name for @code{log-type} @code{file} parameter.
  18800. Defaults to @samp{"/var/log/zabbix/agent.log"}.
  18801. @end deftypevr
  18802. @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
  18803. Name of PID file.
  18804. Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
  18805. @end deftypevr
  18806. @deftypevr {@code{zabbix-agent-configuration} parameter} list server
  18807. List of IP addresses, optionally in CIDR notation, or hostnames of
  18808. Zabbix servers and Zabbix proxies. Incoming connections will be
  18809. accepted only from the hosts listed here.
  18810. Defaults to @samp{("127.0.0.1")}.
  18811. @end deftypevr
  18812. @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
  18813. List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
  18814. proxies for active checks. If port is not specified, default port is
  18815. used. If this parameter is not specified, active checks are disabled.
  18816. Defaults to @samp{("127.0.0.1")}.
  18817. @end deftypevr
  18818. @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
  18819. Extra options will be appended to Zabbix server configuration file.
  18820. Defaults to @samp{""}.
  18821. @end deftypevr
  18822. @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
  18823. You may include individual files or all files in a directory in the
  18824. configuration file.
  18825. Defaults to @samp{()}.
  18826. @end deftypevr
  18827. @c %end of fragment
  18828. @subsubheading Zabbix front-end
  18829. @cindex zabbix zabbix-front-end
  18830. This service provides a WEB interface to Zabbix server.
  18831. @c %start of fragment
  18832. Available @code{zabbix-front-end-configuration} fields are:
  18833. @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
  18834. NGINX configuration.
  18835. @end deftypevr
  18836. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
  18837. Database host name.
  18838. Defaults to @samp{"localhost"}.
  18839. @end deftypevr
  18840. @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
  18841. Database port.
  18842. Defaults to @samp{5432}.
  18843. @end deftypevr
  18844. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
  18845. Database name.
  18846. Defaults to @samp{"zabbix"}.
  18847. @end deftypevr
  18848. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
  18849. Database user.
  18850. Defaults to @samp{"zabbix"}.
  18851. @end deftypevr
  18852. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
  18853. Database password. Please, use @code{db-secret-file} instead.
  18854. Defaults to @samp{""}.
  18855. @end deftypevr
  18856. @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
  18857. Secret file containing the credentials for the Zabbix front-end. The value
  18858. must be a local file name, not a G-expression. You are expected to create
  18859. this file manually. Its contents will be copied into @file{zabbix.conf.php}
  18860. as the value of @code{$DB['PASSWORD']}.
  18861. Defaults to @samp{""}.
  18862. @end deftypevr
  18863. @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
  18864. Zabbix server hostname.
  18865. Defaults to @samp{"localhost"}.
  18866. @end deftypevr
  18867. @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
  18868. Zabbix server port.
  18869. Defaults to @samp{10051}.
  18870. @end deftypevr
  18871. @c %end of fragment
  18872. @node Kerberos Services
  18873. @subsection Kerberos Services
  18874. @cindex Kerberos
  18875. The @code{(gnu services kerberos)} module provides services relating to
  18876. the authentication protocol @dfn{Kerberos}.
  18877. @subsubheading Krb5 Service
  18878. Programs using a Kerberos client library normally
  18879. expect a configuration file in @file{/etc/krb5.conf}.
  18880. This service generates such a file from a definition provided in the
  18881. operating system declaration.
  18882. It does not cause any daemon to be started.
  18883. No ``keytab'' files are provided by this service---you must explicitly create them.
  18884. This service is known to work with the MIT client library, @code{mit-krb5}.
  18885. Other implementations have not been tested.
  18886. @defvr {Scheme Variable} krb5-service-type
  18887. A service type for Kerberos 5 clients.
  18888. @end defvr
  18889. @noindent
  18890. Here is an example of its use:
  18891. @lisp
  18892. (service krb5-service-type
  18893. (krb5-configuration
  18894. (default-realm "EXAMPLE.COM")
  18895. (allow-weak-crypto? #t)
  18896. (realms (list
  18897. (krb5-realm
  18898. (name "EXAMPLE.COM")
  18899. (admin-server "groucho.example.com")
  18900. (kdc "karl.example.com"))
  18901. (krb5-realm
  18902. (name "ARGRX.EDU")
  18903. (admin-server "kerb-admin.argrx.edu")
  18904. (kdc "keys.argrx.edu"))))))
  18905. @end lisp
  18906. @noindent
  18907. This example provides a Kerberos@tie{}5 client configuration which:
  18908. @itemize
  18909. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  18910. of which have distinct administration servers and key distribution centers;
  18911. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  18912. specified by clients;
  18913. @item Accepts services which only support encryption types known to be weak.
  18914. @end itemize
  18915. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  18916. Only the most commonly used ones are described here.
  18917. For a full list, and more detailed explanation of each, see the MIT
  18918. @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  18919. documentation.
  18920. @deftp {Data Type} krb5-realm
  18921. @cindex realm, kerberos
  18922. @table @asis
  18923. @item @code{name}
  18924. This field is a string identifying the name of the realm.
  18925. A common convention is to use the fully qualified DNS name of your organization,
  18926. converted to upper case.
  18927. @item @code{admin-server}
  18928. This field is a string identifying the host where the administration server is
  18929. running.
  18930. @item @code{kdc}
  18931. This field is a string identifying the key distribution center
  18932. for the realm.
  18933. @end table
  18934. @end deftp
  18935. @deftp {Data Type} krb5-configuration
  18936. @table @asis
  18937. @item @code{allow-weak-crypto?} (default: @code{#f})
  18938. If this flag is @code{#t} then services which only offer encryption algorithms
  18939. known to be weak will be accepted.
  18940. @item @code{default-realm} (default: @code{#f})
  18941. This field should be a string identifying the default Kerberos
  18942. realm for the client.
  18943. You should set this field to the name of your Kerberos realm.
  18944. If this value is @code{#f}
  18945. then a realm must be specified with every Kerberos principal when invoking programs
  18946. such as @command{kinit}.
  18947. @item @code{realms}
  18948. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  18949. access.
  18950. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  18951. field.
  18952. @end table
  18953. @end deftp
  18954. @subsubheading PAM krb5 Service
  18955. @cindex pam-krb5
  18956. The @code{pam-krb5} service allows for login authentication and password
  18957. management via Kerberos.
  18958. You will need this service if you want PAM enabled applications to authenticate
  18959. users using Kerberos.
  18960. @defvr {Scheme Variable} pam-krb5-service-type
  18961. A service type for the Kerberos 5 PAM module.
  18962. @end defvr
  18963. @deftp {Data Type} pam-krb5-configuration
  18964. Data type representing the configuration of the Kerberos 5 PAM module.
  18965. This type has the following parameters:
  18966. @table @asis
  18967. @item @code{pam-krb5} (default: @code{pam-krb5})
  18968. The pam-krb5 package to use.
  18969. @item @code{minimum-uid} (default: @code{1000})
  18970. The smallest user ID for which Kerberos authentications should be attempted.
  18971. Local accounts with lower values will silently fail to authenticate.
  18972. @end table
  18973. @end deftp
  18974. @node LDAP Services
  18975. @subsection LDAP Services
  18976. @cindex LDAP
  18977. @cindex nslcd, LDAP service
  18978. The @code{(gnu services authentication)} module provides the
  18979. @code{nslcd-service-type}, which can be used to authenticate against an LDAP
  18980. server. In addition to configuring the service itself, you may want to add
  18981. @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
  18982. Switch} for detailed information.
  18983. Here is a simple operating system declaration with a default configuration of
  18984. the @code{nslcd-service-type} and a Name Service Switch configuration that
  18985. consults the @code{ldap} name service last:
  18986. @lisp
  18987. (use-service-modules authentication)
  18988. (use-modules (gnu system nss))
  18989. ...
  18990. (operating-system
  18991. ...
  18992. (services
  18993. (cons*
  18994. (service nslcd-service-type)
  18995. (service dhcp-client-service-type)
  18996. %base-services))
  18997. (name-service-switch
  18998. (let ((services (list (name-service (name "db"))
  18999. (name-service (name "files"))
  19000. (name-service (name "ldap")))))
  19001. (name-service-switch
  19002. (inherit %mdns-host-lookup-nss)
  19003. (password services)
  19004. (shadow services)
  19005. (group services)
  19006. (netgroup services)
  19007. (gshadow services)))))
  19008. @end lisp
  19009. @c %start of generated documentation for nslcd-configuration
  19010. Available @code{nslcd-configuration} fields are:
  19011. @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
  19012. The @code{nss-pam-ldapd} package to use.
  19013. @end deftypevr
  19014. @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
  19015. The number of threads to start that can handle requests and perform LDAP
  19016. queries. Each thread opens a separate connection to the LDAP server.
  19017. The default is to start 5 threads.
  19018. Defaults to @samp{disabled}.
  19019. @end deftypevr
  19020. @deftypevr {@code{nslcd-configuration} parameter} string uid
  19021. This specifies the user id with which the daemon should be run.
  19022. Defaults to @samp{"nslcd"}.
  19023. @end deftypevr
  19024. @deftypevr {@code{nslcd-configuration} parameter} string gid
  19025. This specifies the group id with which the daemon should be run.
  19026. Defaults to @samp{"nslcd"}.
  19027. @end deftypevr
  19028. @deftypevr {@code{nslcd-configuration} parameter} log-option log
  19029. This option controls the way logging is done via a list containing
  19030. SCHEME and LEVEL@. The SCHEME argument may either be the symbols
  19031. @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
  19032. argument is optional and specifies the log level. The log level may be
  19033. one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
  19034. @samp{notice}, @samp{info} or @samp{debug}. All messages with the
  19035. specified log level or higher are logged.
  19036. Defaults to @samp{("/var/log/nslcd" info)}.
  19037. @end deftypevr
  19038. @deftypevr {@code{nslcd-configuration} parameter} list uri
  19039. The list of LDAP server URIs. Normally, only the first server will be
  19040. used with the following servers as fall-back.
  19041. Defaults to @samp{("ldap://localhost:389/")}.
  19042. @end deftypevr
  19043. @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
  19044. The version of the LDAP protocol to use. The default is to use the
  19045. maximum version supported by the LDAP library.
  19046. Defaults to @samp{disabled}.
  19047. @end deftypevr
  19048. @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
  19049. Specifies the distinguished name with which to bind to the directory
  19050. server for lookups. The default is to bind anonymously.
  19051. Defaults to @samp{disabled}.
  19052. @end deftypevr
  19053. @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
  19054. Specifies the credentials with which to bind. This option is only
  19055. applicable when used with binddn.
  19056. Defaults to @samp{disabled}.
  19057. @end deftypevr
  19058. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
  19059. Specifies the distinguished name to use when the root user tries to
  19060. modify a user's password using the PAM module.
  19061. Defaults to @samp{disabled}.
  19062. @end deftypevr
  19063. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
  19064. Specifies the credentials with which to bind if the root user tries to
  19065. change a user's password. This option is only applicable when used with
  19066. rootpwmoddn
  19067. Defaults to @samp{disabled}.
  19068. @end deftypevr
  19069. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
  19070. Specifies the SASL mechanism to be used when performing SASL
  19071. authentication.
  19072. Defaults to @samp{disabled}.
  19073. @end deftypevr
  19074. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
  19075. Specifies the SASL realm to be used when performing SASL authentication.
  19076. Defaults to @samp{disabled}.
  19077. @end deftypevr
  19078. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
  19079. Specifies the authentication identity to be used when performing SASL
  19080. authentication.
  19081. Defaults to @samp{disabled}.
  19082. @end deftypevr
  19083. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
  19084. Specifies the authorization identity to be used when performing SASL
  19085. authentication.
  19086. Defaults to @samp{disabled}.
  19087. @end deftypevr
  19088. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
  19089. Determines whether the LDAP server host name should be canonicalised. If
  19090. this is enabled the LDAP library will do a reverse host name lookup. By
  19091. default, it is left up to the LDAP library whether this check is
  19092. performed or not.
  19093. Defaults to @samp{disabled}.
  19094. @end deftypevr
  19095. @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
  19096. Set the name for the GSS-API Kerberos credentials cache.
  19097. Defaults to @samp{disabled}.
  19098. @end deftypevr
  19099. @deftypevr {@code{nslcd-configuration} parameter} string base
  19100. The directory search base.
  19101. Defaults to @samp{"dc=example,dc=com"}.
  19102. @end deftypevr
  19103. @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
  19104. Specifies the search scope (subtree, onelevel, base or children). The
  19105. default scope is subtree; base scope is almost never useful for name
  19106. service lookups; children scope is not supported on all servers.
  19107. Defaults to @samp{(subtree)}.
  19108. @end deftypevr
  19109. @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
  19110. Specifies the policy for dereferencing aliases. The default policy is
  19111. to never dereference aliases.
  19112. Defaults to @samp{disabled}.
  19113. @end deftypevr
  19114. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
  19115. Specifies whether automatic referral chasing should be enabled. The
  19116. default behaviour is to chase referrals.
  19117. Defaults to @samp{disabled}.
  19118. @end deftypevr
  19119. @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
  19120. This option allows for custom attributes to be looked up instead of the
  19121. default RFC 2307 attributes. It is a list of maps, each consisting of
  19122. the name of a map, the RFC 2307 attribute to match and the query
  19123. expression for the attribute as it is available in the directory.
  19124. Defaults to @samp{()}.
  19125. @end deftypevr
  19126. @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
  19127. A list of filters consisting of the name of a map to which the filter
  19128. applies and an LDAP search filter expression.
  19129. Defaults to @samp{()}.
  19130. @end deftypevr
  19131. @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
  19132. Specifies the time limit in seconds to use when connecting to the
  19133. directory server. The default value is 10 seconds.
  19134. Defaults to @samp{disabled}.
  19135. @end deftypevr
  19136. @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
  19137. Specifies the time limit (in seconds) to wait for a response from the
  19138. LDAP server. A value of zero, which is the default, is to wait
  19139. indefinitely for searches to be completed.
  19140. Defaults to @samp{disabled}.
  19141. @end deftypevr
  19142. @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
  19143. Specifies the period if inactivity (in seconds) after which the con‐
  19144. nection to the LDAP server will be closed. The default is not to time
  19145. out connections.
  19146. Defaults to @samp{disabled}.
  19147. @end deftypevr
  19148. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
  19149. Specifies the number of seconds to sleep when connecting to all LDAP
  19150. servers fails. By default one second is waited between the first
  19151. failure and the first retry.
  19152. Defaults to @samp{disabled}.
  19153. @end deftypevr
  19154. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
  19155. Specifies the time after which the LDAP server is considered to be
  19156. permanently unavailable. Once this time is reached retries will be done
  19157. only once per this time period. The default value is 10 seconds.
  19158. Defaults to @samp{disabled}.
  19159. @end deftypevr
  19160. @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
  19161. Specifies whether to use SSL/TLS or not (the default is not to). If
  19162. 'start-tls is specified then StartTLS is used rather than raw LDAP over
  19163. SSL.
  19164. Defaults to @samp{disabled}.
  19165. @end deftypevr
  19166. @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
  19167. Specifies what checks to perform on a server-supplied certificate. The
  19168. meaning of the values is described in the ldap.conf(5) manual page.
  19169. Defaults to @samp{disabled}.
  19170. @end deftypevr
  19171. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
  19172. Specifies the directory containing X.509 certificates for peer authen‐
  19173. tication. This parameter is ignored when using GnuTLS.
  19174. Defaults to @samp{disabled}.
  19175. @end deftypevr
  19176. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
  19177. Specifies the path to the X.509 certificate for peer authentication.
  19178. Defaults to @samp{disabled}.
  19179. @end deftypevr
  19180. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
  19181. Specifies the path to an entropy source. This parameter is ignored when
  19182. using GnuTLS.
  19183. Defaults to @samp{disabled}.
  19184. @end deftypevr
  19185. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
  19186. Specifies the ciphers to use for TLS as a string.
  19187. Defaults to @samp{disabled}.
  19188. @end deftypevr
  19189. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
  19190. Specifies the path to the file containing the local certificate for
  19191. client TLS authentication.
  19192. Defaults to @samp{disabled}.
  19193. @end deftypevr
  19194. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
  19195. Specifies the path to the file containing the private key for client TLS
  19196. authentication.
  19197. Defaults to @samp{disabled}.
  19198. @end deftypevr
  19199. @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
  19200. Set this to a number greater than 0 to request paged results from the
  19201. LDAP server in accordance with RFC2696. The default (0) is to not
  19202. request paged results.
  19203. Defaults to @samp{disabled}.
  19204. @end deftypevr
  19205. @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
  19206. This option prevents group membership lookups through LDAP for the
  19207. specified users. Alternatively, the value 'all-local may be used. With
  19208. that value nslcd builds a full list of non-LDAP users on startup.
  19209. Defaults to @samp{disabled}.
  19210. @end deftypevr
  19211. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
  19212. This option ensures that LDAP users with a numeric user id lower than
  19213. the specified value are ignored.
  19214. Defaults to @samp{disabled}.
  19215. @end deftypevr
  19216. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
  19217. This option specifies an offset that is added to all LDAP numeric user
  19218. ids. This can be used to avoid user id collisions with local users.
  19219. Defaults to @samp{disabled}.
  19220. @end deftypevr
  19221. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
  19222. This option specifies an offset that is added to all LDAP numeric group
  19223. ids. This can be used to avoid user id collisions with local groups.
  19224. Defaults to @samp{disabled}.
  19225. @end deftypevr
  19226. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
  19227. If this option is set, the member attribute of a group may point to
  19228. another group. Members of nested groups are also returned in the higher
  19229. level group and parent groups are returned when finding groups for a
  19230. specific user. The default is not to perform extra searches for nested
  19231. groups.
  19232. Defaults to @samp{disabled}.
  19233. @end deftypevr
  19234. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
  19235. If this option is set, the group member list is not retrieved when
  19236. looking up groups. Lookups for finding which groups a user belongs to
  19237. will remain functional so the user will likely still get the correct
  19238. groups assigned on login.
  19239. Defaults to @samp{disabled}.
  19240. @end deftypevr
  19241. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
  19242. If this option is set, functions which cause all user/group entries to
  19243. be loaded from the directory will not succeed in doing so. This can
  19244. dramatically reduce LDAP server load in situations where there are a
  19245. great number of users and/or groups. This option is not recommended for
  19246. most configurations.
  19247. Defaults to @samp{disabled}.
  19248. @end deftypevr
  19249. @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
  19250. This option can be used to specify how user and group names are verified
  19251. within the system. This pattern is used to check all user and group
  19252. names that are requested and returned from LDAP.
  19253. Defaults to @samp{disabled}.
  19254. @end deftypevr
  19255. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
  19256. This specifies whether or not to perform searches using case-insensitive
  19257. matching. Enabling this could open up the system to authorization
  19258. bypass vulnerabilities and introduce nscd cache poisoning
  19259. vulnerabilities which allow denial of service.
  19260. Defaults to @samp{disabled}.
  19261. @end deftypevr
  19262. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
  19263. This option specifies whether password policy controls are requested and
  19264. handled from the LDAP server when performing user authentication.
  19265. Defaults to @samp{disabled}.
  19266. @end deftypevr
  19267. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
  19268. By default nslcd performs an LDAP search with the user's credentials
  19269. after BIND (authentication) to ensure that the BIND operation was
  19270. successful. The default search is a simple check to see if the user's
  19271. DN exists. A search filter can be specified that will be used instead.
  19272. It should return at least one entry.
  19273. Defaults to @samp{disabled}.
  19274. @end deftypevr
  19275. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
  19276. This option allows flexible fine tuning of the authorisation check that
  19277. should be performed. The search filter specified is executed and if any
  19278. entries match, access is granted, otherwise access is denied.
  19279. Defaults to @samp{disabled}.
  19280. @end deftypevr
  19281. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
  19282. If this option is set password modification using pam_ldap will be
  19283. denied and the specified message will be presented to the user instead.
  19284. The message can be used to direct the user to an alternative means of
  19285. changing their password.
  19286. Defaults to @samp{disabled}.
  19287. @end deftypevr
  19288. @deftypevr {@code{nslcd-configuration} parameter} list pam-services
  19289. List of pam service names for which LDAP authentication should suffice.
  19290. Defaults to @samp{()}.
  19291. @end deftypevr
  19292. @c %end of generated documentation for nslcd-configuration
  19293. @node Web Services
  19294. @subsection Web Services
  19295. @cindex web
  19296. @cindex www
  19297. @cindex HTTP
  19298. The @code{(gnu services web)} module provides the Apache HTTP Server,
  19299. the nginx web server, and also a fastcgi wrapper daemon.
  19300. @subsubheading Apache HTTP Server
  19301. @deffn {Scheme Variable} httpd-service-type
  19302. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  19303. (@dfn{httpd}). The value for this service type is a
  19304. @code{httpd-configuration} record.
  19305. A simple example configuration is given below.
  19306. @lisp
  19307. (service httpd-service-type
  19308. (httpd-configuration
  19309. (config
  19310. (httpd-config-file
  19311. (server-name "www.example.com")
  19312. (document-root "/srv/http/www.example.com")))))
  19313. @end lisp
  19314. Other services can also extend the @code{httpd-service-type} to add to
  19315. the configuration.
  19316. @lisp
  19317. (simple-service 'www.example.com-server httpd-service-type
  19318. (list
  19319. (httpd-virtualhost
  19320. "*:80"
  19321. (list (string-join '("ServerName www.example.com"
  19322. "DocumentRoot /srv/http/www.example.com")
  19323. "\n")))))
  19324. @end lisp
  19325. @end deffn
  19326. The details for the @code{httpd-configuration}, @code{httpd-module},
  19327. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  19328. given below.
  19329. @deffn {Data Type} httpd-configuration
  19330. This data type represents the configuration for the httpd service.
  19331. @table @asis
  19332. @item @code{package} (default: @code{httpd})
  19333. The httpd package to use.
  19334. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  19335. The pid file used by the shepherd-service.
  19336. @item @code{config} (default: @code{(httpd-config-file)})
  19337. The configuration file to use with the httpd service. The default value
  19338. is a @code{httpd-config-file} record, but this can also be a different
  19339. G-expression that generates a file, for example a @code{plain-file}. A
  19340. file outside of the store can also be specified through a string.
  19341. @end table
  19342. @end deffn
  19343. @deffn {Data Type} httpd-module
  19344. This data type represents a module for the httpd service.
  19345. @table @asis
  19346. @item @code{name}
  19347. The name of the module.
  19348. @item @code{file}
  19349. The file for the module. This can be relative to the httpd package being
  19350. used, the absolute location of a file, or a G-expression for a file
  19351. within the store, for example @code{(file-append mod-wsgi
  19352. "/modules/mod_wsgi.so")}.
  19353. @end table
  19354. @end deffn
  19355. @defvr {Scheme Variable} %default-httpd-modules
  19356. A default list of @code{httpd-module} objects.
  19357. @end defvr
  19358. @deffn {Data Type} httpd-config-file
  19359. This data type represents a configuration file for the httpd service.
  19360. @table @asis
  19361. @item @code{modules} (default: @code{%default-httpd-modules})
  19362. The modules to load. Additional modules can be added here, or loaded by
  19363. additional configuration.
  19364. For example, in order to handle requests for PHP files, you can use Apache’s
  19365. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  19366. @lisp
  19367. (service httpd-service-type
  19368. (httpd-configuration
  19369. (config
  19370. (httpd-config-file
  19371. (modules (cons*
  19372. (httpd-module
  19373. (name "proxy_module")
  19374. (file "modules/mod_proxy.so"))
  19375. (httpd-module
  19376. (name "proxy_fcgi_module")
  19377. (file "modules/mod_proxy_fcgi.so"))
  19378. %default-httpd-modules))
  19379. (extra-config (list "\
  19380. <FilesMatch \\.php$>
  19381. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  19382. </FilesMatch>"))))))
  19383. (service php-fpm-service-type
  19384. (php-fpm-configuration
  19385. (socket "/var/run/php-fpm.sock")
  19386. (socket-group "httpd")))
  19387. @end lisp
  19388. @item @code{server-root} (default: @code{httpd})
  19389. The @code{ServerRoot} in the configuration file, defaults to the httpd
  19390. package. Directives including @code{Include} and @code{LoadModule} are
  19391. taken as relative to the server root.
  19392. @item @code{server-name} (default: @code{#f})
  19393. The @code{ServerName} in the configuration file, used to specify the
  19394. request scheme, hostname and port that the server uses to identify
  19395. itself.
  19396. This doesn't need to be set in the server config, and can be specified
  19397. in virtual hosts. The default is @code{#f} to not specify a
  19398. @code{ServerName}.
  19399. @item @code{document-root} (default: @code{"/srv/http"})
  19400. The @code{DocumentRoot} from which files will be served.
  19401. @item @code{listen} (default: @code{'("80")})
  19402. The list of values for the @code{Listen} directives in the config
  19403. file. The value should be a list of strings, when each string can
  19404. specify the port number to listen on, and optionally the IP address and
  19405. protocol to use.
  19406. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  19407. The @code{PidFile} to use. This should match the @code{pid-file} set in
  19408. the @code{httpd-configuration} so that the Shepherd service is
  19409. configured correctly.
  19410. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  19411. The @code{ErrorLog} to which the server will log errors.
  19412. @item @code{user} (default: @code{"httpd"})
  19413. The @code{User} which the server will answer requests as.
  19414. @item @code{group} (default: @code{"httpd"})
  19415. The @code{Group} which the server will answer requests as.
  19416. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  19417. A flat list of strings and G-expressions which will be added to the end
  19418. of the configuration file.
  19419. Any values which the service is extended with will be appended to this
  19420. list.
  19421. @end table
  19422. @end deffn
  19423. @deffn {Data Type} httpd-virtualhost
  19424. This data type represents a virtualhost configuration block for the httpd service.
  19425. These should be added to the extra-config for the httpd-service.
  19426. @lisp
  19427. (simple-service 'www.example.com-server httpd-service-type
  19428. (list
  19429. (httpd-virtualhost
  19430. "*:80"
  19431. (list (string-join '("ServerName www.example.com"
  19432. "DocumentRoot /srv/http/www.example.com")
  19433. "\n")))))
  19434. @end lisp
  19435. @table @asis
  19436. @item @code{addresses-and-ports}
  19437. The addresses and ports for the @code{VirtualHost} directive.
  19438. @item @code{contents}
  19439. The contents of the @code{VirtualHost} directive, this should be a list
  19440. of strings and G-expressions.
  19441. @end table
  19442. @end deffn
  19443. @subsubheading NGINX
  19444. @deffn {Scheme Variable} nginx-service-type
  19445. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  19446. value for this service type is a @code{<nginx-configuration>} record.
  19447. A simple example configuration is given below.
  19448. @lisp
  19449. (service nginx-service-type
  19450. (nginx-configuration
  19451. (server-blocks
  19452. (list (nginx-server-configuration
  19453. (server-name '("www.example.com"))
  19454. (root "/srv/http/www.example.com"))))))
  19455. @end lisp
  19456. In addition to adding server blocks to the service configuration
  19457. directly, this service can be extended by other services to add server
  19458. blocks, as in this example:
  19459. @lisp
  19460. (simple-service 'my-extra-server nginx-service-type
  19461. (list (nginx-server-configuration
  19462. (root "/srv/http/extra-website")
  19463. (try-files (list "$uri" "$uri/index.html")))))
  19464. @end lisp
  19465. @end deffn
  19466. At startup, @command{nginx} has not yet read its configuration file, so
  19467. it uses a default file to log error messages. If it fails to load its
  19468. configuration file, that is where error messages are logged. After the
  19469. configuration file is loaded, the default error log file changes as per
  19470. configuration. In our case, startup error messages can be found in
  19471. @file{/var/run/nginx/logs/error.log}, and after configuration in
  19472. @file{/var/log/nginx/error.log}. The second location can be changed
  19473. with the @var{log-directory} configuration option.
  19474. @deffn {Data Type} nginx-configuration
  19475. This data type represents the configuration for NGinx. Some
  19476. configuration can be done through this and the other provided record
  19477. types, or alternatively, a config file can be provided.
  19478. @table @asis
  19479. @item @code{nginx} (default: @code{nginx})
  19480. The nginx package to use.
  19481. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  19482. The directory to which NGinx will write log files.
  19483. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  19484. The directory in which NGinx will create a pid file, and write temporary
  19485. files.
  19486. @item @code{server-blocks} (default: @code{'()})
  19487. A list of @dfn{server blocks} to create in the generated configuration
  19488. file, the elements should be of type
  19489. @code{<nginx-server-configuration>}.
  19490. The following example would setup NGinx to serve @code{www.example.com}
  19491. from the @code{/srv/http/www.example.com} directory, without using
  19492. HTTPS.
  19493. @lisp
  19494. (service nginx-service-type
  19495. (nginx-configuration
  19496. (server-blocks
  19497. (list (nginx-server-configuration
  19498. (server-name '("www.example.com"))
  19499. (root "/srv/http/www.example.com"))))))
  19500. @end lisp
  19501. @item @code{upstream-blocks} (default: @code{'()})
  19502. A list of @dfn{upstream blocks} to create in the generated configuration
  19503. file, the elements should be of type
  19504. @code{<nginx-upstream-configuration>}.
  19505. Configuring upstreams through the @code{upstream-blocks} can be useful
  19506. when combined with @code{locations} in the
  19507. @code{<nginx-server-configuration>} records. The following example
  19508. creates a server configuration with one location configuration, that
  19509. will proxy requests to a upstream configuration, which will handle
  19510. requests with two servers.
  19511. @lisp
  19512. (service
  19513. nginx-service-type
  19514. (nginx-configuration
  19515. (server-blocks
  19516. (list (nginx-server-configuration
  19517. (server-name '("www.example.com"))
  19518. (root "/srv/http/www.example.com")
  19519. (locations
  19520. (list
  19521. (nginx-location-configuration
  19522. (uri "/path1")
  19523. (body '("proxy_pass http://server-proxy;"))))))))
  19524. (upstream-blocks
  19525. (list (nginx-upstream-configuration
  19526. (name "server-proxy")
  19527. (servers (list "server1.example.com"
  19528. "server2.example.com")))))))
  19529. @end lisp
  19530. @item @code{file} (default: @code{#f})
  19531. If a configuration @var{file} is provided, this will be used, rather than
  19532. generating a configuration file from the provided @code{log-directory},
  19533. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  19534. proper operation, these arguments should match what is in @var{file} to ensure
  19535. that the directories are created when the service is activated.
  19536. This can be useful if you have an existing configuration file, or it's
  19537. not possible to do what is required through the other parts of the
  19538. nginx-configuration record.
  19539. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  19540. Bucket size for the server names hash tables, defaults to @code{#f} to
  19541. use the size of the processors cache line.
  19542. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  19543. Maximum bucket size for the server names hash tables.
  19544. @item @code{modules} (default: @code{'()})
  19545. List of nginx dynamic modules to load. This should be a list of file
  19546. names of loadable modules, as in this example:
  19547. @lisp
  19548. (modules
  19549. (list
  19550. (file-append nginx-accept-language-module "\
  19551. /etc/nginx/modules/ngx_http_accept_language_module.so")
  19552. (file-append nginx-lua-module "\
  19553. /etc/nginx/modules/ngx_http_lua_module.so")))
  19554. @end lisp
  19555. @item @code{lua-package-path} (default: @code{'()})
  19556. List of nginx lua packages to load. This should be a list of package
  19557. names of loadable lua modules, as in this example:
  19558. @lisp
  19559. (lua-package-path (list lua-resty-core
  19560. lua-resty-lrucache
  19561. lua-resty-signal
  19562. lua-tablepool
  19563. lua-resty-shell))
  19564. @end lisp
  19565. @item @code{lua-package-cpath} (default: @code{'()})
  19566. List of nginx lua C packages to load. This should be a list of package
  19567. names of loadable lua C modules, as in this example:
  19568. @lisp
  19569. (lua-package-cpath (list lua-resty-signal))
  19570. @end lisp
  19571. @item @code{global-directives} (default: @code{'((events . ()))})
  19572. Association list of global directives for the top level of the nginx
  19573. configuration. Values may themselves be association lists.
  19574. @lisp
  19575. (global-directives
  19576. `((worker_processes . 16)
  19577. (pcre_jit . on)
  19578. (events . ((worker_connections . 1024)))))
  19579. @end lisp
  19580. @item @code{extra-content} (default: @code{""})
  19581. Extra content for the @code{http} block. Should be string or a string
  19582. valued G-expression.
  19583. @end table
  19584. @end deffn
  19585. @deftp {Data Type} nginx-server-configuration
  19586. Data type representing the configuration of an nginx server block.
  19587. This type has the following parameters:
  19588. @table @asis
  19589. @item @code{listen} (default: @code{'("80" "443 ssl")})
  19590. Each @code{listen} directive sets the address and port for IP, or the
  19591. path for a UNIX-domain socket on which the server will accept requests.
  19592. Both address and port, or only address or only port can be specified.
  19593. An address may also be a hostname, for example:
  19594. @lisp
  19595. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  19596. @end lisp
  19597. @item @code{server-name} (default: @code{(list 'default)})
  19598. A list of server names this server represents. @code{'default} represents the
  19599. default server for connections matching no other server.
  19600. @item @code{root} (default: @code{"/srv/http"})
  19601. Root of the website nginx will serve.
  19602. @item @code{locations} (default: @code{'()})
  19603. A list of @dfn{nginx-location-configuration} or
  19604. @dfn{nginx-named-location-configuration} records to use within this
  19605. server block.
  19606. @item @code{index} (default: @code{(list "index.html")})
  19607. Index files to look for when clients ask for a directory. If it cannot be found,
  19608. Nginx will send the list of files in the directory.
  19609. @item @code{try-files} (default: @code{'()})
  19610. A list of files whose existence is checked in the specified order.
  19611. @code{nginx} will use the first file it finds to process the request.
  19612. @item @code{ssl-certificate} (default: @code{#f})
  19613. Where to find the certificate for secure connections. Set it to @code{#f} if
  19614. you don't have a certificate or you don't want to use HTTPS.
  19615. @item @code{ssl-certificate-key} (default: @code{#f})
  19616. Where to find the private key for secure connections. Set it to @code{#f} if
  19617. you don't have a key or you don't want to use HTTPS.
  19618. @item @code{server-tokens?} (default: @code{#f})
  19619. Whether the server should add its configuration to response.
  19620. @item @code{raw-content} (default: @code{'()})
  19621. A list of raw lines added to the server block.
  19622. @end table
  19623. @end deftp
  19624. @deftp {Data Type} nginx-upstream-configuration
  19625. Data type representing the configuration of an nginx @code{upstream}
  19626. block. This type has the following parameters:
  19627. @table @asis
  19628. @item @code{name}
  19629. Name for this group of servers.
  19630. @item @code{servers}
  19631. Specify the addresses of the servers in the group. The address can be
  19632. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  19633. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  19634. prefix @samp{unix:}. For addresses using an IP address or domain name,
  19635. the default port is 80, and a different port can be specified
  19636. explicitly.
  19637. @end table
  19638. @end deftp
  19639. @deftp {Data Type} nginx-location-configuration
  19640. Data type representing the configuration of an nginx @code{location}
  19641. block. This type has the following parameters:
  19642. @table @asis
  19643. @item @code{uri}
  19644. URI which this location block matches.
  19645. @anchor{nginx-location-configuration body}
  19646. @item @code{body}
  19647. Body of the location block, specified as a list of strings. This can contain
  19648. many
  19649. configuration directives. For example, to pass requests to a upstream
  19650. server group defined using an @code{nginx-upstream-configuration} block,
  19651. the following directive would be specified in the body @samp{(list "proxy_pass
  19652. http://upstream-name;")}.
  19653. @end table
  19654. @end deftp
  19655. @deftp {Data Type} nginx-named-location-configuration
  19656. Data type representing the configuration of an nginx named location
  19657. block. Named location blocks are used for request redirection, and not
  19658. used for regular request processing. This type has the following
  19659. parameters:
  19660. @table @asis
  19661. @item @code{name}
  19662. Name to identify this location block.
  19663. @item @code{body}
  19664. @xref{nginx-location-configuration body}, as the body for named location
  19665. blocks can be used in a similar way to the
  19666. @code{nginx-location-configuration body}. One restriction is that the
  19667. body of a named location block cannot contain location blocks.
  19668. @end table
  19669. @end deftp
  19670. @subsubheading Varnish Cache
  19671. @cindex Varnish
  19672. Varnish is a fast cache server that sits in between web applications
  19673. and end users. It proxies requests from clients and caches the
  19674. accessed URLs such that multiple requests for the same resource only
  19675. creates one request to the back-end.
  19676. @defvr {Scheme Variable} varnish-service-type
  19677. Service type for the Varnish daemon.
  19678. @end defvr
  19679. @deftp {Data Type} varnish-configuration
  19680. Data type representing the @code{varnish} service configuration.
  19681. This type has the following parameters:
  19682. @table @asis
  19683. @item @code{package} (default: @code{varnish})
  19684. The Varnish package to use.
  19685. @item @code{name} (default: @code{"default"})
  19686. A name for this Varnish instance. Varnish will create a directory in
  19687. @file{/var/varnish/} with this name and keep temporary files there. If
  19688. the name starts with a forward slash, it is interpreted as an absolute
  19689. directory name.
  19690. Pass the @code{-n} argument to other Varnish programs to connect to the
  19691. named instance, e.g.@: @command{varnishncsa -n default}.
  19692. @item @code{backend} (default: @code{"localhost:8080"})
  19693. The backend to use. This option has no effect if @code{vcl} is set.
  19694. @item @code{vcl} (default: #f)
  19695. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  19696. is @code{#f}, Varnish will proxy @code{backend} using the default
  19697. configuration. Otherwise this must be a file-like object with valid
  19698. VCL syntax.
  19699. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  19700. For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
  19701. can do something along these lines:
  19702. @lisp
  19703. (define %gnu-mirror
  19704. (plain-file "gnu.vcl"
  19705. "vcl 4.1;
  19706. backend gnu @{ .host = \"www.gnu.org\"; @}"))
  19707. (operating-system
  19708. ;; @dots{}
  19709. (services (cons (service varnish-service-type
  19710. (varnish-configuration
  19711. (listen '(":80"))
  19712. (vcl %gnu-mirror)))
  19713. %base-services)))
  19714. @end lisp
  19715. The configuration of an already running Varnish instance can be inspected
  19716. and changed using the @command{varnishadm} program.
  19717. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  19718. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  19719. comprehensive documentation on Varnish and its configuration language.
  19720. @item @code{listen} (default: @code{'("localhost:80")})
  19721. List of addresses Varnish will listen on.
  19722. @item @code{storage} (default: @code{'("malloc,128m")})
  19723. List of storage backends that will be available in VCL.
  19724. @item @code{parameters} (default: @code{'()})
  19725. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  19726. @item @code{extra-options} (default: @code{'()})
  19727. Additional arguments to pass to the @command{varnishd} process.
  19728. @end table
  19729. @end deftp
  19730. @subsubheading Patchwork
  19731. @cindex Patchwork
  19732. Patchwork is a patch tracking system. It can collect patches sent to a
  19733. mailing list, and display them in a web interface.
  19734. @defvr {Scheme Variable} patchwork-service-type
  19735. Service type for Patchwork.
  19736. @end defvr
  19737. The following example is an example of a minimal service for Patchwork, for
  19738. the @code{patchwork.example.com} domain.
  19739. @lisp
  19740. (service patchwork-service-type
  19741. (patchwork-configuration
  19742. (domain "patchwork.example.com")
  19743. (settings-module
  19744. (patchwork-settings-module
  19745. (allowed-hosts (list domain))
  19746. (default-from-email "patchwork@@patchwork.example.com")))
  19747. (getmail-retriever-config
  19748. (getmail-retriever-configuration
  19749. (type "SimpleIMAPSSLRetriever")
  19750. (server "imap.example.com")
  19751. (port 993)
  19752. (username "patchwork")
  19753. (password-command
  19754. (list (file-append coreutils "/bin/cat")
  19755. "/etc/getmail-patchwork-imap-password"))
  19756. (extra-parameters
  19757. '((mailboxes . ("Patches"))))))))
  19758. @end lisp
  19759. There are three records for configuring the Patchwork service. The
  19760. @code{<patchwork-configuration>} relates to the configuration for Patchwork
  19761. within the HTTPD service.
  19762. The @code{settings-module} field within the @code{<patchwork-configuration>}
  19763. record can be populated with the @code{<patchwork-settings-module>} record,
  19764. which describes a settings module that is generated within the Guix store.
  19765. For the @code{database-configuration} field within the
  19766. @code{<patchwork-settings-module>}, the
  19767. @code{<patchwork-database-configuration>} must be used.
  19768. @deftp {Data Type} patchwork-configuration
  19769. Data type representing the Patchwork service configuration. This type has the
  19770. following parameters:
  19771. @table @asis
  19772. @item @code{patchwork} (default: @code{patchwork})
  19773. The Patchwork package to use.
  19774. @item @code{domain}
  19775. The domain to use for Patchwork, this is used in the HTTPD service virtual
  19776. host.
  19777. @item @code{settings-module}
  19778. The settings module to use for Patchwork. As a Django application, Patchwork
  19779. is configured with a Python module containing the settings. This can either be
  19780. an instance of the @code{<patchwork-settings-module>} record, any other record
  19781. that represents the settings in the store, or a directory outside of the
  19782. store.
  19783. @item @code{static-path} (default: @code{"/static/"})
  19784. The path under which the HTTPD service should serve the static files.
  19785. @item @code{getmail-retriever-config}
  19786. The getmail-retriever-configuration record value to use with
  19787. Patchwork. Getmail will be configured with this value, the messages will be
  19788. delivered to Patchwork.
  19789. @end table
  19790. @end deftp
  19791. @deftp {Data Type} patchwork-settings-module
  19792. Data type representing a settings module for Patchwork. Some of these
  19793. settings relate directly to Patchwork, but others relate to Django, the web
  19794. framework used by Patchwork, or the Django Rest Framework library. This type
  19795. has the following parameters:
  19796. @table @asis
  19797. @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
  19798. The database connection settings used for Patchwork. See the
  19799. @code{<patchwork-database-configuration>} record type for more information.
  19800. @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
  19801. Patchwork, as a Django web application uses a secret key for cryptographically
  19802. signing values. This file should contain a unique unpredictable value.
  19803. If this file does not exist, it will be created and populated with a random
  19804. value by the patchwork-setup shepherd service.
  19805. This setting relates to Django.
  19806. @item @code{allowed-hosts}
  19807. A list of valid hosts for this Patchwork service. This should at least include
  19808. the domain specified in the @code{<patchwork-configuration>} record.
  19809. This is a Django setting.
  19810. @item @code{default-from-email}
  19811. The email address from which Patchwork should send email by default.
  19812. This is a Patchwork setting.
  19813. @item @code{static-url} (default: @code{#f})
  19814. The URL to use when serving static assets. It can be part of a URL, or a full
  19815. URL, but must end in a @code{/}.
  19816. If the default value is used, the @code{static-path} value from the
  19817. @code{<patchwork-configuration>} record will be used.
  19818. This is a Django setting.
  19819. @item @code{admins} (default: @code{'()})
  19820. Email addresses to send the details of errors that occur. Each value should
  19821. be a list containing two elements, the name and then the email address.
  19822. This is a Django setting.
  19823. @item @code{debug?} (default: @code{#f})
  19824. Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
  19825. messages will be shown.
  19826. This is a Django setting.
  19827. @item @code{enable-rest-api?} (default: @code{#t})
  19828. Whether to enable the Patchwork REST API.
  19829. This is a Patchwork setting.
  19830. @item @code{enable-xmlrpc?} (default: @code{#t})
  19831. Whether to enable the XML RPC API.
  19832. This is a Patchwork setting.
  19833. @item @code{force-https-links?} (default: @code{#t})
  19834. Whether to use HTTPS links on Patchwork pages.
  19835. This is a Patchwork setting.
  19836. @item @code{extra-settings} (default: @code{""})
  19837. Extra code to place at the end of the Patchwork settings module.
  19838. @end table
  19839. @end deftp
  19840. @deftp {Data Type} patchwork-database-configuration
  19841. Data type representing the database configuration for Patchwork.
  19842. @table @asis
  19843. @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
  19844. The database engine to use.
  19845. @item @code{name} (default: @code{"patchwork"})
  19846. The name of the database to use.
  19847. @item @code{user} (default: @code{"httpd"})
  19848. The user to connect to the database as.
  19849. @item @code{password} (default: @code{""})
  19850. The password to use when connecting to the database.
  19851. @item @code{host} (default: @code{""})
  19852. The host to make the database connection to.
  19853. @item @code{port} (default: @code{""})
  19854. The port on which to connect to the database.
  19855. @end table
  19856. @end deftp
  19857. @subsubheading Mumi
  19858. @cindex Mumi, Debbugs Web interface
  19859. @cindex Debbugs, Mumi Web interface
  19860. @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
  19861. Web interface to the Debbugs bug tracker, by default for
  19862. @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
  19863. but it also fetches and indexes mail retrieved from Debbugs.
  19864. @defvr {Scheme Variable} mumi-service-type
  19865. This is the service type for Mumi.
  19866. @end defvr
  19867. @deftp {Data Type} mumi-configuration
  19868. Data type representing the Mumi service configuration. This type has the
  19869. following fields:
  19870. @table @asis
  19871. @item @code{mumi} (default: @code{mumi})
  19872. The Mumi package to use.
  19873. @item @code{mailer?} (default: @code{#true})
  19874. Whether to enable or disable the mailer component.
  19875. @item @code{mumi-configuration-sender}
  19876. The email address used as the sender for comments.
  19877. @item @code{mumi-configuration-smtp}
  19878. A URI to configure the SMTP settings for Mailutils. This could be
  19879. something like @code{sendmail:///path/to/bin/msmtp} or any other URI
  19880. supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
  19881. mailutils, GNU@tie{}Mailutils}.
  19882. @end table
  19883. @end deftp
  19884. @subsubheading FastCGI
  19885. @cindex fastcgi
  19886. @cindex fcgiwrap
  19887. FastCGI is an interface between the front-end and the back-end of a web
  19888. service. It is a somewhat legacy facility; new web services should
  19889. generally just talk HTTP between the front-end and the back-end.
  19890. However there are a number of back-end services such as PHP or the
  19891. optimized HTTP Git repository access that use FastCGI, so we have
  19892. support for it in Guix.
  19893. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  19894. dispatch some subset of its requests to the fastcgi backend, which
  19895. listens on a local TCP or UNIX socket. There is an intermediary
  19896. @code{fcgiwrap} program that sits between the actual backend process and
  19897. the web server. The front-end indicates which backend program to run,
  19898. passing that information to the @code{fcgiwrap} process.
  19899. @defvr {Scheme Variable} fcgiwrap-service-type
  19900. A service type for the @code{fcgiwrap} FastCGI proxy.
  19901. @end defvr
  19902. @deftp {Data Type} fcgiwrap-configuration
  19903. Data type representing the configuration of the @code{fcgiwrap} service.
  19904. This type has the following parameters:
  19905. @table @asis
  19906. @item @code{package} (default: @code{fcgiwrap})
  19907. The fcgiwrap package to use.
  19908. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  19909. The socket on which the @code{fcgiwrap} process should listen, as a
  19910. string. Valid @var{socket} values include
  19911. @code{unix:@var{/path/to/unix/socket}},
  19912. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  19913. @code{tcp6:[@var{ipv6_addr}]:port}.
  19914. @item @code{user} (default: @code{fcgiwrap})
  19915. @itemx @code{group} (default: @code{fcgiwrap})
  19916. The user and group names, as strings, under which to run the
  19917. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  19918. the user asks for the specific user or group names @code{fcgiwrap} that
  19919. the corresponding user and/or group is present on the system.
  19920. It is possible to configure a FastCGI-backed web service to pass HTTP
  19921. authentication information from the front-end to the back-end, and to
  19922. allow @code{fcgiwrap} to run the back-end process as a corresponding
  19923. local user. To enable this capability on the back-end, run
  19924. @code{fcgiwrap} as the @code{root} user and group. Note that this
  19925. capability also has to be configured on the front-end as well.
  19926. @end table
  19927. @end deftp
  19928. @cindex php-fpm
  19929. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  19930. with some additional features useful for sites of any size.
  19931. These features include:
  19932. @itemize @bullet
  19933. @item Adaptive process spawning
  19934. @item Basic statistics (similar to Apache's mod_status)
  19935. @item Advanced process management with graceful stop/start
  19936. @item Ability to start workers with different uid/gid/chroot/environment
  19937. and different php.ini (replaces safe_mode)
  19938. @item Stdout & stderr logging
  19939. @item Emergency restart in case of accidental opcode cache destruction
  19940. @item Accelerated upload support
  19941. @item Support for a "slowlog"
  19942. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  19943. a special function to finish request & flush all data while continuing to do
  19944. something time-consuming (video converting, stats processing, etc.)
  19945. @end itemize
  19946. ...@: and much more.
  19947. @defvr {Scheme Variable} php-fpm-service-type
  19948. A Service type for @code{php-fpm}.
  19949. @end defvr
  19950. @deftp {Data Type} php-fpm-configuration
  19951. Data Type for php-fpm service configuration.
  19952. @table @asis
  19953. @item @code{php} (default: @code{php})
  19954. The php package to use.
  19955. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  19956. The address on which to accept FastCGI requests. Valid syntaxes are:
  19957. @table @asis
  19958. @item @code{"ip.add.re.ss:port"}
  19959. Listen on a TCP socket to a specific address on a specific port.
  19960. @item @code{"port"}
  19961. Listen on a TCP socket to all addresses on a specific port.
  19962. @item @code{"/path/to/unix/socket"}
  19963. Listen on a unix socket.
  19964. @end table
  19965. @item @code{user} (default: @code{php-fpm})
  19966. User who will own the php worker processes.
  19967. @item @code{group} (default: @code{php-fpm})
  19968. Group of the worker processes.
  19969. @item @code{socket-user} (default: @code{php-fpm})
  19970. User who can speak to the php-fpm socket.
  19971. @item @code{socket-group} (default: @code{nginx})
  19972. Group that can speak to the php-fpm socket.
  19973. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  19974. The process id of the php-fpm process is written to this file
  19975. once the service has started.
  19976. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  19977. Log for the php-fpm master process.
  19978. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  19979. Detailed settings for the php-fpm process manager.
  19980. Must be one of:
  19981. @table @asis
  19982. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  19983. @item @code{<php-fpm-static-process-manager-configuration>}
  19984. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  19985. @end table
  19986. @item @code{display-errors} (default @code{#f})
  19987. Determines whether php errors and warning should be sent to clients
  19988. and displayed in their browsers.
  19989. This is useful for local php development, but a security risk for public sites,
  19990. as error messages can reveal passwords and personal data.
  19991. @item @code{timezone} (default @code{#f})
  19992. Specifies @code{php_admin_value[date.timezone]} parameter.
  19993. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  19994. This file will log the @code{stderr} outputs of php worker processes.
  19995. Can be set to @code{#f} to disable logging.
  19996. @item @code{file} (default @code{#f})
  19997. An optional override of the whole configuration.
  19998. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  19999. @item @code{php-ini-file} (default @code{#f})
  20000. An optional override of the default php settings.
  20001. It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
  20002. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  20003. For local development it is useful to set a higher timeout and memory
  20004. limit for spawned php processes. This be accomplished with the
  20005. following operating system configuration snippet:
  20006. @lisp
  20007. (define %local-php-ini
  20008. (plain-file "php.ini"
  20009. "memory_limit = 2G
  20010. max_execution_time = 1800"))
  20011. (operating-system
  20012. ;; @dots{}
  20013. (services (cons (service php-fpm-service-type
  20014. (php-fpm-configuration
  20015. (php-ini-file %local-php-ini)))
  20016. %base-services)))
  20017. @end lisp
  20018. Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
  20019. directives} for comprehensive documentation on the acceptable
  20020. @file{php.ini} directives.
  20021. @end table
  20022. @end deftp
  20023. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  20024. Data Type for the @code{dynamic} php-fpm process manager. With the
  20025. @code{dynamic} process manager, spare worker processes are kept around
  20026. based on it's configured limits.
  20027. @table @asis
  20028. @item @code{max-children} (default: @code{5})
  20029. Maximum of worker processes.
  20030. @item @code{start-servers} (default: @code{2})
  20031. How many worker processes should be started on start-up.
  20032. @item @code{min-spare-servers} (default: @code{1})
  20033. How many spare worker processes should be kept around at minimum.
  20034. @item @code{max-spare-servers} (default: @code{3})
  20035. How many spare worker processes should be kept around at maximum.
  20036. @end table
  20037. @end deftp
  20038. @deftp {Data type} php-fpm-static-process-manager-configuration
  20039. Data Type for the @code{static} php-fpm process manager. With the
  20040. @code{static} process manager, an unchanging number of worker processes
  20041. are created.
  20042. @table @asis
  20043. @item @code{max-children} (default: @code{5})
  20044. Maximum of worker processes.
  20045. @end table
  20046. @end deftp
  20047. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  20048. Data Type for the @code{on-demand} php-fpm process manager. With the
  20049. @code{on-demand} process manager, worker processes are only created as
  20050. requests arrive.
  20051. @table @asis
  20052. @item @code{max-children} (default: @code{5})
  20053. Maximum of worker processes.
  20054. @item @code{process-idle-timeout} (default: @code{10})
  20055. The time in seconds after which a process with no requests is killed.
  20056. @end table
  20057. @end deftp
  20058. @deffn {Scheme Procedure} nginx-php-location @
  20059. [#:nginx-package nginx] @
  20060. [socket (string-append "/var/run/php" @
  20061. (version-major (package-version php)) @
  20062. "-fpm.sock")]
  20063. A helper function to quickly add php to an @code{nginx-server-configuration}.
  20064. @end deffn
  20065. A simple services setup for nginx with php can look like this:
  20066. @lisp
  20067. (services (cons* (service dhcp-client-service-type)
  20068. (service php-fpm-service-type)
  20069. (service nginx-service-type
  20070. (nginx-server-configuration
  20071. (server-name '("example.com"))
  20072. (root "/srv/http/")
  20073. (locations
  20074. (list (nginx-php-location)))
  20075. (listen '("80"))
  20076. (ssl-certificate #f)
  20077. (ssl-certificate-key #f)))
  20078. %base-services))
  20079. @end lisp
  20080. @cindex cat-avatar-generator
  20081. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  20082. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  20083. the hash of a user's email address.
  20084. @deffn {Scheme Procedure} cat-avatar-generator-service @
  20085. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  20086. [#:package cat-avatar-generator] @
  20087. [#:configuration (nginx-server-configuration)]
  20088. Returns an nginx-server-configuration that inherits @code{configuration}. It
  20089. extends the nginx configuration to add a server block that serves @code{package},
  20090. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  20091. be able to use @code{cache-dir} as its cache directory.
  20092. @end deffn
  20093. A simple setup for cat-avatar-generator can look like this:
  20094. @lisp
  20095. (services (cons* (cat-avatar-generator-service
  20096. #:configuration
  20097. (nginx-server-configuration
  20098. (server-name '("example.com"))))
  20099. ...
  20100. %base-services))
  20101. @end lisp
  20102. @subsubheading Hpcguix-web
  20103. @cindex hpcguix-web
  20104. The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
  20105. program is a customizable web interface to browse Guix packages,
  20106. initially designed for users of high-performance computing (HPC)
  20107. clusters.
  20108. @defvr {Scheme Variable} hpcguix-web-service-type
  20109. The service type for @code{hpcguix-web}.
  20110. @end defvr
  20111. @deftp {Data Type} hpcguix-web-configuration
  20112. Data type for the hpcguix-web service configuration.
  20113. @table @asis
  20114. @item @code{specs}
  20115. A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
  20116. configuration. The main items available in this spec are:
  20117. @table @asis
  20118. @item @code{title-prefix} (default: @code{"hpcguix | "})
  20119. The page title prefix.
  20120. @item @code{guix-command} (default: @code{"guix"})
  20121. The @command{guix} command.
  20122. @item @code{package-filter-proc} (default: @code{(const #t)})
  20123. A procedure specifying how to filter packages that are displayed.
  20124. @item @code{package-page-extension-proc} (default: @code{(const '())})
  20125. Extension package for @code{hpcguix-web}.
  20126. @item @code{menu} (default: @code{'()})
  20127. Additional entry in page @code{menu}.
  20128. @item @code{channels} (default: @code{%default-channels})
  20129. List of channels from which the package list is built (@pxref{Channels}).
  20130. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  20131. The expiration time, in seconds, after which the package list is rebuilt from
  20132. the latest instances of the given channels.
  20133. @end table
  20134. See the hpcguix-web repository for a
  20135. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  20136. complete example}.
  20137. @item @code{package} (default: @code{hpcguix-web})
  20138. The hpcguix-web package to use.
  20139. @end table
  20140. @end deftp
  20141. A typical hpcguix-web service declaration looks like this:
  20142. @lisp
  20143. (service hpcguix-web-service-type
  20144. (hpcguix-web-configuration
  20145. (specs
  20146. #~(define site-config
  20147. (hpcweb-configuration
  20148. (title-prefix "Guix-HPC - ")
  20149. (menu '(("/about" "ABOUT"))))))))
  20150. @end lisp
  20151. @quotation Note
  20152. The hpcguix-web service periodically updates the package list it publishes by
  20153. pulling channels from Git. To that end, it needs to access X.509 certificates
  20154. so that it can authenticate Git servers when communicating over HTTPS, and it
  20155. assumes that @file{/etc/ssl/certs} contains those certificates.
  20156. Thus, make sure to add @code{nss-certs} or another certificate package to the
  20157. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  20158. more information on X.509 certificates.
  20159. @end quotation
  20160. @subsubheading gmnisrv
  20161. @cindex gmnisrv
  20162. The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
  20163. simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
  20164. @deffn {Scheme Variable} gmnisrv-service-type
  20165. This is the type of the gmnisrv service, whose value should be a
  20166. @code{gmnisrv-configuration} object, as in this example:
  20167. @lisp
  20168. (service gmnisrv-service-type
  20169. (gmnisrv-configuration
  20170. (config-file (local-file "./my-gmnisrv.ini"))))
  20171. @end lisp
  20172. @end deffn
  20173. @deftp {Data Type} gmnisrv-configuration
  20174. Data type representing the configuration of gmnisrv.
  20175. @table @asis
  20176. @item @code{package} (default: @var{gmnisrv})
  20177. Package object of the gmnisrv server.
  20178. @item @code{config-file} (default: @code{%default-gmnisrv-config-file})
  20179. File-like object of the gmnisrv configuration file to use. The default
  20180. configuration listens on port 1965 and serves files from
  20181. @file{/srv/gemini}. Certificates are stored in
  20182. @file{/var/lib/gemini/certs}. For more information, run @command{man
  20183. gmnisrv} and @command{man gmnisrv.ini}.
  20184. @end table
  20185. @end deftp
  20186. @subsubheading Agate
  20187. @cindex agate
  20188. The @uref{gemini://qwertqwefsday.eu/agate.gmi, Agate}
  20189. (@uref{https://github.com/mbrubeck/agate, GitHub page over HTTPS})
  20190. program is a simple @uref{https://gemini.circumlunar.space/, Gemini}
  20191. protocol server written in Rust.
  20192. @deffn {Scheme Variable} agate-service-type
  20193. This is the type of the agate service, whose value should be an
  20194. @code{agate-service-type} object, as in this example:
  20195. @lisp
  20196. (service agate-service-type
  20197. (agate-configuration
  20198. (content "/srv/gemini")
  20199. (cert "/srv/cert.pem")
  20200. (key "/srv/key.rsa")))
  20201. @end lisp
  20202. The example above represents the minimal tweaking necessary to get Agate
  20203. up and running. Specifying the path to the certificate and key is
  20204. always necessary, as the Gemini protocol requires TLS by default.
  20205. To obtain a certificate and a key, you could, for example, use OpenSSL,
  20206. running a command similar to the following example:
  20207. @example
  20208. openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
  20209. -days 3650 -nodes -subj "/CN=example.com"
  20210. @end example
  20211. Of course, you'll have to replace @i{example.com} with your own domain
  20212. name, and then point the Agate configuration towards the path of the
  20213. generated key and certificate.
  20214. @end deffn
  20215. @deftp {Data Type} agate-configuration
  20216. Data type representing the configuration of Agate.
  20217. @table @asis
  20218. @item @code{package} (default: @code{agate})
  20219. The package object of the Agate server.
  20220. @item @code{content} (default: @file{"/srv/gemini"})
  20221. The directory from which Agate will serve files.
  20222. @item @code{cert} (default: @code{#f})
  20223. The path to the TLS certificate PEM file to be used for encrypted
  20224. connections. Must be filled in with a value from the user.
  20225. @item @code{key} (default: @code{#f})
  20226. The path to the PKCS8 private key file to be used for encrypted
  20227. connections. Must be filled in with a value from the user.
  20228. @item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
  20229. A list of the addresses to listen on.
  20230. @item @code{hostname} (default: @code{#f})
  20231. The domain name of this Gemini server. Optional.
  20232. @item @code{lang} (default: @code{#f})
  20233. RFC 4646 language code(s) for text/gemini documents. Optional.
  20234. @item @code{silent?} (default: @code{#f})
  20235. Set to @code{#t} to disable logging output.
  20236. @item @code{serve-secret?} (default: @code{#f})
  20237. Set to @code{#t} to serve secret files (files/directories starting with
  20238. a dot).
  20239. @item @code{log-ip?} (default: @code{#t})
  20240. Whether or not to output IP addresses when logging.
  20241. @item @code{user} (default: @code{"agate"})
  20242. Owner of the @code{agate} process.
  20243. @item @code{group} (default: @code{"agate"})
  20244. Owner's group of the @code{agate} process.
  20245. @item @code{log-file} (default: @file{"/var/log/agate.log"})
  20246. The file which should store the logging output of Agate.
  20247. @end table
  20248. @end deftp
  20249. @node Certificate Services
  20250. @subsection Certificate Services
  20251. @cindex Web
  20252. @cindex HTTP, HTTPS
  20253. @cindex Let's Encrypt
  20254. @cindex TLS certificates
  20255. The @code{(gnu services certbot)} module provides a service to
  20256. automatically obtain a valid TLS certificate from the Let's Encrypt
  20257. certificate authority. These certificates can then be used to serve
  20258. content securely over HTTPS or other TLS-based protocols, with the
  20259. knowledge that the client will be able to verify the server's
  20260. authenticity.
  20261. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  20262. @code{certbot} tool to automate the certification process. This tool
  20263. first securely generates a key on the server. It then makes a request
  20264. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  20265. checks that the request originates from the host in question by using a
  20266. challenge-response protocol, requiring the server to provide its
  20267. response over HTTP@. If that protocol completes successfully, the CA
  20268. signs the key, resulting in a certificate. That certificate is valid
  20269. for a limited period of time, and therefore to continue to provide TLS
  20270. services, the server needs to periodically ask the CA to renew its
  20271. signature.
  20272. The certbot service automates this process: the initial key
  20273. generation, the initial certification request to the Let's Encrypt
  20274. service, the web server challenge/response integration, writing the
  20275. certificate to disk, the automated periodic renewals, and the deployment
  20276. tasks associated with the renewal (e.g.@: reloading services, copying keys
  20277. with different permissions).
  20278. Certbot is run twice a day, at a random minute within the hour. It
  20279. won't do anything until your certificates are due for renewal or
  20280. revoked, but running it regularly would give your service a chance of
  20281. staying online in case a Let's Encrypt-initiated revocation happened for
  20282. some reason.
  20283. By using this service, you agree to the ACME Subscriber Agreement, which
  20284. can be found there:
  20285. @url{https://acme-v01.api.letsencrypt.org/directory}.
  20286. @defvr {Scheme Variable} certbot-service-type
  20287. A service type for the @code{certbot} Let's Encrypt client. Its value
  20288. must be a @code{certbot-configuration} record as in this example:
  20289. @lisp
  20290. (define %nginx-deploy-hook
  20291. (program-file
  20292. "nginx-deploy-hook"
  20293. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  20294. (kill pid SIGHUP))))
  20295. (service certbot-service-type
  20296. (certbot-configuration
  20297. (email "foo@@example.net")
  20298. (certificates
  20299. (list
  20300. (certificate-configuration
  20301. (domains '("example.net" "www.example.net"))
  20302. (deploy-hook %nginx-deploy-hook))
  20303. (certificate-configuration
  20304. (domains '("bar.example.net")))))))
  20305. @end lisp
  20306. See below for details about @code{certbot-configuration}.
  20307. @end defvr
  20308. @deftp {Data Type} certbot-configuration
  20309. Data type representing the configuration of the @code{certbot} service.
  20310. This type has the following parameters:
  20311. @table @asis
  20312. @item @code{package} (default: @code{certbot})
  20313. The certbot package to use.
  20314. @item @code{webroot} (default: @code{/var/www})
  20315. The directory from which to serve the Let's Encrypt challenge/response
  20316. files.
  20317. @item @code{certificates} (default: @code{()})
  20318. A list of @code{certificates-configuration}s for which to generate
  20319. certificates and request signatures. Each certificate has a @code{name}
  20320. and several @code{domains}.
  20321. @item @code{email} (default: @code{#f})
  20322. Optional email address used for registration and recovery contact.
  20323. Setting this is encouraged as it allows you to receive important
  20324. notifications about the account and issued certificates.
  20325. @item @code{server} (default: @code{#f})
  20326. Optional URL of ACME server. Setting this overrides certbot's default,
  20327. which is the Let's Encrypt server.
  20328. @item @code{rsa-key-size} (default: @code{2048})
  20329. Size of the RSA key.
  20330. @item @code{default-location} (default: @i{see below})
  20331. The default @code{nginx-location-configuration}. Because @code{certbot}
  20332. needs to be able to serve challenges and responses, it needs to be able
  20333. to run a web server. It does so by extending the @code{nginx} web
  20334. service with an @code{nginx-server-configuration} listening on the
  20335. @var{domains} on port 80, and which has a
  20336. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  20337. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  20338. these nginx configuration data types.
  20339. Requests to other URL paths will be matched by the
  20340. @code{default-location}, which if present is added to all
  20341. @code{nginx-server-configuration}s.
  20342. By default, the @code{default-location} will issue a redirect from
  20343. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  20344. you to define what to serve on your site via @code{https}.
  20345. Pass @code{#f} to not issue a default location.
  20346. @end table
  20347. @end deftp
  20348. @deftp {Data Type} certificate-configuration
  20349. Data type representing the configuration of a certificate.
  20350. This type has the following parameters:
  20351. @table @asis
  20352. @item @code{name} (default: @i{see below})
  20353. This name is used by Certbot for housekeeping and in file paths; it
  20354. doesn't affect the content of the certificate itself. To see
  20355. certificate names, run @code{certbot certificates}.
  20356. Its default is the first provided domain.
  20357. @item @code{domains} (default: @code{()})
  20358. The first domain provided will be the subject CN of the certificate, and
  20359. all domains will be Subject Alternative Names on the certificate.
  20360. @item @code{challenge} (default: @code{#f})
  20361. The challenge type that has to be run by certbot. If @code{#f} is specified,
  20362. default to the HTTP challenge. If a value is specified, defaults to the
  20363. manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
  20364. the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
  20365. and gives Let's Encrypt permission to log the public IP address of the
  20366. requesting machine.
  20367. @item @code{authentication-hook} (default: @code{#f})
  20368. Command to be run in a shell once for each certificate challenge to be
  20369. answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
  20370. will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
  20371. contains the validation string and @code{$CERTBOT_TOKEN} contains the
  20372. file name of the resource requested when performing an HTTP-01 challenge.
  20373. @item @code{cleanup-hook} (default: @code{#f})
  20374. Command to be run in a shell once for each certificate challenge that
  20375. have been answered by the @code{auth-hook}. For this command, the shell
  20376. variables available in the @code{auth-hook} script are still available, and
  20377. additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
  20378. of the @code{auth-hook} script.
  20379. @item @code{deploy-hook} (default: @code{#f})
  20380. Command to be run in a shell once for each successfully issued
  20381. certificate. For this command, the shell variable
  20382. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  20383. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  20384. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  20385. contain a space-delimited list of renewed certificate domains (for
  20386. example, @samp{"example.com www.example.com"}.
  20387. @end table
  20388. @end deftp
  20389. For each @code{certificate-configuration}, the certificate is saved to
  20390. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  20391. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  20392. @node DNS Services
  20393. @subsection DNS Services
  20394. @cindex DNS (domain name system)
  20395. @cindex domain name system (DNS)
  20396. The @code{(gnu services dns)} module provides services related to the
  20397. @dfn{domain name system} (DNS). It provides a server service for hosting
  20398. an @emph{authoritative} DNS server for multiple zones, slave or master.
  20399. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  20400. caching and forwarding DNS server for the LAN, which uses
  20401. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  20402. @subsubheading Knot Service
  20403. An example configuration of an authoritative server for two zones, one master
  20404. and one slave, is:
  20405. @lisp
  20406. (define-zone-entries example.org.zone
  20407. ;; Name TTL Class Type Data
  20408. ("@@" "" "IN" "A" "127.0.0.1")
  20409. ("@@" "" "IN" "NS" "ns")
  20410. ("ns" "" "IN" "A" "127.0.0.1"))
  20411. (define master-zone
  20412. (knot-zone-configuration
  20413. (domain "example.org")
  20414. (zone (zone-file
  20415. (origin "example.org")
  20416. (entries example.org.zone)))))
  20417. (define slave-zone
  20418. (knot-zone-configuration
  20419. (domain "plop.org")
  20420. (dnssec-policy "default")
  20421. (master (list "plop-master"))))
  20422. (define plop-master
  20423. (knot-remote-configuration
  20424. (id "plop-master")
  20425. (address (list "208.76.58.171"))))
  20426. (operating-system
  20427. ;; ...
  20428. (services (cons* (service knot-service-type
  20429. (knot-configuration
  20430. (remotes (list plop-master))
  20431. (zones (list master-zone slave-zone))))
  20432. ;; ...
  20433. %base-services)))
  20434. @end lisp
  20435. @deffn {Scheme Variable} knot-service-type
  20436. This is the type for the Knot DNS server.
  20437. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  20438. zones, that is to say domain names you would buy from a registrar. This server
  20439. is not a resolver, meaning that it can only resolve names for which it is
  20440. authoritative. This server can be configured to serve zones as a master server
  20441. or a slave server as a per-zone basis. Slave zones will get their data from
  20442. masters, and will serve it as an authoritative server. From the point of view
  20443. of a resolver, there is no difference between master and slave.
  20444. The following data types are used to configure the Knot DNS server:
  20445. @end deffn
  20446. @deftp {Data Type} knot-key-configuration
  20447. Data type representing a key.
  20448. This type has the following parameters:
  20449. @table @asis
  20450. @item @code{id} (default: @code{""})
  20451. An identifier for other configuration fields to refer to this key. IDs must
  20452. be unique and must not be empty.
  20453. @item @code{algorithm} (default: @code{#f})
  20454. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  20455. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  20456. and @code{'hmac-sha512}.
  20457. @item @code{secret} (default: @code{""})
  20458. The secret key itself.
  20459. @end table
  20460. @end deftp
  20461. @deftp {Data Type} knot-acl-configuration
  20462. Data type representing an Access Control List (ACL) configuration.
  20463. This type has the following parameters:
  20464. @table @asis
  20465. @item @code{id} (default: @code{""})
  20466. An identifier for other configuration fields to refer to this key. IDs must be
  20467. unique and must not be empty.
  20468. @item @code{address} (default: @code{'()})
  20469. An ordered list of IP addresses, network subnets, or network ranges represented
  20470. with strings. The query must match one of them. Empty value means that
  20471. address match is not required.
  20472. @item @code{key} (default: @code{'()})
  20473. An ordered list of references to keys represented with strings. The string
  20474. must match a key ID defined in a @code{knot-key-configuration}. No key means
  20475. that a key is not require to match that ACL.
  20476. @item @code{action} (default: @code{'()})
  20477. An ordered list of actions that are permitted or forbidden by this ACL@. Possible
  20478. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  20479. and @code{'update}.
  20480. @item @code{deny?} (default: @code{#f})
  20481. When true, the ACL defines restrictions. Listed actions are forbidden. When
  20482. false, listed actions are allowed.
  20483. @end table
  20484. @end deftp
  20485. @deftp {Data Type} zone-entry
  20486. Data type representing a record entry in a zone file.
  20487. This type has the following parameters:
  20488. @table @asis
  20489. @item @code{name} (default: @code{"@@"})
  20490. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  20491. are relative to the origin of the zone. For example, in the @code{example.org}
  20492. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  20493. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  20494. refers to @code{ns.example.org}.
  20495. @item @code{ttl} (default: @code{""})
  20496. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  20497. @item @code{class} (default: @code{"IN"})
  20498. The class of the record. Knot currently supports only @code{"IN"} and
  20499. partially @code{"CH"}.
  20500. @item @code{type} (default: @code{"A"})
  20501. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  20502. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  20503. defined.
  20504. @item @code{data} (default: @code{""})
  20505. The data contained in the record. For instance an IP address associated with
  20506. an A record, or a domain name associated with an NS record. Remember that
  20507. domain names are relative to the origin unless they end with a dot.
  20508. @end table
  20509. @end deftp
  20510. @deftp {Data Type} zone-file
  20511. Data type representing the content of a zone file.
  20512. This type has the following parameters:
  20513. @table @asis
  20514. @item @code{entries} (default: @code{'()})
  20515. The list of entries. The SOA record is taken care of, so you don't need to
  20516. put it in the list of entries. This list should probably contain an entry
  20517. for your primary authoritative DNS server. Other than using a list of entries
  20518. directly, you can use @code{define-zone-entries} to define a object containing
  20519. the list of entries more easily, that you can later pass to the @code{entries}
  20520. field of the @code{zone-file}.
  20521. @item @code{origin} (default: @code{""})
  20522. The name of your zone. This parameter cannot be empty.
  20523. @item @code{ns} (default: @code{"ns"})
  20524. The domain of your primary authoritative DNS server. The name is relative to
  20525. the origin, unless it ends with a dot. It is mandatory that this primary
  20526. DNS server corresponds to an NS record in the zone and that it is associated
  20527. to an IP address in the list of entries.
  20528. @item @code{mail} (default: @code{"hostmaster"})
  20529. An email address people can contact you at, as the owner of the zone. This
  20530. is translated as @code{<mail>@@<origin>}.
  20531. @item @code{serial} (default: @code{1})
  20532. The serial number of the zone. As this is used to keep track of changes by
  20533. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  20534. Always increment it when you make a change in your zone.
  20535. @item @code{refresh} (default: @code{(* 2 24 3600)})
  20536. The frequency at which slaves will do a zone transfer. This value is a number
  20537. of seconds. It can be computed by multiplications or with
  20538. @code{(string->duration)}.
  20539. @item @code{retry} (default: @code{(* 15 60)})
  20540. The period after which a slave will retry to contact its master when it fails
  20541. to do so a first time.
  20542. @item @code{expiry} (default: @code{(* 14 24 3600)})
  20543. Default TTL of records. Existing records are considered correct for at most
  20544. this amount of time. After this period, resolvers will invalidate their cache
  20545. and check again that it still exists.
  20546. @item @code{nx} (default: @code{3600})
  20547. Default TTL of inexistant records. This delay is usually short because you want
  20548. your new domains to reach everyone quickly.
  20549. @end table
  20550. @end deftp
  20551. @deftp {Data Type} knot-remote-configuration
  20552. Data type representing a remote configuration.
  20553. This type has the following parameters:
  20554. @table @asis
  20555. @item @code{id} (default: @code{""})
  20556. An identifier for other configuration fields to refer to this remote. IDs must
  20557. be unique and must not be empty.
  20558. @item @code{address} (default: @code{'()})
  20559. An ordered list of destination IP addresses. Addresses are tried in sequence.
  20560. An optional port can be given with the @@ separator. For instance:
  20561. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  20562. @item @code{via} (default: @code{'()})
  20563. An ordered list of source IP addresses. An empty list will have Knot choose
  20564. an appropriate source IP@. An optional port can be given with the @@ separator.
  20565. The default is to choose at random.
  20566. @item @code{key} (default: @code{#f})
  20567. A reference to a key, that is a string containing the identifier of a key
  20568. defined in a @code{knot-key-configuration} field.
  20569. @end table
  20570. @end deftp
  20571. @deftp {Data Type} knot-keystore-configuration
  20572. Data type representing a keystore to hold dnssec keys.
  20573. This type has the following parameters:
  20574. @table @asis
  20575. @item @code{id} (default: @code{""})
  20576. The id of the keystore. It must not be empty.
  20577. @item @code{backend} (default: @code{'pem})
  20578. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  20579. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  20580. The configuration string of the backend. An example for the PKCS#11 is:
  20581. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  20582. For the pem backend, the string represents a path in the file system.
  20583. @end table
  20584. @end deftp
  20585. @deftp {Data Type} knot-policy-configuration
  20586. Data type representing a dnssec policy. Knot DNS is able to automatically
  20587. sign your zones. It can either generate and manage your keys automatically or
  20588. use keys that you generate.
  20589. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  20590. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  20591. zone. In order to be trusted, the KSK needs to be present in the parent zone
  20592. (usually a top-level domain). If your registrar supports dnssec, you will
  20593. have to send them your KSK's hash so they can add a DS record in their zone.
  20594. This is not automated and need to be done each time you change your KSK.
  20595. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  20596. easily and use weaker cryptographic functions (they use lower parameters) in
  20597. order to sign records quickly, so they are changed often. The KSK however
  20598. requires manual interaction with the registrar, so they are changed less often
  20599. and use stronger parameters because they sign only one record.
  20600. This type has the following parameters:
  20601. @table @asis
  20602. @item @code{id} (default: @code{""})
  20603. The id of the policy. It must not be empty.
  20604. @item @code{keystore} (default: @code{"default"})
  20605. A reference to a keystore, that is a string containing the identifier of a
  20606. keystore defined in a @code{knot-keystore-configuration} field. The
  20607. @code{"default"} identifier means the default keystore (a kasp database that
  20608. was setup by this service).
  20609. @item @code{manual?} (default: @code{#f})
  20610. Whether the key management is manual or automatic.
  20611. @item @code{single-type-signing?} (default: @code{#f})
  20612. When @code{#t}, use the Single-Type Signing Scheme.
  20613. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  20614. An algorithm of signing keys and issued signatures.
  20615. @item @code{ksk-size} (default: @code{256})
  20616. The length of the KSK@. Note that this value is correct for the default
  20617. algorithm, but would be unsecure for other algorithms.
  20618. @item @code{zsk-size} (default: @code{256})
  20619. The length of the ZSK@. Note that this value is correct for the default
  20620. algorithm, but would be unsecure for other algorithms.
  20621. @item @code{dnskey-ttl} (default: @code{'default})
  20622. The TTL value for DNSKEY records added into zone apex. The special
  20623. @code{'default} value means same as the zone SOA TTL.
  20624. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  20625. The period between ZSK publication and the next rollover initiation.
  20626. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  20627. An extra delay added for each key rollover step. This value should be high
  20628. enough to cover propagation of data from the master server to all slaves.
  20629. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  20630. A validity period of newly issued signatures.
  20631. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  20632. A period how long before a signature expiration the signature will be refreshed.
  20633. @item @code{nsec3?} (default: @code{#f})
  20634. When @code{#t}, NSEC3 will be used instead of NSEC.
  20635. @item @code{nsec3-iterations} (default: @code{5})
  20636. The number of additional times the hashing is performed.
  20637. @item @code{nsec3-salt-length} (default: @code{8})
  20638. The length of a salt field in octets, which is appended to the original owner
  20639. name before hashing.
  20640. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  20641. The validity period of newly issued salt field.
  20642. @end table
  20643. @end deftp
  20644. @deftp {Data Type} knot-zone-configuration
  20645. Data type representing a zone served by Knot.
  20646. This type has the following parameters:
  20647. @table @asis
  20648. @item @code{domain} (default: @code{""})
  20649. The domain served by this configuration. It must not be empty.
  20650. @item @code{file} (default: @code{""})
  20651. The file where this zone is saved. This parameter is ignored by master zones.
  20652. Empty means default location that depends on the domain name.
  20653. @item @code{zone} (default: @code{(zone-file)})
  20654. The content of the zone file. This parameter is ignored by slave zones. It
  20655. must contain a zone-file record.
  20656. @item @code{master} (default: @code{'()})
  20657. A list of master remotes. When empty, this zone is a master. When set, this
  20658. zone is a slave. This is a list of remotes identifiers.
  20659. @item @code{ddns-master} (default: @code{#f})
  20660. The main master. When empty, it defaults to the first master in the list of
  20661. masters.
  20662. @item @code{notify} (default: @code{'()})
  20663. A list of slave remote identifiers.
  20664. @item @code{acl} (default: @code{'()})
  20665. A list of acl identifiers.
  20666. @item @code{semantic-checks?} (default: @code{#f})
  20667. When set, this adds more semantic checks to the zone.
  20668. @item @code{disable-any?} (default: @code{#f})
  20669. When set, this forbids queries of the ANY type.
  20670. @item @code{zonefile-sync} (default: @code{0})
  20671. The delay between a modification in memory and on disk. 0 means immediate
  20672. synchronization.
  20673. @item @code{zonefile-load} (default: @code{#f})
  20674. The way the zone file contents are applied during zone load. Possible values
  20675. are:
  20676. @itemize
  20677. @item @code{#f} for using the default value from Knot,
  20678. @item @code{'none} for not using the zone file at all,
  20679. @item @code{'difference} for computing the difference between already available
  20680. contents and zone contents and applying it to the current zone contents,
  20681. @item @code{'difference-no-serial} for the same as @code{'difference}, but
  20682. ignoring the SOA serial in the zone file, while the server takes care of it
  20683. automatically.
  20684. @item @code{'whole} for loading zone contents from the zone file.
  20685. @end itemize
  20686. @item @code{journal-content} (default: @code{#f})
  20687. The way the journal is used to store zone and its changes. Possible values
  20688. are @code{'none} to not use it at all, @code{'changes} to store changes and
  20689. @code{'all} to store contents. @code{#f} does not set this option, so the
  20690. default value from Knot is used.
  20691. @item @code{max-journal-usage} (default: @code{#f})
  20692. The maximum size for the journal on disk. @code{#f} does not set this option,
  20693. so the default value from Knot is used.
  20694. @item @code{max-journal-depth} (default: @code{#f})
  20695. The maximum size of the history. @code{#f} does not set this option, so the
  20696. default value from Knot is used.
  20697. @item @code{max-zone-size} (default: @code{#f})
  20698. The maximum size of the zone file. This limit is enforced for incoming
  20699. transfer and updates. @code{#f} does not set this option, so the default
  20700. value from Knot is used.
  20701. @item @code{dnssec-policy} (default: @code{#f})
  20702. A reference to a @code{knot-policy-configuration} record, or the special
  20703. name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
  20704. on this zone.
  20705. @item @code{serial-policy} (default: @code{'increment})
  20706. A policy between @code{'increment} and @code{'unixtime}.
  20707. @end table
  20708. @end deftp
  20709. @deftp {Data Type} knot-configuration
  20710. Data type representing the Knot configuration.
  20711. This type has the following parameters:
  20712. @table @asis
  20713. @item @code{knot} (default: @code{knot})
  20714. The Knot package.
  20715. @item @code{run-directory} (default: @code{"/var/run/knot"})
  20716. The run directory. This directory will be used for pid file and sockets.
  20717. @item @code{includes} (default: @code{'()})
  20718. A list of strings or file-like objects denoting other files that must be
  20719. included at the top of the configuration file.
  20720. @cindex secrets, Knot service
  20721. This can be used to manage secrets out-of-band. For example, secret
  20722. keys may be stored in an out-of-band file not managed by Guix, and
  20723. thus not visible in @file{/gnu/store}---e.g., you could store secret
  20724. key configuration in @file{/etc/knot/secrets.conf} and add this file
  20725. to the @code{includes} list.
  20726. One can generate a secret tsig key (for nsupdate and zone transfers with the
  20727. keymgr command from the knot package. Note that the package is not automatically
  20728. installed by the service. The following example shows how to generate a new
  20729. tsig key:
  20730. @example
  20731. keymgr -t mysecret > /etc/knot/secrets.conf
  20732. chmod 600 /etc/knot/secrets.conf
  20733. @end example
  20734. Also note that the generated key will be named @var{mysecret}, so it is the
  20735. name that needs to be used in the @var{key} field of the
  20736. @code{knot-acl-configuration} record and in other places that need to refer
  20737. to that key.
  20738. It can also be used to add configuration not supported by this interface.
  20739. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  20740. An ip address on which to listen.
  20741. @item @code{listen-v6} (default: @code{"::"})
  20742. An ip address on which to listen.
  20743. @item @code{listen-port} (default: @code{53})
  20744. A port on which to listen.
  20745. @item @code{keys} (default: @code{'()})
  20746. The list of knot-key-configuration used by this configuration.
  20747. @item @code{acls} (default: @code{'()})
  20748. The list of knot-acl-configuration used by this configuration.
  20749. @item @code{remotes} (default: @code{'()})
  20750. The list of knot-remote-configuration used by this configuration.
  20751. @item @code{zones} (default: @code{'()})
  20752. The list of knot-zone-configuration used by this configuration.
  20753. @end table
  20754. @end deftp
  20755. @subsubheading Knot Resolver Service
  20756. @deffn {Scheme Variable} knot-resolver-service-type
  20757. This is the type of the knot resolver service, whose value should be
  20758. an @code{knot-resolver-configuration} object as in this example:
  20759. @lisp
  20760. (service knot-resolver-service-type
  20761. (knot-resolver-configuration
  20762. (kresd-config-file (plain-file "kresd.conf" "
  20763. net.listen('192.168.0.1', 5353)
  20764. user('knot-resolver', 'knot-resolver')
  20765. modules = @{ 'hints > iterate', 'stats', 'predict' @}
  20766. cache.size = 100 * MB
  20767. "))))
  20768. @end lisp
  20769. For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
  20770. @end deffn
  20771. @deftp {Data Type} knot-resolver-configuration
  20772. Data type representing the configuration of knot-resolver.
  20773. @table @asis
  20774. @item @code{package} (default: @var{knot-resolver})
  20775. Package object of the knot DNS resolver.
  20776. @item @code{kresd-config-file} (default: %kresd.conf)
  20777. File-like object of the kresd configuration file to use, by default it
  20778. will listen on @code{127.0.0.1} and @code{::1}.
  20779. @item @code{garbage-collection-interval} (default: 1000)
  20780. Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
  20781. @end table
  20782. @end deftp
  20783. @subsubheading Dnsmasq Service
  20784. @deffn {Scheme Variable} dnsmasq-service-type
  20785. This is the type of the dnsmasq service, whose value should be an
  20786. @code{dnsmasq-configuration} object as in this example:
  20787. @lisp
  20788. (service dnsmasq-service-type
  20789. (dnsmasq-configuration
  20790. (no-resolv? #t)
  20791. (servers '("192.168.1.1"))))
  20792. @end lisp
  20793. @end deffn
  20794. @deftp {Data Type} dnsmasq-configuration
  20795. Data type representing the configuration of dnsmasq.
  20796. @table @asis
  20797. @item @code{package} (default: @var{dnsmasq})
  20798. Package object of the dnsmasq server.
  20799. @item @code{no-hosts?} (default: @code{#f})
  20800. When true, don't read the hostnames in /etc/hosts.
  20801. @item @code{port} (default: @code{53})
  20802. The port to listen on. Setting this to zero completely disables DNS
  20803. responses, leaving only DHCP and/or TFTP functions.
  20804. @item @code{local-service?} (default: @code{#t})
  20805. Accept DNS queries only from hosts whose address is on a local subnet,
  20806. ie a subnet for which an interface exists on the server.
  20807. @item @code{listen-addresses} (default: @code{'()})
  20808. Listen on the given IP addresses.
  20809. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  20810. The file to read the IP address of the upstream nameservers from.
  20811. @item @code{no-resolv?} (default: @code{#f})
  20812. When true, don't read @var{resolv-file}.
  20813. @item @code{servers} (default: @code{'()})
  20814. Specify IP address of upstream servers directly.
  20815. @item @code{addresses} (default: @code{'()})
  20816. For each entry, specify an IP address to return for any host in the
  20817. given domains. Queries in the domains are never forwarded and always
  20818. replied to with the specified IP address.
  20819. This is useful for redirecting hosts locally, for example:
  20820. @lisp
  20821. (service dnsmasq-service-type
  20822. (dnsmasq-configuration
  20823. (addresses
  20824. '(; Redirect to a local web-server.
  20825. "/example.org/127.0.0.1"
  20826. ; Redirect subdomain to a specific IP.
  20827. "/subdomain.example.org/192.168.1.42"))))
  20828. @end lisp
  20829. Note that rules in @file{/etc/hosts} take precedence over this.
  20830. @item @code{cache-size} (default: @code{150})
  20831. Set the size of dnsmasq's cache. Setting the cache size to zero
  20832. disables caching.
  20833. @item @code{negative-cache?} (default: @code{#t})
  20834. When false, disable negative caching.
  20835. @item @code{tftp-enable?} (default: @code{#f})
  20836. Whether to enable the built-in TFTP server.
  20837. @item @code{tftp-no-fail?} (default: @code{#f})
  20838. If true, does not fail dnsmasq if the TFTP server could not start up.
  20839. @item @code{tftp-single-port?} (default: @code{#f})
  20840. Whether to use only one single port for TFTP.
  20841. @item @code{tftp-secure?} (default: @code{#f})
  20842. If true, only files owned by the user running the dnsmasq process are accessible.
  20843. If dnsmasq is being run as root, different rules apply:
  20844. @code{tftp-secure?} has no effect, but only files which have the
  20845. world-readable bit set are accessible.
  20846. @item @code{tftp-max} (default: @code{#f})
  20847. If set, sets the maximal number of concurrent connections allowed.
  20848. @item @code{tftp-mtu} (default: @code{#f})
  20849. If set, sets the MTU for TFTP packets to that value.
  20850. @item @code{tftp-no-blocksize?} (default: @code{#f})
  20851. If true, stops the TFTP server from negotiating the blocksize with a client.
  20852. @item @code{tftp-lowercase?} (default: @code{#f})
  20853. Whether to convert all filenames in TFTP requests to lowercase.
  20854. @item @code{tftp-port-range} (default: @code{#f})
  20855. If set, fixes the dynamical ports (one per client) to the given range
  20856. (@code{"<start>,<end>"}).
  20857. @item @code{tftp-root} (default: @code{/var/empty,lo})
  20858. Look for files to transfer using TFTP relative to the given directory.
  20859. When this is set, TFTP paths which include @samp{..} are rejected, to stop clients
  20860. getting outside the specified root. Absolute paths (starting with @samp{/}) are
  20861. allowed, but they must be within the TFTP-root. If the optional interface
  20862. argument is given, the directory is only used for TFTP requests via that
  20863. interface.
  20864. @item @code{tftp-unique-root} (default: @code{#f})
  20865. If set, add the IP or hardware address of the TFTP client as a path component
  20866. on the end of the TFTP-root. Only valid if a TFTP root is set and the
  20867. directory exists. Defaults to adding IP address (in standard dotted-quad
  20868. format).
  20869. For instance, if @option{--tftp-root} is @samp{/tftp} and client
  20870. @samp{1.2.3.4} requests file @file{myfile} then the effective path will
  20871. be @file{/tftp/1.2.3.4/myfile} if @file{/tftp/1.2.3.4} exists or
  20872. @file{/tftp/myfile} otherwise. When @samp{=mac} is specified it will
  20873. append the MAC address instead, using lowercase zero padded digits
  20874. separated by dashes, e.g.: @samp{01-02-03-04-aa-bb}. Note that
  20875. resolving MAC addresses is only possible if the client is in the local
  20876. network or obtained a DHCP lease from dnsmasq.
  20877. @end table
  20878. @end deftp
  20879. @subsubheading ddclient Service
  20880. @cindex ddclient
  20881. The ddclient service described below runs the ddclient daemon, which takes
  20882. care of automatically updating DNS entries for service providers such as
  20883. @uref{https://dyn.com/dns/, Dyn}.
  20884. The following example show instantiates the service with its default
  20885. configuration:
  20886. @lisp
  20887. (service ddclient-service-type)
  20888. @end lisp
  20889. Note that ddclient needs to access credentials that are stored in a
  20890. @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
  20891. @code{secret-file} below). You are expected to create this file manually, in
  20892. an ``out-of-band'' fashion (you @emph{could} make this file part of the
  20893. service configuration, for instance by using @code{plain-file}, but it will be
  20894. world-readable @i{via} @file{/gnu/store}). See the examples in the
  20895. @file{share/ddclient} directory of the @code{ddclient} package.
  20896. @c %start of fragment
  20897. Available @code{ddclient-configuration} fields are:
  20898. @deftypevr {@code{ddclient-configuration} parameter} package ddclient
  20899. The ddclient package.
  20900. @end deftypevr
  20901. @deftypevr {@code{ddclient-configuration} parameter} integer daemon
  20902. The period after which ddclient will retry to check IP and domain name.
  20903. Defaults to @samp{300}.
  20904. @end deftypevr
  20905. @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
  20906. Use syslog for the output.
  20907. Defaults to @samp{#t}.
  20908. @end deftypevr
  20909. @deftypevr {@code{ddclient-configuration} parameter} string mail
  20910. Mail to user.
  20911. Defaults to @samp{"root"}.
  20912. @end deftypevr
  20913. @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
  20914. Mail failed update to user.
  20915. Defaults to @samp{"root"}.
  20916. @end deftypevr
  20917. @deftypevr {@code{ddclient-configuration} parameter} string pid
  20918. The ddclient PID file.
  20919. Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
  20920. @end deftypevr
  20921. @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
  20922. Enable SSL support.
  20923. Defaults to @samp{#t}.
  20924. @end deftypevr
  20925. @deftypevr {@code{ddclient-configuration} parameter} string user
  20926. Specifies the user name or ID that is used when running ddclient
  20927. program.
  20928. Defaults to @samp{"ddclient"}.
  20929. @end deftypevr
  20930. @deftypevr {@code{ddclient-configuration} parameter} string group
  20931. Group of the user who will run the ddclient program.
  20932. Defaults to @samp{"ddclient"}.
  20933. @end deftypevr
  20934. @deftypevr {@code{ddclient-configuration} parameter} string secret-file
  20935. Secret file which will be appended to @file{ddclient.conf} file. This
  20936. file contains credentials for use by ddclient. You are expected to
  20937. create it manually.
  20938. Defaults to @samp{"/etc/ddclient/secrets.conf"}.
  20939. @end deftypevr
  20940. @deftypevr {@code{ddclient-configuration} parameter} list extra-options
  20941. Extra options will be appended to @file{ddclient.conf} file.
  20942. Defaults to @samp{()}.
  20943. @end deftypevr
  20944. @c %end of fragment
  20945. @node VPN Services
  20946. @subsection VPN Services
  20947. @cindex VPN (virtual private network)
  20948. @cindex virtual private network (VPN)
  20949. The @code{(gnu services vpn)} module provides services related to
  20950. @dfn{virtual private networks} (VPNs).
  20951. @subsubheading OpenVPN
  20952. It provides a @emph{client} service for your machine to connect to a
  20953. VPN, and a @emph{server} service for your machine to host a VPN@.
  20954. @deffn {Scheme Procedure} openvpn-client-service @
  20955. [#:config (openvpn-client-configuration)]
  20956. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  20957. @end deffn
  20958. @deffn {Scheme Procedure} openvpn-server-service @
  20959. [#:config (openvpn-server-configuration)]
  20960. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  20961. Both can be run simultaneously.
  20962. @end deffn
  20963. @c %automatically generated documentation
  20964. Available @code{openvpn-client-configuration} fields are:
  20965. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  20966. The OpenVPN package.
  20967. @end deftypevr
  20968. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  20969. The OpenVPN pid file.
  20970. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  20971. @end deftypevr
  20972. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  20973. The protocol (UDP or TCP) used to open a channel between clients and
  20974. servers.
  20975. Defaults to @samp{udp}.
  20976. @end deftypevr
  20977. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  20978. The device type used to represent the VPN connection.
  20979. Defaults to @samp{tun}.
  20980. @end deftypevr
  20981. If you do not have some of these files (eg.@: you use a username and
  20982. password), you can disable any of the following three fields by setting
  20983. it to @code{'disabled}.
  20984. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
  20985. The certificate authority to check connections against.
  20986. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  20987. @end deftypevr
  20988. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string cert
  20989. The certificate of the machine the daemon is running on. It should be
  20990. signed by the authority given in @code{ca}.
  20991. Defaults to @samp{"/etc/openvpn/client.crt"}.
  20992. @end deftypevr
  20993. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string key
  20994. The key of the machine the daemon is running on. It must be the key whose
  20995. certificate is @code{cert}.
  20996. Defaults to @samp{"/etc/openvpn/client.key"}.
  20997. @end deftypevr
  20998. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  20999. Whether to use the lzo compression algorithm.
  21000. Defaults to @samp{#t}.
  21001. @end deftypevr
  21002. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  21003. Don't re-read key files across SIGUSR1 or --ping-restart.
  21004. Defaults to @samp{#t}.
  21005. @end deftypevr
  21006. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  21007. Don't close and reopen TUN/TAP device or run up/down scripts across
  21008. SIGUSR1 or --ping-restart restarts.
  21009. Defaults to @samp{#t}.
  21010. @end deftypevr
  21011. @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
  21012. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  21013. poll/epoll/select prior to the write operation.
  21014. Defaults to @samp{#f}.
  21015. @end deftypevr
  21016. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  21017. Verbosity level.
  21018. Defaults to @samp{3}.
  21019. @end deftypevr
  21020. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  21021. Add an additional layer of HMAC authentication on top of the TLS control
  21022. channel to protect against DoS attacks.
  21023. Defaults to @samp{#f}.
  21024. @end deftypevr
  21025. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
  21026. Authenticate with server using username/password. The option is a file
  21027. containing username/password on 2 lines. Do not use a file-like object as it
  21028. would be added to the store and readable by any user.
  21029. Defaults to @samp{'disabled}.
  21030. @end deftypevr
  21031. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  21032. Whether to check the server certificate has server usage extension.
  21033. Defaults to @samp{#t}.
  21034. @end deftypevr
  21035. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  21036. Bind to a specific local port number.
  21037. Defaults to @samp{#f}.
  21038. @end deftypevr
  21039. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  21040. Retry resolving server address.
  21041. Defaults to @samp{#t}.
  21042. @end deftypevr
  21043. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  21044. A list of remote servers to connect to.
  21045. Defaults to @samp{()}.
  21046. Available @code{openvpn-remote-configuration} fields are:
  21047. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  21048. Server name.
  21049. Defaults to @samp{"my-server"}.
  21050. @end deftypevr
  21051. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  21052. Port number the server listens to.
  21053. Defaults to @samp{1194}.
  21054. @end deftypevr
  21055. @end deftypevr
  21056. @c %end of automatic openvpn-client documentation
  21057. @c %automatically generated documentation
  21058. Available @code{openvpn-server-configuration} fields are:
  21059. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  21060. The OpenVPN package.
  21061. @end deftypevr
  21062. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  21063. The OpenVPN pid file.
  21064. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  21065. @end deftypevr
  21066. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  21067. The protocol (UDP or TCP) used to open a channel between clients and
  21068. servers.
  21069. Defaults to @samp{udp}.
  21070. @end deftypevr
  21071. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  21072. The device type used to represent the VPN connection.
  21073. Defaults to @samp{tun}.
  21074. @end deftypevr
  21075. If you do not have some of these files (eg.@: you use a username and
  21076. password), you can disable any of the following three fields by setting
  21077. it to @code{'disabled}.
  21078. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
  21079. The certificate authority to check connections against.
  21080. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  21081. @end deftypevr
  21082. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string cert
  21083. The certificate of the machine the daemon is running on. It should be
  21084. signed by the authority given in @code{ca}.
  21085. Defaults to @samp{"/etc/openvpn/client.crt"}.
  21086. @end deftypevr
  21087. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string key
  21088. The key of the machine the daemon is running on. It must be the key whose
  21089. certificate is @code{cert}.
  21090. Defaults to @samp{"/etc/openvpn/client.key"}.
  21091. @end deftypevr
  21092. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  21093. Whether to use the lzo compression algorithm.
  21094. Defaults to @samp{#t}.
  21095. @end deftypevr
  21096. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  21097. Don't re-read key files across SIGUSR1 or --ping-restart.
  21098. Defaults to @samp{#t}.
  21099. @end deftypevr
  21100. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  21101. Don't close and reopen TUN/TAP device or run up/down scripts across
  21102. SIGUSR1 or --ping-restart restarts.
  21103. Defaults to @samp{#t}.
  21104. @end deftypevr
  21105. @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
  21106. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  21107. poll/epoll/select prior to the write operation.
  21108. Defaults to @samp{#f}.
  21109. @end deftypevr
  21110. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  21111. Verbosity level.
  21112. Defaults to @samp{3}.
  21113. @end deftypevr
  21114. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  21115. Add an additional layer of HMAC authentication on top of the TLS control
  21116. channel to protect against DoS attacks.
  21117. Defaults to @samp{#f}.
  21118. @end deftypevr
  21119. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  21120. Specifies the port number on which the server listens.
  21121. Defaults to @samp{1194}.
  21122. @end deftypevr
  21123. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  21124. An ip and mask specifying the subnet inside the virtual network.
  21125. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  21126. @end deftypevr
  21127. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  21128. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  21129. Defaults to @samp{#f}.
  21130. @end deftypevr
  21131. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  21132. The Diffie-Hellman parameters file.
  21133. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  21134. @end deftypevr
  21135. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  21136. The file that records client IPs.
  21137. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  21138. @end deftypevr
  21139. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  21140. When true, the server will act as a gateway for its clients.
  21141. Defaults to @samp{#f}.
  21142. @end deftypevr
  21143. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  21144. When true, clients are allowed to talk to each other inside the VPN.
  21145. Defaults to @samp{#f}.
  21146. @end deftypevr
  21147. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  21148. Causes ping-like messages to be sent back and forth over the link so
  21149. that each side knows when the other side has gone down. @code{keepalive}
  21150. requires a pair. The first element is the period of the ping sending,
  21151. and the second element is the timeout before considering the other side
  21152. down.
  21153. @end deftypevr
  21154. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  21155. The maximum number of clients.
  21156. Defaults to @samp{100}.
  21157. @end deftypevr
  21158. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  21159. The status file. This file shows a small report on current connection.
  21160. It is truncated and rewritten every minute.
  21161. Defaults to @samp{"/var/run/openvpn/status"}.
  21162. @end deftypevr
  21163. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  21164. The list of configuration for some clients.
  21165. Defaults to @samp{()}.
  21166. Available @code{openvpn-ccd-configuration} fields are:
  21167. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  21168. Client name.
  21169. Defaults to @samp{"client"}.
  21170. @end deftypevr
  21171. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  21172. Client own network
  21173. Defaults to @samp{#f}.
  21174. @end deftypevr
  21175. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  21176. Client VPN IP.
  21177. Defaults to @samp{#f}.
  21178. @end deftypevr
  21179. @end deftypevr
  21180. @c %end of automatic openvpn-server documentation
  21181. @subsubheading Wireguard
  21182. @defvr {Scheme Variable} wireguard-service-type
  21183. A service type for a Wireguard tunnel interface. Its value must be a
  21184. @code{wireguard-configuration} record as in this example:
  21185. @lisp
  21186. (service wireguard-service-type
  21187. (wireguard-configuration
  21188. (peers
  21189. (list
  21190. (wireguard-peer
  21191. (name "my-peer")
  21192. (endpoint "my.wireguard.com:51820")
  21193. (public-key "hzpKg9X1yqu1axN6iJp0mWf6BZGo8m1wteKwtTmDGF4=")
  21194. (allowed-ips '("10.0.0.2/32")))))))
  21195. @end lisp
  21196. @end defvr
  21197. @deftp {Data Type} wireguard-configuration
  21198. Data type representing the configuration of the Wireguard service.
  21199. @table @asis
  21200. @item @code{wireguard}
  21201. The wireguard package to use for this service.
  21202. @item @code{interface} (default: @code{"wg0"})
  21203. The interface name for the VPN.
  21204. @item @code{addresses} (default: @code{'("10.0.0.1/32")})
  21205. The IP addresses to be assigned to the above interface.
  21206. @item @code{private-key} (default: @code{"/etc/wireguard/private.key"})
  21207. The private key file for the interface. It is automatically generated if
  21208. the file does not exist.
  21209. @item @code{peers} (default: @code{'()})
  21210. The authorized peers on this interface. This is a list of
  21211. @var{wireguard-peer} records.
  21212. @end table
  21213. @end deftp
  21214. @deftp {Data Type} wireguard-peer
  21215. Data type representing a Wireguard peer attached to a given interface.
  21216. @table @asis
  21217. @item @code{name}
  21218. The peer name.
  21219. @item @code{endpoint} (default: @code{#f})
  21220. The optional endpoint for the peer, such as
  21221. @code{"demo.wireguard.com:51820"}.
  21222. @item @code{public-key}
  21223. The peer public-key represented as a base64 string.
  21224. @item @code{allowed-ips}
  21225. A list of IP addresses from which incoming traffic for this peer is
  21226. allowed and to which incoming traffic for this peer is directed.
  21227. @end table
  21228. @end deftp
  21229. @node Network File System
  21230. @subsection Network File System
  21231. @cindex NFS
  21232. The @code{(gnu services nfs)} module provides the following services,
  21233. which are most commonly used in relation to mounting or exporting
  21234. directory trees as @dfn{network file systems} (NFS).
  21235. While it is possible to use the individual components that together make
  21236. up a Network File System service, we recommended to configure an NFS
  21237. server with the @code{nfs-service-type}.
  21238. @subsubheading NFS Service
  21239. @cindex NFS, server
  21240. The NFS service takes care of setting up all NFS component services,
  21241. kernel configuration file systems, and installs configuration files in
  21242. the locations that NFS expects.
  21243. @defvr {Scheme Variable} nfs-service-type
  21244. A service type for a complete NFS server.
  21245. @end defvr
  21246. @deftp {Data Type} nfs-configuration
  21247. This data type represents the configuration of the NFS service and all
  21248. of its subsystems.
  21249. It has the following parameters:
  21250. @table @asis
  21251. @item @code{nfs-utils} (default: @code{nfs-utils})
  21252. The nfs-utils package to use.
  21253. @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
  21254. If a list of string values is provided, the @command{rpc.nfsd} daemon
  21255. will be limited to supporting the given versions of the NFS protocol.
  21256. @item @code{exports} (default: @code{'()})
  21257. This is a list of directories the NFS server should export. Each entry
  21258. is a list consisting of two elements: a directory name and a string
  21259. containing all options. This is an example in which the directory
  21260. @file{/export} is served to all NFS clients as a read-only share:
  21261. @lisp
  21262. (nfs-configuration
  21263. (exports
  21264. '(("/export"
  21265. "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
  21266. @end lisp
  21267. @item @code{rpcmountd-port} (default: @code{#f})
  21268. The network port that the @command{rpc.mountd} daemon should use.
  21269. @item @code{rpcstatd-port} (default: @code{#f})
  21270. The network port that the @command{rpc.statd} daemon should use.
  21271. @item @code{rpcbind} (default: @code{rpcbind})
  21272. The rpcbind package to use.
  21273. @item @code{idmap-domain} (default: @code{"localdomain"})
  21274. The local NFSv4 domain name.
  21275. @item @code{nfsd-port} (default: @code{2049})
  21276. The network port that the @command{nfsd} daemon should use.
  21277. @item @code{nfsd-threads} (default: @code{8})
  21278. The number of threads used by the @command{nfsd} daemon.
  21279. @item @code{nfsd-tcp?} (default: @code{#t})
  21280. Whether the @command{nfsd} daemon should listen on a TCP socket.
  21281. @item @code{nfsd-udp?} (default: @code{#f})
  21282. Whether the @command{nfsd} daemon should listen on a UDP socket.
  21283. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  21284. The directory where the pipefs file system is mounted.
  21285. @item @code{debug} (default: @code{'()"})
  21286. A list of subsystems for which debugging output should be enabled. This
  21287. is a list of symbols. Any of these symbols are valid: @code{nfsd},
  21288. @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
  21289. @end table
  21290. @end deftp
  21291. If you don't need a complete NFS service or prefer to build it yourself
  21292. you can use the individual component services that are documented below.
  21293. @subsubheading RPC Bind Service
  21294. @cindex rpcbind
  21295. The RPC Bind service provides a facility to map program numbers into
  21296. universal addresses.
  21297. Many NFS related services use this facility. Hence it is automatically
  21298. started when a dependent service starts.
  21299. @defvr {Scheme Variable} rpcbind-service-type
  21300. A service type for the RPC portmapper daemon.
  21301. @end defvr
  21302. @deftp {Data Type} rpcbind-configuration
  21303. Data type representing the configuration of the RPC Bind Service.
  21304. This type has the following parameters:
  21305. @table @asis
  21306. @item @code{rpcbind} (default: @code{rpcbind})
  21307. The rpcbind package to use.
  21308. @item @code{warm-start?} (default: @code{#t})
  21309. If this parameter is @code{#t}, then the daemon will read a
  21310. state file on startup thus reloading state information saved by a previous
  21311. instance.
  21312. @end table
  21313. @end deftp
  21314. @subsubheading Pipefs Pseudo File System
  21315. @cindex pipefs
  21316. @cindex rpc_pipefs
  21317. The pipefs file system is used to transfer NFS related data
  21318. between the kernel and user space programs.
  21319. @defvr {Scheme Variable} pipefs-service-type
  21320. A service type for the pipefs pseudo file system.
  21321. @end defvr
  21322. @deftp {Data Type} pipefs-configuration
  21323. Data type representing the configuration of the pipefs pseudo file system service.
  21324. This type has the following parameters:
  21325. @table @asis
  21326. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  21327. The directory to which the file system is to be attached.
  21328. @end table
  21329. @end deftp
  21330. @subsubheading GSS Daemon Service
  21331. @cindex GSSD
  21332. @cindex GSS
  21333. @cindex global security system
  21334. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  21335. based protocols.
  21336. Before exchanging RPC requests an RPC client must establish a security
  21337. context. Typically this is done using the Kerberos command @command{kinit}
  21338. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  21339. @defvr {Scheme Variable} gss-service-type
  21340. A service type for the Global Security System (GSS) daemon.
  21341. @end defvr
  21342. @deftp {Data Type} gss-configuration
  21343. Data type representing the configuration of the GSS daemon service.
  21344. This type has the following parameters:
  21345. @table @asis
  21346. @item @code{nfs-utils} (default: @code{nfs-utils})
  21347. The package in which the @command{rpc.gssd} command is to be found.
  21348. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  21349. The directory where the pipefs file system is mounted.
  21350. @end table
  21351. @end deftp
  21352. @subsubheading IDMAP Daemon Service
  21353. @cindex idmapd
  21354. @cindex name mapper
  21355. The idmap daemon service provides mapping between user IDs and user names.
  21356. Typically it is required in order to access file systems mounted via NFSv4.
  21357. @defvr {Scheme Variable} idmap-service-type
  21358. A service type for the Identity Mapper (IDMAP) daemon.
  21359. @end defvr
  21360. @deftp {Data Type} idmap-configuration
  21361. Data type representing the configuration of the IDMAP daemon service.
  21362. This type has the following parameters:
  21363. @table @asis
  21364. @item @code{nfs-utils} (default: @code{nfs-utils})
  21365. The package in which the @command{rpc.idmapd} command is to be found.
  21366. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  21367. The directory where the pipefs file system is mounted.
  21368. @item @code{domain} (default: @code{#f})
  21369. The local NFSv4 domain name.
  21370. This must be a string or @code{#f}.
  21371. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  21372. @item @code{verbosity} (default: @code{0})
  21373. The verbosity level of the daemon.
  21374. @end table
  21375. @end deftp
  21376. @node Continuous Integration
  21377. @subsection Continuous Integration
  21378. @cindex continuous integration
  21379. @uref{https://guix.gnu.org/cuirass/, Cuirass} is a continuous
  21380. integration tool for Guix. It can be used both for development and for
  21381. providing substitutes to others (@pxref{Substitutes}).
  21382. The @code{(gnu services cuirass)} module provides the following service.
  21383. @defvr {Scheme Procedure} cuirass-service-type
  21384. The type of the Cuirass service. Its value must be a
  21385. @code{cuirass-configuration} object, as described below.
  21386. @end defvr
  21387. To add build jobs, you have to set the @code{specifications} field of
  21388. the configuration. For instance, the following example will build all
  21389. the packages provided by the @code{my-channel} channel.
  21390. @lisp
  21391. (define %cuirass-specs
  21392. #~(list (specification
  21393. (name "my-channel")
  21394. (build '(channels my-channel))
  21395. (channels
  21396. (cons (channel
  21397. (name 'my-channel)
  21398. (url "https://my-channel.git"))
  21399. %default-channels)))))
  21400. (service cuirass-service-type
  21401. (cuirass-configuration
  21402. (specifications %cuirass-specs)))
  21403. @end lisp
  21404. To build the @code{linux-libre} package defined by the default Guix
  21405. channel, one can use the following configuration.
  21406. @lisp
  21407. (define %cuirass-specs
  21408. #~(list (specification
  21409. (name "my-linux")
  21410. (build '(packages "linux-libre")))))
  21411. (service cuirass-service-type
  21412. (cuirass-configuration
  21413. (specifications %cuirass-specs)))
  21414. @end lisp
  21415. The other configuration possibilities, as well as the specification
  21416. record itself are described in the Cuirass manual
  21417. (@pxref{Specifications,,, cuirass, Cuirass}).
  21418. While information related to build jobs is located directly in the
  21419. specifications, global settings for the @command{cuirass} process are
  21420. accessible in other @code{cuirass-configuration} fields.
  21421. @deftp {Data Type} cuirass-configuration
  21422. Data type representing the configuration of Cuirass.
  21423. @table @asis
  21424. @item @code{cuirass} (default: @code{cuirass})
  21425. The Cuirass package to use.
  21426. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  21427. Location of the log file.
  21428. @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
  21429. Location of the log file used by the web interface.
  21430. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  21431. Location of the repository cache.
  21432. @item @code{user} (default: @code{"cuirass"})
  21433. Owner of the @code{cuirass} process.
  21434. @item @code{group} (default: @code{"cuirass"})
  21435. Owner's group of the @code{cuirass} process.
  21436. @item @code{interval} (default: @code{60})
  21437. Number of seconds between the poll of the repositories followed by the
  21438. Cuirass jobs.
  21439. @item @code{parameters} (default: @code{#f})
  21440. Read parameters from the given @var{parameters} file. The supported
  21441. parameters are described here (@pxref{Parameters,,, cuirass, Cuirass}).
  21442. @item @code{remote-server} (default: @code{#f})
  21443. A @code{cuirass-remote-server-configuration} record to use the build
  21444. remote mechanism or @code{#f} to use the default build mechanism.
  21445. @item @code{database} (default: @code{"dbname=cuirass host=/var/run/postgresql"})
  21446. Use @var{database} as the database containing the jobs and the past
  21447. build results. Since Cuirass uses PostgreSQL as a database engine,
  21448. @var{database} must be a string such as @code{"dbname=cuirass
  21449. host=localhost"}.
  21450. @item @code{port} (default: @code{8081})
  21451. Port number used by the HTTP server.
  21452. @item @code{host} (default: @code{"localhost"})
  21453. Listen on the network interface for @var{host}. The default is to
  21454. accept connections from localhost.
  21455. @item @code{specifications} (default: @code{#~'()})
  21456. A gexp (@pxref{G-Expressions}) that evaluates to a list of
  21457. specifications records. The specification record is described in the
  21458. Cuirass manual (@pxref{Specifications,,, cuirass, Cuirass}).
  21459. @item @code{use-substitutes?} (default: @code{#f})
  21460. This allows using substitutes to avoid building every dependencies of a job
  21461. from source.
  21462. @item @code{one-shot?} (default: @code{#f})
  21463. Only evaluate specifications and build derivations once.
  21464. @item @code{fallback?} (default: @code{#f})
  21465. When substituting a pre-built binary fails, fall back to building
  21466. packages locally.
  21467. @item @code{extra-options} (default: @code{'()})
  21468. Extra options to pass when running the Cuirass processes.
  21469. @end table
  21470. @end deftp
  21471. @cindex remote build
  21472. @subsubheading Cuirass remote building
  21473. Cuirass supports two mechanisms to build derivations.
  21474. @itemize
  21475. @item Using the local Guix daemon.
  21476. This is the default build mechanism. Once the build jobs are
  21477. evaluated, they are sent to the local Guix daemon. Cuirass then
  21478. listens to the Guix daemon output to detect the various build events.
  21479. @item Using the remote build mechanism.
  21480. The build jobs are not submitted to the local Guix daemon. Instead, a
  21481. remote server dispatches build requests to the connect remote workers,
  21482. according to the build priorities.
  21483. @end itemize
  21484. To enable this build mode a @code{cuirass-remote-server-configuration}
  21485. record must be passed as @code{remote-server} argument of the
  21486. @code{cuirass-configuration} record. The
  21487. @code{cuirass-remote-server-configuration} record is described below.
  21488. This build mode scales way better than the default build mode. This is
  21489. the build mode that is used on the GNU Guix build farm at
  21490. @url{https://ci.guix.gnu.org}. It should be preferred when using
  21491. Cuirass to build large amount of packages.
  21492. @deftp {Data Type} cuirass-remote-server-configuration
  21493. Data type representing the configuration of the Cuirass remote-server.
  21494. @table @asis
  21495. @item @code{backend-port} (default: @code{5555})
  21496. The TCP port for communicating with @code{remote-worker} processes
  21497. using ZMQ. It defaults to @code{5555}.
  21498. @item @code{log-port} (default: @code{5556})
  21499. The TCP port of the log server. It defaults to @code{5556}.
  21500. @item @code{publish-port} (default: @code{5557})
  21501. The TCP port of the publish server. It defaults to @code{5557}.
  21502. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-server.log"})
  21503. Location of the log file.
  21504. @item @code{cache} (default: @code{"/var/cache/cuirass/remote"})
  21505. Use @var{cache} directory to cache build log files.
  21506. @item @code{trigger-url} (default: @code{#f})
  21507. Once a substitute is successfully fetched, trigger substitute baking at
  21508. @var{trigger-url}.
  21509. @item @code{public-key}
  21510. @item @code{private-key}
  21511. Use the specific @var{file}s as the public/private key pair used to sign
  21512. the store items being published.
  21513. @end table
  21514. @end deftp
  21515. At least one remote worker must also be started on any machine of the
  21516. local network to actually perform the builds and report their status.
  21517. @deftp {Data Type} cuirass-remote-worker-configuration
  21518. Data type representing the configuration of the Cuirass remote-worker.
  21519. @table @asis
  21520. @item @code{cuirass} (default: @code{cuirass})
  21521. The Cuirass package to use.
  21522. @item @code{workers} (default: @code{1})
  21523. Start @var{workers} parallel workers.
  21524. @item @code{server} (default: @code{#f})
  21525. Do not use Avahi discovery and connect to the given @code{server} IP
  21526. address instead.
  21527. @item @code{systems} (default: @code{(list (%current-system))})
  21528. Only request builds for the given @var{systems}.
  21529. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-worker.log"})
  21530. Location of the log file.
  21531. @item @code{publish-port} (default: @code{5558})
  21532. The TCP port of the publish server. It defaults to @code{5558}.
  21533. @item @code{public-key}
  21534. @item @code{private-key}
  21535. Use the specific @var{file}s as the public/private key pair used to sign
  21536. the store items being published.
  21537. @end table
  21538. @end deftp
  21539. @node Power Management Services
  21540. @subsection Power Management Services
  21541. @cindex tlp
  21542. @cindex power management with TLP
  21543. @subsubheading TLP daemon
  21544. The @code{(gnu services pm)} module provides a Guix service definition
  21545. for the Linux power management tool TLP.
  21546. TLP enables various powersaving modes in userspace and kernel.
  21547. Contrary to @code{upower-service}, it is not a passive,
  21548. monitoring tool, as it will apply custom settings each time a new power
  21549. source is detected. More information can be found at
  21550. @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
  21551. @deffn {Scheme Variable} tlp-service-type
  21552. The service type for the TLP tool. The default settings are optimised
  21553. for battery life on most systems, but you can tweak them to your heart's
  21554. content by adding a valid @code{tlp-configuration}:
  21555. @lisp
  21556. (service tlp-service-type
  21557. (tlp-configuration
  21558. (cpu-scaling-governor-on-ac (list "performance"))
  21559. (sched-powersave-on-bat? #t)))
  21560. @end lisp
  21561. @end deffn
  21562. Each parameter definition is preceded by its type; for example,
  21563. @samp{boolean foo} indicates that the @code{foo} parameter
  21564. should be specified as a boolean. Types starting with
  21565. @code{maybe-} denote parameters that won't show up in TLP config file
  21566. when their value is @code{'disabled}.
  21567. @c The following documentation was initially generated by
  21568. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  21569. @c documentation is better, so we shouldn't hesitate to edit below as
  21570. @c needed. However if the change you want to make to this documentation
  21571. @c can be done in an automated way, it's probably easier to change
  21572. @c (generate-documentation) than to make it below and have to deal with
  21573. @c the churn as TLP updates.
  21574. Available @code{tlp-configuration} fields are:
  21575. @deftypevr {@code{tlp-configuration} parameter} package tlp
  21576. The TLP package.
  21577. @end deftypevr
  21578. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  21579. Set to true if you wish to enable TLP.
  21580. Defaults to @samp{#t}.
  21581. @end deftypevr
  21582. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  21583. Default mode when no power supply can be detected. Alternatives are AC
  21584. and BAT.
  21585. Defaults to @samp{"AC"}.
  21586. @end deftypevr
  21587. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  21588. Number of seconds Linux kernel has to wait after the disk goes idle,
  21589. before syncing on AC.
  21590. Defaults to @samp{0}.
  21591. @end deftypevr
  21592. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  21593. Same as @code{disk-idle-ac} but on BAT mode.
  21594. Defaults to @samp{2}.
  21595. @end deftypevr
  21596. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  21597. Dirty pages flushing periodicity, expressed in seconds.
  21598. Defaults to @samp{15}.
  21599. @end deftypevr
  21600. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  21601. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  21602. Defaults to @samp{60}.
  21603. @end deftypevr
  21604. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  21605. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  21606. alternatives are powersave and performance. With acpi-cpufreq driver,
  21607. alternatives are ondemand, powersave, performance and conservative.
  21608. Defaults to @samp{disabled}.
  21609. @end deftypevr
  21610. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  21611. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  21612. Defaults to @samp{disabled}.
  21613. @end deftypevr
  21614. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  21615. Set the min available frequency for the scaling governor on AC.
  21616. Defaults to @samp{disabled}.
  21617. @end deftypevr
  21618. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  21619. Set the max available frequency for the scaling governor on AC.
  21620. Defaults to @samp{disabled}.
  21621. @end deftypevr
  21622. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  21623. Set the min available frequency for the scaling governor on BAT.
  21624. Defaults to @samp{disabled}.
  21625. @end deftypevr
  21626. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  21627. Set the max available frequency for the scaling governor on BAT.
  21628. Defaults to @samp{disabled}.
  21629. @end deftypevr
  21630. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  21631. Limit the min P-state to control the power dissipation of the CPU, in AC
  21632. mode. Values are stated as a percentage of the available performance.
  21633. Defaults to @samp{disabled}.
  21634. @end deftypevr
  21635. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  21636. Limit the max P-state to control the power dissipation of the CPU, in AC
  21637. mode. Values are stated as a percentage of the available performance.
  21638. Defaults to @samp{disabled}.
  21639. @end deftypevr
  21640. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  21641. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  21642. Defaults to @samp{disabled}.
  21643. @end deftypevr
  21644. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  21645. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  21646. Defaults to @samp{disabled}.
  21647. @end deftypevr
  21648. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  21649. Enable CPU turbo boost feature on AC mode.
  21650. Defaults to @samp{disabled}.
  21651. @end deftypevr
  21652. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  21653. Same as @code{cpu-boost-on-ac?} on BAT mode.
  21654. Defaults to @samp{disabled}.
  21655. @end deftypevr
  21656. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  21657. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  21658. used under light load conditions.
  21659. Defaults to @samp{#f}.
  21660. @end deftypevr
  21661. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  21662. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  21663. Defaults to @samp{#t}.
  21664. @end deftypevr
  21665. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  21666. Enable Linux kernel NMI watchdog.
  21667. Defaults to @samp{#f}.
  21668. @end deftypevr
  21669. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  21670. For Linux kernels with PHC patch applied, change CPU voltages. An
  21671. example value would be @samp{"F:V F:V F:V F:V"}.
  21672. Defaults to @samp{disabled}.
  21673. @end deftypevr
  21674. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  21675. Set CPU performance versus energy saving policy on AC@. Alternatives are
  21676. performance, normal, powersave.
  21677. Defaults to @samp{"performance"}.
  21678. @end deftypevr
  21679. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  21680. Same as @code{energy-perf-policy-ac} but on BAT mode.
  21681. Defaults to @samp{"powersave"}.
  21682. @end deftypevr
  21683. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  21684. Hard disk devices.
  21685. @end deftypevr
  21686. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  21687. Hard disk advanced power management level.
  21688. @end deftypevr
  21689. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  21690. Same as @code{disk-apm-bat} but on BAT mode.
  21691. @end deftypevr
  21692. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  21693. Hard disk spin down timeout. One value has to be specified for each
  21694. declared hard disk.
  21695. Defaults to @samp{disabled}.
  21696. @end deftypevr
  21697. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  21698. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  21699. Defaults to @samp{disabled}.
  21700. @end deftypevr
  21701. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  21702. Select IO scheduler for disk devices. One value has to be specified for
  21703. each declared hard disk. Example alternatives are cfq, deadline and
  21704. noop.
  21705. Defaults to @samp{disabled}.
  21706. @end deftypevr
  21707. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  21708. SATA aggressive link power management (ALPM) level. Alternatives are
  21709. min_power, medium_power, max_performance.
  21710. Defaults to @samp{"max_performance"}.
  21711. @end deftypevr
  21712. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  21713. Same as @code{sata-linkpwr-ac} but on BAT mode.
  21714. Defaults to @samp{"min_power"}.
  21715. @end deftypevr
  21716. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  21717. Exclude specified SATA host devices for link power management.
  21718. Defaults to @samp{disabled}.
  21719. @end deftypevr
  21720. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  21721. Enable Runtime Power Management for AHCI controller and disks on AC
  21722. mode.
  21723. Defaults to @samp{disabled}.
  21724. @end deftypevr
  21725. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  21726. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  21727. Defaults to @samp{disabled}.
  21728. @end deftypevr
  21729. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  21730. Seconds of inactivity before disk is suspended.
  21731. Defaults to @samp{15}.
  21732. @end deftypevr
  21733. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  21734. PCI Express Active State Power Management level. Alternatives are
  21735. default, performance, powersave.
  21736. Defaults to @samp{"performance"}.
  21737. @end deftypevr
  21738. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  21739. Same as @code{pcie-aspm-ac} but on BAT mode.
  21740. Defaults to @samp{"powersave"}.
  21741. @end deftypevr
  21742. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  21743. Radeon graphics clock speed level. Alternatives are low, mid, high,
  21744. auto, default.
  21745. Defaults to @samp{"high"}.
  21746. @end deftypevr
  21747. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  21748. Same as @code{radeon-power-ac} but on BAT mode.
  21749. Defaults to @samp{"low"}.
  21750. @end deftypevr
  21751. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  21752. Radeon dynamic power management method (DPM). Alternatives are battery,
  21753. performance.
  21754. Defaults to @samp{"performance"}.
  21755. @end deftypevr
  21756. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  21757. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  21758. Defaults to @samp{"battery"}.
  21759. @end deftypevr
  21760. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  21761. Radeon DPM performance level. Alternatives are auto, low, high.
  21762. Defaults to @samp{"auto"}.
  21763. @end deftypevr
  21764. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  21765. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  21766. Defaults to @samp{"auto"}.
  21767. @end deftypevr
  21768. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  21769. Wifi power saving mode.
  21770. Defaults to @samp{#f}.
  21771. @end deftypevr
  21772. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  21773. Same as @code{wifi-power-ac?} but on BAT mode.
  21774. Defaults to @samp{#t}.
  21775. @end deftypevr
  21776. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  21777. Disable wake on LAN.
  21778. Defaults to @samp{#t}.
  21779. @end deftypevr
  21780. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  21781. Timeout duration in seconds before activating audio power saving on
  21782. Intel HDA and AC97 devices. A value of 0 disables power saving.
  21783. Defaults to @samp{0}.
  21784. @end deftypevr
  21785. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  21786. Same as @code{sound-powersave-ac} but on BAT mode.
  21787. Defaults to @samp{1}.
  21788. @end deftypevr
  21789. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  21790. Disable controller in powersaving mode on Intel HDA devices.
  21791. Defaults to @samp{#t}.
  21792. @end deftypevr
  21793. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  21794. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  21795. powered on again by releasing (and reinserting) the eject lever or by
  21796. pressing the disc eject button on newer models.
  21797. Defaults to @samp{#f}.
  21798. @end deftypevr
  21799. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  21800. Name of the optical drive device to power off.
  21801. Defaults to @samp{"sr0"}.
  21802. @end deftypevr
  21803. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  21804. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  21805. and auto.
  21806. Defaults to @samp{"on"}.
  21807. @end deftypevr
  21808. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  21809. Same as @code{runtime-pm-ac} but on BAT mode.
  21810. Defaults to @samp{"auto"}.
  21811. @end deftypevr
  21812. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  21813. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  21814. ones.
  21815. Defaults to @samp{#t}.
  21816. @end deftypevr
  21817. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  21818. Exclude specified PCI(e) device addresses from Runtime Power Management.
  21819. Defaults to @samp{disabled}.
  21820. @end deftypevr
  21821. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  21822. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  21823. Power Management.
  21824. @end deftypevr
  21825. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  21826. Enable USB autosuspend feature.
  21827. Defaults to @samp{#t}.
  21828. @end deftypevr
  21829. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  21830. Exclude specified devices from USB autosuspend.
  21831. Defaults to @samp{disabled}.
  21832. @end deftypevr
  21833. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  21834. Exclude WWAN devices from USB autosuspend.
  21835. Defaults to @samp{#t}.
  21836. @end deftypevr
  21837. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  21838. Include specified devices into USB autosuspend, even if they are already
  21839. excluded by the driver or via @code{usb-blacklist-wwan?}.
  21840. Defaults to @samp{disabled}.
  21841. @end deftypevr
  21842. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  21843. Enable USB autosuspend before shutdown.
  21844. Defaults to @samp{disabled}.
  21845. @end deftypevr
  21846. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  21847. Restore radio device state (bluetooth, wifi, wwan) from previous
  21848. shutdown on system startup.
  21849. Defaults to @samp{#f}.
  21850. @end deftypevr
  21851. @cindex thermald
  21852. @cindex CPU frequency scaling with thermald
  21853. @subsubheading Thermald daemon
  21854. The @code{(gnu services pm)} module provides an interface to
  21855. thermald, a CPU frequency scaling service which helps prevent overheating.
  21856. @defvr {Scheme Variable} thermald-service-type
  21857. This is the service type for
  21858. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  21859. Thermal Daemon, which is responsible for controlling the thermal state
  21860. of processors and preventing overheating.
  21861. @end defvr
  21862. @deftp {Data Type} thermald-configuration
  21863. Data type representing the configuration of @code{thermald-service-type}.
  21864. @table @asis
  21865. @item @code{ignore-cpuid-check?} (default: @code{#f})
  21866. Ignore cpuid check for supported CPU models.
  21867. @item @code{thermald} (default: @var{thermald})
  21868. Package object of thermald.
  21869. @end table
  21870. @end deftp
  21871. @node Audio Services
  21872. @subsection Audio Services
  21873. The @code{(gnu services audio)} module provides a service to start MPD
  21874. (the Music Player Daemon).
  21875. @cindex mpd
  21876. @subsubheading Music Player Daemon
  21877. The Music Player Daemon (MPD) is a service that can play music while
  21878. being controlled from the local machine or over the network by a variety
  21879. of clients.
  21880. The following example shows how one might run @code{mpd} as user
  21881. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  21882. @lisp
  21883. (service mpd-service-type
  21884. (mpd-configuration
  21885. (user "bob")
  21886. (port "6666")))
  21887. @end lisp
  21888. @defvr {Scheme Variable} mpd-service-type
  21889. The service type for @command{mpd}
  21890. @end defvr
  21891. @deftp {Data Type} mpd-configuration
  21892. Data type representing the configuration of @command{mpd}.
  21893. @table @asis
  21894. @item @code{user} (default: @code{"mpd"})
  21895. The user to run mpd as.
  21896. @item @code{music-dir} (default: @code{"~/Music"})
  21897. The directory to scan for music files.
  21898. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  21899. The directory to store playlists.
  21900. @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
  21901. The location of the music database.
  21902. @item @code{state-file} (default: @code{"~/.mpd/state"})
  21903. The location of the file that stores current MPD's state.
  21904. @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
  21905. The location of the sticker database.
  21906. @item @code{port} (default: @code{"6600"})
  21907. The port to run mpd on.
  21908. @item @code{address} (default: @code{"any"})
  21909. The address that mpd will bind to. To use a Unix domain socket,
  21910. an absolute path can be specified here.
  21911. @item @code{outputs} (default: @code{"(list (mpd-output))"})
  21912. The audio outputs that MPD can use. By default this is a single output using pulseaudio.
  21913. @end table
  21914. @end deftp
  21915. @deftp {Data Type} mpd-output
  21916. Data type representing an @command{mpd} audio output.
  21917. @table @asis
  21918. @item @code{name} (default: @code{"MPD"})
  21919. The name of the audio output.
  21920. @item @code{type} (default: @code{"pulse"})
  21921. The type of audio output.
  21922. @item @code{enabled?} (default: @code{#t})
  21923. Specifies whether this audio output is enabled when MPD is started. By
  21924. default, all audio outputs are enabled. This is just the default
  21925. setting when there is no state file; with a state file, the previous
  21926. state is restored.
  21927. @item @code{tags?} (default: @code{#t})
  21928. If set to @code{#f}, then MPD will not send tags to this output. This
  21929. is only useful for output plugins that can receive tags, for example the
  21930. @code{httpd} output plugin.
  21931. @item @code{always-on?} (default: @code{#f})
  21932. If set to @code{#t}, then MPD attempts to keep this audio output always
  21933. open. This may be useful for streaming servers, when you don’t want to
  21934. disconnect all listeners even when playback is accidentally stopped.
  21935. @item @code{mixer-type}
  21936. This field accepts a symbol that specifies which mixer should be used
  21937. for this audio output: the @code{hardware} mixer, the @code{software}
  21938. mixer, the @code{null} mixer (allows setting the volume, but with no
  21939. effect; this can be used as a trick to implement an external mixer
  21940. External Mixer) or no mixer (@code{none}).
  21941. @item @code{extra-options} (default: @code{'()})
  21942. An association list of option symbols to string values to be appended to
  21943. the audio output configuration.
  21944. @end table
  21945. @end deftp
  21946. The following example shows a configuration of @code{mpd} that provides
  21947. an HTTP audio streaming output.
  21948. @lisp
  21949. (service mpd-service-type
  21950. (mpd-configuration
  21951. (outputs
  21952. (list (mpd-output
  21953. (name "streaming")
  21954. (type "httpd")
  21955. (mixer-type 'null)
  21956. (extra-options
  21957. `((encoder . "vorbis")
  21958. (port . "8080"))))))))
  21959. @end lisp
  21960. @node Virtualization Services
  21961. @subsection Virtualization Services
  21962. The @code{(gnu services virtualization)} module provides services for
  21963. the libvirt and virtlog daemons, as well as other virtualization-related
  21964. services.
  21965. @subsubheading Libvirt daemon
  21966. @code{libvirtd} is the server side daemon component of the libvirt
  21967. virtualization management system. This daemon runs on host servers
  21968. and performs required management tasks for virtualized guests.
  21969. @deffn {Scheme Variable} libvirt-service-type
  21970. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  21971. Its value must be a @code{libvirt-configuration}.
  21972. @lisp
  21973. (service libvirt-service-type
  21974. (libvirt-configuration
  21975. (unix-sock-group "libvirt")
  21976. (tls-port "16555")))
  21977. @end lisp
  21978. @end deffn
  21979. @c Auto-generated with (generate-libvirt-documentation)
  21980. Available @code{libvirt-configuration} fields are:
  21981. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  21982. Libvirt package.
  21983. @end deftypevr
  21984. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  21985. Flag listening for secure TLS connections on the public TCP/IP port.
  21986. You must set @code{listen} for this to have any effect.
  21987. It is necessary to setup a CA and issue server certificates before using
  21988. this capability.
  21989. Defaults to @samp{#t}.
  21990. @end deftypevr
  21991. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  21992. Listen for unencrypted TCP connections on the public TCP/IP port. You must
  21993. set @code{listen} for this to have any effect.
  21994. Using the TCP socket requires SASL authentication by default. Only SASL
  21995. mechanisms which support data encryption are allowed. This is
  21996. DIGEST_MD5 and GSSAPI (Kerberos5).
  21997. Defaults to @samp{#f}.
  21998. @end deftypevr
  21999. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  22000. Port for accepting secure TLS connections. This can be a port number,
  22001. or service name.
  22002. Defaults to @samp{"16514"}.
  22003. @end deftypevr
  22004. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  22005. Port for accepting insecure TCP connections. This can be a port number,
  22006. or service name.
  22007. Defaults to @samp{"16509"}.
  22008. @end deftypevr
  22009. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  22010. IP address or hostname used for client connections.
  22011. Defaults to @samp{"0.0.0.0"}.
  22012. @end deftypevr
  22013. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  22014. Flag toggling mDNS advertisement of the libvirt service.
  22015. Alternatively can disable for all services on a host by stopping the
  22016. Avahi daemon.
  22017. Defaults to @samp{#f}.
  22018. @end deftypevr
  22019. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  22020. Default mDNS advertisement name. This must be unique on the immediate
  22021. broadcast network.
  22022. Defaults to @samp{"Virtualization Host <hostname>"}.
  22023. @end deftypevr
  22024. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  22025. UNIX domain socket group ownership. This can be used to allow a
  22026. 'trusted' set of users access to management capabilities without
  22027. becoming root.
  22028. Defaults to @samp{"root"}.
  22029. @end deftypevr
  22030. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  22031. UNIX socket permissions for the R/O socket. This is used for monitoring
  22032. VM status only.
  22033. Defaults to @samp{"0777"}.
  22034. @end deftypevr
  22035. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  22036. UNIX socket permissions for the R/W socket. Default allows only root.
  22037. If PolicyKit is enabled on the socket, the default will change to allow
  22038. everyone (eg, 0777)
  22039. Defaults to @samp{"0770"}.
  22040. @end deftypevr
  22041. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  22042. UNIX socket permissions for the admin socket. Default allows only owner
  22043. (root), do not change it unless you are sure to whom you are exposing
  22044. the access to.
  22045. Defaults to @samp{"0777"}.
  22046. @end deftypevr
  22047. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  22048. The directory in which sockets will be found/created.
  22049. Defaults to @samp{"/var/run/libvirt"}.
  22050. @end deftypevr
  22051. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  22052. Authentication scheme for UNIX read-only sockets. By default socket
  22053. permissions allow anyone to connect
  22054. Defaults to @samp{"polkit"}.
  22055. @end deftypevr
  22056. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  22057. Authentication scheme for UNIX read-write sockets. By default socket
  22058. permissions only allow root. If PolicyKit support was compiled into
  22059. libvirt, the default will be to use 'polkit' auth.
  22060. Defaults to @samp{"polkit"}.
  22061. @end deftypevr
  22062. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  22063. Authentication scheme for TCP sockets. If you don't enable SASL, then
  22064. all TCP traffic is cleartext. Don't do this outside of a dev/test
  22065. scenario.
  22066. Defaults to @samp{"sasl"}.
  22067. @end deftypevr
  22068. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  22069. Authentication scheme for TLS sockets. TLS sockets already have
  22070. encryption provided by the TLS layer, and limited authentication is done
  22071. by certificates.
  22072. It is possible to make use of any SASL authentication mechanism as well,
  22073. by using 'sasl' for this option
  22074. Defaults to @samp{"none"}.
  22075. @end deftypevr
  22076. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  22077. API access control scheme.
  22078. By default an authenticated user is allowed access to all APIs. Access
  22079. drivers can place restrictions on this.
  22080. Defaults to @samp{()}.
  22081. @end deftypevr
  22082. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  22083. Server key file path. If set to an empty string, then no private key is
  22084. loaded.
  22085. Defaults to @samp{""}.
  22086. @end deftypevr
  22087. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  22088. Server key file path. If set to an empty string, then no certificate is
  22089. loaded.
  22090. Defaults to @samp{""}.
  22091. @end deftypevr
  22092. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  22093. Server key file path. If set to an empty string, then no CA certificate
  22094. is loaded.
  22095. Defaults to @samp{""}.
  22096. @end deftypevr
  22097. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  22098. Certificate revocation list path. If set to an empty string, then no
  22099. CRL is loaded.
  22100. Defaults to @samp{""}.
  22101. @end deftypevr
  22102. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  22103. Disable verification of our own server certificates.
  22104. When libvirtd starts it performs some sanity checks against its own
  22105. certificates.
  22106. Defaults to @samp{#f}.
  22107. @end deftypevr
  22108. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  22109. Disable verification of client certificates.
  22110. Client certificate verification is the primary authentication mechanism.
  22111. Any client which does not present a certificate signed by the CA will be
  22112. rejected.
  22113. Defaults to @samp{#f}.
  22114. @end deftypevr
  22115. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  22116. Whitelist of allowed x509 Distinguished Name.
  22117. Defaults to @samp{()}.
  22118. @end deftypevr
  22119. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  22120. Whitelist of allowed SASL usernames. The format for username depends on
  22121. the SASL authentication mechanism.
  22122. Defaults to @samp{()}.
  22123. @end deftypevr
  22124. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  22125. Override the compile time default TLS priority string. The default is
  22126. usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
  22127. is desired for libvirt to deviate from the global default settings.
  22128. Defaults to @samp{"NORMAL"}.
  22129. @end deftypevr
  22130. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  22131. Maximum number of concurrent client connections to allow over all
  22132. sockets combined.
  22133. Defaults to @samp{5000}.
  22134. @end deftypevr
  22135. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  22136. Maximum length of queue of connections waiting to be accepted by the
  22137. daemon. Note, that some protocols supporting retransmission may obey
  22138. this so that a later reattempt at connection succeeds.
  22139. Defaults to @samp{1000}.
  22140. @end deftypevr
  22141. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  22142. Maximum length of queue of accepted but not yet authenticated clients.
  22143. Set this to zero to turn this feature off
  22144. Defaults to @samp{20}.
  22145. @end deftypevr
  22146. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  22147. Number of workers to start up initially.
  22148. Defaults to @samp{5}.
  22149. @end deftypevr
  22150. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  22151. Maximum number of worker threads.
  22152. If the number of active clients exceeds @code{min-workers}, then more
  22153. threads are spawned, up to max_workers limit. Typically you'd want
  22154. max_workers to equal maximum number of clients allowed.
  22155. Defaults to @samp{20}.
  22156. @end deftypevr
  22157. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  22158. Number of priority workers. If all workers from above pool are stuck,
  22159. some calls marked as high priority (notably domainDestroy) can be
  22160. executed in this pool.
  22161. Defaults to @samp{5}.
  22162. @end deftypevr
  22163. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  22164. Total global limit on concurrent RPC calls.
  22165. Defaults to @samp{20}.
  22166. @end deftypevr
  22167. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  22168. Limit on concurrent requests from a single client connection. To avoid
  22169. one client monopolizing the server this should be a small fraction of
  22170. the global max_requests and max_workers parameter.
  22171. Defaults to @samp{5}.
  22172. @end deftypevr
  22173. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  22174. Same as @code{min-workers} but for the admin interface.
  22175. Defaults to @samp{1}.
  22176. @end deftypevr
  22177. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  22178. Same as @code{max-workers} but for the admin interface.
  22179. Defaults to @samp{5}.
  22180. @end deftypevr
  22181. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  22182. Same as @code{max-clients} but for the admin interface.
  22183. Defaults to @samp{5}.
  22184. @end deftypevr
  22185. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  22186. Same as @code{max-queued-clients} but for the admin interface.
  22187. Defaults to @samp{5}.
  22188. @end deftypevr
  22189. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  22190. Same as @code{max-client-requests} but for the admin interface.
  22191. Defaults to @samp{5}.
  22192. @end deftypevr
  22193. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  22194. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  22195. Defaults to @samp{3}.
  22196. @end deftypevr
  22197. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  22198. Logging filters.
  22199. A filter allows to select a different logging level for a given category
  22200. of logs. The format for a filter is one of:
  22201. @itemize @bullet
  22202. @item
  22203. x:name
  22204. @item
  22205. x:+name
  22206. @end itemize
  22207. where @code{name} is a string which is matched against the category
  22208. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  22209. file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
  22210. name in the filter can be a substring of the full category name, in
  22211. order to match multiple similar categories), the optional @samp{"+"}
  22212. prefix tells libvirt to log stack trace for each message matching name,
  22213. and @code{x} is the minimal level where matching messages should be
  22214. logged:
  22215. @itemize @bullet
  22216. @item
  22217. 1: DEBUG
  22218. @item
  22219. 2: INFO
  22220. @item
  22221. 3: WARNING
  22222. @item
  22223. 4: ERROR
  22224. @end itemize
  22225. Multiple filters can be defined in a single filters statement, they just
  22226. need to be separated by spaces.
  22227. Defaults to @samp{"3:remote 4:event"}.
  22228. @end deftypevr
  22229. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  22230. Logging outputs.
  22231. An output is one of the places to save logging information. The format
  22232. for an output can be:
  22233. @table @code
  22234. @item x:stderr
  22235. output goes to stderr
  22236. @item x:syslog:name
  22237. use syslog for the output and use the given name as the ident
  22238. @item x:file:file_path
  22239. output to a file, with the given filepath
  22240. @item x:journald
  22241. output to journald logging system
  22242. @end table
  22243. In all case the x prefix is the minimal level, acting as a filter
  22244. @itemize @bullet
  22245. @item
  22246. 1: DEBUG
  22247. @item
  22248. 2: INFO
  22249. @item
  22250. 3: WARNING
  22251. @item
  22252. 4: ERROR
  22253. @end itemize
  22254. Multiple outputs can be defined, they just need to be separated by
  22255. spaces.
  22256. Defaults to @samp{"3:stderr"}.
  22257. @end deftypevr
  22258. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  22259. Allows usage of the auditing subsystem to be altered
  22260. @itemize @bullet
  22261. @item
  22262. 0: disable all auditing
  22263. @item
  22264. 1: enable auditing, only if enabled on host
  22265. @item
  22266. 2: enable auditing, and exit if disabled on host.
  22267. @end itemize
  22268. Defaults to @samp{1}.
  22269. @end deftypevr
  22270. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  22271. Send audit messages via libvirt logging infrastructure.
  22272. Defaults to @samp{#f}.
  22273. @end deftypevr
  22274. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  22275. Host UUID@. UUID must not have all digits be the same.
  22276. Defaults to @samp{""}.
  22277. @end deftypevr
  22278. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  22279. Source to read host UUID.
  22280. @itemize @bullet
  22281. @item
  22282. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  22283. @item
  22284. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  22285. @end itemize
  22286. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  22287. be generated.
  22288. Defaults to @samp{"smbios"}.
  22289. @end deftypevr
  22290. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  22291. A keepalive message is sent to a client after @code{keepalive_interval}
  22292. seconds of inactivity to check if the client is still responding. If
  22293. set to -1, libvirtd will never send keepalive requests; however clients
  22294. can still send them and the daemon will send responses.
  22295. Defaults to @samp{5}.
  22296. @end deftypevr
  22297. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  22298. Maximum number of keepalive messages that are allowed to be sent to the
  22299. client without getting any response before the connection is considered
  22300. broken.
  22301. In other words, the connection is automatically closed approximately
  22302. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  22303. the last message received from the client. When @code{keepalive-count}
  22304. is set to 0, connections will be automatically closed after
  22305. @code{keepalive-interval} seconds of inactivity without sending any
  22306. keepalive messages.
  22307. Defaults to @samp{5}.
  22308. @end deftypevr
  22309. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  22310. Same as above but for admin interface.
  22311. Defaults to @samp{5}.
  22312. @end deftypevr
  22313. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  22314. Same as above but for admin interface.
  22315. Defaults to @samp{5}.
  22316. @end deftypevr
  22317. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  22318. Timeout for Open vSwitch calls.
  22319. The @code{ovs-vsctl} utility is used for the configuration and its
  22320. timeout option is set by default to 5 seconds to avoid potential
  22321. infinite waits blocking libvirt.
  22322. Defaults to @samp{5}.
  22323. @end deftypevr
  22324. @c %end of autogenerated docs
  22325. @subsubheading Virtlog daemon
  22326. The virtlogd service is a server side daemon component of libvirt that is
  22327. used to manage logs from virtual machine consoles.
  22328. This daemon is not used directly by libvirt client applications, rather it
  22329. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  22330. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  22331. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  22332. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  22333. @deffn {Scheme Variable} virtlog-service-type
  22334. This is the type of the virtlog daemon.
  22335. Its value must be a @code{virtlog-configuration}.
  22336. @lisp
  22337. (service virtlog-service-type
  22338. (virtlog-configuration
  22339. (max-clients 1000)))
  22340. @end lisp
  22341. @end deffn
  22342. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  22343. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  22344. Defaults to @samp{3}.
  22345. @end deftypevr
  22346. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  22347. Logging filters.
  22348. A filter allows to select a different logging level for a given category
  22349. of logs The format for a filter is one of:
  22350. @itemize @bullet
  22351. @item
  22352. x:name
  22353. @item
  22354. x:+name
  22355. @end itemize
  22356. where @code{name} is a string which is matched against the category
  22357. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  22358. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  22359. be a substring of the full category name, in order to match multiple
  22360. similar categories), the optional "+" prefix tells libvirt to log stack
  22361. trace for each message matching name, and @code{x} is the minimal level
  22362. where matching messages should be logged:
  22363. @itemize @bullet
  22364. @item
  22365. 1: DEBUG
  22366. @item
  22367. 2: INFO
  22368. @item
  22369. 3: WARNING
  22370. @item
  22371. 4: ERROR
  22372. @end itemize
  22373. Multiple filters can be defined in a single filters statement, they just
  22374. need to be separated by spaces.
  22375. Defaults to @samp{"3:remote 4:event"}.
  22376. @end deftypevr
  22377. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  22378. Logging outputs.
  22379. An output is one of the places to save logging information The format
  22380. for an output can be:
  22381. @table @code
  22382. @item x:stderr
  22383. output goes to stderr
  22384. @item x:syslog:name
  22385. use syslog for the output and use the given name as the ident
  22386. @item x:file:file_path
  22387. output to a file, with the given filepath
  22388. @item x:journald
  22389. output to journald logging system
  22390. @end table
  22391. In all case the x prefix is the minimal level, acting as a filter
  22392. @itemize @bullet
  22393. @item
  22394. 1: DEBUG
  22395. @item
  22396. 2: INFO
  22397. @item
  22398. 3: WARNING
  22399. @item
  22400. 4: ERROR
  22401. @end itemize
  22402. Multiple outputs can be defined, they just need to be separated by
  22403. spaces.
  22404. Defaults to @samp{"3:stderr"}.
  22405. @end deftypevr
  22406. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  22407. Maximum number of concurrent client connections to allow over all
  22408. sockets combined.
  22409. Defaults to @samp{1024}.
  22410. @end deftypevr
  22411. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  22412. Maximum file size before rolling over.
  22413. Defaults to @samp{2MB}
  22414. @end deftypevr
  22415. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  22416. Maximum number of backup files to keep.
  22417. Defaults to @samp{3}
  22418. @end deftypevr
  22419. @anchor{transparent-emulation-qemu}
  22420. @subsubheading Transparent Emulation with QEMU
  22421. @cindex emulation
  22422. @cindex @code{binfmt_misc}
  22423. @code{qemu-binfmt-service-type} provides support for transparent
  22424. emulation of program binaries built for different architectures---e.g.,
  22425. it allows you to transparently execute an ARMv7 program on an x86_64
  22426. machine. It achieves this by combining the @uref{https://www.qemu.org,
  22427. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  22428. This feature only allows you to emulate GNU/Linux on a different
  22429. architecture, but see below for GNU/Hurd support.
  22430. @defvr {Scheme Variable} qemu-binfmt-service-type
  22431. This is the type of the QEMU/binfmt service for transparent emulation.
  22432. Its value must be a @code{qemu-binfmt-configuration} object, which
  22433. specifies the QEMU package to use as well as the architecture we want to
  22434. emulated:
  22435. @lisp
  22436. (service qemu-binfmt-service-type
  22437. (qemu-binfmt-configuration
  22438. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  22439. @end lisp
  22440. In this example, we enable transparent emulation for the ARM and aarch64
  22441. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  22442. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  22443. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  22444. @end defvr
  22445. @deftp {Data Type} qemu-binfmt-configuration
  22446. This is the configuration for the @code{qemu-binfmt} service.
  22447. @table @asis
  22448. @item @code{platforms} (default: @code{'()})
  22449. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  22450. object} as returned by @code{lookup-qemu-platforms} (see below).
  22451. For example, let's suppose you're on an x86_64 machine and you have this
  22452. service:
  22453. @lisp
  22454. (service qemu-binfmt-service-type
  22455. (qemu-binfmt-configuration
  22456. (platforms (lookup-qemu-platforms "arm"))))
  22457. @end lisp
  22458. You can run:
  22459. @example
  22460. guix build -s armhf-linux inkscape
  22461. @end example
  22462. @noindent
  22463. and it will build Inkscape for ARMv7 @emph{as if it were a native
  22464. build}, transparently using QEMU to emulate the ARMv7 CPU@. Pretty handy
  22465. if you'd like to test a package build for an architecture you don't have
  22466. access to!
  22467. @item @code{qemu} (default: @code{qemu})
  22468. The QEMU package to use.
  22469. @end table
  22470. @end deftp
  22471. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  22472. Return the list of QEMU platform objects corresponding to
  22473. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  22474. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  22475. @code{"mips64el"}, and so on.
  22476. @end deffn
  22477. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  22478. Return true if @var{obj} is a platform object.
  22479. @end deffn
  22480. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  22481. Return the name of @var{platform}---a string such as @code{"arm"}.
  22482. @end deffn
  22483. @subsubheading The Hurd in a Virtual Machine
  22484. @cindex @code{hurd}
  22485. @cindex the Hurd
  22486. @cindex childhurd
  22487. Service @code{hurd-vm} provides support for running GNU/Hurd in a
  22488. virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
  22489. to be used on GNU/Linux and the given GNU/Hurd operating system
  22490. configuration is cross-compiled. The virtual machine is a Shepherd
  22491. service that can be referred to by the names @code{hurd-vm} and
  22492. @code{childhurd} and be controlled with commands such as:
  22493. @example
  22494. herd start hurd-vm
  22495. herd stop childhurd
  22496. @end example
  22497. When the service is running, you can view its console by connecting to
  22498. it with a VNC client, for example with:
  22499. @example
  22500. guix environment --ad-hoc tigervnc-client -- \
  22501. vncviewer localhost:5900
  22502. @end example
  22503. The default configuration (see @code{hurd-vm-configuration} below)
  22504. spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
  22505. (the virtual machine emulator) redirects to port 10222 on the host.
  22506. Thus, you can connect over SSH to the childhurd with:
  22507. @example
  22508. ssh root@@localhost -p 10022
  22509. @end example
  22510. The childhurd is volatile and stateless: it starts with a fresh root
  22511. file system every time you restart it. By default though, all the files
  22512. under @file{/etc/childhurd} on the host are copied as is to the root
  22513. file system of the childhurd when it boots. This allows you to
  22514. initialize ``secrets'' inside the VM: SSH host keys, authorized
  22515. substitute keys, and so on---see the explanation of @code{secret-root}
  22516. below.
  22517. @defvr {Scheme Variable} hurd-vm-service-type
  22518. This is the type of the Hurd in a Virtual Machine service. Its value
  22519. must be a @code{hurd-vm-configuration} object, which specifies the
  22520. operating system (@pxref{operating-system Reference}) and the disk size
  22521. for the Hurd Virtual Machine, the QEMU package to use as well as the
  22522. options for running it.
  22523. For example:
  22524. @lisp
  22525. (service hurd-vm-service-type
  22526. (hurd-vm-configuration
  22527. (disk-size (* 5000 (expt 2 20))) ;5G
  22528. (memory-size 1024))) ;1024MiB
  22529. @end lisp
  22530. would create a disk image big enough to build GNU@tie{}Hello, with some
  22531. extra memory.
  22532. @end defvr
  22533. @deftp {Data Type} hurd-vm-configuration
  22534. The data type representing the configuration for
  22535. @code{hurd-vm-service-type}.
  22536. @table @asis
  22537. @item @code{os} (default: @var{%hurd-vm-operating-system})
  22538. The operating system to instantiate. This default is bare-bones with a
  22539. permissive OpenSSH secure shell daemon listening on port 2222
  22540. (@pxref{Networking Services, @code{openssh-service-type}}).
  22541. @item @code{qemu} (default: @code{qemu-minimal})
  22542. The QEMU package to use.
  22543. @item @code{image} (default: @var{hurd-vm-disk-image})
  22544. The procedure used to build the disk-image built from this
  22545. configuration.
  22546. @item @code{disk-size} (default: @code{'guess})
  22547. The size of the disk image.
  22548. @item @code{memory-size} (default: @code{512})
  22549. The memory size of the Virtual Machine in mebibytes.
  22550. @item @code{options} (default: @code{'("--snapshot")})
  22551. The extra options for running QEMU.
  22552. @item @code{id} (default: @code{#f})
  22553. If set, a non-zero positive integer used to parameterize Childhurd
  22554. instances. It is appended to the service's name,
  22555. e.g. @code{childhurd1}.
  22556. @item @code{net-options} (default: @var{hurd-vm-net-options})
  22557. The procedure used to produce the list of QEMU networking options.
  22558. By default, it produces
  22559. @lisp
  22560. '("--device" "rtl8139,netdev=net0"
  22561. "--netdev" "user,id=net0\
  22562. ,hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004\
  22563. ,hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222\
  22564. ,hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900")
  22565. @end lisp
  22566. with forwarded ports:
  22567. @example
  22568. @var{secrets-port}: @code{(+ 11004 (* 1000 @var{ID}))}
  22569. @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
  22570. @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
  22571. @end example
  22572. @item @code{secret-root} (default: @file{/etc/childhurd})
  22573. The root directory with out-of-band secrets to be installed into the
  22574. childhurd once it runs. Childhurds are volatile which means that on
  22575. every startup, secrets such as the SSH host keys and Guix signing key
  22576. are recreated.
  22577. If the @file{/etc/childhurd} directory does not exist, the
  22578. @code{secret-service} running in the Childhurd will be sent an empty
  22579. list of secrets.
  22580. By default, the service automatically populates @file{/etc/childhurd}
  22581. with the following non-volatile secrets, unless they already exist:
  22582. @example
  22583. /etc/childhurd/etc/guix/acl
  22584. /etc/childhurd/etc/guix/signing-key.pub
  22585. /etc/childhurd/etc/guix/signing-key.sec
  22586. /etc/childhurd/etc/ssh/ssh_host_ed25519_key
  22587. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
  22588. /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
  22589. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
  22590. @end example
  22591. These files are automatically sent to the guest Hurd VM when it boots,
  22592. including permissions.
  22593. @cindex childhurd, offloading
  22594. @cindex Hurd, offloading
  22595. Having these files in place means that only a couple of things are
  22596. missing to allow the host to offload @code{i586-gnu} builds to the
  22597. childhurd:
  22598. @enumerate
  22599. @item
  22600. Authorizing the childhurd's key on the host so that the host accepts
  22601. build results coming from the childhurd, which can be done like so:
  22602. @example
  22603. guix archive --authorize < \
  22604. /etc/childhurd/etc/guix/signing-key.pub
  22605. @end example
  22606. @item
  22607. Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
  22608. Offload Setup}).
  22609. @end enumerate
  22610. We're working towards making that happen automatically---get in touch
  22611. with us at @email{guix-devel@@gnu.org} to discuss it!
  22612. @end table
  22613. @end deftp
  22614. Note that by default the VM image is volatile, i.e., once stopped the
  22615. contents are lost. If you want a stateful image instead, override the
  22616. configuration's @code{image} and @code{options} without
  22617. the @code{--snapshot} flag using something along these lines:
  22618. @lisp
  22619. (service hurd-vm-service-type
  22620. (hurd-vm-configuration
  22621. (image (const "/out/of/store/writable/hurd.img"))
  22622. (options '())))
  22623. @end lisp
  22624. @subsubheading Ganeti
  22625. @cindex ganeti
  22626. @quotation Note
  22627. This service is considered experimental. Configuration options may be changed
  22628. in a backwards-incompatible manner, and not all features have been thorougly
  22629. tested. Users of this service are encouraged to share their experience at
  22630. @email{guix-devel@@gnu.org}.
  22631. @end quotation
  22632. Ganeti is a virtual machine management system. It is designed to keep virtual
  22633. machines running on a cluster of servers even in the event of hardware failures,
  22634. and to make maintenance and recovery tasks easy. It consists of multiple
  22635. services which are described later in this section. In addition to the Ganeti
  22636. service, you will need the OpenSSH service (@pxref{Networking Services,
  22637. @code{openssh-service-type}}), and update the @file{/etc/hosts} file
  22638. (@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
  22639. and address (or use a DNS server).
  22640. All nodes participating in a Ganeti cluster should have the same Ganeti and
  22641. @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
  22642. cluster node that supports multiple storage backends, and installs the
  22643. @code{debootstrap} and @code{guix} @dfn{OS providers}:
  22644. @lisp
  22645. (use-package-modules virtualization)
  22646. (use-service-modules base ganeti networking ssh)
  22647. (operating-system
  22648. ;; @dots{}
  22649. (host-name "node1")
  22650. (hosts-file (plain-file "hosts" (format #f "
  22651. 127.0.0.1 localhost
  22652. ::1 localhost
  22653. 192.168.1.200 ganeti.example.com
  22654. 192.168.1.201 node1.example.com node1
  22655. 192.168.1.202 node2.example.com node2
  22656. ")))
  22657. ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
  22658. ;; in order to use the "plain", "drbd" and "rbd" storage backends.
  22659. (packages (append (map specification->package
  22660. '("qemu" "lvm2" "drbd-utils" "ceph"
  22661. ;; Add the debootstrap and guix OS providers.
  22662. "ganeti-instance-guix" "ganeti-instance-debootstrap"))
  22663. %base-packages))
  22664. (services
  22665. (append (list (static-networking-service "eth0" "192.168.1.201"
  22666. #:netmask "255.255.255.0"
  22667. #:gateway "192.168.1.254"
  22668. #:name-servers '("192.168.1.252"
  22669. "192.168.1.253"))
  22670. ;; Ganeti uses SSH to communicate between nodes.
  22671. (service openssh-service-type
  22672. (openssh-configuration
  22673. (permit-root-login 'without-password)))
  22674. (service ganeti-service-type
  22675. (ganeti-configuration
  22676. ;; This list specifies allowed file system paths
  22677. ;; for storing virtual machine images.
  22678. (file-storage-paths '("/srv/ganeti/file-storage"))
  22679. ;; This variable configures a single "variant" for
  22680. ;; both Debootstrap and Guix that works with KVM.
  22681. (os %default-ganeti-os))))
  22682. %base-services)))
  22683. @end lisp
  22684. Users are advised to read the
  22685. @url{http://docs.ganeti.org/ganeti/master/html/admin.html,Ganeti
  22686. administrators guide} to learn about the various cluster options and
  22687. day-to-day operations. There is also a
  22688. @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
  22689. describing how to configure and initialize a small cluster.
  22690. @defvr {Scheme Variable} ganeti-service-type
  22691. This is a service type that includes all the various services that Ganeti
  22692. nodes should run.
  22693. Its value is a @code{ganeti-configuration} object that defines the package
  22694. to use for CLI operations, as well as configuration for the various daemons.
  22695. Allowed file storage paths and available guest operating systems are also
  22696. configured through this data type.
  22697. @end defvr
  22698. @deftp {Data Type} ganeti-configuration
  22699. The @code{ganeti} service takes the following configuration options:
  22700. @table @asis
  22701. @item @code{ganeti} (default: @code{ganeti})
  22702. The @code{ganeti} package to use. It will be installed to the system profile
  22703. and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
  22704. that the value specified here does not affect the other services as each refer
  22705. to a specific @code{ganeti} package (see below).
  22706. @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
  22707. @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
  22708. @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
  22709. @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
  22710. @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
  22711. @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
  22712. @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
  22713. @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
  22714. @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
  22715. @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
  22716. These options control the various daemons and cron jobs that are distributed
  22717. with Ganeti. The possible values for these are described in detail below.
  22718. To override a setting, you must use the configuration type for that service:
  22719. @lisp
  22720. (service ganeti-service-type
  22721. (ganeti-configuration
  22722. (rapi-configuration
  22723. (ganeti-rapi-configuration
  22724. (interface "eth1"))))
  22725. (watcher-configuration
  22726. (ganeti-watcher-configuration
  22727. (rapi-ip "10.0.0.1"))))
  22728. @end lisp
  22729. @item @code{file-storage-paths} (default: @code{'()})
  22730. List of allowed directories for file storage backend.
  22731. @item @code{os} (default: @code{%default-ganeti-os})
  22732. List of @code{<ganeti-os>} records.
  22733. @end table
  22734. In essence @code{ganeti-service-type} is shorthand for declaring each service
  22735. individually:
  22736. @lisp
  22737. (service ganeti-noded-service-type)
  22738. (service ganeti-confd-service-type)
  22739. (service ganeti-wconfd-service-type)
  22740. (service ganeti-luxid-service-type)
  22741. (service ganeti-kvmd-service-type)
  22742. (service ganeti-mond-service-type)
  22743. (service ganeti-metad-service-type)
  22744. (service ganeti-watcher-service-type)
  22745. (service ganeti-cleaner-service-type)
  22746. @end lisp
  22747. Plus a service extension for @code{etc-service-type} that configures the file
  22748. storage backend and OS variants.
  22749. @end deftp
  22750. @deftp {Data Type} ganeti-os
  22751. This data type is suitable for passing to the @code{os} parameter of
  22752. @code{ganeti-configuration}. It takes the following parameters:
  22753. @table @asis
  22754. @item @code{name}
  22755. The name for this OS provider. It is only used to specify where the
  22756. configuration ends up. Setting it to ``debootstrap'' will create
  22757. @file{/etc/ganeti/instance-debootstrap}.
  22758. @item @code{extension}
  22759. The file extension for variants of this OS type. For example
  22760. @file{.conf} or @file{.scm}.
  22761. @item @code{variants} (default: @code{'()})
  22762. List of @code{ganeti-os-variant} objects for this OS.
  22763. @end table
  22764. @end deftp
  22765. @deftp {Data Type} ganeti-os-variant
  22766. This is the data type for a Ganeti OS variant. It takes the following
  22767. parameters:
  22768. @table @asis
  22769. @item @code{name}
  22770. The name of this variant.
  22771. @item @code{configuration}
  22772. A configuration file for this variant.
  22773. @end table
  22774. @end deftp
  22775. @defvr {Scheme Variable} %default-debootstrap-hooks
  22776. This variable contains hooks to configure networking and the GRUB bootloader.
  22777. @end defvr
  22778. @defvr {Scheme Variable} %default-debootstrap-extra-pkgs
  22779. This variable contains a list of packages suitable for a fully-virtualized guest.
  22780. @end defvr
  22781. @deftp {Data Type} debootstrap-configuration
  22782. This data type creates configuration files suitable for the debootstrap OS provider.
  22783. @table @asis
  22784. @item @code{hooks} (default: @code{%default-debootstrap-hooks})
  22785. When not @code{#f}, this must be a G-expression that specifies a directory with
  22786. scripts that will run when the OS is installed. It can also be a list of
  22787. @code{(name . file-like)} pairs. For example:
  22788. @lisp
  22789. `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
  22790. @end lisp
  22791. That will create a directory with one executable named @code{99-hello-world}
  22792. and run it every time this variant is installed. If set to @code{#f}, hooks
  22793. in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
  22794. @item @code{proxy} (default: @code{#f})
  22795. Optional HTTP proxy to use.
  22796. @item @code{mirror} (default: @code{#f})
  22797. The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
  22798. The default varies depending on the distribution.
  22799. @item @code{arch} (default: @code{#f})
  22800. The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
  22801. on an AArch64 host. Default is to use the current system architecture.
  22802. @item @code{suite} (default: @code{"stable"})
  22803. When set, this must be a Debian distribution ``suite'' such as @code{buster}
  22804. or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
  22805. @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
  22806. List of extra packages that will get installed by dpkg in addition
  22807. to the minimal system.
  22808. @item @code{components} (default: @code{#f})
  22809. When set, must be a list of Debian repository ``components''. For example
  22810. @code{'("main" "contrib")}.
  22811. @item @code{generate-cache?} (default: @code{#t})
  22812. Whether to automatically cache the generated debootstrap archive.
  22813. @item @code{clean-cache} (default: @code{14})
  22814. Discard the cache after this amount of days. Use @code{#f} to never
  22815. clear the cache.
  22816. @item @code{partition-style} (default: @code{'msdos})
  22817. The type of partition to create. When set, it must be one of
  22818. @code{'msdos}, @code{'none} or a string.
  22819. @item @code{partition-alignment} (default: @code{2048})
  22820. Alignment of the partition in sectors.
  22821. @end table
  22822. @end deftp
  22823. @deffn {Scheme Procedure} debootstrap-variant @var{name} @var{configuration}
  22824. This is a helper procedure that creates a @code{ganeti-os-variant} record. It
  22825. takes two parameters: a name and a @code{debootstrap-configuration} object.
  22826. @end deffn
  22827. @deffn {Scheme Procedure} debootstrap-os @var{variants}@dots{}
  22828. This is a helper procedure that creates a @code{ganeti-os} record. It takes
  22829. a list of variants created with @code{debootstrap-variant}.
  22830. @end deffn
  22831. @deffn {Scheme Procedure} guix-variant @var{name} @var{configuration}
  22832. This is a helper procedure that creates a @code{ganeti-os-variant} record for
  22833. use with the Guix OS provider. It takes a name and a G-expression that returns
  22834. a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
  22835. Guix System configuration.
  22836. @end deffn
  22837. @deffn {Scheme Procedure} guix-os @var{variants}@dots{}
  22838. This is a helper procedure that creates a @code{ganeti-os} record. It
  22839. takes a list of variants produced by @code{guix-variant}.
  22840. @end deffn
  22841. @defvr {Scheme Variable} %default-debootstrap-variants
  22842. This is a convenience variable to make the debootstrap provider work
  22843. ``out of the box'' without users having to declare variants manually. It
  22844. contains a single debootstrap variant with the default configuration:
  22845. @lisp
  22846. (list (debootstrap-variant
  22847. "default"
  22848. (debootstrap-configuration)))
  22849. @end lisp
  22850. @end defvr
  22851. @defvr {Scheme Variable} %default-guix-variants
  22852. This is a convenience variable to make the Guix OS provider work without
  22853. additional configuration. It creates a virtual machine that has an SSH
  22854. server, a serial console, and authorizes the Ganeti hosts SSH keys.
  22855. @lisp
  22856. (list (guix-variant
  22857. "default"
  22858. (file-append ganeti-instance-guix
  22859. "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
  22860. @end lisp
  22861. @end defvr
  22862. Users can implement support for OS providers unbeknownst to Guix by extending
  22863. the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
  22864. For example:
  22865. @lisp
  22866. (ganeti-os
  22867. (name "custom")
  22868. (extension ".conf")
  22869. (variants
  22870. (list (ganeti-os-variant
  22871. (name "foo")
  22872. (configuration (plain-file "bar" "this is fine"))))))
  22873. @end lisp
  22874. That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
  22875. to a file in the store with contents @code{this is fine}. It also creates
  22876. @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
  22877. Obviously this may not work for all OS providers out there. If you find the
  22878. interface limiting, please reach out to @email{guix-devel@@gnu.org}.
  22879. The rest of this section documents the various services that are included by
  22880. @code{ganeti-service-type}.
  22881. @defvr {Scheme Variable} ganeti-noded-service-type
  22882. @command{ganeti-noded} is the daemon responsible for node-specific functions
  22883. within the Ganeti system. The value of this service must be a
  22884. @code{ganeti-noded-configuration} object.
  22885. @end defvr
  22886. @deftp {Data Type} ganeti-noded-configuration
  22887. This is the configuration for the @code{ganeti-noded} service.
  22888. @table @asis
  22889. @item @code{ganeti} (default: @code{ganeti})
  22890. The @code{ganeti} package to use for this service.
  22891. @item @code{port} (default: @code{1811})
  22892. The TCP port on which the node daemon listens for network requests.
  22893. @item @code{address} (default: @code{"0.0.0.0"})
  22894. The network address that the daemon will bind to. The default address means
  22895. bind to all available addresses.
  22896. @item @code{interface} (default: @code{#f})
  22897. When this is set, it must be a specific network interface (e.g.@: @code{eth0})
  22898. that the daemon will bind to.
  22899. @item @code{max-clients} (default: @code{20})
  22900. This sets a limit on the maximum number of simultaneous client connections
  22901. that the daemon will handle. Connections above this count are accepted, but
  22902. no responses will be sent until enough connections have closed.
  22903. @item @code{ssl?} (default: @code{#t})
  22904. Whether to use SSL/TLS to encrypt network communications. The certificate
  22905. is automatically provisioned by the cluster and can be rotated with
  22906. @command{gnt-cluster renew-crypto}.
  22907. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  22908. This can be used to provide a specific encryption key for TLS communications.
  22909. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  22910. This can be used to provide a specific certificate for TLS communications.
  22911. @item @code{debug?} (default: @code{#f})
  22912. When true, the daemon performs additional logging for debugging purposes.
  22913. Note that this will leak encryption details to the log files, use with caution.
  22914. @end table
  22915. @end deftp
  22916. @defvr {Scheme Variable} ganeti-confd-service-type
  22917. @command{ganeti-confd} answers queries related to the configuration of a
  22918. Ganeti cluster. The purpose of this daemon is to have a highly available
  22919. and fast way to query cluster configuration values. It is automatically
  22920. active on all @dfn{master candidates}. The value of this service must be a
  22921. @code{ganeti-confd-configuration} object.
  22922. @end defvr
  22923. @deftp {Data Type} ganeti-confd-configuration
  22924. This is the configuration for the @code{ganeti-confd} service.
  22925. @table @asis
  22926. @item @code{ganeti} (default: @code{ganeti})
  22927. The @code{ganeti} package to use for this service.
  22928. @item @code{port} (default: @code{1814})
  22929. The UDP port on which to listen for network requests.
  22930. @item @code{address} (default: @code{"0.0.0.0"})
  22931. Network address that the daemon will bind to.
  22932. @item @code{debug?} (default: @code{#f})
  22933. When true, the daemon performs additional logging for debugging purposes.
  22934. @end table
  22935. @end deftp
  22936. @defvr {Scheme Variable} ganeti-wconfd-service-type
  22937. @command{ganeti-wconfd} is the daemon that has authoritative knowledge
  22938. about the cluster configuration and is the only entity that can accept
  22939. changes to it. All jobs that need to modify the configuration will do so
  22940. by sending appropriate requests to this daemon. It only runs on the
  22941. @dfn{master node} and will automatically disable itself on other nodes.
  22942. The value of this service must be a
  22943. @code{ganeti-wconfd-configuration} object.
  22944. @end defvr
  22945. @deftp {Data Type} ganeti-wconfd-configuration
  22946. This is the configuration for the @code{ganeti-wconfd} service.
  22947. @table @asis
  22948. @item @code{ganeti} (default: @code{ganeti})
  22949. The @code{ganeti} package to use for this service.
  22950. @item @code{no-voting?} (default: @code{#f})
  22951. The daemon will refuse to start if the majority of cluster nodes does not
  22952. agree that it is running on the master node. Set to @code{#t} to start
  22953. even if a quorum can not be reached (dangerous, use with caution).
  22954. @item @code{debug?} (default: @code{#f})
  22955. When true, the daemon performs additional logging for debugging purposes.
  22956. @end table
  22957. @end deftp
  22958. @defvr {Scheme Variable} ganeti-luxid-service-type
  22959. @command{ganeti-luxid} is a daemon used to answer queries related to the
  22960. configuration and the current live state of a Ganeti cluster. Additionally,
  22961. it is the authoritative daemon for the Ganeti job queue. Jobs can be
  22962. submitted via this daemon and it schedules and starts them.
  22963. It takes a @code{ganeti-luxid-configuration} object.
  22964. @end defvr
  22965. @deftp {Data Type} ganeti-luxid-configuration
  22966. This is the configuration for the @code{ganeti-wconfd} service.
  22967. @table @asis
  22968. @item @code{ganeti} (default: @code{ganeti})
  22969. The @code{ganeti} package to use for this service.
  22970. @item @code{no-voting?} (default: @code{#f})
  22971. The daemon will refuse to start if it cannot verify that the majority of
  22972. cluster nodes believes that it is running on the master node. Set to
  22973. @code{#t} to ignore such checks and start anyway (this can be dangerous).
  22974. @item @code{debug?} (default: @code{#f})
  22975. When true, the daemon performs additional logging for debugging purposes.
  22976. @end table
  22977. @end deftp
  22978. @defvr {Scheme Variable} ganeti-rapi-service-type
  22979. @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
  22980. the master node and can be used to perform cluster actions programmatically
  22981. via a JSON-based RPC protocol.
  22982. Most query operations are allowed without authentication (unless
  22983. @var{require-authentication?} is set), whereas write operations require
  22984. explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
  22985. the @url{http://docs.ganeti.org/ganeti/master/html/rapi.html, Ganeti Remote
  22986. API documentation} for more information.
  22987. The value of this service must be a @code{ganeti-rapi-configuration} object.
  22988. @end defvr
  22989. @deftp {Data Type} ganeti-rapi-configuration
  22990. This is the configuration for the @code{ganeti-rapi} service.
  22991. @table @asis
  22992. @item @code{ganeti} (default: @code{ganeti})
  22993. The @code{ganeti} package to use for this service.
  22994. @item @code{require-authentication?} (default: @code{#f})
  22995. Whether to require authentication even for read-only operations.
  22996. @item @code{port} (default: @code{5080})
  22997. The TCP port on which to listen to API requests.
  22998. @item @code{address} (default: @code{"0.0.0.0"})
  22999. The network address that the service will bind to. By default it listens
  23000. on all configured addresses.
  23001. @item @code{interface} (default: @code{#f})
  23002. When set, it must specify a specific network interface such as @code{eth0}
  23003. that the daemon will bind to.
  23004. @item @code{max-clients} (default: @code{20})
  23005. The maximum number of simultaneous client requests to handle. Further
  23006. connections are allowed, but no responses are sent until enough connections
  23007. have closed.
  23008. @item @code{ssl?} (default: @code{#t})
  23009. Whether to use SSL/TLS encryption on the RAPI port.
  23010. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  23011. This can be used to provide a specific encryption key for TLS communications.
  23012. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  23013. This can be used to provide a specific certificate for TLS communications.
  23014. @item @code{debug?} (default: @code{#f})
  23015. When true, the daemon performs additional logging for debugging purposes.
  23016. Note that this will leak encryption details to the log files, use with caution.
  23017. @end table
  23018. @end deftp
  23019. @defvr {Scheme Variable} ganeti-kvmd-service-type
  23020. @command{ganeti-kvmd} is responsible for determining whether a given KVM
  23021. instance was shut down by an administrator or a user. Normally Ganeti will
  23022. restart an instance that was not stopped through Ganeti itself. If the
  23023. cluster option @code{user_shutdown} is true, this daemon monitors the
  23024. @code{QMP} socket provided by QEMU and listens for shutdown events, and
  23025. marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
  23026. it shuts down gracefully by itself.
  23027. It takes a @code{ganeti-kvmd-configuration} object.
  23028. @end defvr
  23029. @deftp {Data Type} ganeti-kvmd-configuration
  23030. @table @asis
  23031. @item @code{ganeti} (default: @code{ganeti})
  23032. The @code{ganeti} package to use for this service.
  23033. @item @code{debug?} (default: @code{#f})
  23034. When true, the daemon performs additional logging for debugging purposes.
  23035. @end table
  23036. @end deftp
  23037. @defvr {Scheme Variable} ganeti-mond-service-type
  23038. @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
  23039. functionality. It is responsible for running data collectors and publish the
  23040. collected information through a HTTP interface.
  23041. It takes a @code{ganeti-mond-configuration} object.
  23042. @end defvr
  23043. @deftp {Data Type} ganeti-mond-configuration
  23044. @table @asis
  23045. @item @code{ganeti} (default: @code{ganeti})
  23046. The @code{ganeti} package to use for this service.
  23047. @item @code{port} (default: @code{1815})
  23048. The port on which the daemon will listen.
  23049. @item @code{address} (default: @code{"0.0.0.0"})
  23050. The network address that the daemon will bind to. By default it binds to all
  23051. available interfaces.
  23052. @item @code{debug?} (default: @code{#f})
  23053. When true, the daemon performs additional logging for debugging purposes.
  23054. @end table
  23055. @end deftp
  23056. @defvr {Scheme Variable} ganeti-metad-service-type
  23057. @command{ganeti-metad} is an optional daemon that can be used to provide
  23058. information about the cluster to instances or OS install scripts.
  23059. It takes a @code{ganeti-metad-configuration} object.
  23060. @end defvr
  23061. @deftp {Data Type} ganeti-metad-configuration
  23062. @table @asis
  23063. @item @code{ganeti} (default: @code{ganeti})
  23064. The @code{ganeti} package to use for this service.
  23065. @item @code{port} (default: @code{80})
  23066. The port on which the daemon will listen.
  23067. @item @code{address} (default: @code{#f})
  23068. If set, the daemon will bind to this address only. If left unset, the behavior
  23069. depends on the cluster configuration.
  23070. @item @code{debug?} (default: @code{#f})
  23071. When true, the daemon performs additional logging for debugging purposes.
  23072. @end table
  23073. @end deftp
  23074. @defvr {Scheme Variable} ganeti-watcher-service-type
  23075. @command{ganeti-watcher} is a script designed to run periodically and ensure
  23076. the health of a cluster. It will automatically restart instances that have
  23077. stopped without Ganeti's consent, and repairs DRBD links in case a node has
  23078. rebooted. It also archives old cluster jobs and restarts Ganeti daemons
  23079. that are not running. If the cluster parameter @code{ensure_node_health}
  23080. is set, the watcher will also shutdown instances and DRBD devices if the
  23081. node it is running on is declared offline by known master candidates.
  23082. It can be paused on all nodes with @command{gnt-cluster watcher pause}.
  23083. The service takes a @code{ganeti-watcher-configuration} object.
  23084. @end defvr
  23085. @deftp {Data Type} ganeti-watcher-configuration
  23086. @table @asis
  23087. @item @code{ganeti} (default: @code{ganeti})
  23088. The @code{ganeti} package to use for this service.
  23089. @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
  23090. How often to run the script. The default is every five minutes.
  23091. @item @code{rapi-ip} (default: @code{#f})
  23092. This option needs to be specified only if the RAPI daemon is configured to use
  23093. a particular interface or address. By default the cluster address is used.
  23094. @item @code{job-age} (default: @code{(* 6 3600)})
  23095. Archive cluster jobs older than this age, specified in seconds. The default
  23096. is 6 hours. This keeps @command{gnt-job list} manageable.
  23097. @item @code{verify-disks?} (default: @code{#t})
  23098. If this is @code{#f}, the watcher will not try to repair broken DRBD links
  23099. automatically. Administrators will need to use @command{gnt-cluster verify-disks}
  23100. manually instead.
  23101. @item @code{debug?} (default: @code{#f})
  23102. When @code{#t}, the script performs additional logging for debugging purposes.
  23103. @end table
  23104. @end deftp
  23105. @defvr {Scheme Variable} ganeti-cleaner-service-type
  23106. @command{ganeti-cleaner} is a script designed to run periodically and remove
  23107. old files from the cluster. This service type controls two @dfn{cron jobs}:
  23108. one intended for the master node that permanently purges old cluster jobs,
  23109. and one intended for every node that removes expired X509 certificates, keys,
  23110. and outdated @command{ganeti-watcher} information. Like all Ganeti services,
  23111. it is safe to include even on non-master nodes as it will disable itself as
  23112. necessary.
  23113. It takes a @code{ganeti-cleaner-configuration} object.
  23114. @end defvr
  23115. @deftp {Data Type} ganeti-cleaner-configuration
  23116. @table @asis
  23117. @item @code{ganeti} (default: @code{ganeti})
  23118. The @code{ganeti} package to use for the @command{gnt-cleaner} command.
  23119. @item @code{master-schedule} (default: @code{"45 1 * * *"})
  23120. How often to run the master cleaning job. The default is once per day, at
  23121. 01:45:00.
  23122. @item @code{node-schedule} (default: @code{"45 2 * * *"})
  23123. How often to run the node cleaning job. The default is once per day, at
  23124. 02:45:00.
  23125. @end table
  23126. @end deftp
  23127. @node Version Control Services
  23128. @subsection Version Control Services
  23129. The @code{(gnu services version-control)} module provides a service to
  23130. allow remote access to local Git repositories. There are three options:
  23131. the @code{git-daemon-service}, which provides access to repositories via
  23132. the @code{git://} unsecured TCP-based protocol, extending the
  23133. @code{nginx} web server to proxy some requests to
  23134. @code{git-http-backend}, or providing a web interface with
  23135. @code{cgit-service-type}.
  23136. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  23137. Return a service that runs @command{git daemon}, a simple TCP server to
  23138. expose repositories over the Git protocol for anonymous access.
  23139. The optional @var{config} argument should be a
  23140. @code{<git-daemon-configuration>} object, by default it allows read-only
  23141. access to exported@footnote{By creating the magic file
  23142. @file{git-daemon-export-ok} in the repository directory.} repositories under
  23143. @file{/srv/git}.
  23144. @end deffn
  23145. @deftp {Data Type} git-daemon-configuration
  23146. Data type representing the configuration for @code{git-daemon-service}.
  23147. @table @asis
  23148. @item @code{package} (default: @code{git})
  23149. Package object of the Git distributed version control system.
  23150. @item @code{export-all?} (default: @code{#f})
  23151. Whether to allow access for all Git repositories, even if they do not
  23152. have the @file{git-daemon-export-ok} file.
  23153. @item @code{base-path} (default: @file{/srv/git})
  23154. Whether to remap all the path requests as relative to the given path.
  23155. If you run @command{git daemon} with @code{(base-path "/srv/git")} on
  23156. @samp{example.com}, then if you later try to pull
  23157. @indicateurl{git://example.com/hello.git}, git daemon will interpret the
  23158. path as @file{/srv/git/hello.git}.
  23159. @item @code{user-path} (default: @code{#f})
  23160. Whether to allow @code{~user} notation to be used in requests. When
  23161. specified with empty string, requests to
  23162. @indicateurl{git://host/~alice/foo} is taken as a request to access
  23163. @code{foo} repository in the home directory of user @code{alice}. If
  23164. @code{(user-path "@var{path}")} is specified, the same request is taken
  23165. as a request to access @file{@var{path}/foo} repository in the home
  23166. directory of user @code{alice}.
  23167. @item @code{listen} (default: @code{'()})
  23168. Whether to listen on specific IP addresses or hostnames, defaults to
  23169. all.
  23170. @item @code{port} (default: @code{#f})
  23171. Whether to listen on an alternative port, which defaults to 9418.
  23172. @item @code{whitelist} (default: @code{'()})
  23173. If not empty, only allow access to this list of directories.
  23174. @item @code{extra-options} (default: @code{'()})
  23175. Extra options will be passed to @command{git daemon}, please run
  23176. @command{man git-daemon} for more information.
  23177. @end table
  23178. @end deftp
  23179. The @code{git://} protocol lacks authentication. When you pull from a
  23180. repository fetched via @code{git://}, you don't know whether the data you
  23181. receive was modified or is even coming from the specified host, and your
  23182. connection is subject to eavesdropping. It's better to use an authenticated
  23183. and encrypted transport, such as @code{https}. Although Git allows you
  23184. to serve repositories using unsophisticated file-based web servers,
  23185. there is a faster protocol implemented by the @code{git-http-backend}
  23186. program. This program is the back-end of a proper Git web service. It
  23187. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  23188. on running the necessary @code{fcgiwrap} daemon.
  23189. Guix has a separate configuration data type for serving Git repositories
  23190. over HTTP.
  23191. @deftp {Data Type} git-http-configuration
  23192. Data type representing the configuration for a future
  23193. @code{git-http-service-type}; can currently be used to configure Nginx
  23194. through @code{git-http-nginx-location-configuration}.
  23195. @table @asis
  23196. @item @code{package} (default: @var{git})
  23197. Package object of the Git distributed version control system.
  23198. @item @code{git-root} (default: @file{/srv/git})
  23199. Directory containing the Git repositories to expose to the world.
  23200. @item @code{export-all?} (default: @code{#f})
  23201. Whether to expose access for all Git repositories in @var{git-root},
  23202. even if they do not have the @file{git-daemon-export-ok} file.
  23203. @item @code{uri-path} (default: @samp{/git/})
  23204. Path prefix for Git access. With the default @samp{/git/} prefix, this
  23205. will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
  23206. @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  23207. with this prefix are not passed on to this Git instance.
  23208. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  23209. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  23210. Services}.
  23211. @end table
  23212. @end deftp
  23213. There is no @code{git-http-service-type}, currently; instead you can
  23214. create an @code{nginx-location-configuration} from a
  23215. @code{git-http-configuration} and then add that location to a web
  23216. server.
  23217. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  23218. [config=(git-http-configuration)]
  23219. Compute an @code{nginx-location-configuration} that corresponds to the
  23220. given Git http configuration. An example nginx service definition to
  23221. serve the default @file{/srv/git} over HTTPS might be:
  23222. @lisp
  23223. (service nginx-service-type
  23224. (nginx-configuration
  23225. (server-blocks
  23226. (list
  23227. (nginx-server-configuration
  23228. (listen '("443 ssl"))
  23229. (server-name "git.my-host.org")
  23230. (ssl-certificate
  23231. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  23232. (ssl-certificate-key
  23233. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  23234. (locations
  23235. (list
  23236. (git-http-nginx-location-configuration
  23237. (git-http-configuration (uri-path "/"))))))))))
  23238. @end lisp
  23239. This example assumes that you are using Let's Encrypt to get your TLS
  23240. certificate. @xref{Certificate Services}. The default @code{certbot}
  23241. service will redirect all HTTP traffic on @code{git.my-host.org} to
  23242. HTTPS@. You will also need to add an @code{fcgiwrap} proxy to your
  23243. system services. @xref{Web Services}.
  23244. @end deffn
  23245. @subsubheading Cgit Service
  23246. @cindex Cgit service
  23247. @cindex Git, web interface
  23248. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  23249. repositories written in C.
  23250. The following example will configure the service with default values.
  23251. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  23252. @lisp
  23253. (service cgit-service-type)
  23254. @end lisp
  23255. The @code{file-object} type designates either a file-like object
  23256. (@pxref{G-Expressions, file-like objects}) or a string.
  23257. @c %start of fragment
  23258. Available @code{cgit-configuration} fields are:
  23259. @deftypevr {@code{cgit-configuration} parameter} package package
  23260. The CGIT package.
  23261. @end deftypevr
  23262. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  23263. NGINX configuration.
  23264. @end deftypevr
  23265. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  23266. Specifies a command which will be invoked to format the content of about
  23267. pages (both top-level and for each repository).
  23268. Defaults to @samp{""}.
  23269. @end deftypevr
  23270. @deftypevr {@code{cgit-configuration} parameter} string agefile
  23271. Specifies a path, relative to each repository path, which can be used to
  23272. specify the date and time of the youngest commit in the repository.
  23273. Defaults to @samp{""}.
  23274. @end deftypevr
  23275. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  23276. Specifies a command that will be invoked for authenticating repository
  23277. access.
  23278. Defaults to @samp{""}.
  23279. @end deftypevr
  23280. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  23281. Flag which, when set to @samp{age}, enables date ordering in the branch
  23282. ref list, and when set @samp{name} enables ordering by branch name.
  23283. Defaults to @samp{"name"}.
  23284. @end deftypevr
  23285. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  23286. Path used to store the cgit cache entries.
  23287. Defaults to @samp{"/var/cache/cgit"}.
  23288. @end deftypevr
  23289. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  23290. Number which specifies the time-to-live, in minutes, for the cached
  23291. version of repository pages accessed with a fixed SHA1.
  23292. Defaults to @samp{-1}.
  23293. @end deftypevr
  23294. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  23295. Number which specifies the time-to-live, in minutes, for the cached
  23296. version of repository pages accessed without a fixed SHA1.
  23297. Defaults to @samp{5}.
  23298. @end deftypevr
  23299. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  23300. Number which specifies the time-to-live, in minutes, for the cached
  23301. version of the repository summary page.
  23302. Defaults to @samp{5}.
  23303. @end deftypevr
  23304. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  23305. Number which specifies the time-to-live, in minutes, for the cached
  23306. version of the repository index page.
  23307. Defaults to @samp{5}.
  23308. @end deftypevr
  23309. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  23310. Number which specifies the time-to-live, in minutes, for the result of
  23311. scanning a path for Git repositories.
  23312. Defaults to @samp{15}.
  23313. @end deftypevr
  23314. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  23315. Number which specifies the time-to-live, in minutes, for the cached
  23316. version of the repository about page.
  23317. Defaults to @samp{15}.
  23318. @end deftypevr
  23319. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  23320. Number which specifies the time-to-live, in minutes, for the cached
  23321. version of snapshots.
  23322. Defaults to @samp{5}.
  23323. @end deftypevr
  23324. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  23325. The maximum number of entries in the cgit cache. When set to @samp{0},
  23326. caching is disabled.
  23327. Defaults to @samp{0}.
  23328. @end deftypevr
  23329. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  23330. Sort items in the repo list case sensitively.
  23331. Defaults to @samp{#t}.
  23332. @end deftypevr
  23333. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  23334. List of common prefixes which, when combined with a repository URL,
  23335. generates valid clone URLs for the repository.
  23336. Defaults to @samp{()}.
  23337. @end deftypevr
  23338. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  23339. List of @code{clone-url} templates.
  23340. Defaults to @samp{()}.
  23341. @end deftypevr
  23342. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  23343. Command which will be invoked to format commit messages.
  23344. Defaults to @samp{""}.
  23345. @end deftypevr
  23346. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  23347. Flag which, when set to @samp{date}, enables strict date ordering in the
  23348. commit log, and when set to @samp{topo} enables strict topological
  23349. ordering.
  23350. Defaults to @samp{"git log"}.
  23351. @end deftypevr
  23352. @deftypevr {@code{cgit-configuration} parameter} file-object css
  23353. URL which specifies the css document to include in all cgit pages.
  23354. Defaults to @samp{"/share/cgit/cgit.css"}.
  23355. @end deftypevr
  23356. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  23357. Specifies a command which will be invoked to format names and email
  23358. address of committers, authors, and taggers, as represented in various
  23359. places throughout the cgit interface.
  23360. Defaults to @samp{""}.
  23361. @end deftypevr
  23362. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  23363. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  23364. fragment suitable for embedding in other HTML pages.
  23365. Defaults to @samp{#f}.
  23366. @end deftypevr
  23367. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  23368. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  23369. commit history graph to the left of the commit messages in the
  23370. repository log page.
  23371. Defaults to @samp{#f}.
  23372. @end deftypevr
  23373. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  23374. Flag which, when set to @samp{#t}, allows all filter settings to be
  23375. overridden in repository-specific cgitrc files.
  23376. Defaults to @samp{#f}.
  23377. @end deftypevr
  23378. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  23379. Flag which, when set to @samp{#t}, allows users to follow a file in the
  23380. log view.
  23381. Defaults to @samp{#f}.
  23382. @end deftypevr
  23383. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  23384. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  23385. clones.
  23386. Defaults to @samp{#t}.
  23387. @end deftypevr
  23388. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  23389. Flag which, when set to @samp{#t}, will make cgit generate extra links
  23390. "summary", "commit", "tree" for each repo in the repository index.
  23391. Defaults to @samp{#f}.
  23392. @end deftypevr
  23393. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  23394. Flag which, when set to @samp{#t}, will make cgit display the owner of
  23395. each repo in the repository index.
  23396. Defaults to @samp{#t}.
  23397. @end deftypevr
  23398. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  23399. Flag which, when set to @samp{#t}, will make cgit print the number of
  23400. modified files for each commit on the repository log page.
  23401. Defaults to @samp{#f}.
  23402. @end deftypevr
  23403. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  23404. Flag which, when set to @samp{#t}, will make cgit print the number of
  23405. added and removed lines for each commit on the repository log page.
  23406. Defaults to @samp{#f}.
  23407. @end deftypevr
  23408. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  23409. Flag which, when set to @code{#t}, will make cgit display remote
  23410. branches in the summary and refs views.
  23411. Defaults to @samp{#f}.
  23412. @end deftypevr
  23413. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  23414. Flag which, when set to @code{1}, will make cgit use the subject of the
  23415. parent commit as link text when generating links to parent commits in
  23416. commit view.
  23417. Defaults to @samp{#f}.
  23418. @end deftypevr
  23419. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  23420. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  23421. parent commit as link text when generating links to parent commits in
  23422. commit view.
  23423. Defaults to @samp{#f}.
  23424. @end deftypevr
  23425. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  23426. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  23427. links for plaintext blobs printed in the tree view.
  23428. Defaults to @samp{#t}.
  23429. @end deftypevr
  23430. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  23431. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  23432. set any repo specific settings.
  23433. Defaults to @samp{#f}.
  23434. @end deftypevr
  23435. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  23436. URL used as link to a shortcut icon for cgit.
  23437. Defaults to @samp{"/favicon.ico"}.
  23438. @end deftypevr
  23439. @deftypevr {@code{cgit-configuration} parameter} string footer
  23440. The content of the file specified with this option will be included
  23441. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  23442. "generated by..."@: message).
  23443. Defaults to @samp{""}.
  23444. @end deftypevr
  23445. @deftypevr {@code{cgit-configuration} parameter} string head-include
  23446. The content of the file specified with this option will be included
  23447. verbatim in the HTML HEAD section on all pages.
  23448. Defaults to @samp{""}.
  23449. @end deftypevr
  23450. @deftypevr {@code{cgit-configuration} parameter} string header
  23451. The content of the file specified with this option will be included
  23452. verbatim at the top of all pages.
  23453. Defaults to @samp{""}.
  23454. @end deftypevr
  23455. @deftypevr {@code{cgit-configuration} parameter} file-object include
  23456. Name of a configfile to include before the rest of the current config-
  23457. file is parsed.
  23458. Defaults to @samp{""}.
  23459. @end deftypevr
  23460. @deftypevr {@code{cgit-configuration} parameter} string index-header
  23461. The content of the file specified with this option will be included
  23462. verbatim above the repository index.
  23463. Defaults to @samp{""}.
  23464. @end deftypevr
  23465. @deftypevr {@code{cgit-configuration} parameter} string index-info
  23466. The content of the file specified with this option will be included
  23467. verbatim below the heading on the repository index page.
  23468. Defaults to @samp{""}.
  23469. @end deftypevr
  23470. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  23471. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  23472. in the servers timezone.
  23473. Defaults to @samp{#f}.
  23474. @end deftypevr
  23475. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  23476. URL which specifies the source of an image which will be used as a logo
  23477. on all cgit pages.
  23478. Defaults to @samp{"/share/cgit/cgit.png"}.
  23479. @end deftypevr
  23480. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  23481. URL loaded when clicking on the cgit logo image.
  23482. Defaults to @samp{""}.
  23483. @end deftypevr
  23484. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  23485. Command which will be invoked to format the Owner column of the main
  23486. page.
  23487. Defaults to @samp{""}.
  23488. @end deftypevr
  23489. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  23490. Number of items to display in atom feeds view.
  23491. Defaults to @samp{10}.
  23492. @end deftypevr
  23493. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  23494. Number of entries to list per page in "log" view.
  23495. Defaults to @samp{50}.
  23496. @end deftypevr
  23497. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  23498. Number of commit message characters to display in "log" view.
  23499. Defaults to @samp{80}.
  23500. @end deftypevr
  23501. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  23502. Specifies the number of entries to list per page on the repository index
  23503. page.
  23504. Defaults to @samp{50}.
  23505. @end deftypevr
  23506. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  23507. Specifies the maximum number of repo description characters to display
  23508. on the repository index page.
  23509. Defaults to @samp{80}.
  23510. @end deftypevr
  23511. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  23512. Specifies the maximum size of a blob to display HTML for in KBytes.
  23513. Defaults to @samp{0}.
  23514. @end deftypevr
  23515. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  23516. Maximum statistics period. Valid values are @samp{week},@samp{month},
  23517. @samp{quarter} and @samp{year}.
  23518. Defaults to @samp{""}.
  23519. @end deftypevr
  23520. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  23521. Mimetype for the specified filename extension.
  23522. Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
  23523. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  23524. "image/png") (svg "image/svg+xml"))}.
  23525. @end deftypevr
  23526. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  23527. Specifies the file to use for automatic mimetype lookup.
  23528. Defaults to @samp{""}.
  23529. @end deftypevr
  23530. @deftypevr {@code{cgit-configuration} parameter} string module-link
  23531. Text which will be used as the formatstring for a hyperlink when a
  23532. submodule is printed in a directory listing.
  23533. Defaults to @samp{""}.
  23534. @end deftypevr
  23535. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  23536. If set to the value @samp{#t} caching will be disabled.
  23537. Defaults to @samp{#f}.
  23538. @end deftypevr
  23539. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  23540. If set to @samp{#t} showing full author email addresses will be
  23541. disabled.
  23542. Defaults to @samp{#f}.
  23543. @end deftypevr
  23544. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  23545. Flag which, when set to @samp{#t}, will make cgit omit the standard
  23546. header on all pages.
  23547. Defaults to @samp{#f}.
  23548. @end deftypevr
  23549. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  23550. A list of subdirectories inside of @code{repository-directory}, relative
  23551. to it, that should loaded as Git repositories. An empty list means that
  23552. all subdirectories will be loaded.
  23553. Defaults to @samp{()}.
  23554. @end deftypevr
  23555. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  23556. Text which will be used as default value for @code{cgit-repo-readme}.
  23557. Defaults to @samp{""}.
  23558. @end deftypevr
  23559. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  23560. If set to @code{#t} and @code{repository-directory} is enabled, if any
  23561. repositories are found with a suffix of @code{.git}, this suffix will be
  23562. removed for the URL and name.
  23563. Defaults to @samp{#f}.
  23564. @end deftypevr
  23565. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  23566. Maximum number of files to consider when detecting renames.
  23567. Defaults to @samp{-1}.
  23568. @end deftypevr
  23569. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  23570. The way in which repositories in each section are sorted.
  23571. Defaults to @samp{""}.
  23572. @end deftypevr
  23573. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  23574. Text used as content for the @code{robots} meta-tag.
  23575. Defaults to @samp{("noindex" "nofollow")}.
  23576. @end deftypevr
  23577. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  23578. Text printed below the heading on the repository index page.
  23579. Defaults to @samp{"a fast webinterface for the git dscm"}.
  23580. @end deftypevr
  23581. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  23582. The content of the file specified with this option will be included
  23583. verbatim below the ``about'' link on the repository index page.
  23584. Defaults to @samp{""}.
  23585. @end deftypevr
  23586. @deftypevr {@code{cgit-configuration} parameter} string root-title
  23587. Text printed as heading on the repository index page.
  23588. Defaults to @samp{""}.
  23589. @end deftypevr
  23590. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  23591. If set to @samp{#t} and repository-directory is enabled,
  23592. repository-directory will recurse into directories whose name starts
  23593. with a period. Otherwise, repository-directory will stay away from such
  23594. directories, considered as ``hidden''. Note that this does not apply to
  23595. the @file{.git} directory in non-bare repos.
  23596. Defaults to @samp{#f}.
  23597. @end deftypevr
  23598. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  23599. Text which specifies the default set of snapshot formats that cgit
  23600. generates links for.
  23601. Defaults to @samp{()}.
  23602. @end deftypevr
  23603. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  23604. Name of the directory to scan for repositories (represents
  23605. @code{scan-path}).
  23606. Defaults to @samp{"/srv/git"}.
  23607. @end deftypevr
  23608. @deftypevr {@code{cgit-configuration} parameter} string section
  23609. The name of the current repository section - all repositories defined
  23610. after this option will inherit the current section name.
  23611. Defaults to @samp{""}.
  23612. @end deftypevr
  23613. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  23614. Flag which, when set to @samp{1}, will sort the sections on the
  23615. repository listing by name.
  23616. Defaults to @samp{""}.
  23617. @end deftypevr
  23618. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  23619. A number which, if defined prior to repository-directory, specifies how
  23620. many path elements from each repo path to use as a default section name.
  23621. Defaults to @samp{0}.
  23622. @end deftypevr
  23623. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  23624. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  23625. default.
  23626. Defaults to @samp{#f}.
  23627. @end deftypevr
  23628. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  23629. Specifies a command which will be invoked to format plaintext blobs in
  23630. the tree view.
  23631. Defaults to @samp{""}.
  23632. @end deftypevr
  23633. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  23634. Specifies the number of branches to display in the repository ``summary''
  23635. view.
  23636. Defaults to @samp{10}.
  23637. @end deftypevr
  23638. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  23639. Specifies the number of log entries to display in the repository
  23640. ``summary'' view.
  23641. Defaults to @samp{10}.
  23642. @end deftypevr
  23643. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  23644. Specifies the number of tags to display in the repository ``summary''
  23645. view.
  23646. Defaults to @samp{10}.
  23647. @end deftypevr
  23648. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  23649. Filename which, if specified, needs to be present within the repository
  23650. for cgit to allow access to that repository.
  23651. Defaults to @samp{""}.
  23652. @end deftypevr
  23653. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  23654. URL which, if specified, will be used as root for all cgit links.
  23655. Defaults to @samp{"/"}.
  23656. @end deftypevr
  23657. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  23658. A list of @dfn{cgit-repo} records to use with config.
  23659. Defaults to @samp{()}.
  23660. Available @code{repository-cgit-configuration} fields are:
  23661. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  23662. A mask of snapshot formats for this repo that cgit generates links for,
  23663. restricted by the global @code{snapshots} setting.
  23664. Defaults to @samp{()}.
  23665. @end deftypevr
  23666. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  23667. Override the default @code{source-filter}.
  23668. Defaults to @samp{""}.
  23669. @end deftypevr
  23670. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  23671. The relative URL used to access the repository.
  23672. Defaults to @samp{""}.
  23673. @end deftypevr
  23674. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  23675. Override the default @code{about-filter}.
  23676. Defaults to @samp{""}.
  23677. @end deftypevr
  23678. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  23679. Flag which, when set to @samp{age}, enables date ordering in the branch
  23680. ref list, and when set to @samp{name} enables ordering by branch name.
  23681. Defaults to @samp{""}.
  23682. @end deftypevr
  23683. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  23684. A list of URLs which can be used to clone repo.
  23685. Defaults to @samp{()}.
  23686. @end deftypevr
  23687. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  23688. Override the default @code{commit-filter}.
  23689. Defaults to @samp{""}.
  23690. @end deftypevr
  23691. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  23692. Flag which, when set to @samp{date}, enables strict date ordering in the
  23693. commit log, and when set to @samp{topo} enables strict topological
  23694. ordering.
  23695. Defaults to @samp{""}.
  23696. @end deftypevr
  23697. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  23698. The name of the default branch for this repository. If no such branch
  23699. exists in the repository, the first branch name (when sorted) is used as
  23700. default instead. By default branch pointed to by HEAD, or ``master'' if
  23701. there is no suitable HEAD.
  23702. Defaults to @samp{""}.
  23703. @end deftypevr
  23704. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  23705. The value to show as repository description.
  23706. Defaults to @samp{""}.
  23707. @end deftypevr
  23708. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  23709. The value to show as repository homepage.
  23710. Defaults to @samp{""}.
  23711. @end deftypevr
  23712. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  23713. Override the default @code{email-filter}.
  23714. Defaults to @samp{""}.
  23715. @end deftypevr
  23716. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  23717. A flag which can be used to disable the global setting
  23718. @code{enable-commit-graph?}.
  23719. Defaults to @samp{disabled}.
  23720. @end deftypevr
  23721. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  23722. A flag which can be used to disable the global setting
  23723. @code{enable-log-filecount?}.
  23724. Defaults to @samp{disabled}.
  23725. @end deftypevr
  23726. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  23727. A flag which can be used to disable the global setting
  23728. @code{enable-log-linecount?}.
  23729. Defaults to @samp{disabled}.
  23730. @end deftypevr
  23731. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  23732. Flag which, when set to @code{#t}, will make cgit display remote
  23733. branches in the summary and refs views.
  23734. Defaults to @samp{disabled}.
  23735. @end deftypevr
  23736. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  23737. A flag which can be used to override the global setting
  23738. @code{enable-subject-links?}.
  23739. Defaults to @samp{disabled}.
  23740. @end deftypevr
  23741. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  23742. A flag which can be used to override the global setting
  23743. @code{enable-html-serving?}.
  23744. Defaults to @samp{disabled}.
  23745. @end deftypevr
  23746. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  23747. Flag which, when set to @code{#t}, hides the repository from the
  23748. repository index.
  23749. Defaults to @samp{#f}.
  23750. @end deftypevr
  23751. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  23752. Flag which, when set to @samp{#t}, ignores the repository.
  23753. Defaults to @samp{#f}.
  23754. @end deftypevr
  23755. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  23756. URL which specifies the source of an image which will be used as a logo
  23757. on this repo’s pages.
  23758. Defaults to @samp{""}.
  23759. @end deftypevr
  23760. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  23761. URL loaded when clicking on the cgit logo image.
  23762. Defaults to @samp{""}.
  23763. @end deftypevr
  23764. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  23765. Override the default @code{owner-filter}.
  23766. Defaults to @samp{""}.
  23767. @end deftypevr
  23768. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  23769. Text which will be used as the formatstring for a hyperlink when a
  23770. submodule is printed in a directory listing. The arguments for the
  23771. formatstring are the path and SHA1 of the submodule commit.
  23772. Defaults to @samp{""}.
  23773. @end deftypevr
  23774. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  23775. Text which will be used as the formatstring for a hyperlink when a
  23776. submodule with the specified subdirectory path is printed in a directory
  23777. listing.
  23778. Defaults to @samp{()}.
  23779. @end deftypevr
  23780. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  23781. Override the default maximum statistics period.
  23782. Defaults to @samp{""}.
  23783. @end deftypevr
  23784. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  23785. The value to show as repository name.
  23786. Defaults to @samp{""}.
  23787. @end deftypevr
  23788. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  23789. A value used to identify the owner of the repository.
  23790. Defaults to @samp{""}.
  23791. @end deftypevr
  23792. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  23793. An absolute path to the repository directory.
  23794. Defaults to @samp{""}.
  23795. @end deftypevr
  23796. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  23797. A path (relative to repo) which specifies a file to include verbatim as
  23798. the ``About'' page for this repo.
  23799. Defaults to @samp{""}.
  23800. @end deftypevr
  23801. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  23802. The name of the current repository section - all repositories defined
  23803. after this option will inherit the current section name.
  23804. Defaults to @samp{""}.
  23805. @end deftypevr
  23806. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  23807. Extra options will be appended to cgitrc file.
  23808. Defaults to @samp{()}.
  23809. @end deftypevr
  23810. @end deftypevr
  23811. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  23812. Extra options will be appended to cgitrc file.
  23813. Defaults to @samp{()}.
  23814. @end deftypevr
  23815. @c %end of fragment
  23816. However, it could be that you just want to get a @code{cgitrc} up and
  23817. running. In that case, you can pass an @code{opaque-cgit-configuration}
  23818. as a record to @code{cgit-service-type}. As its name indicates, an
  23819. opaque configuration does not have easy reflective capabilities.
  23820. Available @code{opaque-cgit-configuration} fields are:
  23821. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  23822. The cgit package.
  23823. @end deftypevr
  23824. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  23825. The contents of the @code{cgitrc}, as a string.
  23826. @end deftypevr
  23827. For example, if your @code{cgitrc} is just the empty string, you
  23828. could instantiate a cgit service like this:
  23829. @lisp
  23830. (service cgit-service-type
  23831. (opaque-cgit-configuration
  23832. (cgitrc "")))
  23833. @end lisp
  23834. @subsubheading Gitolite Service
  23835. @cindex Gitolite service
  23836. @cindex Git, hosting
  23837. @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  23838. repositories on a central server.
  23839. Gitolite can handle multiple repositories and users, and supports flexible
  23840. configuration of the permissions for the users on the repositories.
  23841. The following example will configure Gitolite using the default @code{git}
  23842. user, and the provided SSH public key.
  23843. @lisp
  23844. (service gitolite-service-type
  23845. (gitolite-configuration
  23846. (admin-pubkey (plain-file
  23847. "yourname.pub"
  23848. "ssh-rsa AAAA... guix@@example.com"))))
  23849. @end lisp
  23850. Gitolite is configured through a special admin repository which you can clone,
  23851. for example, if you setup Gitolite on @code{example.com}, you would run the
  23852. following command to clone the admin repository.
  23853. @example
  23854. git clone git@@example.com:gitolite-admin
  23855. @end example
  23856. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  23857. be inserted in to the @file{keydir} directory in the gitolite-admin
  23858. repository. If this results in a change in the repository, it will be
  23859. committed using the message ``gitolite setup by GNU Guix''.
  23860. @deftp {Data Type} gitolite-configuration
  23861. Data type representing the configuration for @code{gitolite-service-type}.
  23862. @table @asis
  23863. @item @code{package} (default: @var{gitolite})
  23864. Gitolite package to use.
  23865. @item @code{user} (default: @var{git})
  23866. User to use for Gitolite. This will be user that you use when accessing
  23867. Gitolite over SSH.
  23868. @item @code{group} (default: @var{git})
  23869. Group to use for Gitolite.
  23870. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  23871. Directory in which to store the Gitolite configuration and repositories.
  23872. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  23873. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  23874. representing the configuration for Gitolite.
  23875. @item @code{admin-pubkey} (default: @var{#f})
  23876. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  23877. setup Gitolite. This will be inserted in to the @file{keydir} directory
  23878. within the gitolite-admin repository.
  23879. To specify the SSH key as a string, use the @code{plain-file} function.
  23880. @lisp
  23881. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  23882. @end lisp
  23883. @end table
  23884. @end deftp
  23885. @deftp {Data Type} gitolite-rc-file
  23886. Data type representing the Gitolite RC file.
  23887. @table @asis
  23888. @item @code{umask} (default: @code{#o0077})
  23889. This controls the permissions Gitolite sets on the repositories and their
  23890. contents.
  23891. A value like @code{#o0027} will give read access to the group used by Gitolite
  23892. (by default: @code{git}). This is necessary when using Gitolite with software
  23893. like cgit or gitweb.
  23894. @item @code{git-config-keys} (default: @code{""})
  23895. Gitolite allows you to set git config values using the @samp{config}
  23896. keyword. This setting allows control over the config keys to accept.
  23897. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  23898. Set the role names allowed to be used by users running the perms command.
  23899. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  23900. This setting controls the commands and features to enable within Gitolite.
  23901. @end table
  23902. @end deftp
  23903. @node Game Services
  23904. @subsection Game Services
  23905. @subsubheading The Battle for Wesnoth Service
  23906. @cindex wesnothd
  23907. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  23908. based tactical strategy game, with several single player campaigns, and
  23909. multiplayer games (both networked and local).
  23910. @defvar {Scheme Variable} wesnothd-service-type
  23911. Service type for the wesnothd service. Its value must be a
  23912. @code{wesnothd-configuration} object. To run wesnothd in the default
  23913. configuration, instantiate it as:
  23914. @lisp
  23915. (service wesnothd-service-type)
  23916. @end lisp
  23917. @end defvar
  23918. @deftp {Data Type} wesnothd-configuration
  23919. Data type representing the configuration of @command{wesnothd}.
  23920. @table @asis
  23921. @item @code{package} (default: @code{wesnoth-server})
  23922. The wesnoth server package to use.
  23923. @item @code{port} (default: @code{15000})
  23924. The port to bind the server to.
  23925. @end table
  23926. @end deftp
  23927. @node PAM Mount Service
  23928. @subsection PAM Mount Service
  23929. @cindex pam-mount
  23930. The @code{(gnu services pam-mount)} module provides a service allowing
  23931. users to mount volumes when they log in. It should be able to mount any
  23932. volume format supported by the system.
  23933. @defvar {Scheme Variable} pam-mount-service-type
  23934. Service type for PAM Mount support.
  23935. @end defvar
  23936. @deftp {Data Type} pam-mount-configuration
  23937. Data type representing the configuration of PAM Mount.
  23938. It takes the following parameters:
  23939. @table @asis
  23940. @item @code{rules}
  23941. The configuration rules that will be used to generate
  23942. @file{/etc/security/pam_mount.conf.xml}.
  23943. The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
  23944. Guile Reference Manual}), and the default ones don't mount anything for
  23945. anyone at login:
  23946. @lisp
  23947. `((debug (@@ (enable "0")))
  23948. (mntoptions (@@ (allow ,(string-join
  23949. '("nosuid" "nodev" "loop"
  23950. "encryption" "fsck" "nonempty"
  23951. "allow_root" "allow_other")
  23952. ","))))
  23953. (mntoptions (@@ (require "nosuid,nodev")))
  23954. (logout (@@ (wait "0")
  23955. (hup "0")
  23956. (term "no")
  23957. (kill "no")))
  23958. (mkmountpoint (@@ (enable "1")
  23959. (remove "true"))))
  23960. @end lisp
  23961. Some @code{volume} elements must be added to automatically mount volumes
  23962. at login. Here's an example allowing the user @code{alice} to mount her
  23963. encrypted @env{HOME} directory and allowing the user @code{bob} to mount
  23964. the partition where he stores his data:
  23965. @lisp
  23966. (define pam-mount-rules
  23967. `((debug (@@ (enable "0")))
  23968. (volume (@@ (user "alice")
  23969. (fstype "crypt")
  23970. (path "/dev/sda2")
  23971. (mountpoint "/home/alice")))
  23972. (volume (@@ (user "bob")
  23973. (fstype "auto")
  23974. (path "/dev/sdb3")
  23975. (mountpoint "/home/bob/data")
  23976. (options "defaults,autodefrag,compress")))
  23977. (mntoptions (@@ (allow ,(string-join
  23978. '("nosuid" "nodev" "loop"
  23979. "encryption" "fsck" "nonempty"
  23980. "allow_root" "allow_other")
  23981. ","))))
  23982. (mntoptions (@@ (require "nosuid,nodev")))
  23983. (logout (@@ (wait "0")
  23984. (hup "0")
  23985. (term "no")
  23986. (kill "no")))
  23987. (mkmountpoint (@@ (enable "1")
  23988. (remove "true")))))
  23989. (service pam-mount-service-type
  23990. (pam-mount-configuration
  23991. (rules pam-mount-rules)))
  23992. @end lisp
  23993. The complete list of possible options can be found in the man page for
  23994. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
  23995. @end table
  23996. @end deftp
  23997. @node Guix Services
  23998. @subsection Guix Services
  23999. @subsubheading Guix Build Coordinator
  24000. The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
  24001. Coordinator} aids in distributing derivation builds among machines
  24002. running an @dfn{agent}. The build daemon is still used to build the
  24003. derivations, but the Guix Build Coordinator manages allocating builds
  24004. and working with the results.
  24005. @quotation Note
  24006. This service is considered experimental. Configuration options may be
  24007. changed in a backwards-incompatible manner, and not all features have
  24008. been thorougly tested.
  24009. @end quotation
  24010. The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
  24011. more connected @dfn{agent} processes. The coordinator process handles
  24012. clients submitting builds, and allocating builds to agents. The agent
  24013. processes talk to a build daemon to actually perform the builds, then
  24014. send the results back to the coordinator.
  24015. There is a script to run the coordinator component of the Guix Build
  24016. Coordinator, but the Guix service uses a custom Guile script instead, to
  24017. provide better integration with G-expressions used in the configuration.
  24018. @defvar {Scheme Variable} guix-build-coordinator-service-type
  24019. Service type for the Guix Build Coordinator. Its value must be a
  24020. @code{guix-build-coordinator-configuration} object.
  24021. @end defvar
  24022. @deftp {Data Type} guix-build-coordinator-configuration
  24023. Data type representing the configuration of the Guix Build Coordinator.
  24024. @table @asis
  24025. @item @code{package} (default: @code{guix-build-coordinator})
  24026. The Guix Build Coordinator package to use.
  24027. @item @code{user} (default: @code{"guix-build-coordinator"})
  24028. The system user to run the service as.
  24029. @item @code{group} (default: @code{"guix-build-coordinator"})
  24030. The system group to run the service as.
  24031. @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
  24032. The URI to use for the database.
  24033. @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
  24034. The URI describing how to listen to requests from agent processes.
  24035. @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
  24036. The URI describing how to listen to requests from clients. The client
  24037. API allows submitting builds and currently isn't authenticated, so take
  24038. care when configuring this value.
  24039. @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
  24040. A G-expression for the allocation strategy to be used. This is a
  24041. procedure that takes the datastore as an argument and populates the
  24042. allocation plan in the database.
  24043. @item @code{hooks} (default: @var{'()})
  24044. An association list of hooks. These provide a way to execute arbitrary
  24045. code upon certain events, like a build result being processed.
  24046. @item @code{guile} (default: @code{guile-3.0-latest})
  24047. The Guile package with which to run the Guix Build Coordinator.
  24048. @end table
  24049. @end deftp
  24050. @defvar {Scheme Variable} guix-build-coordinator-agent-service-type
  24051. Service type for a Guix Build Coordinator agent. Its value must be a
  24052. @code{guix-build-coordinator-agent-configuration} object.
  24053. @end defvar
  24054. @deftp {Data Type} guix-build-coordinator-agent-configuration
  24055. Data type representing the configuration a Guix Build Coordinator agent.
  24056. @table @asis
  24057. @item @code{package} (default: @code{guix-build-coordinator})
  24058. The Guix Build Coordinator package to use.
  24059. @item @code{user} (default: @code{"guix-build-coordinator-agent"})
  24060. The system user to run the service as.
  24061. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  24062. The URI to use when connecting to the coordinator.
  24063. @item @code{authentication}
  24064. Record describing how this agent should authenticate with the
  24065. coordinator. Possible record types are described below.
  24066. @item @code{systems} (default: @code{#f})
  24067. The systems for which this agent should fetch builds. The agent process
  24068. will use the current system it's running on as the default.
  24069. @item @code{max-parallel-builds} (default: @code{1})
  24070. The number of builds to perform in parallel.
  24071. @item @code{derivation-substitute-urls} (default: @code{#f})
  24072. URLs from which to attempt to fetch substitutes for derivations, if the
  24073. derivations aren't already available.
  24074. @item @code{non-derivation-substitute-urls} (default: @code{#f})
  24075. URLs from which to attempt to fetch substitutes for build inputs, if the
  24076. input store items aren't already available.
  24077. @end table
  24078. @end deftp
  24079. @deftp {Data Type} guix-build-coordinator-agent-password-auth
  24080. Data type representing an agent authenticating with a coordinator via a
  24081. UUID and password.
  24082. @table @asis
  24083. @item @code{uuid}
  24084. The UUID of the agent. This should be generated by the coordinator
  24085. process, stored in the coordinator database, and used by the intended
  24086. agent.
  24087. @item @code{password}
  24088. The password to use when connecting to the coordinator.
  24089. @end table
  24090. @end deftp
  24091. @deftp {Data Type} guix-build-coordinator-agent-password-file-auth
  24092. Data type representing an agent authenticating with a coordinator via a
  24093. UUID and password read from a file.
  24094. @table @asis
  24095. @item @code{uuid}
  24096. The UUID of the agent. This should be generated by the coordinator
  24097. process, stored in the coordinator database, and used by the intended
  24098. agent.
  24099. @item @code{password-file}
  24100. A file containing the password to use when connecting to the
  24101. coordinator.
  24102. @end table
  24103. @end deftp
  24104. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth
  24105. Data type representing an agent authenticating with a coordinator via a
  24106. dyanmic auth token and agent name.
  24107. @table @asis
  24108. @item @code{agent-name}
  24109. Name of an agent, this is used to match up to an existing entry in the
  24110. database if there is one. When no existing entry is found, a new entry
  24111. is automatically added.
  24112. @item @code{token}
  24113. Dynamic auth token, this is created and stored in the coordinator
  24114. database, and is used by the agent to authenticate.
  24115. @end table
  24116. @end deftp
  24117. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth-with-file
  24118. Data type representing an agent authenticating with a coordinator via a
  24119. dyanmic auth token read from a file and agent name.
  24120. @table @asis
  24121. @item @code{agent-name}
  24122. Name of an agent, this is used to match up to an existing entry in the
  24123. database if there is one. When no existing entry is found, a new entry
  24124. is automatically added.
  24125. @item @code{token-file}
  24126. File containing the dynamic auth token, this is created and stored in
  24127. the coordinator database, and is used by the agent to authenticate.
  24128. @end table
  24129. @end deftp
  24130. The Guix Build Coordinator package contains a script to query an
  24131. instance of the Guix Data Service for derivations to build, and then
  24132. submit builds for those derivations to the coordinator. The service
  24133. type below assists in running this script. This is an additional tool
  24134. that may be useful when building derivations contained within an
  24135. instance of the Guix Data Service.
  24136. @defvar {Scheme Variable} guix-build-coordinator-queue-builds-service-type
  24137. Service type for the
  24138. guix-build-coordinator-queue-builds-from-guix-data-service script. Its
  24139. value must be a @code{guix-build-coordinator-queue-builds-configuration}
  24140. object.
  24141. @end defvar
  24142. @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
  24143. Data type representing the options to the queue builds from guix data
  24144. service script.
  24145. @table @asis
  24146. @item @code{package} (default: @code{guix-build-coordinator})
  24147. The Guix Build Coordinator package to use.
  24148. @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
  24149. The system user to run the service as.
  24150. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  24151. The URI to use when connecting to the coordinator.
  24152. @item @code{systems} (default: @code{#f})
  24153. The systems for which to fetch derivations to build.
  24154. @item @code{systems-and-targets} (default: @code{#f})
  24155. An association list of system and target pairs for which to fetch
  24156. derivations to build.
  24157. @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
  24158. The Guix Data Service instance from which to query to find out about
  24159. derivations to build.
  24160. @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
  24161. A file to record which commits have been processed, to avoid needlessly
  24162. processing them again if the service is restarted.
  24163. @end table
  24164. @end deftp
  24165. @subsubheading Guix Data Service
  24166. The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
  24167. and provides data about GNU Guix. This includes information about
  24168. packages, derivations and lint warnings.
  24169. The data is stored in a PostgreSQL database, and available through a web
  24170. interface.
  24171. @defvar {Scheme Variable} guix-data-service-type
  24172. Service type for the Guix Data Service. Its value must be a
  24173. @code{guix-data-service-configuration} object. The service optionally
  24174. extends the getmail service, as the guix-commits mailing list is used to
  24175. find out about changes in the Guix git repository.
  24176. @end defvar
  24177. @deftp {Data Type} guix-data-service-configuration
  24178. Data type representing the configuration of the Guix Data Service.
  24179. @table @asis
  24180. @item @code{package} (default: @code{guix-data-service})
  24181. The Guix Data Service package to use.
  24182. @item @code{user} (default: @code{"guix-data-service"})
  24183. The system user to run the service as.
  24184. @item @code{group} (default: @code{"guix-data-service"})
  24185. The system group to run the service as.
  24186. @item @code{port} (default: @code{8765})
  24187. The port to bind the web service to.
  24188. @item @code{host} (default: @code{"127.0.0.1"})
  24189. The host to bind the web service to.
  24190. @item @code{getmail-idle-mailboxes} (default: @code{#f})
  24191. If set, this is the list of mailboxes that the getmail service will be
  24192. configured to listen to.
  24193. @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
  24194. If set, this is the @code{getmail-retriever-configuration} object with
  24195. which to configure getmail to fetch mail from the guix-commits mailing
  24196. list.
  24197. @item @code{extra-options} (default: @var{'()})
  24198. Extra command line options for @code{guix-data-service}.
  24199. @item @code{extra-process-jobs-options} (default: @var{'()})
  24200. Extra command line options for @code{guix-data-service-process-jobs}.
  24201. @end table
  24202. @end deftp
  24203. @node Linux Services
  24204. @subsection Linux Services
  24205. @cindex oom
  24206. @cindex out of memory killer
  24207. @cindex earlyoom
  24208. @cindex early out of memory daemon
  24209. @subsubheading Early OOM Service
  24210. @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
  24211. Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
  24212. space and provides a more responsive and configurable alternative to the
  24213. in-kernel OOM killer. It is useful to prevent the system from becoming
  24214. unresponsive when it runs out of memory.
  24215. @deffn {Scheme Variable} earlyoom-service-type
  24216. The service type for running @command{earlyoom}, the Early OOM daemon.
  24217. Its value must be a @code{earlyoom-configuration} object, described
  24218. below. The service can be instantiated in its default configuration
  24219. with:
  24220. @lisp
  24221. (service earlyoom-service-type)
  24222. @end lisp
  24223. @end deffn
  24224. @deftp {Data Type} earlyoom-configuration
  24225. This is the configuration record for the @code{earlyoom-service-type}.
  24226. @table @asis
  24227. @item @code{earlyoom} (default: @var{earlyoom})
  24228. The Earlyoom package to use.
  24229. @item @code{minimum-available-memory} (default: @code{10})
  24230. The threshold for the minimum @emph{available} memory, in percentages.
  24231. @item @code{minimum-free-swap} (default: @code{10})
  24232. The threshold for the minimum free swap memory, in percentages.
  24233. @item @code{prefer-regexp} (default: @code{#f})
  24234. A regular expression (as a string) to match the names of the processes
  24235. that should be preferably killed.
  24236. @item @code{avoid-regexp} (default: @code{#f})
  24237. A regular expression (as a string) to match the names of the processes
  24238. that should @emph{not} be killed.
  24239. @item @code{memory-report-interval} (default: @code{0})
  24240. The interval in seconds at which a memory report is printed. It is
  24241. disabled by default.
  24242. @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
  24243. A boolean indicating whether the positive adjustments set in
  24244. @file{/proc/*/oom_score_adj} should be ignored.
  24245. @item @code{show-debug-messages?} (default: @code{#f})
  24246. A boolean indicating whether debug messages should be printed. The logs
  24247. are saved at @file{/var/log/earlyoom.log}.
  24248. @item @code{send-notification-command} (default: @code{#f})
  24249. This can be used to provide a custom command used for sending
  24250. notifications.
  24251. @end table
  24252. @end deftp
  24253. @cindex modprobe
  24254. @cindex kernel module loader
  24255. @subsubheading Kernel Module Loader Service
  24256. The kernel module loader service allows one to load loadable kernel
  24257. modules at boot. This is especially useful for modules that don't
  24258. autoload and need to be manually loaded, as it's the case with
  24259. @code{ddcci}.
  24260. @deffn {Scheme Variable} kernel-module-loader-service-type
  24261. The service type for loading loadable kernel modules at boot with
  24262. @command{modprobe}. Its value must be a list of strings representing
  24263. module names. For example loading the drivers provided by
  24264. @code{ddcci-driver-linux}, in debugging mode by passing some module
  24265. parameters, can be done as follow:
  24266. @lisp
  24267. (use-modules (gnu) (gnu services))
  24268. (use-package-modules linux)
  24269. (use-service-modules linux)
  24270. (define ddcci-config
  24271. (plain-file "ddcci.conf"
  24272. "options ddcci dyndbg delay=120"))
  24273. (operating-system
  24274. ...
  24275. (services (cons* (service kernel-module-loader-service-type
  24276. '("ddcci" "ddcci_backlight"))
  24277. (simple-service 'ddcci-config etc-service-type
  24278. (list `("modprobe.d/ddcci.conf"
  24279. ,ddcci-config)))
  24280. %base-services))
  24281. (kernel-loadable-modules (list ddcci-driver-linux)))
  24282. @end lisp
  24283. @end deffn
  24284. @cindex zram
  24285. @cindex compressed swap
  24286. @cindex Compressed RAM-based block devices
  24287. @subsubheading Zram Device Service
  24288. The Zram device service provides a compressed swap device in system
  24289. memory. The Linux Kernel documentation has more information about
  24290. @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
  24291. devices.
  24292. @deffn {Scheme Variable} zram-device-service-type
  24293. This service creates the zram block device, formats it as swap and
  24294. enables it as a swap device. The service's value is a
  24295. @code{zram-device-configuration} record.
  24296. @deftp {Data Type} zram-device-configuration
  24297. This is the data type representing the configuration for the zram-device
  24298. service.
  24299. @table @asis
  24300. @item @code{size} (default @code{"1G"})
  24301. This is the amount of space you wish to provide for the zram device. It
  24302. accepts a string and can be a number of bytes or use a suffix, eg.:
  24303. @code{"512M"} or @code{1024000}.
  24304. @item @code{compression-algorithm} (default @code{'lzo})
  24305. This is the compression algorithm you wish to use. It is difficult to
  24306. list all the possible compression options, but common ones supported by
  24307. Guix's Linux Libre Kernel include @code{'lzo}, @code{'lz4} and @code{'zstd}.
  24308. @item @code{memory-limit} (default @code{0})
  24309. This is the maximum amount of memory which the zram device can use.
  24310. Setting it to '0' disables the limit. While it is generally expected
  24311. that compression will be 2:1, it is possible that uncompressable data
  24312. can be written to swap and this is a method to limit how much memory can
  24313. be used. It accepts a string and can be a number of bytes or use a
  24314. suffix, eg.: @code{"2G"}.
  24315. @item @code{priority} (default @code{-1})
  24316. This is the priority of the swap device created from the zram device.
  24317. @code{swapon} accepts values between -1 and 32767, with higher values
  24318. indicating higher priority. Higher priority swap will generally be used
  24319. first.
  24320. @end table
  24321. @end deftp
  24322. @end deffn
  24323. @node Hurd Services
  24324. @subsection Hurd Services
  24325. @defvr {Scheme Variable} hurd-console-service-type
  24326. This service starts the fancy @code{VGA} console client on the Hurd.
  24327. The service's value is a @code{hurd-console-configuration} record.
  24328. @end defvr
  24329. @deftp {Data Type} hurd-console-configuration
  24330. This is the data type representing the configuration for the
  24331. hurd-console-service.
  24332. @table @asis
  24333. @item @code{hurd} (default: @var{hurd})
  24334. The Hurd package to use.
  24335. @end table
  24336. @end deftp
  24337. @defvr {Scheme Variable} hurd-getty-service-type
  24338. This service starts a tty using the Hurd @code{getty} program.
  24339. The service's value is a @code{hurd-getty-configuration} record.
  24340. @end defvr
  24341. @deftp {Data Type} hurd-getty-configuration
  24342. This is the data type representing the configuration for the
  24343. hurd-getty-service.
  24344. @table @asis
  24345. @item @code{hurd} (default: @var{hurd})
  24346. The Hurd package to use.
  24347. @item @code{tty}
  24348. The name of the console this Getty runs on---e.g., @code{"tty1"}.
  24349. @item @code{baud-rate} (default: @code{38400})
  24350. An integer specifying the baud rate of the tty.
  24351. @end table
  24352. @end deftp
  24353. @node Miscellaneous Services
  24354. @subsection Miscellaneous Services
  24355. @cindex fingerprint
  24356. @subsubheading Fingerprint Service
  24357. The @code{(gnu services authentication)} module provides a DBus service to
  24358. read and identify fingerprints via a fingerprint sensor.
  24359. @defvr {Scheme Variable} fprintd-service-type
  24360. The service type for @command{fprintd}, which provides the fingerprint
  24361. reading capability.
  24362. @lisp
  24363. (service fprintd-service-type)
  24364. @end lisp
  24365. @end defvr
  24366. @cindex sysctl
  24367. @subsubheading System Control Service
  24368. The @code{(gnu services sysctl)} provides a service to configure kernel
  24369. parameters at boot.
  24370. @defvr {Scheme Variable} sysctl-service-type
  24371. The service type for @command{sysctl}, which modifies kernel parameters
  24372. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  24373. instantiated as:
  24374. @lisp
  24375. (service sysctl-service-type
  24376. (sysctl-configuration
  24377. (settings '(("net.ipv4.ip_forward" . "1")))))
  24378. @end lisp
  24379. Since @code{sysctl-service-type} is used in the default lists of
  24380. services, @code{%base-services} and @code{%desktop-services}, you can
  24381. use @code{modify-services} to change its configuration and add the
  24382. kernel parameters that you want (@pxref{Service Reference,
  24383. @code{modify-services}}).
  24384. @lisp
  24385. (modify-services %base-services
  24386. (sysctl-service-type config =>
  24387. (sysctl-configuration
  24388. (settings (append '(("net.ipv4.ip_forward" . "1"))
  24389. %default-sysctl-settings)))))
  24390. @end lisp
  24391. @end defvr
  24392. @deftp {Data Type} sysctl-configuration
  24393. The data type representing the configuration of @command{sysctl}.
  24394. @table @asis
  24395. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  24396. The @command{sysctl} executable to use.
  24397. @item @code{settings} (default: @code{%default-sysctl-settings})
  24398. An association list specifies kernel parameters and their values.
  24399. @end table
  24400. @end deftp
  24401. @defvr {Scheme Variable} %default-sysctl-settings
  24402. An association list specifying the default @command{sysctl} parameters
  24403. on Guix System.
  24404. @end defvr
  24405. @cindex pcscd
  24406. @subsubheading PC/SC Smart Card Daemon Service
  24407. The @code{(gnu services security-token)} module provides the following service
  24408. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  24409. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  24410. manager that coordinates communications with smart card readers, smart cards
  24411. and cryptographic tokens that are connected to the system.
  24412. @defvr {Scheme Variable} pcscd-service-type
  24413. Service type for the @command{pcscd} service. Its value must be a
  24414. @code{pcscd-configuration} object. To run pcscd in the default
  24415. configuration, instantiate it as:
  24416. @lisp
  24417. (service pcscd-service-type)
  24418. @end lisp
  24419. @end defvr
  24420. @deftp {Data Type} pcscd-configuration
  24421. The data type representing the configuration of @command{pcscd}.
  24422. @table @asis
  24423. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  24424. The pcsc-lite package that provides pcscd.
  24425. @item @code{usb-drivers} (default: @code{(list ccid)})
  24426. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  24427. under @file{pcsc/drivers} in the store directory of the package.
  24428. @end table
  24429. @end deftp
  24430. @cindex lirc
  24431. @subsubheading Lirc Service
  24432. The @code{(gnu services lirc)} module provides the following service.
  24433. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  24434. [#:device #f] [#:driver #f] [#:config-file #f] @
  24435. [#:extra-options '()]
  24436. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  24437. decodes infrared signals from remote controls.
  24438. Optionally, @var{device}, @var{driver} and @var{config-file}
  24439. (configuration file name) may be specified. See @command{lircd} manual
  24440. for details.
  24441. Finally, @var{extra-options} is a list of additional command-line options
  24442. passed to @command{lircd}.
  24443. @end deffn
  24444. @cindex spice
  24445. @subsubheading Spice Service
  24446. The @code{(gnu services spice)} module provides the following service.
  24447. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  24448. Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
  24449. that enables sharing the clipboard with a vm and setting the guest display
  24450. resolution when the graphical console window resizes.
  24451. @end deffn
  24452. @cindex inputattach
  24453. @subsubheading inputattach Service
  24454. @cindex tablet input, for Xorg
  24455. @cindex touchscreen input, for Xorg
  24456. The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
  24457. use input devices such as Wacom tablets, touchscreens, or joysticks with the
  24458. Xorg display server.
  24459. @deffn {Scheme Variable} inputattach-service-type
  24460. Type of a service that runs @command{inputattach} on a device and
  24461. dispatches events from it.
  24462. @end deffn
  24463. @deftp {Data Type} inputattach-configuration
  24464. @table @asis
  24465. @item @code{device-type} (default: @code{"wacom"})
  24466. The type of device to connect to. Run @command{inputattach --help}, from the
  24467. @code{inputattach} package, to see the list of supported device types.
  24468. @item @code{device} (default: @code{"/dev/ttyS0"})
  24469. The device file to connect to the device.
  24470. @item @code{baud-rate} (default: @code{#f})
  24471. Baud rate to use for the serial connection.
  24472. Should be a number or @code{#f}.
  24473. @item @code{log-file} (default: @code{#f})
  24474. If true, this must be the name of a file to log messages to.
  24475. @end table
  24476. @end deftp
  24477. @subsubheading Dictionary Service
  24478. @cindex dictionary
  24479. The @code{(gnu services dict)} module provides the following service:
  24480. @defvr {Scheme Variable} dicod-service-type
  24481. This is the type of the service that runs the @command{dicod} daemon, an
  24482. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  24483. @end defvr
  24484. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  24485. Return a service that runs the @command{dicod} daemon, an implementation
  24486. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  24487. The optional @var{config} argument specifies the configuration for
  24488. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  24489. default it serves the GNU Collaborative International Dictionary of English.
  24490. You can add @command{open localhost} to your @file{~/.dico} file to make
  24491. @code{localhost} the default server for @command{dico} client
  24492. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  24493. @end deffn
  24494. @deftp {Data Type} dicod-configuration
  24495. Data type representing the configuration of dicod.
  24496. @table @asis
  24497. @item @code{dico} (default: @var{dico})
  24498. Package object of the GNU Dico dictionary server.
  24499. @item @code{interfaces} (default: @var{'("localhost")})
  24500. This is the list of IP addresses and ports and possibly socket file
  24501. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  24502. dico, GNU Dico Manual}).
  24503. @item @code{handlers} (default: @var{'()})
  24504. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  24505. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  24506. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  24507. @end table
  24508. @end deftp
  24509. @deftp {Data Type} dicod-handler
  24510. Data type representing a dictionary handler (module instance).
  24511. @table @asis
  24512. @item @code{name}
  24513. Name of the handler (module instance).
  24514. @item @code{module} (default: @var{#f})
  24515. Name of the dicod module of the handler (instance). If it is @code{#f},
  24516. the module has the same name as the handler.
  24517. (@pxref{Modules,,, dico, GNU Dico Manual}).
  24518. @item @code{options}
  24519. List of strings or gexps representing the arguments for the module handler
  24520. @end table
  24521. @end deftp
  24522. @deftp {Data Type} dicod-database
  24523. Data type representing a dictionary database.
  24524. @table @asis
  24525. @item @code{name}
  24526. Name of the database, will be used in DICT commands.
  24527. @item @code{handler}
  24528. Name of the dicod handler (module instance) used by this database
  24529. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  24530. @item @code{complex?} (default: @var{#f})
  24531. Whether the database configuration complex. The complex configuration
  24532. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  24533. @item @code{options}
  24534. List of strings or gexps representing the arguments for the database
  24535. (@pxref{Databases,,, dico, GNU Dico Manual}).
  24536. @end table
  24537. @end deftp
  24538. @defvr {Scheme Variable} %dicod-database:gcide
  24539. A @code{<dicod-database>} object serving the GNU Collaborative International
  24540. Dictionary of English using the @code{gcide} package.
  24541. @end defvr
  24542. The following is an example @code{dicod-service} configuration.
  24543. @lisp
  24544. (dicod-service #:config
  24545. (dicod-configuration
  24546. (handlers (list (dicod-handler
  24547. (name "wordnet")
  24548. (module "dictorg")
  24549. (options
  24550. (list #~(string-append "dbdir=" #$wordnet))))))
  24551. (databases (list (dicod-database
  24552. (name "wordnet")
  24553. (complex? #t)
  24554. (handler "wordnet")
  24555. (options '("database=wn")))
  24556. %dicod-database:gcide))))
  24557. @end lisp
  24558. @cindex Docker
  24559. @subsubheading Docker Service
  24560. The @code{(gnu services docker)} module provides the following services.
  24561. @defvr {Scheme Variable} docker-service-type
  24562. This is the type of the service that runs @url{https://www.docker.com,Docker},
  24563. a daemon that can execute application bundles (sometimes referred to as
  24564. ``containers'') in isolated environments.
  24565. @end defvr
  24566. @deftp {Data Type} docker-configuration
  24567. This is the data type representing the configuration of Docker and Containerd.
  24568. @table @asis
  24569. @item @code{package} (default: @code{docker})
  24570. The Docker daemon package to use.
  24571. @item @code{package} (default: @code{docker-cli})
  24572. The Docker client package to use.
  24573. @item @code{containerd} (default: @var{containerd})
  24574. The Containerd package to use.
  24575. @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
  24576. The Docker user-land networking proxy package to use.
  24577. @item @code{enable-proxy?} (default @code{#t})
  24578. Enable or disable the use of the Docker user-land networking proxy.
  24579. @item @code{debug?} (default @code{#f})
  24580. Enable or disable debug output.
  24581. @item @code{enable-iptables?} (default @code{#t})
  24582. Enable or disable the addition of iptables rules.
  24583. @end table
  24584. @end deftp
  24585. @cindex Singularity, container service
  24586. @defvr {Scheme Variable} singularity-service-type
  24587. This is the type of the service that allows you to run
  24588. @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
  24589. create and run application bundles (aka. ``containers''). The value for this
  24590. service is the Singularity package to use.
  24591. The service does not install a daemon; instead, it installs helper programs as
  24592. setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
  24593. @command{singularity run} and similar commands.
  24594. @end defvr
  24595. @cindex Audit
  24596. @subsubheading Auditd Service
  24597. The @code{(gnu services auditd)} module provides the following service.
  24598. @defvr {Scheme Variable} auditd-service-type
  24599. This is the type of the service that runs
  24600. @url{https://people.redhat.com/sgrubb/audit/,auditd},
  24601. a daemon that tracks security-relevant information on your system.
  24602. Examples of things that can be tracked:
  24603. @enumerate
  24604. @item
  24605. File accesses
  24606. @item
  24607. System calls
  24608. @item
  24609. Invoked commands
  24610. @item
  24611. Failed login attempts
  24612. @item
  24613. Firewall filtering
  24614. @item
  24615. Network access
  24616. @end enumerate
  24617. @command{auditctl} from the @code{audit} package can be used in order
  24618. to add or remove events to be tracked (until the next reboot).
  24619. In order to permanently track events, put the command line arguments
  24620. of auditctl into a file called @code{audit.rules} in the configuration
  24621. directory (see below).
  24622. @command{aureport} from the @code{audit} package can be used in order
  24623. to view a report of all recorded events.
  24624. The audit daemon by default logs into the file
  24625. @file{/var/log/audit.log}.
  24626. @end defvr
  24627. @deftp {Data Type} auditd-configuration
  24628. This is the data type representing the configuration of auditd.
  24629. @table @asis
  24630. @item @code{audit} (default: @code{audit})
  24631. The audit package to use.
  24632. @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
  24633. The directory containing the configuration file for the audit package, which
  24634. must be named @code{auditd.conf}, and optionally some audit rules to
  24635. instantiate on startup.
  24636. @end table
  24637. @end deftp
  24638. @cindex rshiny
  24639. @subsubheading R-Shiny service
  24640. The @code{(gnu services science)} module provides the following service.
  24641. @defvr {Scheme Variable} rshiny-service-type
  24642. This is a type of service which is used to run a webapp created with
  24643. @code{r-shiny}. This service sets the @env{R_LIBS_USER} environment
  24644. variable and runs the provided script to call @code{runApp}.
  24645. @deftp {Data Type} rshiny-configuration
  24646. This is the data type representing the configuration of rshiny.
  24647. @table @asis
  24648. @item @code{package} (default: @code{r-shiny})
  24649. The package to use.
  24650. @item @code{binary} (defaunlt @code{"rshiny"})
  24651. The name of the binary or shell script located at @code{package/bin/} to
  24652. run when the service is run.
  24653. The common way to create this file is as follows:
  24654. @lisp
  24655. @dots{}
  24656. (let* ((out (assoc-ref %outputs "out"))
  24657. (targetdir (string-append out "/share/" ,name))
  24658. (app (string-append out "/bin/" ,name))
  24659. (Rbin (string-append (assoc-ref %build-inputs "r-min")
  24660. "/bin/Rscript")))
  24661. ;; @dots{}
  24662. (mkdir-p (string-append out "/bin"))
  24663. (call-with-output-file app
  24664. (lambda (port)
  24665. (format port
  24666. "#!~a
  24667. library(shiny)
  24668. setwd(\"~a\")
  24669. runApp(launch.browser=0, port=4202)~%\n"
  24670. Rbin targetdir))))
  24671. @end lisp
  24672. @end table
  24673. @end deftp
  24674. @end defvr
  24675. @cindex Nix
  24676. @subsubheading Nix service
  24677. The @code{(gnu services nix)} module provides the following service.
  24678. @defvr {Scheme Variable} nix-service-type
  24679. This is the type of the service that runs build daemon of the
  24680. @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
  24681. how to use it:
  24682. @lisp
  24683. (use-modules (gnu))
  24684. (use-service-modules nix)
  24685. (use-package-modules package-management)
  24686. (operating-system
  24687. ;; @dots{}
  24688. (packages (append (list nix)
  24689. %base-packages))
  24690. (services (append (list (service nix-service-type))
  24691. %base-services)))
  24692. @end lisp
  24693. After @command{guix system reconfigure} configure Nix for your user:
  24694. @itemize
  24695. @item Add a Nix channel and update it. See
  24696. @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
  24697. @item Create a symlink to your profile and activate Nix profile:
  24698. @end itemize
  24699. @example
  24700. $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
  24701. $ source /run/current-system/profile/etc/profile.d/nix.sh
  24702. @end example
  24703. @end defvr
  24704. @deftp {Data Type} nix-configuration
  24705. This data type represents the configuration of the Nix daemon.
  24706. @table @asis
  24707. @item @code{nix} (default: @code{nix})
  24708. The Nix package to use.
  24709. @item @code{sandbox} (default: @code{#t})
  24710. Specifies whether builds are sandboxed by default.
  24711. @item @code{build-sandbox-items} (default: @code{'()})
  24712. This is a list of strings or objects appended to the
  24713. @code{build-sandbox-items} field of the configuration file.
  24714. @item @code{extra-config} (default: @code{'()})
  24715. This is a list of strings or objects appended to the configuration file.
  24716. It is used to pass extra text to be added verbatim to the configuration
  24717. file.
  24718. @item @code{extra-options} (default: @code{'()})
  24719. Extra command line options for @code{nix-service-type}.
  24720. @end table
  24721. @end deftp
  24722. @node Setuid Programs
  24723. @section Setuid Programs
  24724. @cindex setuid programs
  24725. Some programs need to run with ``root'' privileges, even when they are
  24726. launched by unprivileged users. A notorious example is the
  24727. @command{passwd} program, which users can run to change their
  24728. password, and which needs to access the @file{/etc/passwd} and
  24729. @file{/etc/shadow} files---something normally restricted to root, for
  24730. obvious security reasons. To address that, these executables are
  24731. @dfn{setuid-root}, meaning that they always run with root privileges
  24732. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  24733. for more info about the setuid mechanism).
  24734. The store itself @emph{cannot} contain setuid programs: that would be a
  24735. security issue since any user on the system can write derivations that
  24736. populate the store (@pxref{The Store}). Thus, a different mechanism is
  24737. used: instead of changing the setuid bit directly on files that are in
  24738. the store, we let the system administrator @emph{declare} which programs
  24739. should be setuid root.
  24740. The @code{setuid-programs} field of an @code{operating-system}
  24741. declaration contains a list of G-expressions denoting the names of
  24742. programs to be setuid-root (@pxref{Using the Configuration System}).
  24743. For instance, the @command{passwd} program, which is part of the Shadow
  24744. package, can be designated by this G-expression (@pxref{G-Expressions}):
  24745. @example
  24746. #~(string-append #$shadow "/bin/passwd")
  24747. @end example
  24748. A default set of setuid programs is defined by the
  24749. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  24750. @defvr {Scheme Variable} %setuid-programs
  24751. A list of G-expressions denoting common programs that are setuid-root.
  24752. The list includes commands such as @command{passwd}, @command{ping},
  24753. @command{su}, and @command{sudo}.
  24754. @end defvr
  24755. Under the hood, the actual setuid programs are created in the
  24756. @file{/run/setuid-programs} directory at system activation time. The
  24757. files in this directory refer to the ``real'' binaries, which are in the
  24758. store.
  24759. @node X.509 Certificates
  24760. @section X.509 Certificates
  24761. @cindex HTTPS, certificates
  24762. @cindex X.509 certificates
  24763. @cindex TLS
  24764. Web servers available over HTTPS (that is, HTTP over the transport-layer
  24765. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  24766. that the client can then use to @emph{authenticate} the server. To do
  24767. that, clients verify that the server's certificate is signed by a
  24768. so-called @dfn{certificate authority} (CA). But to verify the CA's
  24769. signature, clients must have first acquired the CA's certificate.
  24770. Web browsers such as GNU@tie{}IceCat include their own set of CA
  24771. certificates, such that they are able to verify CA signatures
  24772. out-of-the-box.
  24773. However, most other programs that can talk HTTPS---@command{wget},
  24774. @command{git}, @command{w3m}, etc.---need to be told where CA
  24775. certificates can be found.
  24776. @cindex @code{nss-certs}
  24777. In Guix, this is done by adding a package that provides certificates
  24778. to the @code{packages} field of the @code{operating-system} declaration
  24779. (@pxref{operating-system Reference}). Guix includes one such package,
  24780. @code{nss-certs}, which is a set of CA certificates provided as part of
  24781. Mozilla's Network Security Services.
  24782. Note that it is @emph{not} part of @code{%base-packages}, so you need to
  24783. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  24784. most applications and libraries look for certificates by default, points
  24785. to the certificates installed globally.
  24786. Unprivileged users, including users of Guix on a foreign distro,
  24787. can also install their own certificate package in
  24788. their profile. A number of environment variables need to be defined so
  24789. that applications and libraries know where to find them. Namely, the
  24790. OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
  24791. variables. Some applications add their own environment variables; for
  24792. instance, the Git version control system honors the certificate bundle
  24793. pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
  24794. would typically run something like:
  24795. @example
  24796. guix install nss-certs
  24797. export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  24798. export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  24799. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  24800. @end example
  24801. As another example, R requires the @env{CURL_CA_BUNDLE} environment
  24802. variable to point to a certificate bundle, so you would have to run
  24803. something like this:
  24804. @example
  24805. guix install nss-certs
  24806. export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  24807. @end example
  24808. For other applications you may want to look up the required environment
  24809. variable in the relevant documentation.
  24810. @node Name Service Switch
  24811. @section Name Service Switch
  24812. @cindex name service switch
  24813. @cindex NSS
  24814. The @code{(gnu system nss)} module provides bindings to the
  24815. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  24816. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  24817. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  24818. extended with new ``name'' lookup methods for system databases, which
  24819. includes host names, service names, user accounts, and more (@pxref{Name
  24820. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  24821. C Library Reference Manual}).
  24822. The NSS configuration specifies, for each system database, which lookup
  24823. method is to be used, and how the various methods are chained
  24824. together---for instance, under which circumstances NSS should try the
  24825. next method in the list. The NSS configuration is given in the
  24826. @code{name-service-switch} field of @code{operating-system} declarations
  24827. (@pxref{operating-system Reference, @code{name-service-switch}}).
  24828. @cindex nss-mdns
  24829. @cindex .local, host name lookup
  24830. As an example, the declaration below configures the NSS to use the
  24831. @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  24832. back-end}, which supports host name lookups over multicast DNS (mDNS)
  24833. for host names ending in @code{.local}:
  24834. @lisp
  24835. (name-service-switch
  24836. (hosts (list %files ;first, check /etc/hosts
  24837. ;; If the above did not succeed, try
  24838. ;; with 'mdns_minimal'.
  24839. (name-service
  24840. (name "mdns_minimal")
  24841. ;; 'mdns_minimal' is authoritative for
  24842. ;; '.local'. When it returns "not found",
  24843. ;; no need to try the next methods.
  24844. (reaction (lookup-specification
  24845. (not-found => return))))
  24846. ;; Then fall back to DNS.
  24847. (name-service
  24848. (name "dns"))
  24849. ;; Finally, try with the "full" 'mdns'.
  24850. (name-service
  24851. (name "mdns")))))
  24852. @end lisp
  24853. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  24854. contains this configuration, so you will not have to type it if all you
  24855. want is to have @code{.local} host lookup working.
  24856. Note that, in this case, in addition to setting the
  24857. @code{name-service-switch} of the @code{operating-system} declaration,
  24858. you also need to use @code{avahi-service-type} (@pxref{Networking Services,
  24859. @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
  24860. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  24861. to the name service cache daemon (@pxref{Base Services,
  24862. @code{nscd-service}}).
  24863. For convenience, the following variables provide typical NSS
  24864. configurations.
  24865. @defvr {Scheme Variable} %default-nss
  24866. This is the default name service switch configuration, a
  24867. @code{name-service-switch} object.
  24868. @end defvr
  24869. @defvr {Scheme Variable} %mdns-host-lookup-nss
  24870. This is the name service switch configuration with support for host name
  24871. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  24872. @end defvr
  24873. The reference for name service switch configuration is given below. It
  24874. is a direct mapping of the configuration file format of the C library , so
  24875. please refer to the C library manual for more information (@pxref{NSS
  24876. Configuration File,,, libc, The GNU C Library Reference Manual}).
  24877. Compared to the configuration file format of libc NSS, it has the advantage
  24878. not only of adding this warm parenthetic feel that we like, but also
  24879. static checks: you will know about syntax errors and typos as soon as you
  24880. run @command{guix system}.
  24881. @deftp {Data Type} name-service-switch
  24882. This is the data type representation the configuration of libc's name
  24883. service switch (NSS). Each field below represents one of the supported
  24884. system databases.
  24885. @table @code
  24886. @item aliases
  24887. @itemx ethers
  24888. @itemx group
  24889. @itemx gshadow
  24890. @itemx hosts
  24891. @itemx initgroups
  24892. @itemx netgroup
  24893. @itemx networks
  24894. @itemx password
  24895. @itemx public-key
  24896. @itemx rpc
  24897. @itemx services
  24898. @itemx shadow
  24899. The system databases handled by the NSS@. Each of these fields must be a
  24900. list of @code{<name-service>} objects (see below).
  24901. @end table
  24902. @end deftp
  24903. @deftp {Data Type} name-service
  24904. This is the data type representing an actual name service and the
  24905. associated lookup action.
  24906. @table @code
  24907. @item name
  24908. A string denoting the name service (@pxref{Services in the NSS
  24909. configuration,,, libc, The GNU C Library Reference Manual}).
  24910. Note that name services listed here must be visible to nscd. This is
  24911. achieved by passing the @code{#:name-services} argument to
  24912. @code{nscd-service} the list of packages providing the needed name
  24913. services (@pxref{Base Services, @code{nscd-service}}).
  24914. @item reaction
  24915. An action specified using the @code{lookup-specification} macro
  24916. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  24917. Reference Manual}). For example:
  24918. @lisp
  24919. (lookup-specification (unavailable => continue)
  24920. (success => return))
  24921. @end lisp
  24922. @end table
  24923. @end deftp
  24924. @node Initial RAM Disk
  24925. @section Initial RAM Disk
  24926. @cindex initrd
  24927. @cindex initial RAM disk
  24928. For bootstrapping purposes, the Linux-Libre kernel is passed an
  24929. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  24930. root file system as well as an initialization script. The latter is
  24931. responsible for mounting the real root file system, and for loading any
  24932. kernel modules that may be needed to achieve that.
  24933. The @code{initrd-modules} field of an @code{operating-system}
  24934. declaration allows you to specify Linux-libre kernel modules that must
  24935. be available in the initrd. In particular, this is where you would list
  24936. modules needed to actually drive the hard disk where your root partition
  24937. is---although the default value of @code{initrd-modules} should cover
  24938. most use cases. For example, assuming you need the @code{megaraid_sas}
  24939. module in addition to the default modules to be able to access your root
  24940. file system, you would write:
  24941. @lisp
  24942. (operating-system
  24943. ;; @dots{}
  24944. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  24945. @end lisp
  24946. @defvr {Scheme Variable} %base-initrd-modules
  24947. This is the list of kernel modules included in the initrd by default.
  24948. @end defvr
  24949. Furthermore, if you need lower-level customization, the @code{initrd}
  24950. field of an @code{operating-system} declaration allows
  24951. you to specify which initrd you would like to use. The @code{(gnu
  24952. system linux-initrd)} module provides three ways to build an initrd: the
  24953. high-level @code{base-initrd} procedure and the low-level
  24954. @code{raw-initrd} and @code{expression->initrd} procedures.
  24955. The @code{base-initrd} procedure is intended to cover most common uses.
  24956. For example, if you want to add a bunch of kernel modules to be loaded
  24957. at boot time, you can define the @code{initrd} field of the operating
  24958. system declaration like this:
  24959. @lisp
  24960. (initrd (lambda (file-systems . rest)
  24961. ;; Create a standard initrd but set up networking
  24962. ;; with the parameters QEMU expects by default.
  24963. (apply base-initrd file-systems
  24964. #:qemu-networking? #t
  24965. rest)))
  24966. @end lisp
  24967. The @code{base-initrd} procedure also handles common use cases that
  24968. involves using the system as a QEMU guest, or as a ``live'' system with
  24969. volatile root file system.
  24970. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  24971. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  24972. such as trying to guess which kernel modules and packages should be included
  24973. to the initrd. An example use of @code{raw-initrd} is when a user has
  24974. a custom Linux kernel configuration and default kernel modules included by
  24975. @code{base-initrd} are not available.
  24976. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  24977. honors several options passed on the Linux kernel command line
  24978. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  24979. @code{-append} option of QEMU), notably:
  24980. @table @code
  24981. @item --load=@var{boot}
  24982. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  24983. program, once it has mounted the root file system.
  24984. Guix uses this option to yield control to a boot program that runs the
  24985. service activation programs and then spawns the GNU@tie{}Shepherd, the
  24986. initialization system.
  24987. @item --root=@var{root}
  24988. Mount @var{root} as the root file system. @var{root} can be a device
  24989. name like @code{/dev/sda1}, a file system label, or a file system UUID.
  24990. When unspecified, the device name from the root file system of the
  24991. operating system declaration is used.
  24992. @item --system=@var{system}
  24993. Have @file{/run/booted-system} and @file{/run/current-system} point to
  24994. @var{system}.
  24995. @item modprobe.blacklist=@var{modules}@dots{}
  24996. @cindex module, black-listing
  24997. @cindex black list, of kernel modules
  24998. Instruct the initial RAM disk as well as the @command{modprobe} command
  24999. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  25000. must be a comma-separated list of module names---e.g.,
  25001. @code{usbkbd,9pnet}.
  25002. @item --repl
  25003. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  25004. tries to load kernel modules and to mount the root file system. Our
  25005. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  25006. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  25007. Manual}, for more information on Guile's REPL.
  25008. @end table
  25009. Now that you know all the features that initial RAM disks produced by
  25010. @code{base-initrd} and @code{raw-initrd} provide,
  25011. here is how to use it and customize it further.
  25012. @cindex initrd
  25013. @cindex initial RAM disk
  25014. @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
  25015. [#:linux-modules '()] [#:mapped-devices '()] @
  25016. [#:keyboard-layout #f] @
  25017. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  25018. Return a derivation that builds a raw initrd. @var{file-systems} is
  25019. a list of file systems to be mounted by the initrd, possibly in addition to
  25020. the root file system specified on the kernel command line via @option{--root}.
  25021. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  25022. @var{mapped-devices} is a list of device mappings to realize before
  25023. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  25024. @var{helper-packages} is a list of packages to be copied in the initrd.
  25025. It may
  25026. include @code{e2fsck/static} or other packages needed by the initrd to check
  25027. the root file system.
  25028. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  25029. the desired console keyboard layout. This is done before @var{mapped-devices}
  25030. are set up and before @var{file-systems} are mounted such that, should the
  25031. user need to enter a passphrase or use the REPL, this happens using the
  25032. intended keyboard layout.
  25033. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  25034. parameters. When @var{virtio?} is true, load additional modules so that the
  25035. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  25036. When @var{volatile-root?} is true, the root file system is writable but any changes
  25037. to it are lost.
  25038. @end deffn
  25039. @deffn {Scheme Procedure} base-initrd @var{file-systems} @
  25040. [#:mapped-devices '()] [#:keyboard-layout #f] @
  25041. [#:qemu-networking? #f] [#:volatile-root? #f] @
  25042. [#:linux-modules '()]
  25043. Return as a file-like object a generic initrd, with kernel
  25044. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  25045. mounted by the initrd, possibly in addition to the root file system specified
  25046. on the kernel command line via @option{--root}. @var{mapped-devices} is a list of device
  25047. mappings to realize before @var{file-systems} are mounted.
  25048. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  25049. the desired console keyboard layout. This is done before @var{mapped-devices}
  25050. are set up and before @var{file-systems} are mounted such that, should the
  25051. user need to enter a passphrase or use the REPL, this happens using the
  25052. intended keyboard layout.
  25053. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  25054. The initrd is automatically populated with all the kernel modules necessary
  25055. for @var{file-systems} and for the given options. Additional kernel
  25056. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  25057. loaded at boot time in the order in which they appear.
  25058. @end deffn
  25059. Needless to say, the initrds we produce and use embed a
  25060. statically-linked Guile, and the initialization program is a Guile
  25061. program. That gives a lot of flexibility. The
  25062. @code{expression->initrd} procedure builds such an initrd, given the
  25063. program to run in that initrd.
  25064. @deffn {Scheme Procedure} expression->initrd @var{exp} @
  25065. [#:guile %guile-3.0-static-stripped] [#:name "guile-initrd"]
  25066. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  25067. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  25068. upon booting. All the derivations referenced by @var{exp} are
  25069. automatically copied to the initrd.
  25070. @end deffn
  25071. @node Bootloader Configuration
  25072. @section Bootloader Configuration
  25073. @cindex bootloader
  25074. @cindex boot loader
  25075. The operating system supports multiple bootloaders. The bootloader is
  25076. configured using @code{bootloader-configuration} declaration. All the
  25077. fields of this structure are bootloader agnostic except for one field,
  25078. @code{bootloader} that indicates the bootloader to be configured and
  25079. installed.
  25080. Some of the bootloaders do not honor every field of
  25081. @code{bootloader-configuration}. For instance, the extlinux
  25082. bootloader does not support themes and thus ignores the @code{theme}
  25083. field.
  25084. @deftp {Data Type} bootloader-configuration
  25085. The type of a bootloader configuration declaration.
  25086. @table @asis
  25087. @item @code{bootloader}
  25088. @cindex EFI, bootloader
  25089. @cindex UEFI, bootloader
  25090. @cindex BIOS, bootloader
  25091. The bootloader to use, as a @code{bootloader} object. For now
  25092. @code{grub-bootloader}, @code{grub-efi-bootloader},
  25093. @code{grub-efi-netboot-bootloader}, @code{extlinux-bootloader} and
  25094. @code{u-boot-bootloader} are supported.
  25095. @cindex ARM, bootloaders
  25096. @cindex AArch64, bootloaders
  25097. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  25098. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  25099. of bootloaders for a wide range of ARM and AArch64 systems, using the
  25100. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  25101. @vindex grub-efi-bootloader
  25102. @code{grub-efi-bootloader} allows to boot on modern systems using the
  25103. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  25104. use if the installation image contains a @file{/sys/firmware/efi} directory
  25105. when you boot it on your system.
  25106. @vindex grub-bootloader
  25107. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  25108. in ``legacy'' BIOS mode.
  25109. @vindex grub-efi-netboot-bootloader
  25110. @code{grub-efi-netboot-bootloader} allows you to boot your system over network
  25111. through TFTP@. In combination with an NFS root file system this allows you to
  25112. build a diskless Guix system.
  25113. The installation of the @code{grub-efi-netboot-bootloader} generates the content
  25114. of the TFTP root directory at @code{target}
  25115. (@pxref{Bootloader Configuration, @code{target}}), to be served by a TFTP server.
  25116. You may want to mount your TFTP server directory onto @code{target} to move the
  25117. required files to the TFTP server automatically.
  25118. If you plan to use an NFS root file system as well (actually if you mount the
  25119. store from an NFS share), then the TFTP server needs to serve the file
  25120. @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
  25121. image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
  25122. initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
  25123. files from the store will be accessed by GRUB through TFTP with their normal
  25124. store path, for example as
  25125. @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
  25126. Two symlinks are created to make this possible. The first symlink is
  25127. @code{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
  25128. @file{../../../boot/grub/grub.cfg},
  25129. where @code{target} may be @file{/boot}. In this case the link is not leaving
  25130. the served TFTP root directory, but otherwise it does. The second link is
  25131. @code{target}@file{/gnu/store} and points to @file{../gnu/store}. This link
  25132. is leaving the served TFTP root directory.
  25133. The assumption behind all this is that you have an NFS server exporting the root
  25134. file system for your Guix system, and additionally a TFTP server exporting your
  25135. @code{target} directory—usually @file{/boot}—from that same root file system for
  25136. your Guix system. In this constellation the symlinks will work.
  25137. For other constellations you will have to program your own bootloader installer,
  25138. which then takes care to make necessary files from the store accessible through
  25139. TFTP, for example by copying them into the TFTP root directory at @code{target}.
  25140. It is important to note that symlinks pointing outside the TFTP root directory
  25141. may need to be allowed in the configuration of your TFTP server. Further the
  25142. store link exposes the whole store through TFTP@. Both points need to be
  25143. considered carefully for security aspects.
  25144. Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
  25145. NFS servers, you also need a properly configured DHCP server to make the booting
  25146. over netboot possible. For all this we can currently only recommend you to look
  25147. for instructions about @acronym{PXE, Preboot eXecution Environment}.
  25148. @item @code{target}
  25149. This is a string denoting the target onto which to install the
  25150. bootloader.
  25151. The interpretation depends on the bootloader in question. For
  25152. @code{grub-bootloader}, for example, it should be a device name understood by
  25153. the bootloader @command{installer} command, such as @code{/dev/sda} or
  25154. @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
  25155. @code{grub-efi-bootloader}, it should be the mount point of the EFI file
  25156. system, usually @file{/boot/efi}. For @code{grub-efi-netboot-bootloader},
  25157. @code{target} should be the mount point corresponding to the TFTP root
  25158. directory of your TFTP server.
  25159. @item @code{menu-entries} (default: @code{()})
  25160. A possibly empty list of @code{menu-entry} objects (see below), denoting
  25161. entries to appear in the bootloader menu, in addition to the current
  25162. system entry and the entry pointing to previous system generations.
  25163. @item @code{default-entry} (default: @code{0})
  25164. The index of the default boot menu entry. Index 0 is for the entry of the
  25165. current system.
  25166. @item @code{timeout} (default: @code{5})
  25167. The number of seconds to wait for keyboard input before booting. Set to
  25168. 0 to boot immediately, and to -1 to wait indefinitely.
  25169. @cindex keyboard layout, for the bootloader
  25170. @item @code{keyboard-layout} (default: @code{#f})
  25171. If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
  25172. layout, usually US@tie{}English (``qwerty'').
  25173. Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
  25174. Layout}).
  25175. @quotation Note
  25176. This option is currently ignored by bootloaders other than @code{grub} and
  25177. @code{grub-efi}.
  25178. @end quotation
  25179. @item @code{theme} (default: @var{#f})
  25180. The bootloader theme object describing the theme to use. If no theme
  25181. is provided, some bootloaders might use a default theme, that's true
  25182. for GRUB.
  25183. @item @code{terminal-outputs} (default: @code{'(gfxterm)})
  25184. The output terminals used for the bootloader boot menu, as a list of
  25185. symbols. GRUB accepts the values: @code{console}, @code{serial},
  25186. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  25187. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  25188. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  25189. configuration,,, grub,GNU GRUB manual}).
  25190. @item @code{terminal-inputs} (default: @code{'()})
  25191. The input terminals used for the bootloader boot menu, as a list of
  25192. symbols. For GRUB, the default is the native platform terminal as
  25193. determined at run-time. GRUB accepts the values: @code{console},
  25194. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  25195. @code{usb_keyboard}. This field corresponds to the GRUB variable
  25196. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  25197. manual}).
  25198. @item @code{serial-unit} (default: @code{#f})
  25199. The serial unit used by the bootloader, as an integer from 0 to 3.
  25200. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  25201. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  25202. @item @code{serial-speed} (default: @code{#f})
  25203. The speed of the serial interface, as an integer. For GRUB, the
  25204. default value is chosen at run-time; currently GRUB chooses
  25205. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  25206. @end table
  25207. @end deftp
  25208. @cindex dual boot
  25209. @cindex boot menu
  25210. Should you want to list additional boot menu entries @i{via} the
  25211. @code{menu-entries} field above, you will need to create them with the
  25212. @code{menu-entry} form. For example, imagine you want to be able to
  25213. boot another distro (hard to imagine!), you can define a menu entry
  25214. along these lines:
  25215. @lisp
  25216. (menu-entry
  25217. (label "The Other Distro")
  25218. (linux "/boot/old/vmlinux-2.6.32")
  25219. (linux-arguments '("root=/dev/sda2"))
  25220. (initrd "/boot/old/initrd"))
  25221. @end lisp
  25222. Details below.
  25223. @deftp {Data Type} menu-entry
  25224. The type of an entry in the bootloader menu.
  25225. @table @asis
  25226. @item @code{label}
  25227. The label to show in the menu---e.g., @code{"GNU"}.
  25228. @item @code{linux} (default: @code{#f})
  25229. The Linux kernel image to boot, for example:
  25230. @lisp
  25231. (file-append linux-libre "/bzImage")
  25232. @end lisp
  25233. For GRUB, it is also possible to specify a device explicitly in the
  25234. file path using GRUB's device naming convention (@pxref{Naming
  25235. convention,,, grub, GNU GRUB manual}), for example:
  25236. @example
  25237. "(hd0,msdos1)/boot/vmlinuz"
  25238. @end example
  25239. If the device is specified explicitly as above, then the @code{device}
  25240. field is ignored entirely.
  25241. @item @code{linux-arguments} (default: @code{()})
  25242. The list of extra Linux kernel command-line arguments---e.g.,
  25243. @code{("console=ttyS0")}.
  25244. @item @code{initrd} (default: @code{#f})
  25245. A G-Expression or string denoting the file name of the initial RAM disk
  25246. to use (@pxref{G-Expressions}).
  25247. @item @code{device} (default: @code{#f})
  25248. The device where the kernel and initrd are to be found---i.e., for GRUB,
  25249. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  25250. This may be a file system label (a string), a file system UUID (a
  25251. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  25252. the bootloader will search the device containing the file specified by
  25253. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  25254. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  25255. @item @code{multiboot-kernel} (default: @code{#f})
  25256. The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
  25257. manual}). When this field is set, a Multiboot menu-entry is generated.
  25258. For example:
  25259. @lisp
  25260. (file-append mach "/boot/gnumach")
  25261. @end lisp
  25262. @item @code{multiboot-arguments} (default: @code{()})
  25263. The list of extra command-line arguments for the multiboot-kernel.
  25264. @item @code{multiboot-modules} (default: @code{()})
  25265. The list of commands for loading Multiboot modules. For example:
  25266. @lisp
  25267. (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
  25268. @dots{})
  25269. (list (file-append libc "/lib/ld.so.1") "exec"
  25270. @dots{}))
  25271. @end lisp
  25272. @end table
  25273. @end deftp
  25274. @cindex HDPI
  25275. @cindex HiDPI
  25276. @cindex resolution
  25277. @c FIXME: Write documentation once it's stable.
  25278. For now only GRUB has theme support. GRUB themes are created using
  25279. the @code{grub-theme} form, which is not fully documented yet.
  25280. @deftp {Data Type} grub-theme
  25281. Data type representing the configuration of the GRUB theme.
  25282. @table @asis
  25283. @item @code{gfxmode} (default: @code{'("auto")})
  25284. The GRUB @code{gfxmode} to set (a list of screen resolution strings,
  25285. @pxref{gfxmode,,, grub, GNU GRUB manual}).
  25286. @end table
  25287. @end deftp
  25288. @deffn {Scheme Procedure} grub-theme
  25289. Return the default GRUB theme used by the operating system if no
  25290. @code{theme} field is specified in @code{bootloader-configuration}
  25291. record.
  25292. It comes with a fancy background image displaying the GNU and Guix
  25293. logos.
  25294. @end deffn
  25295. For example, to override the default resolution, you may use something
  25296. like
  25297. @lisp
  25298. (bootloader
  25299. (bootloader-configuration
  25300. ;; @dots{}
  25301. (theme (grub-theme
  25302. (inherit (grub-theme))
  25303. (gfxmode '("1024x786x32" "auto"))))))
  25304. @end lisp
  25305. @node Invoking guix system
  25306. @section Invoking @code{guix system}
  25307. Once you have written an operating system declaration as seen in the
  25308. previous section, it can be @dfn{instantiated} using the @command{guix
  25309. system} command. The synopsis is:
  25310. @example
  25311. guix system @var{options}@dots{} @var{action} @var{file}
  25312. @end example
  25313. @var{file} must be the name of a file containing an
  25314. @code{operating-system} declaration. @var{action} specifies how the
  25315. operating system is instantiated. Currently the following values are
  25316. supported:
  25317. @table @code
  25318. @item search
  25319. Display available service type definitions that match the given regular
  25320. expressions, sorted by relevance:
  25321. @cindex HDPI
  25322. @cindex HiDPI
  25323. @cindex resolution
  25324. @example
  25325. $ guix system search console
  25326. name: console-fonts
  25327. location: gnu/services/base.scm:806:2
  25328. extends: shepherd-root
  25329. description: Install the given fonts on the specified ttys (fonts are per
  25330. + virtual console on GNU/Linux). The value of this service is a list of
  25331. + tty/font pairs. The font can be the name of a font provided by the `kbd'
  25332. + package or any valid argument to `setfont', as in this example:
  25333. +
  25334. + '(("tty1" . "LatGrkCyr-8x16")
  25335. + ("tty2" . (file-append
  25336. + font-tamzen
  25337. + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  25338. + ("tty3" . (file-append
  25339. + font-terminus
  25340. + "/share/consolefonts/ter-132n"))) ; for HDPI
  25341. relevance: 9
  25342. name: mingetty
  25343. location: gnu/services/base.scm:1190:2
  25344. extends: shepherd-root
  25345. description: Provide console login using the `mingetty' program.
  25346. relevance: 2
  25347. name: login
  25348. location: gnu/services/base.scm:860:2
  25349. extends: pam
  25350. description: Provide a console log-in service as specified by its
  25351. + configuration value, a `login-configuration' object.
  25352. relevance: 2
  25353. @dots{}
  25354. @end example
  25355. As for @command{guix package --search}, the result is written in
  25356. @code{recutils} format, which makes it easy to filter the output
  25357. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  25358. @item reconfigure
  25359. Build the operating system described in @var{file}, activate it, and
  25360. switch to it@footnote{This action (and the related actions
  25361. @code{switch-generation} and @code{roll-back}) are usable only on
  25362. systems already running Guix System.}.
  25363. @quotation Note
  25364. @c The paragraph below refers to the problem discussed at
  25365. @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  25366. It is highly recommended to run @command{guix pull} once before you run
  25367. @command{guix system reconfigure} for the first time (@pxref{Invoking
  25368. guix pull}). Failing to do that you would see an older version of Guix
  25369. once @command{reconfigure} has completed.
  25370. @end quotation
  25371. This effects all the configuration specified in @var{file}: user
  25372. accounts, system services, global package list, setuid programs, etc.
  25373. The command starts system services specified in @var{file} that are not
  25374. currently running; if a service is currently running this command will
  25375. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  25376. @code{herd stop X} or @code{herd restart X}).
  25377. This command creates a new generation whose number is one greater than
  25378. the current generation (as reported by @command{guix system
  25379. list-generations}). If that generation already exists, it will be
  25380. overwritten. This behavior mirrors that of @command{guix package}
  25381. (@pxref{Invoking guix package}).
  25382. It also adds a bootloader menu entry for the new OS configuration,
  25383. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  25384. entries for older configurations to a submenu, allowing you to choose
  25385. an older system generation at boot time should you need it.
  25386. @cindex provenance tracking, of the operating system
  25387. Upon completion, the new system is deployed under
  25388. @file{/run/current-system}. This directory contains @dfn{provenance
  25389. meta-data}: the list of channels in use (@pxref{Channels}) and
  25390. @var{file} itself, when available. You can view it by running:
  25391. @example
  25392. guix system describe
  25393. @end example
  25394. This information is useful should you later want to inspect how this
  25395. particular generation was built. In fact, assuming @var{file} is
  25396. self-contained, you can later rebuild generation @var{n} of your
  25397. operating system with:
  25398. @example
  25399. guix time-machine \
  25400. -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
  25401. system reconfigure \
  25402. /var/guix/profiles/system-@var{n}-link/configuration.scm
  25403. @end example
  25404. You can think of it as some sort of built-in version control! Your
  25405. system is not just a binary artifact: @emph{it carries its own source}.
  25406. @xref{Service Reference, @code{provenance-service-type}}, for more
  25407. information on provenance tracking.
  25408. By default, @command{reconfigure} @emph{prevents you from downgrading
  25409. your system}, which could (re)introduce security vulnerabilities and
  25410. also cause problems with ``stateful'' services such as database
  25411. management systems. You can override that behavior by passing
  25412. @option{--allow-downgrades}.
  25413. @item switch-generation
  25414. @cindex generations
  25415. Switch to an existing system generation. This action atomically
  25416. switches the system profile to the specified system generation. It
  25417. also rearranges the system's existing bootloader menu entries. It
  25418. makes the menu entry for the specified system generation the default,
  25419. and it moves the entries for the other generations to a submenu, if
  25420. supported by the bootloader being used. The next time the system
  25421. boots, it will use the specified system generation.
  25422. The bootloader itself is not being reinstalled when using this
  25423. command. Thus, the installed bootloader is used with an updated
  25424. configuration file.
  25425. The target generation can be specified explicitly by its generation
  25426. number. For example, the following invocation would switch to system
  25427. generation 7:
  25428. @example
  25429. guix system switch-generation 7
  25430. @end example
  25431. The target generation can also be specified relative to the current
  25432. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  25433. ``3 generations ahead of the current generation,'' and @code{-1} means
  25434. ``1 generation prior to the current generation.'' When specifying a
  25435. negative value such as @code{-1}, you must precede it with @code{--} to
  25436. prevent it from being parsed as an option. For example:
  25437. @example
  25438. guix system switch-generation -- -1
  25439. @end example
  25440. Currently, the effect of invoking this action is @emph{only} to switch
  25441. the system profile to an existing generation and rearrange the
  25442. bootloader menu entries. To actually start using the target system
  25443. generation, you must reboot after running this action. In the future,
  25444. it will be updated to do the same things as @command{reconfigure},
  25445. like activating and deactivating services.
  25446. This action will fail if the specified generation does not exist.
  25447. @item roll-back
  25448. @cindex rolling back
  25449. Switch to the preceding system generation. The next time the system
  25450. boots, it will use the preceding system generation. This is the inverse
  25451. of @command{reconfigure}, and it is exactly the same as invoking
  25452. @command{switch-generation} with an argument of @code{-1}.
  25453. Currently, as with @command{switch-generation}, you must reboot after
  25454. running this action to actually start using the preceding system
  25455. generation.
  25456. @item delete-generations
  25457. @cindex deleting system generations
  25458. @cindex saving space
  25459. Delete system generations, making them candidates for garbage collection
  25460. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  25461. collector'').
  25462. This works in the same way as @samp{guix package --delete-generations}
  25463. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  25464. arguments, all system generations but the current one are deleted:
  25465. @example
  25466. guix system delete-generations
  25467. @end example
  25468. You can also select the generations you want to delete. The example below
  25469. deletes all the system generations that are more than two month old:
  25470. @example
  25471. guix system delete-generations 2m
  25472. @end example
  25473. Running this command automatically reinstalls the bootloader with an updated
  25474. list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
  25475. longer lists the generations that have been deleted.
  25476. @item build
  25477. Build the derivation of the operating system, which includes all the
  25478. configuration files and programs needed to boot and run the system.
  25479. This action does not actually install anything.
  25480. @item init
  25481. Populate the given directory with all the files necessary to run the
  25482. operating system specified in @var{file}. This is useful for first-time
  25483. installations of Guix System. For instance:
  25484. @example
  25485. guix system init my-os-config.scm /mnt
  25486. @end example
  25487. copies to @file{/mnt} all the store items required by the configuration
  25488. specified in @file{my-os-config.scm}. This includes configuration
  25489. files, packages, and so on. It also creates other essential files
  25490. needed for the system to operate correctly---e.g., the @file{/etc},
  25491. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  25492. This command also installs bootloader on the target specified in
  25493. @file{my-os-config}, unless the @option{--no-bootloader} option was
  25494. passed.
  25495. @item vm
  25496. @cindex virtual machine
  25497. @cindex VM
  25498. @anchor{guix system vm}
  25499. Build a virtual machine that contains the operating system declared in
  25500. @var{file}, and return a script to run that virtual machine (VM).
  25501. @quotation Note
  25502. The @code{vm} action and others below
  25503. can use KVM support in the Linux-libre kernel. Specifically, if the
  25504. machine has hardware virtualization support, the corresponding
  25505. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  25506. must exist and be readable and writable by the user and by the
  25507. build users of the daemon (@pxref{Build Environment Setup}).
  25508. @end quotation
  25509. Arguments given to the script are passed to QEMU as in the example
  25510. below, which enables networking and requests 1@tie{}GiB of RAM for the
  25511. emulated machine:
  25512. @example
  25513. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -net user,model=virtio-net-pci
  25514. @end example
  25515. The VM shares its store with the host system.
  25516. Additional file systems can be shared between the host and the VM using
  25517. the @option{--share} and @option{--expose} command-line options: the former
  25518. specifies a directory to be shared with write access, while the latter
  25519. provides read-only access to the shared directory.
  25520. The example below creates a VM in which the user's home directory is
  25521. accessible read-only, and where the @file{/exchange} directory is a
  25522. read-write mapping of @file{$HOME/tmp} on the host:
  25523. @example
  25524. guix system vm my-config.scm \
  25525. --expose=$HOME --share=$HOME/tmp=/exchange
  25526. @end example
  25527. On GNU/Linux, the default is to boot directly to the kernel; this has
  25528. the advantage of requiring only a very tiny root disk image since the
  25529. store of the host can then be mounted.
  25530. The @option{--full-boot} option forces a complete boot sequence, starting
  25531. with the bootloader. This requires more disk space since a root image
  25532. containing at least the kernel, initrd, and bootloader data files must
  25533. be created. The @option{--image-size} option can be used to specify the
  25534. size of the image.
  25535. @cindex System images, creation in various formats
  25536. @cindex Creating system images in various formats
  25537. @item image
  25538. @itemx docker-image
  25539. Return a virtual machine, disk image, or Docker image of the operating
  25540. system declared in @var{file} that stands alone. By default,
  25541. @command{guix system} estimates the size of the image needed to store
  25542. the system, but you can use the @option{--image-size} option to specify
  25543. a value. Docker images are built to contain exactly what they need, so
  25544. the @option{--image-size} option is ignored in the case of
  25545. @code{docker-image}.
  25546. @cindex image, creating disk images
  25547. The @code{image} command can produce various image types. The
  25548. image type can be selected using the @option{--image-type} option. It
  25549. defaults to @code{efi-raw}. When its value is @code{iso9660}, the
  25550. @option{--label} option can be used to specify a volume ID with
  25551. @code{image}. By default, the root file system of a disk image is
  25552. mounted non-volatile; the @option{--volatile} option can be provided to
  25553. make it volatile instead. When using @code{image}, the bootloader
  25554. installed on the generated image is taken from the provided
  25555. @code{operating-system} definition. The following example demonstrates
  25556. how to generate an image that uses the @code{grub-efi-bootloader}
  25557. bootloader and boot it with QEMU:
  25558. @example
  25559. image=$(guix system image --image-type=qcow2 \
  25560. gnu/system/examples/lightweight-desktop.tmpl)
  25561. cp $image /tmp/my-image.qcow2
  25562. chmod +w /tmp/my-image.qcow2
  25563. qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
  25564. -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
  25565. @end example
  25566. When using the @code{efi-raw} image type, a raw disk image is produced;
  25567. it can be copied as is to a USB stick, for instance. Assuming
  25568. @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
  25569. the image to it using the following command:
  25570. @example
  25571. # dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress
  25572. @end example
  25573. The @code{--list-image-types} command lists all the available image
  25574. types.
  25575. @cindex creating virtual machine images
  25576. When using the @code{qcow2} image type, the returned image is in qcow2
  25577. format, which the QEMU emulator can efficiently use. @xref{Running Guix
  25578. in a VM}, for more information on how to run the image in a virtual
  25579. machine. The @code{grub-bootloader} bootloader is always used
  25580. independently of what is declared in the @code{operating-system} file
  25581. passed as argument. This is to make it easier to work with QEMU, which
  25582. uses the SeaBIOS BIOS by default, expecting a bootloader to be installed
  25583. in the Master Boot Record (MBR).
  25584. @cindex docker-image, creating docker images
  25585. When using @code{docker-image}, a Docker image is produced. Guix builds
  25586. the image from scratch, not from a pre-existing Docker base image. As a
  25587. result, it contains @emph{exactly} what you define in the operating
  25588. system configuration file. You can then load the image and launch a
  25589. Docker container using commands like the following:
  25590. @example
  25591. image_id="$(docker load < guix-system-docker-image.tar.gz)"
  25592. container_id="$(docker create $image_id)"
  25593. docker start $container_id
  25594. @end example
  25595. This command starts a new Docker container from the specified image. It
  25596. will boot the Guix system in the usual manner, which means it will
  25597. start any services you have defined in the operating system
  25598. configuration. You can get an interactive shell running in the container
  25599. using @command{docker exec}:
  25600. @example
  25601. docker exec -ti $container_id /run/current-system/profile/bin/bash --login
  25602. @end example
  25603. Depending on what you run in the Docker container, it
  25604. may be necessary to give the container additional permissions. For
  25605. example, if you intend to build software using Guix inside of the Docker
  25606. container, you may need to pass the @option{--privileged} option to
  25607. @code{docker create}.
  25608. Last, the @option{--network} option applies to @command{guix system
  25609. docker-image}: it produces an image where network is supposedly shared
  25610. with the host, and thus without services like nscd or NetworkManager.
  25611. @item container
  25612. Return a script to run the operating system declared in @var{file}
  25613. within a container. Containers are a set of lightweight isolation
  25614. mechanisms provided by the kernel Linux-libre. Containers are
  25615. substantially less resource-demanding than full virtual machines since
  25616. the kernel, shared objects, and other resources can be shared with the
  25617. host system; this also means they provide thinner isolation.
  25618. Currently, the script must be run as root in order to support more than
  25619. a single user and group. The container shares its store with the host
  25620. system.
  25621. As with the @code{vm} action (@pxref{guix system vm}), additional file
  25622. systems to be shared between the host and container can be specified
  25623. using the @option{--share} and @option{--expose} options:
  25624. @example
  25625. guix system container my-config.scm \
  25626. --expose=$HOME --share=$HOME/tmp=/exchange
  25627. @end example
  25628. @quotation Note
  25629. This option requires Linux-libre 3.19 or newer.
  25630. @end quotation
  25631. @end table
  25632. @var{options} can contain any of the common build options (@pxref{Common
  25633. Build Options}). In addition, @var{options} can contain one of the
  25634. following:
  25635. @table @option
  25636. @item --expression=@var{expr}
  25637. @itemx -e @var{expr}
  25638. Consider the operating-system @var{expr} evaluates to.
  25639. This is an alternative to specifying a file which evaluates to an
  25640. operating system.
  25641. This is used to generate the Guix system installer @pxref{Building the
  25642. Installation Image}).
  25643. @item --system=@var{system}
  25644. @itemx -s @var{system}
  25645. Attempt to build for @var{system} instead of the host system type.
  25646. This works as per @command{guix build} (@pxref{Invoking guix build}).
  25647. @item --derivation
  25648. @itemx -d
  25649. Return the derivation file name of the given operating system without
  25650. building anything.
  25651. @cindex provenance tracking, of the operating system
  25652. @item --save-provenance
  25653. As discussed above, @command{guix system init} and @command{guix system
  25654. reconfigure} always save provenance information @i{via} a dedicated
  25655. service (@pxref{Service Reference, @code{provenance-service-type}}).
  25656. However, other commands don't do that by default. If you wish to, say,
  25657. create a virtual machine image that contains provenance information, you
  25658. can run:
  25659. @example
  25660. guix system image -t qcow2 --save-provenance config.scm
  25661. @end example
  25662. That way, the resulting image will effectively ``embed its own source''
  25663. in the form of meta-data in @file{/run/current-system}. With that
  25664. information, one can rebuild the image to make sure it really contains
  25665. what it pretends to contain; or they could use that to derive a variant
  25666. of the image.
  25667. @item --image-type=@var{type}
  25668. @itemx -t @var{type}
  25669. For the @code{image} action, create an image with given @var{type}.
  25670. When this option is omitted, @command{guix system} uses the
  25671. @code{efi-raw} image type.
  25672. @cindex ISO-9660 format
  25673. @cindex CD image format
  25674. @cindex DVD image format
  25675. @option{--image-type=iso9660} produces an ISO-9660 image, suitable
  25676. for burning on CDs and DVDs.
  25677. @item --image-size=@var{size}
  25678. For the @code{image} action, create an image of the given @var{size}.
  25679. @var{size} may be a number of bytes, or it may include a unit as a
  25680. suffix (@pxref{Block size, size specifications,, coreutils, GNU
  25681. Coreutils}).
  25682. When this option is omitted, @command{guix system} computes an estimate
  25683. of the image size as a function of the size of the system declared in
  25684. @var{file}.
  25685. @item --network
  25686. @itemx -N
  25687. For the @code{container} action, allow containers to access the host network,
  25688. that is, do not create a network namespace.
  25689. @item --root=@var{file}
  25690. @itemx -r @var{file}
  25691. Make @var{file} a symlink to the result, and register it as a garbage
  25692. collector root.
  25693. @item --skip-checks
  25694. Skip pre-installation safety checks.
  25695. By default, @command{guix system init} and @command{guix system
  25696. reconfigure} perform safety checks: they make sure the file systems that
  25697. appear in the @code{operating-system} declaration actually exist
  25698. (@pxref{File Systems}), and that any Linux kernel modules that may be
  25699. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  25700. RAM Disk}). Passing this option skips these tests altogether.
  25701. @item --allow-downgrades
  25702. Instruct @command{guix system reconfigure} to allow system downgrades.
  25703. By default, @command{reconfigure} prevents you from downgrading your
  25704. system. It achieves that by comparing the provenance info of your
  25705. system (shown by @command{guix system describe}) with that of your
  25706. @command{guix} command (shown by @command{guix describe}). If the
  25707. commits for @command{guix} are not descendants of those used for your
  25708. system, @command{guix system reconfigure} errors out. Passing
  25709. @option{--allow-downgrades} allows you to bypass these checks.
  25710. @quotation Note
  25711. Make sure you understand its security implications before using
  25712. @option{--allow-downgrades}.
  25713. @end quotation
  25714. @cindex on-error
  25715. @cindex on-error strategy
  25716. @cindex error strategy
  25717. @item --on-error=@var{strategy}
  25718. Apply @var{strategy} when an error occurs when reading @var{file}.
  25719. @var{strategy} may be one of the following:
  25720. @table @code
  25721. @item nothing-special
  25722. Report the error concisely and exit. This is the default strategy.
  25723. @item backtrace
  25724. Likewise, but also display a backtrace.
  25725. @item debug
  25726. Report the error and enter Guile's debugger. From there, you can run
  25727. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  25728. display local variable values, and more generally inspect the state of the
  25729. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  25730. a list of available debugging commands.
  25731. @end table
  25732. @end table
  25733. Once you have built, configured, re-configured, and re-re-configured
  25734. your Guix installation, you may find it useful to list the operating
  25735. system generations available on disk---and that you can choose from the
  25736. bootloader boot menu:
  25737. @table @code
  25738. @item describe
  25739. Describe the current system generation: its file name, the kernel and
  25740. bootloader used, etc., as well as provenance information when available.
  25741. @item list-generations
  25742. List a summary of each generation of the operating system available on
  25743. disk, in a human-readable way. This is similar to the
  25744. @option{--list-generations} option of @command{guix package}
  25745. (@pxref{Invoking guix package}).
  25746. Optionally, one can specify a pattern, with the same syntax that is used
  25747. in @command{guix package --list-generations}, to restrict the list of
  25748. generations displayed. For instance, the following command displays
  25749. generations that are up to 10 days old:
  25750. @example
  25751. $ guix system list-generations 10d
  25752. @end example
  25753. @end table
  25754. The @command{guix system} command has even more to offer! The following
  25755. sub-commands allow you to visualize how your system services relate to
  25756. each other:
  25757. @anchor{system-extension-graph}
  25758. @table @code
  25759. @item extension-graph
  25760. Emit to standard output the @dfn{service
  25761. extension graph} of the operating system defined in @var{file}
  25762. (@pxref{Service Composition}, for more information on service
  25763. extensions). By default the output is in Dot/Graphviz format, but you
  25764. can choose a different format with @option{--graph-backend}, as with
  25765. @command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}):
  25766. The command:
  25767. @example
  25768. $ guix system extension-graph @var{file} | xdot -
  25769. @end example
  25770. shows the extension relations among services.
  25771. @anchor{system-shepherd-graph}
  25772. @item shepherd-graph
  25773. Emit to standard output the @dfn{dependency
  25774. graph} of shepherd services of the operating system defined in
  25775. @var{file}. @xref{Shepherd Services}, for more information and for an
  25776. example graph.
  25777. Again, the default output format is Dot/Graphviz, but you can pass
  25778. @option{--graph-backend} to select a different one.
  25779. @end table
  25780. @node Invoking guix deploy
  25781. @section Invoking @code{guix deploy}
  25782. We've already seen @code{operating-system} declarations used to manage a
  25783. machine's configuration locally. Suppose you need to configure multiple
  25784. machines, though---perhaps you're managing a service on the web that's
  25785. comprised of several servers. @command{guix deploy} enables you to use those
  25786. same @code{operating-system} declarations to manage multiple remote hosts at
  25787. once as a logical ``deployment''.
  25788. @quotation Note
  25789. The functionality described in this section is still under development
  25790. and is subject to change. Get in touch with us on
  25791. @email{guix-devel@@gnu.org}!
  25792. @end quotation
  25793. @example
  25794. guix deploy @var{file}
  25795. @end example
  25796. Such an invocation will deploy the machines that the code within @var{file}
  25797. evaluates to. As an example, @var{file} might contain a definition like this:
  25798. @lisp
  25799. ;; This is a Guix deployment of a "bare bones" setup, with
  25800. ;; no X11 display server, to a machine with an SSH daemon
  25801. ;; listening on localhost:2222. A configuration such as this
  25802. ;; may be appropriate for virtual machine with ports
  25803. ;; forwarded to the host's loopback interface.
  25804. (use-service-modules networking ssh)
  25805. (use-package-modules bootloaders)
  25806. (define %system
  25807. (operating-system
  25808. (host-name "gnu-deployed")
  25809. (timezone "Etc/UTC")
  25810. (bootloader (bootloader-configuration
  25811. (bootloader grub-bootloader)
  25812. (target "/dev/vda")
  25813. (terminal-outputs '(console))))
  25814. (file-systems (cons (file-system
  25815. (mount-point "/")
  25816. (device "/dev/vda1")
  25817. (type "ext4"))
  25818. %base-file-systems))
  25819. (services
  25820. (append (list (service dhcp-client-service-type)
  25821. (service openssh-service-type
  25822. (openssh-configuration
  25823. (permit-root-login #t)
  25824. (allow-empty-passwords? #t))))
  25825. %base-services))))
  25826. (list (machine
  25827. (operating-system %system)
  25828. (environment managed-host-environment-type)
  25829. (configuration (machine-ssh-configuration
  25830. (host-name "localhost")
  25831. (system "x86_64-linux")
  25832. (user "alice")
  25833. (identity "./id_rsa")
  25834. (port 2222)))))
  25835. @end lisp
  25836. The file should evaluate to a list of @var{machine} objects. This example,
  25837. upon being deployed, will create a new generation on the remote system
  25838. realizing the @code{operating-system} declaration @code{%system}.
  25839. @code{environment} and @code{configuration} specify how the machine should be
  25840. provisioned---that is, how the computing resources should be created and
  25841. managed. The above example does not create any resources, as a
  25842. @code{'managed-host} is a machine that is already running the Guix system and
  25843. available over the network. This is a particularly simple case; a more
  25844. complex deployment may involve, for example, starting virtual machines through
  25845. a Virtual Private Server (VPS) provider. In such a case, a different
  25846. @var{environment} type would be used.
  25847. Do note that you first need to generate a key pair on the coordinator machine
  25848. to allow the daemon to export signed archives of files from the store
  25849. (@pxref{Invoking guix archive}), though this step is automatic on Guix
  25850. System:
  25851. @example
  25852. # guix archive --generate-key
  25853. @end example
  25854. @noindent
  25855. Each target machine must authorize the key of the master machine so that it
  25856. accepts store items it receives from the coordinator:
  25857. @example
  25858. # guix archive --authorize < coordinator-public-key.txt
  25859. @end example
  25860. @code{user}, in this example, specifies the name of the user account to log in
  25861. as to perform the deployment. Its default value is @code{root}, but root
  25862. login over SSH may be forbidden in some cases. To work around this,
  25863. @command{guix deploy} can log in as an unprivileged user and employ
  25864. @code{sudo} to escalate privileges. This will only work if @code{sudo} is
  25865. currently installed on the remote and can be invoked non-interactively as
  25866. @code{user}. That is, the line in @code{sudoers} granting @code{user} the
  25867. ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
  25868. be accomplished with the following operating system configuration snippet:
  25869. @lisp
  25870. (use-modules ...
  25871. (gnu system)) ;for %sudoers-specification
  25872. (define %user "username")
  25873. (operating-system
  25874. ...
  25875. (sudoers-file
  25876. (plain-file "sudoers"
  25877. (string-append (plain-file-content %sudoers-specification)
  25878. (format #f "~a ALL = NOPASSWD: ALL~%"
  25879. %user)))))
  25880. @end lisp
  25881. For more information regarding the format of the @file{sudoers} file,
  25882. consult @command{man sudoers}.
  25883. @deftp {Data Type} machine
  25884. This is the data type representing a single machine in a heterogeneous Guix
  25885. deployment.
  25886. @table @asis
  25887. @item @code{operating-system}
  25888. The object of the operating system configuration to deploy.
  25889. @item @code{environment}
  25890. An @code{environment-type} describing how the machine should be provisioned.
  25891. @item @code{configuration} (default: @code{#f})
  25892. An object describing the configuration for the machine's @code{environment}.
  25893. If the @code{environment} has a default configuration, @code{#f} may be used.
  25894. If @code{#f} is used for an environment with no default configuration,
  25895. however, an error will be thrown.
  25896. @end table
  25897. @end deftp
  25898. @deftp {Data Type} machine-ssh-configuration
  25899. This is the data type representing the SSH client parameters for a machine
  25900. with an @code{environment} of @code{managed-host-environment-type}.
  25901. @table @asis
  25902. @item @code{host-name}
  25903. @item @code{build-locally?} (default: @code{#t})
  25904. If false, system derivations will be built on the machine being deployed to.
  25905. @item @code{system}
  25906. The system type describing the architecture of the machine being deployed
  25907. to---e.g., @code{"x86_64-linux"}.
  25908. @item @code{authorize?} (default: @code{#t})
  25909. If true, the coordinator's signing key will be added to the remote's ACL
  25910. keyring.
  25911. @item @code{port} (default: @code{22})
  25912. @item @code{user} (default: @code{"root"})
  25913. @item @code{identity} (default: @code{#f})
  25914. If specified, the path to the SSH private key to use to authenticate with the
  25915. remote host.
  25916. @item @code{host-key} (default: @code{#f})
  25917. This should be the SSH host key of the machine, which looks like this:
  25918. @example
  25919. ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
  25920. @end example
  25921. When @code{host-key} is @code{#f}, the server is authenticated against
  25922. the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
  25923. client does.
  25924. @item @code{allow-downgrades?} (default: @code{#f})
  25925. Whether to allow potential downgrades.
  25926. Like @command{guix system reconfigure}, @command{guix deploy} compares
  25927. the channel commits currently deployed on the remote host (as returned
  25928. by @command{guix system describe}) to those currently in use (as
  25929. returned by @command{guix describe}) to determine whether commits
  25930. currently in use are descendants of those deployed. When this is not
  25931. the case and @code{allow-downgrades?} is false, it raises an error.
  25932. This ensures you do not accidentally downgrade remote machines.
  25933. @end table
  25934. @end deftp
  25935. @deftp {Data Type} digital-ocean-configuration
  25936. This is the data type describing the Droplet that should be created for a
  25937. machine with an @code{environment} of @code{digital-ocean-environment-type}.
  25938. @table @asis
  25939. @item @code{ssh-key}
  25940. The path to the SSH private key to use to authenticate with the remote
  25941. host. In the future, this field may not exist.
  25942. @item @code{tags}
  25943. A list of string ``tags'' that uniquely identify the machine. Must be given
  25944. such that no two machines in the deployment have the same set of tags.
  25945. @item @code{region}
  25946. A Digital Ocean region slug, such as @code{"nyc3"}.
  25947. @item @code{size}
  25948. A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
  25949. @item @code{enable-ipv6?}
  25950. Whether or not the droplet should be created with IPv6 networking.
  25951. @end table
  25952. @end deftp
  25953. @node Running Guix in a VM
  25954. @section Running Guix in a Virtual Machine
  25955. @cindex virtual machine
  25956. To run Guix in a virtual machine (VM), one can use the pre-built Guix VM image
  25957. distributed at
  25958. @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.xz}.
  25959. This image is a compressed image in QCOW format. You will first need to
  25960. decompress with @command{xz -d}, and then you can pass it to an emulator such
  25961. as QEMU (see below for details).
  25962. This image boots the Xfce graphical environment and it contains some
  25963. commonly used tools. You can install more software in the image by running
  25964. @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
  25965. also reconfigure the system based on its initial configuration file available
  25966. as @file{/run/current-system/configuration.scm} (@pxref{Using the
  25967. Configuration System}).
  25968. Instead of using this pre-built image, one can also build their own virtual
  25969. machine image using @command{guix system vm-image} (@pxref{Invoking guix
  25970. system}). The returned image is in qcow2 format, which the
  25971. @uref{https://qemu.org/, QEMU emulator} can efficiently use.
  25972. @cindex QEMU
  25973. If you built your own image, you must copy it out of the store
  25974. (@pxref{The Store}) and give yourself permission to write to the copy
  25975. before you can use it. When invoking QEMU, you must choose a system
  25976. emulator that is suitable for your hardware platform. Here is a minimal
  25977. QEMU invocation that will boot the result of @command{guix system
  25978. image -t qcow2} on x86_64 hardware:
  25979. @example
  25980. $ qemu-system-x86_64 \
  25981. -nic user,model=virtio-net-pci \
  25982. -enable-kvm -m 1024 \
  25983. -device virtio-blk,drive=myhd \
  25984. -drive if=none,file=/tmp/qemu-image,id=myhd
  25985. @end example
  25986. Here is what each of these options means:
  25987. @table @code
  25988. @item qemu-system-x86_64
  25989. This specifies the hardware platform to emulate. This should match the
  25990. host.
  25991. @item -nic user,model=virtio-net-pci
  25992. Enable the unprivileged user-mode network stack. The guest OS can
  25993. access the host but not vice versa. This is the simplest way to get the
  25994. guest OS online. @code{model} specifies which network device to emulate:
  25995. @code{virtio-net-pci} is a special device made for virtualized operating
  25996. systems and recommended for most uses. Assuming your hardware platform is
  25997. x86_64, you can get a list of available NIC models by running
  25998. @command{qemu-system-x86_64 -nic model=help}.
  25999. @item -enable-kvm
  26000. If your system has hardware virtualization extensions, enabling the
  26001. virtual machine support (KVM) of the Linux kernel will make things run
  26002. faster.
  26003. @c To run Xfce + 'guix pull', we need at least 1G of RAM.
  26004. @item -m 1024
  26005. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  26006. which may be insufficient for some operations.
  26007. @item -device virtio-blk,drive=myhd
  26008. Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
  26009. ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
  26010. better performance than if it were emulating a complete disk drive. See the
  26011. QEMU and KVM documentation for more info.
  26012. @item -drive if=none,file=/tmp/qemu-image,id=myhd
  26013. Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing
  26014. store of the ``myhd'' drive.
  26015. @end table
  26016. The default @command{run-vm.sh} script that is returned by an invocation of
  26017. @command{guix system vm} does not add a @command{-nic user} flag by default.
  26018. To get network access from within the vm add the @code{(dhcp-client-service)}
  26019. to your system definition and start the VM using
  26020. @command{$(guix system vm config.scm) -nic user}. An important caveat of using
  26021. @command{-nic user} for networking is that @command{ping} will not work, because
  26022. it uses the ICMP protocol. You'll have to use a different command to check for
  26023. network connectivity, for example @command{guix download}.
  26024. @subsection Connecting Through SSH
  26025. @cindex SSH
  26026. @cindex SSH server
  26027. To enable SSH inside a VM you need to add an SSH server like
  26028. @code{openssh-service-type} to your VM (@pxref{Networking Services,
  26029. @code{openssh-service-type}}). In addition you need to forward the SSH port,
  26030. 22 by default, to the host. You can do this with
  26031. @example
  26032. $(guix system vm config.scm) -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  26033. @end example
  26034. To connect to the VM you can run
  26035. @example
  26036. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
  26037. @end example
  26038. The @command{-p} tells @command{ssh} the port you want to connect to.
  26039. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  26040. every time you modify your @command{config.scm} file and the
  26041. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  26042. connection to an unknown host every time you connect.
  26043. @subsection Using @command{virt-viewer} with Spice
  26044. As an alternative to the default @command{qemu} graphical client you can
  26045. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  26046. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  26047. @command{qemu}. See previous section for further information on how to do this.
  26048. Spice also allows you to do some nice stuff like share your clipboard with your
  26049. VM@. To enable that you'll also have to pass the following flags to @command{qemu}:
  26050. @example
  26051. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  26052. -chardev spicevmc,name=vdagent,id=vdagent
  26053. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
  26054. name=com.redhat.spice.0
  26055. @end example
  26056. You'll also need to add the @code{(spice-vdagent-service)} to your
  26057. system definition (@pxref{Miscellaneous Services, Spice service}).
  26058. @node Defining Services
  26059. @section Defining Services
  26060. The previous sections show the available services and how one can combine
  26061. them in an @code{operating-system} declaration. But how do we define
  26062. them in the first place? And what is a service anyway?
  26063. @menu
  26064. * Service Composition:: The model for composing services.
  26065. * Service Types and Services:: Types and services.
  26066. * Service Reference:: API reference.
  26067. * Shepherd Services:: A particular type of service.
  26068. @end menu
  26069. @node Service Composition
  26070. @subsection Service Composition
  26071. @cindex services
  26072. @cindex daemons
  26073. Here we define a @dfn{service} as, broadly, something that extends the
  26074. functionality of the operating system. Often a service is a process---a
  26075. @dfn{daemon}---started when the system boots: a secure shell server, a
  26076. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  26077. whose execution can be triggered by another daemon---e.g., an FTP server
  26078. started by @command{inetd} or a D-Bus service activated by
  26079. @command{dbus-daemon}. Occasionally, a service does not map to a
  26080. daemon. For instance, the ``account'' service collects user accounts
  26081. and makes sure they exist when the system runs; the ``udev'' service
  26082. collects device management rules and makes them available to the eudev
  26083. daemon; the @file{/etc} service populates the @file{/etc} directory
  26084. of the system.
  26085. @cindex service extensions
  26086. Guix system services are connected by @dfn{extensions}. For instance, the
  26087. secure shell service @emph{extends} the Shepherd---the
  26088. initialization system, running as PID@tie{}1---by giving it the command
  26089. lines to start and stop the secure shell daemon (@pxref{Networking
  26090. Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
  26091. service by passing it its @file{.service} specification, and extends the
  26092. udev service by passing it device management rules (@pxref{Desktop
  26093. Services, @code{upower-service}}); the Guix daemon service extends the
  26094. Shepherd by passing it the command lines to start and stop the daemon,
  26095. and extends the account service by passing it a list of required build
  26096. user accounts (@pxref{Base Services}).
  26097. All in all, services and their ``extends'' relations form a directed
  26098. acyclic graph (DAG). If we represent services as boxes and extensions
  26099. as arrows, a typical system might provide something like this:
  26100. @image{images/service-graph,,5in,Typical service extension graph.}
  26101. @cindex system service
  26102. At the bottom, we see the @dfn{system service}, which produces the
  26103. directory containing everything to run and boot the system, as returned
  26104. by the @command{guix system build} command. @xref{Service Reference},
  26105. to learn about the other service types shown here.
  26106. @xref{system-extension-graph, the @command{guix system extension-graph}
  26107. command}, for information on how to generate this representation for a
  26108. particular operating system definition.
  26109. @cindex service types
  26110. Technically, developers can define @dfn{service types} to express these
  26111. relations. There can be any number of services of a given type on the
  26112. system---for instance, a system running two instances of the GNU secure
  26113. shell server (lsh) has two instances of @code{lsh-service-type}, with
  26114. different parameters.
  26115. The following section describes the programming interface for service
  26116. types and services.
  26117. @node Service Types and Services
  26118. @subsection Service Types and Services
  26119. A @dfn{service type} is a node in the DAG described above. Let us start
  26120. with a simple example, the service type for the Guix build daemon
  26121. (@pxref{Invoking guix-daemon}):
  26122. @lisp
  26123. (define guix-service-type
  26124. (service-type
  26125. (name 'guix)
  26126. (extensions
  26127. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  26128. (service-extension account-service-type guix-accounts)
  26129. (service-extension activation-service-type guix-activation)))
  26130. (default-value (guix-configuration))))
  26131. @end lisp
  26132. @noindent
  26133. It defines three things:
  26134. @enumerate
  26135. @item
  26136. A name, whose sole purpose is to make inspection and debugging easier.
  26137. @item
  26138. A list of @dfn{service extensions}, where each extension designates the
  26139. target service type and a procedure that, given the parameters of the
  26140. service, returns a list of objects to extend the service of that type.
  26141. Every service type has at least one service extension. The only
  26142. exception is the @dfn{boot service type}, which is the ultimate service.
  26143. @item
  26144. Optionally, a default value for instances of this type.
  26145. @end enumerate
  26146. In this example, @code{guix-service-type} extends three services:
  26147. @table @code
  26148. @item shepherd-root-service-type
  26149. The @code{guix-shepherd-service} procedure defines how the Shepherd
  26150. service is extended. Namely, it returns a @code{<shepherd-service>}
  26151. object that defines how @command{guix-daemon} is started and stopped
  26152. (@pxref{Shepherd Services}).
  26153. @item account-service-type
  26154. This extension for this service is computed by @code{guix-accounts},
  26155. which returns a list of @code{user-group} and @code{user-account}
  26156. objects representing the build user accounts (@pxref{Invoking
  26157. guix-daemon}).
  26158. @item activation-service-type
  26159. Here @code{guix-activation} is a procedure that returns a gexp, which is
  26160. a code snippet to run at ``activation time''---e.g., when the service is
  26161. booted.
  26162. @end table
  26163. A service of this type is instantiated like this:
  26164. @lisp
  26165. (service guix-service-type
  26166. (guix-configuration
  26167. (build-accounts 5)
  26168. (extra-options '("--gc-keep-derivations"))))
  26169. @end lisp
  26170. The second argument to the @code{service} form is a value representing
  26171. the parameters of this specific service instance.
  26172. @xref{guix-configuration-type, @code{guix-configuration}}, for
  26173. information about the @code{guix-configuration} data type. When the
  26174. value is omitted, the default value specified by
  26175. @code{guix-service-type} is used:
  26176. @lisp
  26177. (service guix-service-type)
  26178. @end lisp
  26179. @code{guix-service-type} is quite simple because it extends other
  26180. services but is not extensible itself.
  26181. @c @subsubsubsection Extensible Service Types
  26182. The service type for an @emph{extensible} service looks like this:
  26183. @lisp
  26184. (define udev-service-type
  26185. (service-type (name 'udev)
  26186. (extensions
  26187. (list (service-extension shepherd-root-service-type
  26188. udev-shepherd-service)))
  26189. (compose concatenate) ;concatenate the list of rules
  26190. (extend (lambda (config rules)
  26191. (match config
  26192. (($ <udev-configuration> udev initial-rules)
  26193. (udev-configuration
  26194. (udev udev) ;the udev package to use
  26195. (rules (append initial-rules rules)))))))))
  26196. @end lisp
  26197. This is the service type for the
  26198. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  26199. management daemon}. Compared to the previous example, in addition to an
  26200. extension of @code{shepherd-root-service-type}, we see two new fields:
  26201. @table @code
  26202. @item compose
  26203. This is the procedure to @dfn{compose} the list of extensions to
  26204. services of this type.
  26205. Services can extend the udev service by passing it lists of rules; we
  26206. compose those extensions simply by concatenating them.
  26207. @item extend
  26208. This procedure defines how the value of the service is @dfn{extended} with
  26209. the composition of the extensions.
  26210. Udev extensions are composed into a list of rules, but the udev service
  26211. value is itself a @code{<udev-configuration>} record. So here, we
  26212. extend that record by appending the list of rules it contains to the
  26213. list of contributed rules.
  26214. @item description
  26215. This is a string giving an overview of the service type. The string can
  26216. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  26217. @command{guix system search} command searches these strings and displays
  26218. them (@pxref{Invoking guix system}).
  26219. @end table
  26220. There can be only one instance of an extensible service type such as
  26221. @code{udev-service-type}. If there were more, the
  26222. @code{service-extension} specifications would be ambiguous.
  26223. Still here? The next section provides a reference of the programming
  26224. interface for services.
  26225. @node Service Reference
  26226. @subsection Service Reference
  26227. We have seen an overview of service types (@pxref{Service Types and
  26228. Services}). This section provides a reference on how to manipulate
  26229. services and service types. This interface is provided by the
  26230. @code{(gnu services)} module.
  26231. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  26232. Return a new service of @var{type}, a @code{<service-type>} object (see
  26233. below). @var{value} can be any object; it represents the parameters of
  26234. this particular service instance.
  26235. When @var{value} is omitted, the default value specified by @var{type}
  26236. is used; if @var{type} does not specify a default value, an error is
  26237. raised.
  26238. For instance, this:
  26239. @lisp
  26240. (service openssh-service-type)
  26241. @end lisp
  26242. @noindent
  26243. is equivalent to this:
  26244. @lisp
  26245. (service openssh-service-type
  26246. (openssh-configuration))
  26247. @end lisp
  26248. In both cases the result is an instance of @code{openssh-service-type}
  26249. with the default configuration.
  26250. @end deffn
  26251. @deffn {Scheme Procedure} service? @var{obj}
  26252. Return true if @var{obj} is a service.
  26253. @end deffn
  26254. @deffn {Scheme Procedure} service-kind @var{service}
  26255. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  26256. @end deffn
  26257. @deffn {Scheme Procedure} service-value @var{service}
  26258. Return the value associated with @var{service}. It represents its
  26259. parameters.
  26260. @end deffn
  26261. Here is an example of how a service is created and manipulated:
  26262. @lisp
  26263. (define s
  26264. (service nginx-service-type
  26265. (nginx-configuration
  26266. (nginx nginx)
  26267. (log-directory log-directory)
  26268. (run-directory run-directory)
  26269. (file config-file))))
  26270. (service? s)
  26271. @result{} #t
  26272. (eq? (service-kind s) nginx-service-type)
  26273. @result{} #t
  26274. @end lisp
  26275. The @code{modify-services} form provides a handy way to change the
  26276. parameters of some of the services of a list such as
  26277. @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  26278. evaluates to a list of services. Of course, you could always use
  26279. standard list combinators such as @code{map} and @code{fold} to do that
  26280. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  26281. @code{modify-services} simply provides a more concise form for this
  26282. common pattern.
  26283. @deffn {Scheme Syntax} modify-services @var{services} @
  26284. (@var{type} @var{variable} => @var{body}) @dots{}
  26285. Modify the services listed in @var{services} according to the given
  26286. clauses. Each clause has the form:
  26287. @example
  26288. (@var{type} @var{variable} => @var{body})
  26289. @end example
  26290. where @var{type} is a service type---e.g.,
  26291. @code{guix-service-type}---and @var{variable} is an identifier that is
  26292. bound within the @var{body} to the service parameters---e.g., a
  26293. @code{guix-configuration} instance---of the original service of that
  26294. @var{type}.
  26295. The @var{body} should evaluate to the new service parameters, which will
  26296. be used to configure the new service. This new service will replace the
  26297. original in the resulting list. Because a service's service parameters
  26298. are created using @code{define-record-type*}, you can write a succinct
  26299. @var{body} that evaluates to the new service parameters by using the
  26300. @code{inherit} feature that @code{define-record-type*} provides.
  26301. @xref{Using the Configuration System}, for example usage.
  26302. @end deffn
  26303. Next comes the programming interface for service types. This is
  26304. something you want to know when writing new service definitions, but not
  26305. necessarily when simply looking for ways to customize your
  26306. @code{operating-system} declaration.
  26307. @deftp {Data Type} service-type
  26308. @cindex service type
  26309. This is the representation of a @dfn{service type} (@pxref{Service Types
  26310. and Services}).
  26311. @table @asis
  26312. @item @code{name}
  26313. This is a symbol, used only to simplify inspection and debugging.
  26314. @item @code{extensions}
  26315. A non-empty list of @code{<service-extension>} objects (see below).
  26316. @item @code{compose} (default: @code{#f})
  26317. If this is @code{#f}, then the service type denotes services that cannot
  26318. be extended---i.e., services that do not receive ``values'' from other
  26319. services.
  26320. Otherwise, it must be a one-argument procedure. The procedure is called
  26321. by @code{fold-services} and is passed a list of values collected from
  26322. extensions. It may return any single value.
  26323. @item @code{extend} (default: @code{#f})
  26324. If this is @code{#f}, services of this type cannot be extended.
  26325. Otherwise, it must be a two-argument procedure: @code{fold-services}
  26326. calls it, passing it the initial value of the service as the first
  26327. argument and the result of applying @code{compose} to the extension
  26328. values as the second argument. It must return a value that is a valid
  26329. parameter value for the service instance.
  26330. @item @code{description}
  26331. This is a string, possibly using Texinfo markup, describing in a couple
  26332. of sentences what the service is about. This string allows users to
  26333. find about the service through @command{guix system search}
  26334. (@pxref{Invoking guix system}).
  26335. @item @code{default-value} (default: @code{&no-default-value})
  26336. The default value associated for instances of this service type. This
  26337. allows users to use the @code{service} form without its second argument:
  26338. @lisp
  26339. (service @var{type})
  26340. @end lisp
  26341. The returned service in this case has the default value specified by
  26342. @var{type}.
  26343. @end table
  26344. @xref{Service Types and Services}, for examples.
  26345. @end deftp
  26346. @deffn {Scheme Procedure} service-extension @var{target-type} @
  26347. @var{compute}
  26348. Return a new extension for services of type @var{target-type}.
  26349. @var{compute} must be a one-argument procedure: @code{fold-services}
  26350. calls it, passing it the value associated with the service that provides
  26351. the extension; it must return a valid value for the target service.
  26352. @end deffn
  26353. @deffn {Scheme Procedure} service-extension? @var{obj}
  26354. Return true if @var{obj} is a service extension.
  26355. @end deffn
  26356. Occasionally, you might want to simply extend an existing service. This
  26357. involves creating a new service type and specifying the extension of
  26358. interest, which can be verbose; the @code{simple-service} procedure
  26359. provides a shorthand for this.
  26360. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  26361. Return a service that extends @var{target} with @var{value}. This works
  26362. by creating a singleton service type @var{name}, of which the returned
  26363. service is an instance.
  26364. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  26365. an additional job:
  26366. @lisp
  26367. (simple-service 'my-mcron-job mcron-service-type
  26368. #~(job '(next-hour (3)) "guix gc -F 2G"))
  26369. @end lisp
  26370. @end deffn
  26371. At the core of the service abstraction lies the @code{fold-services}
  26372. procedure, which is responsible for ``compiling'' a list of services
  26373. down to a single directory that contains everything needed to boot and
  26374. run the system---the directory shown by the @command{guix system build}
  26375. command (@pxref{Invoking guix system}). In essence, it propagates
  26376. service extensions down the service graph, updating each node parameters
  26377. on the way, until it reaches the root node.
  26378. @deffn {Scheme Procedure} fold-services @var{services} @
  26379. [#:target-type @var{system-service-type}]
  26380. Fold @var{services} by propagating their extensions down to the root of
  26381. type @var{target-type}; return the root service adjusted accordingly.
  26382. @end deffn
  26383. Lastly, the @code{(gnu services)} module also defines several essential
  26384. service types, some of which are listed below.
  26385. @defvr {Scheme Variable} system-service-type
  26386. This is the root of the service graph. It produces the system directory
  26387. as returned by the @command{guix system build} command.
  26388. @end defvr
  26389. @defvr {Scheme Variable} boot-service-type
  26390. The type of the ``boot service'', which produces the @dfn{boot script}.
  26391. The boot script is what the initial RAM disk runs when booting.
  26392. @end defvr
  26393. @defvr {Scheme Variable} etc-service-type
  26394. The type of the @file{/etc} service. This service is used to create
  26395. files under @file{/etc} and can be extended by
  26396. passing it name/file tuples such as:
  26397. @lisp
  26398. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  26399. @end lisp
  26400. In this example, the effect would be to add an @file{/etc/issue} file
  26401. pointing to the given file.
  26402. @end defvr
  26403. @defvr {Scheme Variable} setuid-program-service-type
  26404. Type for the ``setuid-program service''. This service collects lists of
  26405. executable file names, passed as gexps, and adds them to the set of
  26406. setuid-root programs on the system (@pxref{Setuid Programs}).
  26407. @end defvr
  26408. @defvr {Scheme Variable} profile-service-type
  26409. Type of the service that populates the @dfn{system profile}---i.e., the
  26410. programs under @file{/run/current-system/profile}. Other services can
  26411. extend it by passing it lists of packages to add to the system profile.
  26412. @end defvr
  26413. @cindex provenance tracking, of the operating system
  26414. @anchor{provenance-service-type}
  26415. @defvr {Scheme Variable} provenance-service-type
  26416. This is the type of the service that records @dfn{provenance meta-data}
  26417. in the system itself. It creates several files under
  26418. @file{/run/current-system}:
  26419. @table @file
  26420. @item channels.scm
  26421. This is a ``channel file'' that can be passed to @command{guix pull -C}
  26422. or @command{guix time-machine -C}, and which describes the channels used
  26423. to build the system, if that information was available
  26424. (@pxref{Channels}).
  26425. @item configuration.scm
  26426. This is the file that was passed as the value for this
  26427. @code{provenance-service-type} service. By default, @command{guix
  26428. system reconfigure} automatically passes the OS configuration file it
  26429. received on the command line.
  26430. @item provenance
  26431. This contains the same information as the two other files but in a
  26432. format that is more readily processable.
  26433. @end table
  26434. In general, these two pieces of information (channels and configuration
  26435. file) are enough to reproduce the operating system ``from source''.
  26436. @quotation Caveats
  26437. This information is necessary to rebuild your operating system, but it
  26438. is not always sufficient. In particular, @file{configuration.scm}
  26439. itself is insufficient if it is not self-contained---if it refers to
  26440. external Guile modules or to extra files. If you want
  26441. @file{configuration.scm} to be self-contained, we recommend that modules
  26442. or files it refers to be part of a channel.
  26443. Besides, provenance meta-data is ``silent'' in the sense that it does
  26444. not change the bits contained in your system, @emph{except for the
  26445. meta-data bits themselves}. Two different OS configurations or sets of
  26446. channels can lead to the same system, bit-for-bit; when
  26447. @code{provenance-service-type} is used, these two systems will have
  26448. different meta-data and thus different store file names, which makes
  26449. comparison less trivial.
  26450. @end quotation
  26451. This service is automatically added to your operating system
  26452. configuration when you use @command{guix system reconfigure},
  26453. @command{guix system init}, or @command{guix deploy}.
  26454. @end defvr
  26455. @node Shepherd Services
  26456. @subsection Shepherd Services
  26457. @cindex shepherd services
  26458. @cindex PID 1
  26459. @cindex init system
  26460. The @code{(gnu services shepherd)} module provides a way to define
  26461. services managed by the GNU@tie{}Shepherd, which is the
  26462. initialization system---the first process that is started when the
  26463. system boots, also known as PID@tie{}1
  26464. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  26465. Services in the Shepherd can depend on each other. For instance, the
  26466. SSH daemon may need to be started after the syslog daemon has been
  26467. started, which in turn can only happen once all the file systems have
  26468. been mounted. The simple operating system defined earlier (@pxref{Using
  26469. the Configuration System}) results in a service graph like this:
  26470. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  26471. You can actually generate such a graph for any operating system
  26472. definition using the @command{guix system shepherd-graph} command
  26473. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  26474. The @code{%shepherd-root-service} is a service object representing
  26475. PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
  26476. by passing it lists of @code{<shepherd-service>} objects.
  26477. @deftp {Data Type} shepherd-service
  26478. The data type representing a service managed by the Shepherd.
  26479. @table @asis
  26480. @item @code{provision}
  26481. This is a list of symbols denoting what the service provides.
  26482. These are the names that may be passed to @command{herd start},
  26483. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  26484. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  26485. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  26486. @item @code{requirement} (default: @code{'()})
  26487. List of symbols denoting the Shepherd services this one depends on.
  26488. @cindex one-shot services, for the Shepherd
  26489. @item @code{one-shot?} (default: @code{#f})
  26490. Whether this service is @dfn{one-shot}. One-shot services stop immediately
  26491. after their @code{start} action has completed. @xref{Slots of services,,,
  26492. shepherd, The GNU Shepherd Manual}, for more info.
  26493. @item @code{respawn?} (default: @code{#t})
  26494. Whether to restart the service when it stops, for instance when the
  26495. underlying process dies.
  26496. @item @code{start}
  26497. @itemx @code{stop} (default: @code{#~(const #f)})
  26498. The @code{start} and @code{stop} fields refer to the Shepherd's
  26499. facilities to start and stop processes (@pxref{Service De- and
  26500. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  26501. G-expressions that get expanded in the Shepherd configuration file
  26502. (@pxref{G-Expressions}).
  26503. @item @code{actions} (default: @code{'()})
  26504. @cindex actions, of Shepherd services
  26505. This is a list of @code{shepherd-action} objects (see below) defining
  26506. @dfn{actions} supported by the service, in addition to the standard
  26507. @code{start} and @code{stop} actions. Actions listed here become available as
  26508. @command{herd} sub-commands:
  26509. @example
  26510. herd @var{action} @var{service} [@var{arguments}@dots{}]
  26511. @end example
  26512. @item @code{auto-start?} (default: @code{#t})
  26513. Whether this service should be started automatically by the Shepherd. If it
  26514. is @code{#f} the service has to be started manually with @code{herd start}.
  26515. @item @code{documentation}
  26516. A documentation string, as shown when running:
  26517. @example
  26518. herd doc @var{service-name}
  26519. @end example
  26520. where @var{service-name} is one of the symbols in @code{provision}
  26521. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  26522. @item @code{modules} (default: @code{%default-modules})
  26523. This is the list of modules that must be in scope when @code{start} and
  26524. @code{stop} are evaluated.
  26525. @end table
  26526. @end deftp
  26527. The example below defines a Shepherd service that spawns
  26528. @command{syslogd}, the system logger from the GNU Networking Utilities
  26529. (@pxref{syslogd invocation, @command{syslogd},, inetutils, GNU
  26530. Inetutils}):
  26531. @example
  26532. (let ((config (plain-file "syslogd.conf" "@dots{}")))
  26533. (shepherd-service
  26534. (documentation "Run the syslog daemon (syslogd).")
  26535. (provision '(syslogd))
  26536. (requirement '(user-processes))
  26537. (start #~(make-forkexec-constructor
  26538. (list #$(file-append inetutils "/libexec/syslogd")
  26539. "--rcfile" #$config)
  26540. #:pid-file "/var/run/syslog.pid"))
  26541. (stop #~(make-kill-destructor))))
  26542. @end example
  26543. Key elements in this example are the @code{start} and @code{stop}
  26544. fields: they are @dfn{staged} code snippets that use the
  26545. @code{make-forkexec-constructor} procedure provided by the Shepherd and
  26546. its dual, @code{make-kill-destructor} (@pxref{Service De- and
  26547. Constructors,,, shepherd, The GNU Shepherd Manual}). The @code{start}
  26548. field will have @command{shepherd} spawn @command{syslogd} with the
  26549. given option; note that we pass @code{config} after @option{--rcfile},
  26550. which is a configuration file declared above (contents of this file are
  26551. omitted). Likewise, the @code{stop} field tells how this service is to
  26552. be stopped; in this case, it is stopped by making the @code{kill} system
  26553. call on its PID@. Code staging is achieved using G-expressions:
  26554. @code{#~} stages code, while @code{#$} ``escapes'' back to host code
  26555. (@pxref{G-Expressions}).
  26556. @deftp {Data Type} shepherd-action
  26557. This is the data type that defines additional actions implemented by a
  26558. Shepherd service (see above).
  26559. @table @code
  26560. @item name
  26561. Symbol naming the action.
  26562. @item documentation
  26563. This is a documentation string for the action. It can be viewed by running:
  26564. @example
  26565. herd doc @var{service} action @var{action}
  26566. @end example
  26567. @item procedure
  26568. This should be a gexp that evaluates to a procedure of at least one argument,
  26569. which is the ``running value'' of the service (@pxref{Slots of services,,,
  26570. shepherd, The GNU Shepherd Manual}).
  26571. @end table
  26572. The following example defines an action called @code{say-hello} that kindly
  26573. greets the user:
  26574. @lisp
  26575. (shepherd-action
  26576. (name 'say-hello)
  26577. (documentation "Say hi!")
  26578. (procedure #~(lambda (running . args)
  26579. (format #t "Hello, friend! arguments: ~s\n"
  26580. args)
  26581. #t)))
  26582. @end lisp
  26583. Assuming this action is added to the @code{example} service, then you can do:
  26584. @example
  26585. # herd say-hello example
  26586. Hello, friend! arguments: ()
  26587. # herd say-hello example a b c
  26588. Hello, friend! arguments: ("a" "b" "c")
  26589. @end example
  26590. This, as you can see, is a fairly sophisticated way to say hello.
  26591. @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
  26592. info on actions.
  26593. @end deftp
  26594. @defvr {Scheme Variable} shepherd-root-service-type
  26595. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  26596. This is the service type that extensions target when they want to create
  26597. shepherd services (@pxref{Service Types and Services}, for an example).
  26598. Each extension must pass a list of @code{<shepherd-service>}. Its
  26599. value must be a @code{shepherd-configuration}, as described below.
  26600. @end defvr
  26601. @deftp {Data Type} shepherd-configuration
  26602. This data type represents the Shepherd's configuration.
  26603. @table @code
  26604. @item shepherd (default: @code{shepherd})
  26605. The Shepherd package to use.
  26606. @item services (default: @code{'()})
  26607. A list of @code{<shepherd-service>} to start.
  26608. You should probably use the service extension
  26609. mechanism instead (@pxref{Shepherd Services}).
  26610. @end table
  26611. @end deftp
  26612. The following example specifies the Shepherd package for the operating
  26613. system:
  26614. @lisp
  26615. (operating-system
  26616. ;; ...
  26617. (services (append (list openssh-service-type))
  26618. ;; ...
  26619. %desktop-services)
  26620. ;; ...
  26621. ;; Use own Shepherd package.
  26622. (essential-services
  26623. (modify-services (operating-system-default-essential-services
  26624. this-operating-system)
  26625. (shepherd-root-service-type config => (shepherd-configuration
  26626. (inherit config)
  26627. (shepherd my-shepherd))))))
  26628. @end lisp
  26629. @defvr {Scheme Variable} %shepherd-root-service
  26630. This service represents PID@tie{}1.
  26631. @end defvr
  26632. @node Documentation
  26633. @chapter Documentation
  26634. @cindex documentation, searching for
  26635. @cindex searching for documentation
  26636. @cindex Info, documentation format
  26637. @cindex man pages
  26638. @cindex manual pages
  26639. In most cases packages installed with Guix come with documentation.
  26640. There are two main documentation formats: ``Info'', a browseable
  26641. hypertext format used for GNU software, and ``manual pages'' (or ``man
  26642. pages''), the linear documentation format traditionally found on Unix.
  26643. Info manuals are accessed with the @command{info} command or with Emacs,
  26644. and man pages are accessed using @command{man}.
  26645. You can look for documentation of software installed on your system by
  26646. keyword. For example, the following command searches for information
  26647. about ``TLS'' in Info manuals:
  26648. @example
  26649. $ info -k TLS
  26650. "(emacs)Network Security" -- STARTTLS
  26651. "(emacs)Network Security" -- TLS
  26652. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  26653. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  26654. @dots{}
  26655. @end example
  26656. @noindent
  26657. The command below searches for the same keyword in man pages:
  26658. @example
  26659. $ man -k TLS
  26660. SSL (7) - OpenSSL SSL/TLS library
  26661. certtool (1) - GnuTLS certificate tool
  26662. @dots {}
  26663. @end example
  26664. These searches are purely local to your computer so you have the
  26665. guarantee that documentation you find corresponds to what you have
  26666. actually installed, you can access it off-line, and your privacy is
  26667. respected.
  26668. Once you have these results, you can view the relevant documentation by
  26669. running, say:
  26670. @example
  26671. $ info "(gnutls)Core TLS API"
  26672. @end example
  26673. @noindent
  26674. or:
  26675. @example
  26676. $ man certtool
  26677. @end example
  26678. Info manuals contain sections and indices as well as hyperlinks like
  26679. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  26680. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  26681. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  26682. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  26683. Introduction}, for an introduction to Info navigation.
  26684. @node Installing Debugging Files
  26685. @chapter Installing Debugging Files
  26686. @cindex debugging files
  26687. Program binaries, as produced by the GCC compilers for instance, are
  26688. typically written in the ELF format, with a section containing
  26689. @dfn{debugging information}. Debugging information is what allows the
  26690. debugger, GDB, to map binary code to source code; it is required to
  26691. debug a compiled program in good conditions.
  26692. This chapter explains how to use separate debug info when packages
  26693. provide it, and how to rebuild packages with debug info when it's
  26694. missing.
  26695. @menu
  26696. * Separate Debug Info:: Installing 'debug' outputs.
  26697. * Rebuilding Debug Info:: Building missing debug info.
  26698. @end menu
  26699. @node Separate Debug Info
  26700. @section Separate Debug Info
  26701. The problem with debugging information is that is takes up a fair amount
  26702. of disk space. For example, debugging information for the GNU C Library
  26703. weighs in at more than 60 MiB@. Thus, as a user, keeping all the
  26704. debugging info of all the installed programs is usually not an option.
  26705. Yet, space savings should not come at the cost of an impediment to
  26706. debugging---especially in the GNU system, which should make it easier
  26707. for users to exert their computing freedom (@pxref{GNU Distribution}).
  26708. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  26709. mechanism that allows users to get the best of both worlds: debugging
  26710. information can be stripped from the binaries and stored in separate
  26711. files. GDB is then able to load debugging information from those files,
  26712. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  26713. with GDB}).
  26714. The GNU distribution takes advantage of this by storing debugging
  26715. information in the @code{lib/debug} sub-directory of a separate package
  26716. output unimaginatively called @code{debug} (@pxref{Packages with
  26717. Multiple Outputs}). Users can choose to install the @code{debug} output
  26718. of a package when they need it. For instance, the following command
  26719. installs the debugging information for the GNU C Library and for GNU
  26720. Guile:
  26721. @example
  26722. guix install glibc:debug guile:debug
  26723. @end example
  26724. GDB must then be told to look for debug files in the user's profile, by
  26725. setting the @code{debug-file-directory} variable (consider setting it
  26726. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  26727. GDB}):
  26728. @example
  26729. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  26730. @end example
  26731. From there on, GDB will pick up debugging information from the
  26732. @file{.debug} files under @file{~/.guix-profile/lib/debug}.
  26733. In addition, you will most likely want GDB to be able to show the source
  26734. code being debugged. To do that, you will have to unpack the source
  26735. code of the package of interest (obtained with @code{guix build
  26736. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  26737. directory using the @code{directory} command (@pxref{Source Path,
  26738. @code{directory},, gdb, Debugging with GDB}).
  26739. @c XXX: keep me up-to-date
  26740. The @code{debug} output mechanism in Guix is implemented by the
  26741. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  26742. opt-in---debugging information is available only for the packages with
  26743. definitions explicitly declaring a @code{debug} output. To check
  26744. whether a package has a @code{debug} output, use @command{guix package
  26745. --list-available} (@pxref{Invoking guix package}).
  26746. Read on for how to deal with packages lacking a @code{debug} output.
  26747. @node Rebuilding Debug Info
  26748. @section Rebuilding Debug Info
  26749. @cindex debugging info, rebuilding
  26750. As we saw above, some packages, but not all, provide debugging info in a
  26751. @code{debug} output. What can you do when debugging info is missing?
  26752. The @option{--with-debug-info} option provides a solution to that: it
  26753. allows you to rebuild the package(s) for which debugging info is
  26754. missing---and only those---and to graft those onto the application
  26755. you're debugging. Thus, while it's not as fast as installing a
  26756. @code{debug} output, it is relatively inexpensive.
  26757. Let's illustrate that. Suppose you're experiencing a bug in Inkscape
  26758. and would like to see what's going on in GLib, a library that's deep
  26759. down in its dependency graph. As it turns out, GLib does not have a
  26760. @code{debug} output and the backtrace GDB shows is all sadness:
  26761. @example
  26762. (gdb) bt
  26763. #0 0x00007ffff5f92190 in g_getenv ()
  26764. from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0
  26765. #1 0x00007ffff608a7d6 in gobject_init_ctor ()
  26766. from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0
  26767. #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8,
  26768. env=env@@entry=0x7fffffffcfe8) at dl-init.c:72
  26769. #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>)
  26770. at dl-init.c:118
  26771. @end example
  26772. To address that, you install Inkscape linked against a variant GLib that
  26773. contains debug info:
  26774. @example
  26775. guix install inkscape --with-debug-info=glib
  26776. @end example
  26777. This time, debugging will be a whole lot nicer:
  26778. @example
  26779. $ gdb --args sh -c 'exec inkscape'
  26780. @dots{}
  26781. (gdb) b g_getenv
  26782. Function "g_getenv" not defined.
  26783. Make breakpoint pending on future shared library load? (y or [n]) y
  26784. Breakpoint 1 (g_getenv) pending.
  26785. (gdb) r
  26786. Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape
  26787. @dots{}
  26788. (gdb) bt
  26789. #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252
  26790. #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380
  26791. #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493
  26792. #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088,
  26793. env=env@@entry=0x7fffffffd0a8) at dl-init.c:72
  26794. @dots{}
  26795. @end example
  26796. Much better!
  26797. Note that there can be packages for which @option{--with-debug-info}
  26798. will not have the desired effect. @xref{Package Transformation Options,
  26799. @option{--with-debug-info}}, for more information.
  26800. @node Security Updates
  26801. @chapter Security Updates
  26802. @cindex security updates
  26803. @cindex security vulnerabilities
  26804. Occasionally, important security vulnerabilities are discovered in software
  26805. packages and must be patched. Guix developers try hard to keep track of
  26806. known vulnerabilities and to apply fixes as soon as possible in the
  26807. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  26808. containing only security updates). The @command{guix lint} tool helps
  26809. developers find out about vulnerable versions of software packages in the
  26810. distribution:
  26811. @smallexample
  26812. $ guix lint -c cve
  26813. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  26814. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  26815. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  26816. @dots{}
  26817. @end smallexample
  26818. @xref{Invoking guix lint}, for more information.
  26819. Guix follows a functional
  26820. package management discipline (@pxref{Introduction}), which implies
  26821. that, when a package is changed, @emph{every package that depends on it}
  26822. must be rebuilt. This can significantly slow down the deployment of
  26823. fixes in core packages such as libc or Bash, since basically the whole
  26824. distribution would need to be rebuilt. Using pre-built binaries helps
  26825. (@pxref{Substitutes}), but deployment may still take more time than
  26826. desired.
  26827. @cindex grafts
  26828. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  26829. for fast deployment of critical updates without the costs associated
  26830. with a whole-distribution rebuild. The idea is to rebuild only the
  26831. package that needs to be patched, and then to ``graft'' it onto packages
  26832. explicitly installed by the user and that were previously referring to
  26833. the original package. The cost of grafting is typically very low, and
  26834. order of magnitudes lower than a full rebuild of the dependency chain.
  26835. @cindex replacements of packages, for grafts
  26836. For instance, suppose a security update needs to be applied to Bash.
  26837. Guix developers will provide a package definition for the ``fixed''
  26838. Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
  26839. Packages}). Then, the original package definition is augmented with a
  26840. @code{replacement} field pointing to the package containing the bug fix:
  26841. @lisp
  26842. (define bash
  26843. (package
  26844. (name "bash")
  26845. ;; @dots{}
  26846. (replacement bash-fixed)))
  26847. @end lisp
  26848. From there on, any package depending directly or indirectly on Bash---as
  26849. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  26850. gc})---that is installed is automatically ``rewritten'' to refer to
  26851. @code{bash-fixed} instead of @code{bash}. This grafting process takes
  26852. time proportional to the size of the package, usually less than a
  26853. minute for an ``average'' package on a recent machine. Grafting is
  26854. recursive: when an indirect dependency requires grafting, then grafting
  26855. ``propagates'' up to the package that the user is installing.
  26856. Currently, the length of the name and version of the graft and that of
  26857. the package it replaces (@code{bash-fixed} and @code{bash} in the example
  26858. above) must be equal. This restriction mostly comes from the fact that
  26859. grafting works by patching files, including binary files, directly.
  26860. Other restrictions may apply: for instance, when adding a graft to a
  26861. package providing a shared library, the original shared library and its
  26862. replacement must have the same @code{SONAME} and be binary-compatible.
  26863. The @option{--no-grafts} command-line option allows you to forcefully
  26864. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  26865. Thus, the command:
  26866. @example
  26867. guix build bash --no-grafts
  26868. @end example
  26869. @noindent
  26870. returns the store file name of the original Bash, whereas:
  26871. @example
  26872. guix build bash
  26873. @end example
  26874. @noindent
  26875. returns the store file name of the ``fixed'', replacement Bash. This
  26876. allows you to distinguish between the two variants of Bash.
  26877. To verify which Bash your whole profile refers to, you can run
  26878. (@pxref{Invoking guix gc}):
  26879. @example
  26880. guix gc -R $(readlink -f ~/.guix-profile) | grep bash
  26881. @end example
  26882. @noindent
  26883. @dots{} and compare the store file names that you get with those above.
  26884. Likewise for a complete Guix system generation:
  26885. @example
  26886. guix gc -R $(guix system build my-config.scm) | grep bash
  26887. @end example
  26888. Lastly, to check which Bash running processes are using, you can use the
  26889. @command{lsof} command:
  26890. @example
  26891. lsof | grep /gnu/store/.*bash
  26892. @end example
  26893. @node Bootstrapping
  26894. @chapter Bootstrapping
  26895. @c Adapted from the ELS 2013 paper.
  26896. @cindex bootstrapping
  26897. Bootstrapping in our context refers to how the distribution gets built
  26898. ``from nothing''. Remember that the build environment of a derivation
  26899. contains nothing but its declared inputs (@pxref{Introduction}). So
  26900. there's an obvious chicken-and-egg problem: how does the first package
  26901. get built? How does the first compiler get compiled?
  26902. It is tempting to think of this question as one that only die-hard
  26903. hackers may care about. However, while the answer to that question is
  26904. technical in nature, its implications are wide-ranging. How the
  26905. distribution is bootstrapped defines the extent to which we, as
  26906. individuals and as a collective of users and hackers, can trust the
  26907. software we run. It is a central concern from the standpoint of
  26908. @emph{security} and from a @emph{user freedom} viewpoint.
  26909. @cindex bootstrap binaries
  26910. The GNU system is primarily made of C code, with libc at its core. The
  26911. GNU build system itself assumes the availability of a Bourne shell and
  26912. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  26913. `grep'. Furthermore, build programs---programs that run
  26914. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  26915. (@pxref{Derivations}). Consequently, to be able to build anything at
  26916. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  26917. Binutils, libc, and the other packages mentioned above---the
  26918. @dfn{bootstrap binaries}.
  26919. These bootstrap binaries are ``taken for granted'', though we can also
  26920. re-create them if needed (@pxref{Preparing to Use the Bootstrap
  26921. Binaries}).
  26922. @menu
  26923. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  26924. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  26925. @end menu
  26926. @node Reduced Binary Seed Bootstrap
  26927. @section The Reduced Binary Seed Bootstrap
  26928. Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
  26929. a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
  26930. Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
  26931. GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
  26932. ``taken for granted.''
  26933. Taking the bootstrap binaries for granted means that we consider them to
  26934. be a correct and trustworthy ``seed'' for building the complete system.
  26935. Therein lies a problem: the combined size of these bootstrap binaries is
  26936. about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
  26937. or even inspecting these is next to impossible.
  26938. For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
  26939. ``Reduced Binary Seed'' bootstrap @footnote{We would like to say: ``Full
  26940. Source Bootstrap'' and while we are working towards that goal it would
  26941. be hyperbole to use that term for what we do now.}.
  26942. The Reduced Binary Seed bootstrap removes the most critical tools---from a
  26943. trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
  26944. Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
  26945. linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
  26946. written in Scheme and the Mes C Library, built for TinyCC and for GCC).
  26947. Using these new binary seeds the ``missing'' Binutils, GCC, and the GNU
  26948. C Library are built from source. From here on the more traditional
  26949. bootstrap process resumes. This approach has reduced the bootstrap
  26950. binaries in size to about 145MB in Guix v1.1.
  26951. The next step that Guix has taken is to replace the shell and all its
  26952. utilities with implementations in Guile Scheme, the @emph{Scheme-only
  26953. bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
  26954. POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
  26955. which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
  26956. Gzip, Sed, and Tar. The rest of the bootstrap binary seeds that were
  26957. removed are now built from source.
  26958. Building the GNU System from source is currently only possible by adding
  26959. some historical GNU packages as intermediate steps@footnote{Packages
  26960. such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
  26961. @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
  26962. @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
  26963. and GNU packages become more bootstrappable again (e.g., new releases of
  26964. GNU Sed will also ship as gzipped tarballs again, as alternative to the
  26965. hard to bootstrap @code{xz}-compression), this set of added packages can
  26966. hopefully be reduced again.
  26967. The graph below shows the resulting dependency graph for
  26968. @code{gcc-core-mesboot0}, the bootstrap compiler used for the
  26969. traditional bootstrap of the rest of the Guix System.
  26970. @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
  26971. @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
  26972. The only significant binary bootstrap seeds that remain@footnote{
  26973. Ignoring the 68KB @code{mescc-tools}; that will be removed later,
  26974. together with @code{mes}.} are a Scheme intepreter and a Scheme
  26975. compiler: GNU Mes and GNU Guile@footnote{Not shown in this graph are the
  26976. static binaries for @file{bash}, @code{tar}, and @code{xz} that are used
  26977. to get Guile running.}.
  26978. This further reduction has brought down the size of the binary seed to
  26979. about 60MB for @code{i686-linux} and @code{x86_64-linux}.
  26980. Work is ongoing to remove all binary blobs from our free software
  26981. bootstrap stack, working towards a Full Source Bootstrap. Also ongoing
  26982. is work to bring these bootstraps to the @code{arm-linux} and
  26983. @code{aarch64-linux} architectures and to the Hurd.
  26984. If you are interested, join us on @samp{#bootstrappable} on the Freenode
  26985. IRC network or discuss on @email{bug-mes@@gnu.org} or
  26986. @email{gash-devel@@nongnu.org}.
  26987. @node Preparing to Use the Bootstrap Binaries
  26988. @section Preparing to Use the Bootstrap Binaries
  26989. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  26990. @c large image, it's hard to scroll. Oh well.
  26991. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  26992. The figure above shows the very beginning of the dependency graph of the
  26993. distribution, corresponding to the package definitions of the @code{(gnu
  26994. packages bootstrap)} module. A similar figure can be generated with
  26995. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  26996. @example
  26997. guix graph -t derivation \
  26998. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  26999. | dot -Tps > gcc.ps
  27000. @end example
  27001. or, for the further Reduced Binary Seed bootstrap
  27002. @example
  27003. guix graph -t derivation \
  27004. -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
  27005. | dot -Tps > mes.ps
  27006. @end example
  27007. At this level of detail, things are
  27008. slightly complex. First, Guile itself consists of an ELF executable,
  27009. along with many source and compiled Scheme files that are dynamically
  27010. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  27011. tarball shown in this graph. This tarball is part of Guix's ``source''
  27012. distribution, and gets inserted into the store with @code{add-to-store}
  27013. (@pxref{The Store}).
  27014. But how do we write a derivation that unpacks this tarball and adds it
  27015. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  27016. derivation---the first one that gets built---uses @code{bash} as its
  27017. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  27018. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  27019. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  27020. the Guix source distribution, whose sole purpose is to allow the Guile
  27021. tarball to be unpacked.
  27022. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  27023. Guile that can be used to run subsequent build programs. Its first task
  27024. is to download tarballs containing the other pre-built binaries---this
  27025. is what the @file{.tar.xz.drv} derivations do. Guix modules such as
  27026. @code{ftp-client.scm} are used for this purpose. The
  27027. @code{module-import.drv} derivations import those modules in a directory
  27028. in the store, using the original layout. The
  27029. @code{module-import-compiled.drv} derivations compile those modules, and
  27030. write them in an output directory with the right layout. This
  27031. corresponds to the @code{#:modules} argument of
  27032. @code{build-expression->derivation} (@pxref{Derivations}).
  27033. Finally, the various tarballs are unpacked by the derivations
  27034. @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
  27035. @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
  27036. point we have a working C tool chain.
  27037. @unnumberedsec Building the Build Tools
  27038. Bootstrapping is complete when we have a full tool chain that does not
  27039. depend on the pre-built bootstrap tools discussed above. This
  27040. no-dependency requirement is verified by checking whether the files of
  27041. the final tool chain contain references to the @file{/gnu/store}
  27042. directories of the bootstrap inputs. The process that leads to this
  27043. ``final'' tool chain is described by the package definitions found in
  27044. the @code{(gnu packages commencement)} module.
  27045. The @command{guix graph} command allows us to ``zoom out'' compared to
  27046. the graph above, by looking at the level of package objects instead of
  27047. individual derivations---remember that a package may translate to
  27048. several derivations, typically one derivation to download its source,
  27049. one to build the Guile modules it needs, and one to actually build the
  27050. package from source. The command:
  27051. @example
  27052. guix graph -t bag \
  27053. -e '(@@@@ (gnu packages commencement)
  27054. glibc-final-with-bootstrap-bash)' | xdot -
  27055. @end example
  27056. @noindent
  27057. displays the dependency graph leading to the ``final'' C
  27058. library@footnote{You may notice the @code{glibc-intermediate} label,
  27059. suggesting that it is not @emph{quite} final, but as a good
  27060. approximation, we will consider it final.}, depicted below.
  27061. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  27062. @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  27063. The first tool that gets built with the bootstrap binaries is
  27064. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  27065. for all the following packages. From there Findutils and Diffutils get
  27066. built.
  27067. Then come the first-stage Binutils and GCC, built as pseudo cross
  27068. tools---i.e., with @option{--target} equal to @option{--host}. They are
  27069. used to build libc. Thanks to this cross-build trick, this libc is
  27070. guaranteed not to hold any reference to the initial tool chain.
  27071. From there the final Binutils and GCC (not shown above) are built. GCC
  27072. uses @command{ld} from the final Binutils, and links programs against
  27073. the just-built libc. This tool chain is used to build the other
  27074. packages used by Guix and by the GNU Build System: Guile, Bash,
  27075. Coreutils, etc.
  27076. And voilà! At this point we have the complete set of build tools that
  27077. the GNU Build System expects. These are in the @code{%final-inputs}
  27078. variable of the @code{(gnu packages commencement)} module, and are
  27079. implicitly used by any package that uses @code{gnu-build-system}
  27080. (@pxref{Build Systems, @code{gnu-build-system}}).
  27081. @unnumberedsec Building the Bootstrap Binaries
  27082. @cindex bootstrap binaries
  27083. Because the final tool chain does not depend on the bootstrap binaries,
  27084. those rarely need to be updated. Nevertheless, it is useful to have an
  27085. automated way to produce them, should an update occur, and this is what
  27086. the @code{(gnu packages make-bootstrap)} module provides.
  27087. The following command builds the tarballs containing the bootstrap binaries
  27088. (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
  27089. bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
  27090. and Guile, and a tarball containing a mixture of Coreutils and other basic
  27091. command-line tools):
  27092. @example
  27093. guix build bootstrap-tarballs
  27094. @end example
  27095. The generated tarballs are those that should be referred to in the
  27096. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  27097. this section.
  27098. Still here? Then perhaps by now you've started to wonder: when do we
  27099. reach a fixed point? That is an interesting question! The answer is
  27100. unknown, but if you would like to investigate further (and have
  27101. significant computational and storage resources to do so), then let us
  27102. know.
  27103. @unnumberedsec Reducing the Set of Bootstrap Binaries
  27104. Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
  27105. binary code! Why is that a problem? It's a problem because these big chunks
  27106. of binary code are practically non-auditable, which makes it hard to establish
  27107. what source code produced them. Every unauditable binary also leaves us
  27108. vulnerable to compiler backdoors as described by Ken Thompson in the 1984
  27109. paper @emph{Reflections on Trusting Trust}.
  27110. This is mitigated by the fact that our bootstrap binaries were generated
  27111. from an earlier Guix revision. Nevertheless it lacks the level of
  27112. transparency that we get in the rest of the package dependency graph,
  27113. where Guix always gives us a source-to-binary mapping. Thus, our goal
  27114. is to reduce the set of bootstrap binaries to the bare minimum.
  27115. The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
  27116. on-going projects to do that. One of these is about replacing the
  27117. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  27118. of increasing complexity, which could be built from source starting from
  27119. a simple and auditable assembler.
  27120. Our first major achievement is the replacement of of GCC, the GNU C Library
  27121. and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
  27122. (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
  27123. and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
  27124. bootstrapped yet and thus we inject them as binary seeds. We call this the
  27125. Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
  27126. binaries! Also, it has eliminated the C compiler binary; i686-linux and
  27127. x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
  27128. Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
  27129. also looking at any other bootstrap binaries. Your help is welcome!
  27130. @node Porting
  27131. @chapter Porting to a New Platform
  27132. As discussed above, the GNU distribution is self-contained, and
  27133. self-containment is achieved by relying on pre-built ``bootstrap
  27134. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  27135. operating system kernel, CPU architecture, and application binary
  27136. interface (ABI). Thus, to port the distribution to a platform that is
  27137. not yet supported, one must build those bootstrap binaries, and update
  27138. the @code{(gnu packages bootstrap)} module to use them on that platform.
  27139. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  27140. When everything goes well, and assuming the GNU tool chain supports the
  27141. target platform, this can be as simple as running a command like this
  27142. one:
  27143. @example
  27144. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  27145. @end example
  27146. For this to work, the @code{glibc-dynamic-linker} procedure in
  27147. @code{(gnu packages bootstrap)} must be augmented to return the right
  27148. file name for libc's dynamic linker on that platform; likewise,
  27149. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  27150. taught about the new platform.
  27151. Once these are built, the @code{(gnu packages bootstrap)} module needs
  27152. to be updated to refer to these binaries on the target platform. That
  27153. is, the hashes and URLs of the bootstrap tarballs for the new platform
  27154. must be added alongside those of the currently supported platforms. The
  27155. bootstrap Guile tarball is treated specially: it is expected to be
  27156. available locally, and @file{gnu/local.mk} has rules to download it for
  27157. the supported architectures; a rule for the new platform must be added
  27158. as well.
  27159. In practice, there may be some complications. First, it may be that the
  27160. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  27161. above) is not recognized by all the GNU tools. Typically, glibc
  27162. recognizes some of these, whereas GCC uses an extra @option{--with-abi}
  27163. configure flag (see @code{gcc.scm} for examples of how to handle this).
  27164. Second, some of the required packages could fail to build for that
  27165. platform. Lastly, the generated binaries could be broken for some
  27166. reason.
  27167. @c *********************************************************************
  27168. @include contributing.texi
  27169. @c *********************************************************************
  27170. @node Acknowledgments
  27171. @chapter Acknowledgments
  27172. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  27173. which was designed and
  27174. implemented by Eelco Dolstra, with contributions from other people (see
  27175. the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
  27176. management, and promoted unprecedented features, such as transactional
  27177. package upgrades and rollbacks, per-user profiles, and referentially
  27178. transparent build processes. Without this work, Guix would not exist.
  27179. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  27180. an inspiration for Guix.
  27181. GNU@tie{}Guix itself is a collective work with contributions from a
  27182. number of people. See the @file{AUTHORS} file in Guix for more
  27183. information on these fine people. The @file{THANKS} file lists people
  27184. who have helped by reporting bugs, taking care of the infrastructure,
  27185. providing artwork and themes, making suggestions, and more---thank you!
  27186. @c *********************************************************************
  27187. @node GNU Free Documentation License
  27188. @appendix GNU Free Documentation License
  27189. @cindex license, GNU Free Documentation License
  27190. @include fdl-1.3.texi
  27191. @c *********************************************************************
  27192. @node Concept Index
  27193. @unnumbered Concept Index
  27194. @printindex cp
  27195. @node Programming Index
  27196. @unnumbered Programming Index
  27197. @syncodeindex tp fn
  27198. @syncodeindex vr fn
  27199. @printindex fn
  27200. @bye
  27201. @c Local Variables:
  27202. @c ispell-local-dictionary: "american";
  27203. @c End: